-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInstruction.java
More file actions
53 lines (44 loc) · 1.29 KB
/
Copy pathInstruction.java
File metadata and controls
53 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* An instruction in the YVM.
* Each line of a .yvm is an instruction.
* The options are usefull for the asm translation, otherwise we would just
* have used strings.
*/
public class Instruction{
public String inst;
public boolean hasOption1;
public boolean hasOption2;
public boolean isLabel;
public int option1;
public String option2;
public Instruction(String inst){
this.inst = inst;
this.hasOption1 = false;
this.hasOption2 = false;
}
public Instruction(String inst, boolean label){
this(inst);
this.isLabel = label;
}
public Instruction(String inst, int option){
this.inst = inst;
this.hasOption1 = true;
this.option1 = option;
}
public Instruction(String inst, String option){
this.inst = inst;
this.hasOption2 = true;
this.option2 = option;
}
public String toString(){
if(this.isLabel){
return this.inst;
}
if(this.hasOption1){
return "\t" + this.inst + " " + this.option1;
}else if(this.hasOption2){
return "\t" + this.inst + " " + this.option2;
}
return "\t" + this.inst;
}
}