-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSCP.java
73 lines (58 loc) · 1.31 KB
/
DSCP.java
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package compiler;
import java.util.LinkedList;
public class DSCP {
public IdKind idKind;
public String CV;
public DSCP type;
public AddressingMode addmd;
public int address;
public int level;
public int activationRecord;
//----> this is zero for all :|
// public LinkedList<Integer> lb;
public LinkedList<Integer> ub;
public LinkedList<DSCP> arg;
public LinkedList<DSCP> fld;
public int size;
public DSCP() {
CV = "";
type = null;
addmd = null;
address = 0;
level = 0;
activationRecord = 0;
ub = new LinkedList<Integer>();
arg = new LinkedList<DSCP>();
fld = new LinkedList<DSCP>();
size = 0;
}
//----> needs to be checked :|
public void setSize() {
int size = 0;
for(Integer i : ub) {
size = size*i;
}
int temp = 0;
for(DSCP i : fld) {
temp += i.size;
}
if(!fld.isEmpty())
size = size*temp;
int factor = type.size;
if( type.CV.equals("string") )
factor = CV.length()*1;
else if (type.CV.equals("boolean") )
factor = 1;
else if (type.CV.equals("int") )
factor = 4;
else if (type.CV.equals("float") )
factor = 4;
else if (type.CV.equals("char") )
factor = 1;
this.size = size*factor;
}
public boolean equals(Object obj) {
DSCP temp = (DSCP) obj;
return ( (temp.CV.equals(this.CV)) && (temp.level == this.level) );
}
}