forked from sennpy/CSC431
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStructType.java
More file actions
Latest commit
45 lines (37 loc) · 947 Bytes
/
Copy pathStructType.java
File metadata and controls
45 lines (37 loc) · 947 Bytes
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
importjava.util.HashMap;
importjava.util.ArrayList;
publicclassStructTypeextendsType
{
privateHashMap<String, Type> fields;
privateArrayList<String> fieldOffsets;
publicStructType(HashMap<String, Type> h, ArrayList<String> stuff)
{
fields = h;
fieldOffsets = stuff;
}
publicTypegetFieldType(Stringname)
{
Typeret = fields.get(name);
if (ret != null && ret.getClass().equals(RecType.class))
returnthis;
else
returnret;
}
publicintgetFieldOffset(Stringname)
{
return8*fieldOffsets.indexOf(name);
}
publicintsize()
{
returnfieldOffsets.size() * 8;
}
publicbooleanequals(Objecto)
{
if (o.getClass().equals(NullType.class))
returntrue;
if (!o.getClass().equals(getClass()))
returnfalse;
StructTypeother = (StructType)o;
returnfields.equals(other.fields);
}
}