RunInfo.java

1
// Copyright © 2004-2006 University of Helsinki, Department of Computer Science
2
// Copyright © 2012 various contributors
3
// This software is released under GNU Lesser General Public License 2.1.
4
// The license text is at http://www.gnu.org/licenses/lgpl-2.1.html
5
6
package fi.helsinki.cs.titokone;
7
8
import java.util.LinkedList;
9
10
11
/**
12
 * This class tells GUIBrain what the processor has done. RunDebugger
13
 * creates objects from this class and passes them to onwards.
14
 */
15
16
public class RunInfo extends DebugInfo {
17
18
    /**
19
     * This field contains the number of operation type.
20
     */
21
    private int operationType;
22
    /**
23
     * This field contains line number.
24
     */
25
    private int lineNumber;
26
    /**
27
     * This field contains contents of the line,
28
     */
29
    private String lineContents;
30
    /**
31
     * This field contains the command in binary format.
32
     */
33
    private int binary;
34
    /**
35
     * This array contains the current values of registers 0-7
36
     */
37 3
    private int[] registers = new int[8];
38
    /**
39
     * This String contains the colon-representation of current line
40
     */
41
    private String colonString;
42
    /**
43
     * This int represents the number of memoryfetches
44
     */
45
    private int numberOfMemoryfetches;
46
    /**
47
     * This field contains first operand of the command.
48
     */
49
    private int Rj;
50
    /**
51
     * This field contains value of new PC.
52
     */
53
    private int newPC;
54
    /**
55
     * This field contains index register.
56
     */
57
    private int Ri;
58
    /**
59
     * This field represents the address
60
     */
61
    private int addr;
62
    /**
63
     * This field contains the value of address field
64
     */
65
    private int valueAtADDR;
66
    /**
67
     * This field contains the value of second memory fetch
68
     */
69
    private int secondFetchValue;
70
    /**
71
     * This field contains the value of ALU-operation
72
     */
73
    private int aluResult;
74
    /**
75
     * This field contains the compare status of status register.
76
     * 0 - greater, 1 - equal, 2 - less.
77
     */
78 3
    private int compareStatus = -1;
79
    /**
80
     * This boolean value tells is the operation in or out -operation
81
     */
82
    private boolean externalOperation;
83
    /**
84
     * This boolean value is set true if operation is in operation, otherwise false
85
     */
86
    private boolean isIN;
87
    /**
88
     * This String value contains the name of the device
89
     */
90
    private String deviceName;
91
    /**
92
     * This value contains the value of the device
93
     */
94
    private int deviceNumber;
95
    /**
96
     * This value contains the value read or written from / to device
97
     */
98
    private int valueOfDevice;
99
    /**
100
     * This value contains the String representation of SVC-operation
101
     */
102
    private String svcOperation;
103
    /**
104
     * This list contains all changed memory lines. List contains object
105
     * arrays, whose first element is a Integer and second a MemoryLine.
106
     * Integer tells the row where MemoryLine is in memory.
107
     */
108
    LinkedList changedMemoryLines;
109
110
    /**
111
     * This constructor initializes the RunInfo and sets its starting values.
112
     *
113
     * @param lineNumber   Line number of current line.
114
     * @param lineContents String containing symbolic command.
115
     */
116
    public RunInfo(int lineNumber, String lineContents) {
117 1
        this.lineNumber = lineNumber;
118 1
        this.lineContents = lineContents;
119 3
        externalOperation = false;
120 4
        setNewPC(lineNumber + 1);
121
    }
122
123
124
    public void setRegisters(int[] registers) {
125 6
        for (int i = 0; i < Math.min(registers.length, this.registers.length); i++) {
126
            this.registers[i] = registers[i];
127
        }
128
    }
129
130
    /**
131
     * This method sets the type of operation performed.
132
     *
133
     * @param type Type of operation.
134
     */
135
    public void setOperationType(int type) {
136 1
        this.operationType = type;
137
    }
138
139
    /**
140
     * This method sets the colon-presentation of the command.
141
     *
142
     * @param colonString The colon-presentation of the command,
143
     *                    eg. 0:1:0:2:3 (for NOP R1, =3(R2)).
144
     */
145
    public void setColonString(String colonString) {
146 1
        this.colonString = colonString;
147
    }
148
149
    /**
150
     * This method gets the colon-presentation of the command.
151
     *
152
     * @return The colon-presentation of the command.
153
     */
154
    public String getColonString() {
155 1
        return colonString;
156
    }
157
158
    /**
159
     * this method sets the index register.
160
     *
161
     * @param Ri Number of the register.
162
     */
163
    public void setIndexRegister(int Ri) {
164 1
        this.Ri = Ri;
165
    }
166
167
    /**
168
     * This method sets the first operand.
169
     *
170
     * @param Rj Number of the register.
171
     */
172
    public void setFirstOperand(int Rj) {
173 1
        this.Rj = Rj;
174
    }
175
176
    /**
177
     * This method sets the number of fetches.
178
     *
179
     * @param fetches Number of fetches.
180
     */
181
    public void setNumberOfFetches(int fetches) {
182 1
        this.numberOfMemoryfetches = fetches;
183
    }
184
185
    /**
186
     * This method sets the value of the ADDRess field.
187
     *
188
     * @param addr Int containing the ADDR.
189
     */
190
    public void setADDR(int addr) {
191 1
        this.addr = addr;
192
    }
193
194
    /**
195
     * This method sets the value found at ADDR.
196
     *
197
     * @param value Value found at the ADDR.
198
     */
199
    public void setValueAtADDR(int value) {
200 1
        this.valueAtADDR = value;
201
    }
202
203
    /* Sets changed memory lines.
204
@param changedMemoryLines List of changed memory lines. List contains
205
object arrays, whose first element is a Integer and second is a MemoryLine.
206
Integer tells the row where MemoryLine is in memory. */
207
    public void setChangedMemoryLines(LinkedList changedMemoryLines) {
208 1
        this.changedMemoryLines = changedMemoryLines;
209
    }
210
211
    /**
212
     * This sets the result of performed ALU operation
213
     *
214
     * @param result Result of the operation.
215
     */
216
    public void setALUResult(int result) {
217 1
        this.aluResult = result;
218
    }
219
220
    /**
221
     * This method tells info that a compare operation was made and what SR
222
     * bit was changed to what value.
223
     *
224
     * @param whichBit Number of the bit.
225
     */
226
    public void setCompareOperation(int whichBit) {
227 1
        this.compareStatus = whichBit;
228
    }
229
230
    /**
231
     * This method tells is external operation executed
232
     *
233
     * @return boolean true if command is an external operation
234
     */
235
    public boolean isExternalOp() {
236 1
        return externalOperation;
237
    }
238
239
    /**
240
     * This method tells is external operation in or out
241
     *
242
     * @return true if external operation is in operation, otherwise false.
243
     */
244
    public boolean isInOp() {
245 1
        return isIN;
246
    }
247
248
249
    /**
250
     * This method tells info what was read from given device and what was
251
     * the value.
252
     *
253
     * @param deviceName Name of the device.
254
     * @param device     Number of the device.
255
     * @param value      Value read.
256
     */
257
    public void setIN(String deviceName, int device, int value) {
258 3
        this.externalOperation = true;
259 3
        this.isIN = true;
260 1
        this.deviceName = deviceName;
261 1
        this.deviceNumber = device;
262 1
        this.valueOfDevice = value;
263
    }
264
265
266
    /**
267
     * This method tells info what was written to the  given device and what
268
     * was the value.
269
     *
270
     * @param deviceName Name of the device.
271
     * @param device     Number of the device.
272
     * @param value      Value written.
273
     */
274
    public void setOUT(String deviceName, int device, int value) {
275 3
        this.externalOperation = true;
276 3
        this.isIN = false;
277 1
        this.deviceName = deviceName;
278 1
        this.deviceNumber = device;
279 1
        this.valueOfDevice = value;
280
    }
281
282
283
    /**
284
     * This method sets what kind of SVC operation was made.
285
     */
286
    public void setSVCOperation(String operation) {
287 1
        this.svcOperation = operation;
288
    }
289
290
    /**
291
     * Sets the value of new PC.
292
     *
293
     * @param newPC Value of the new PC.
294
     */
295
    public void setNewPC(int newPC) {
296 1
        this.newPC = newPC;
297
    }
298
299
    /**
300
     * Gets the value of new PC.
301
     *
302
     * @return Value of the new PC.
303
     */
304
    public int getNewPC() {
305 1
        return newPC;
306
    }
307
308
    /**
309
     * Gets compare status of status register.
310
     *
311
     * @return Compare status of status register. 0 = grater, 1 = equal, 2 = less.
312
     */
313
    public int getCompareStatus() {
314 1
        return compareStatus;
315
    }
316
317
    /**
318
     * This method tells GUIBrain what kind of operation happened.
319
     *
320
     * @return int value which represents operation type.
321
     */
322
    public int getOperationtype() {
323 1
        return operationType;
324
    }
325
326
    /**
327
     * This methot tells GUIBrain how many memoryfetches were made.
328
     *
329
     * @return int How many fetches were made.
330
     */
331
    public int getMemoryfetches() {
332 1
        return numberOfMemoryfetches;
333
    }
334
335
    /**
336
     * This method returns the number of the line.
337
     *
338
     * @return int containing the line number.
339
     */
340
    public int getLineNumber() {
341 1
        return lineNumber;
342
    }
343
344
    /**
345
     * This method returns the symbolic command found on the line..
346
     *
347
     * @return String String containing the symbolic command.
348
     */
349
    public String getLineContents() {
350 1
        return lineContents;
351
    }
352
353
    /**
354
     * This method returns the binary command.
355
     *
356
     * @return int Integer containing the binary command.
357
     */
358
    public int getBinary() {
359 1
        return binary;
360
    }
361
362
    /**
363
     * This method sets the binary command.
364
     *
365
     * @param binary Contains the binary command.
366
     */
367
    public void setBinary(int binary) {
368 1
        this.binary = binary;
369
    }
370
371
    /**
372
     * Returns register array.
373
     *
374
     * @return int[] int array containing values of the registers.
375
     */
376
    public int[] getRegisters() {
377 1
        return registers;
378
    }
379
380
381
    /* Returns changed memory lines.
382
@return List of changed memory lines. List contains object arrays, whose
383
first element is a Integer and second is a MemoryLine. Integer tells the
384
row where MemoryLine is in memory. */
385
    public LinkedList getChangedMemoryLines() {
386 1
        return changedMemoryLines;
387
    }
388
389
    /**
390
     * This method tells GUIBrain what was result of an OUT command (device
391
     * and value).
392
     *
393
     * @return int[] Integer array containing device number and new value.
394
     */
395
    public int[] whatOUT() {
396 2
        int[] outD = new int[2];
397 2
        outD[0] = deviceNumber;
398 2
        outD[1] = valueOfDevice;
399
400 1
        return outD;
401
    }
402
403
    /**
404
     * This method tells GUIBrain what was result of an IN command (device and
405
     * value.
406
     *
407
     * @return int[] Integer array containing device number and new value.
408
     */
409
    public int[] whatIN() {
410 2
        int[] inD = new int[2];
411 2
        inD[0] = deviceNumber;
412 2
        inD[1] = valueOfDevice;
413
414 1
        return inD;
415
    }
416
417
    /**
418
     * This method returns name of the used device.
419
     *
420
     * @return String devicename.
421
     */
422
    public String whatDevice() {
423 1
        return deviceName;
424
    }
425
426
    /**
427
     * This method returns register number of the first operand.
428
     *
429
     * @return Register number of the first operand.
430
     */
431
    public int getFirstOperand() {
432 1
        return Rj;
433
    }
434
435
    /**
436
     * This method returns number of the index register.
437
     *
438
     * @return Number of the index register.
439
     */
440
    public int getIndexRegister() {
441 1
        return Ri;
442
    }
443
444
    /**
445
     * This method returns value of the ADDR part of the command.
446
     *
447
     * @return int Integer containing the value of the ADDR part of command.
448
     */
449
    public int getADDR() {
450 1
        return addr;
451
    }
452
453
    /**
454
     * This method returns value found at the ADDR.
455
     *
456
     * @return int Integer containing the value found at ADDR..
457
     */
458
    public int getValueAtADDR() {
459 1
        return valueAtADDR;
460
    }
461
462
    /**
463
     * This method sets value of second memory fetch. Indirect memory
464
     * accessing mode needs two memory fetches.
465
     *
466
     * @param secondFetchValue Value which have got at second memory fetch.
467
     */
468
    public void setSecondFetchValue(int secondFetchValue) {
469 1
        this.secondFetchValue = secondFetchValue;
470
    }
471
472
    /**
473
     * This method gets value of second memory fetch. Indirect memory
474
     * accessing mode needs two memory fetches.
475
     *
476
     * @return Value which have got at second memory fetch.
477
     */
478
    public int getSecondFetchValue() {
479 1
        return secondFetchValue;
480
    }
481
482
483
    /**
484
     * This method returns the result of the ALU operation.
485
     *
486
     * @return int Integer containing the result.
487
     */
488
    public int getALUResult() {
489 1
        return aluResult;
490
    }
491
492
493
    /**
494
     * This method returns type of the SVC operation.
495
     *
496
     * @return int Integer containing the operation type.
497
     */
498
    public String getSVC() {
499 1
        return svcOperation;
500
    }
501
502
503
}

