-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathArg.java
More file actions
41 lines (37 loc) · 924 Bytes
/
Arg.java
File metadata and controls
41 lines (37 loc) · 924 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
import java.util.ArrayList;
class Arg extends ExampleToken implements Token
{
Type type;
String id;
boolean isArray;
FullType datum;
public Arg(Type t, String i, boolean a)
{
id = i;
type = t;
isArray = a;
}
public String toString(int t)
{
return type.toString(t) + " " + id + (isArray ? "[]" : "");
}
public Pair<String,FullType> typeCheck() throws ExampleException
{
FullType ft = new FullType(type.toString(0));
ft.isArray = isArray;
datum = ft;
boolean res = table.add(id,ft);
if (!res)
throw new ExampleException("Error: " + id + " can't be redeclared");
return new Pair<String,FullType>(id,ft);
}
public void execute(Object o)
{
if (o instanceof Integer)
datum.value = new Integer((Integer)o);
if (o instanceof Float)
datum.value = new Float((Float)o);
if (o instanceof ArrayList)
datum.value = o;
}
}