-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStructType.java
More file actions
45 lines (37 loc) · 947 Bytes
/
StructType.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
import java.util.HashMap;
import java.util.ArrayList;
public class StructType extends Type
{
private HashMap<String, Type> fields;
private ArrayList<String> fieldOffsets;
public StructType(HashMap<String, Type> h, ArrayList<String> stuff)
{
fields = h;
fieldOffsets = stuff;
}
public Type getFieldType(String name)
{
Type ret = fields.get(name);
if (ret != null && ret.getClass().equals(RecType.class))
return this;
else
return ret;
}
public int getFieldOffset(String name)
{
return 8*fieldOffsets.indexOf(name);
}
public int size()
{
return fieldOffsets.size() * 8;
}
public boolean equals(Object o)
{
if (o.getClass().equals(NullType.class))
return true;
if (!o.getClass().equals(getClass()))
return false;
StructType other = (StructType)o;
return fields.equals(other.fields);
}
}