Mutations

37

Replaced constant value of 8 with 9 : NO_COVERAGE

Substituted 8 with 9 : NO_COVERAGE

Removed assignment to member variable registers : NO_COVERAGE

78

Substituted -1 with 1 : NO_COVERAGE

Substituted -1 with 0 : NO_COVERAGE

Removed assignment to member variable compareStatus : NO_COVERAGE

117

Removed assignment to member variable lineNumber : NO_COVERAGE

118

Removed assignment to member variable lineContents : NO_COVERAGE

119

Removed assignment to member variable externalOperation : NO_COVERAGE

Substituted 0 with 1 : NO_COVERAGE

Substituted 0 with 1 : NO_COVERAGE

120

Substituted 1 with 0 : NO_COVERAGE

Substituted 1 with 0 : NO_COVERAGE

removed call to fi/helsinki/cs/titokone/RunInfo::setNewPC : NO_COVERAGE

Replaced integer addition with subtraction : NO_COVERAGE

125

Substituted 0 with 1 : NO_COVERAGE

removed call to java/lang/Math::min : NO_COVERAGE

Changed increment from 1 to -1 : NO_COVERAGE

changed conditional boundary : NO_COVERAGE

Substituted 0 with 1 : NO_COVERAGE

negated conditional : NO_COVERAGE

