|
1 |
| package edu.rice.cs.javalanglevels.tree; |
|
2 |
| |
|
3 |
| import edu.rice.cs.javalanglevels.SourceInfo; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| public class ArrayAccess extends Primary { |
|
11 |
| private final Expression _array; |
|
12 |
| private final Expression _index; |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
17
| public ArrayAccess(SourceInfo in_sourceInfo, Expression in_array, Expression in_index) {
|
|
19 |
17
| super(in_sourceInfo);
|
|
20 |
| |
|
21 |
17
| if (in_array == null) {
|
|
22 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'array' to the ArrayAccess constructor was null. This class may not have null field values.");
|
|
23 |
| } |
|
24 |
17
| _array = in_array;
|
|
25 |
| |
|
26 |
17
| if (in_index == null) {
|
|
27 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'index' to the ArrayAccess constructor was null. This class may not have null field values.");
|
|
28 |
| } |
|
29 |
17
| _index = in_index;
|
|
30 |
| } |
|
31 |
| |
|
32 |
26
| final public Expression getArray() { return _array; }
|
|
33 |
26
| final public Expression getIndex() { return _index; }
|
|
34 |
| |
|
35 |
16
| public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forArrayAccess(this); }
|
|
36 |
0
| public void visit(JExpressionIFVisitor_void visitor) { visitor.forArrayAccess(this); }
|
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
0
| public java.lang.String toString() {
|
|
43 |
0
| java.io.StringWriter w = new java.io.StringWriter();
|
|
44 |
0
| output(w);
|
|
45 |
0
| return w.toString();
|
|
46 |
| } |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
0
| public void output(java.io.Writer writer) {
|
|
52 |
0
| outputHelp(new TabPrintWriter(writer, 2));
|
|
53 |
| } |
|
54 |
| |
|
55 |
14
| public void outputHelp(TabPrintWriter writer) {
|
|
56 |
14
| writer.print("ArrayAccess" + ":");
|
|
57 |
14
| writer.indent();
|
|
58 |
| |
|
59 |
14
| writer.startLine("");
|
|
60 |
14
| writer.print("sourceInfo = ");
|
|
61 |
14
| SourceInfo temp_sourceInfo = getSourceInfo();
|
|
62 |
14
| if (temp_sourceInfo == null) {
|
|
63 |
0
| writer.print("null");
|
|
64 |
| } else { |
|
65 |
14
| writer.print(temp_sourceInfo);
|
|
66 |
| } |
|
67 |
| |
|
68 |
14
| writer.startLine("");
|
|
69 |
14
| writer.print("array = ");
|
|
70 |
14
| Expression temp_array = getArray();
|
|
71 |
14
| if (temp_array == null) {
|
|
72 |
0
| writer.print("null");
|
|
73 |
| } else { |
|
74 |
14
| temp_array.outputHelp(writer);
|
|
75 |
| } |
|
76 |
| |
|
77 |
14
| writer.startLine("");
|
|
78 |
14
| writer.print("index = ");
|
|
79 |
14
| Expression temp_index = getIndex();
|
|
80 |
14
| if (temp_index == null) {
|
|
81 |
0
| writer.print("null");
|
|
82 |
| } else { |
|
83 |
14
| temp_index.outputHelp(writer);
|
|
84 |
| } |
|
85 |
14
| writer.unindent();
|
|
86 |
| } |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
1
| public boolean equals(java.lang.Object obj) {
|
|
94 |
0
| if (obj == null) return false;
|
|
95 |
1
| if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
|
|
96 |
0
| return false;
|
|
97 |
| } else { |
|
98 |
1
| ArrayAccess casted = (ArrayAccess) obj;
|
|
99 |
0
| if (! (getArray().equals(casted.getArray()))) return false;
|
|
100 |
0
| if (! (getIndex().equals(casted.getIndex()))) return false;
|
|
101 |
1
| return true;
|
|
102 |
| } |
|
103 |
| } |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
| |
|
108 |
| |
|
109 |
| |
|
110 |
| |
|
111 |
1
| protected int generateHashCode() {
|
|
112 |
1
| int code = getClass().hashCode();
|
|
113 |
1
| code ^= 0;
|
|
114 |
1
| code ^= getArray().hashCode();
|
|
115 |
1
| code ^= getIndex().hashCode();
|
|
116 |
1
| return code;
|
|
117 |
| } |
|
118 |
| } |