|
1 |
| package edu.rice.cs.dynamicjava.symbol; |
|
2 |
| |
|
3 |
| import java.lang.reflect.Array; |
|
4 |
| import edu.rice.cs.plt.lambda.Box; |
|
5 |
| import edu.rice.cs.plt.tuple.Option; |
|
6 |
| import edu.rice.cs.dynamicjava.symbol.type.Type; |
|
7 |
| |
|
8 |
| |
|
9 |
| public class ArrayLengthField implements DJField { |
|
10 |
| |
|
11 |
| public static final ArrayLengthField INSTANCE = new ArrayLengthField(); |
|
12 |
| |
|
13 |
| |
|
14 |
1
| private ArrayLengthField() {}
|
|
15 |
| |
|
16 |
0
| public String declaredName() { return "length"; }
|
|
17 |
0
| public DJClass declaringClass() { return null; }
|
|
18 |
216
| public Type type() { return TypeSystem.INT; }
|
|
19 |
0
| public boolean isFinal() { return true; }
|
|
20 |
108
| public boolean isStatic() { return false; }
|
|
21 |
0
| public Access accessibility() { return Access.PUBLIC; }
|
|
22 |
0
| public Access.Module accessModule() { return new TopLevelAccessModule("java.lang"); }
|
|
23 |
| |
|
24 |
0
| public Option<Object> constantValue() { return Option.none(); }
|
|
25 |
38
| public Box<Object> boxForReceiver(final Object receiver) {
|
|
26 |
38
| return new Box<Object>() {
|
|
27 |
38
| public Object value() { return Array.getLength(receiver); }
|
|
28 |
0
| public void set(Object val) {
|
|
29 |
0
| throw new RuntimeException(new IllegalAccessException("Can't set an array's length"));
|
|
30 |
| } |
|
31 |
| }; |
|
32 |
| } |
|
33 |
| |
|
34 |
| } |