136

Removed assignment to member variable operationType : NO_COVERAGE

146

Removed assignment to member variable colonString : NO_COVERAGE

155

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::getColonString to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

164

Removed assignment to member variable Ri : NO_COVERAGE

173

Removed assignment to member variable Rj : NO_COVERAGE

182

Removed assignment to member variable numberOfMemoryfetches : NO_COVERAGE

191

Removed assignment to member variable addr : NO_COVERAGE

200

Removed assignment to member variable valueAtADDR : NO_COVERAGE

208

Removed assignment to member variable changedMemoryLines : NO_COVERAGE

217

Removed assignment to member variable aluResult : NO_COVERAGE

227

Removed assignment to member variable compareStatus : NO_COVERAGE

236

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

245

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

258

Substituted 1 with 0 : NO_COVERAGE

Substituted 1 with 0 : NO_COVERAGE

Removed assignment to member variable externalOperation : NO_COVERAGE

259

Substituted 1 with 0 : NO_COVERAGE

Substituted 1 with 0 : NO_COVERAGE

Removed assignment to member variable isIN : NO_COVERAGE

260

Removed assignment to member variable deviceName : NO_COVERAGE

261

Removed assignment to member variable deviceNumber : NO_COVERAGE

262

Removed assignment to member variable valueOfDevice : NO_COVERAGE

275

Removed assignment to member variable externalOperation : NO_COVERAGE

Substituted 1 with 0 : NO_COVERAGE

Substituted 1 with 0 : NO_COVERAGE

276

Removed assignment to member variable isIN : NO_COVERAGE

Substituted 0 with 1 : NO_COVERAGE

Substituted 0 with 1 : NO_COVERAGE

277

Removed assignment to member variable deviceName : NO_COVERAGE

278

Removed assignment to member variable deviceNumber : NO_COVERAGE

279

Removed assignment to member variable valueOfDevice : NO_COVERAGE

287

Removed assignment to member variable svcOperation : NO_COVERAGE

296

Removed assignment to member variable newPC : NO_COVERAGE

305

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

314

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

323

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

332

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

341

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

350

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::getLineContents to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

359

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

368

Removed assignment to member variable binary : NO_COVERAGE

377

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::getRegisters to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

386

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::getChangedMemoryLines to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

396

Substituted 2 with 3 : NO_COVERAGE

Substituted 2 with 3 : NO_COVERAGE

397

Substituted 0 with 1 : NO_COVERAGE

Substituted 0 with 1 : NO_COVERAGE

398

Substituted 1 with 0 : NO_COVERAGE

Substituted 1 with 0 : NO_COVERAGE

400

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::whatOUT to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

410

Substituted 2 with 3 : NO_COVERAGE

Substituted 2 with 3 : NO_COVERAGE

411

Substituted 0 with 1 : NO_COVERAGE

Substituted 0 with 1 : NO_COVERAGE

412

Substituted 1 with 0 : NO_COVERAGE

Substituted 1 with 0 : NO_COVERAGE

414

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::whatIN to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

423

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::whatDevice to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

432

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

441

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

450

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

459

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

469

Removed assignment to member variable secondFetchValue : NO_COVERAGE

479

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

489

replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE

499

mutated return of Object value for fi/helsinki/cs/titokone/RunInfo::getSVC to ( if (x != null) null else throw new RuntimeException ) : NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 0.27