|
1 |
| package edu.rice.cs.javalanglevels.tree; |
|
2 |
| |
|
3 |
| import edu.rice.cs.javalanglevels.SourceInfo; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| public class ConcreteMethodDef extends MethodDef { |
|
11 |
| private final BracedBody _body; |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
204
| public ConcreteMethodDef(SourceInfo in_sourceInfo, ModifiersAndVisibility in_mav, TypeParameter[] in_typeParams, ReturnTypeI in_result, Word in_name, FormalParameter[] in_params, ReferenceType[] in_throws, BracedBody in_body) {
|
|
18 |
204
| super(in_sourceInfo, in_mav, in_typeParams, in_result, in_name, in_params, in_throws);
|
|
19 |
| |
|
20 |
204
| if (in_body == null) {
|
|
21 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'body' to the ConcreteMethodDef constructor was null. This class may not have null field values.");
|
|
22 |
| } |
|
23 |
204
| _body = in_body;
|
|
24 |
| } |
|
25 |
| |
|
26 |
370
| final public BracedBody getBody() { return _body; }
|
|
27 |
| |
|
28 |
333
| public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forConcreteMethodDef(this); }
|
|
29 |
0
| public void visit(JExpressionIFVisitor_void visitor) { visitor.forConcreteMethodDef(this); }
|
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
2
| public java.lang.String toString() {
|
|
36 |
2
| java.io.StringWriter w = new java.io.StringWriter();
|
|
37 |
2
| output(w);
|
|
38 |
2
| return w.toString();
|
|
39 |
| } |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
2
| public void output(java.io.Writer writer) {
|
|
45 |
2
| outputHelp(new TabPrintWriter(writer, 2));
|
|
46 |
| } |
|
47 |
| |
|
48 |
44
| public void outputHelp(TabPrintWriter writer) {
|
|
49 |
44
| writer.print("ConcreteMethodDef" + ":");
|
|
50 |
44
| writer.indent();
|
|
51 |
| |
|
52 |
44
| writer.startLine("");
|
|
53 |
44
| writer.print("sourceInfo = ");
|
|
54 |
44
| SourceInfo temp_sourceInfo = getSourceInfo();
|
|
55 |
44
| if (temp_sourceInfo == null) {
|
|
56 |
0
| writer.print("null");
|
|
57 |
| } else { |
|
58 |
44
| writer.print(temp_sourceInfo);
|
|
59 |
| } |
|
60 |
| |
|
61 |
44
| writer.startLine("");
|
|
62 |
44
| writer.print("mav = ");
|
|
63 |
44
| ModifiersAndVisibility temp_mav = getMav();
|
|
64 |
44
| if (temp_mav == null) {
|
|
65 |
0
| writer.print("null");
|
|
66 |
| } else { |
|
67 |
44
| temp_mav.outputHelp(writer);
|
|
68 |
| } |
|
69 |
| |
|
70 |
44
| writer.startLine("");
|
|
71 |
44
| writer.print("typeParams = ");
|
|
72 |
44
| writer.print("{");
|
|
73 |
44
| writer.indent();
|
|
74 |
44
| for (int i = 0; i < getTypeParams().length; i++) {
|
|
75 |
2
| TypeParameter temp_typeParams = getTypeParams()[i];
|
|
76 |
2
| writer.startLine("#" + i + ": ");
|
|
77 |
2
| if (temp_typeParams == null) {
|
|
78 |
0
| writer.print("null");
|
|
79 |
| } else { |
|
80 |
2
| temp_typeParams.outputHelp(writer);
|
|
81 |
| } |
|
82 |
| } |
|
83 |
44
| writer.unindent();
|
|
84 |
44
| if (getTypeParams().length > 0) {
|
|
85 |
2
| writer.startLine("");
|
|
86 |
| } |
|
87 |
44
| writer.print("}");
|
|
88 |
| |
|
89 |
44
| writer.startLine("");
|
|
90 |
44
| writer.print("result = ");
|
|
91 |
44
| ReturnTypeI temp_result = getResult();
|
|
92 |
44
| if (temp_result == null) {
|
|
93 |
0
| writer.print("null");
|
|
94 |
| } else { |
|
95 |
44
| temp_result.outputHelp(writer);
|
|
96 |
| } |
|
97 |
| |
|
98 |
44
| writer.startLine("");
|
|
99 |
44
| writer.print("name = ");
|
|
100 |
44
| Word temp_name = getName();
|
|
101 |
44
| if (temp_name == null) {
|
|
102 |
0
| writer.print("null");
|
|
103 |
| } else { |
|
104 |
44
| temp_name.outputHelp(writer);
|
|
105 |
| } |
|
106 |
| |
|
107 |
44
| writer.startLine("");
|
|
108 |
44
| writer.print("params = ");
|
|
109 |
44
| writer.print("{");
|
|
110 |
44
| writer.indent();
|
|
111 |
44
| for (int i = 0; i < getParams().length; i++) {
|
|
112 |
8
| FormalParameter temp_params = getParams()[i];
|
|
113 |
8
| writer.startLine("#" + i + ": ");
|
|
114 |
8
| if (temp_params == null) {
|
|
115 |
0
| writer.print("null");
|
|
116 |
| } else { |
|
117 |
8
| temp_params.outputHelp(writer);
|
|
118 |
| } |
|
119 |
| } |
|
120 |
44
| writer.unindent();
|
|
121 |
44
| if (getParams().length > 0) {
|
|
122 |
8
| writer.startLine("");
|
|
123 |
| } |
|
124 |
44
| writer.print("}");
|
|
125 |
| |
|
126 |
44
| writer.startLine("");
|
|
127 |
44
| writer.print("throws = ");
|
|
128 |
44
| writer.print("{");
|
|
129 |
44
| writer.indent();
|
|
130 |
44
| for (int i = 0; i < getThrows().length; i++) {
|
|
131 |
2
| ReferenceType temp_throws = getThrows()[i];
|
|
132 |
2
| writer.startLine("#" + i + ": ");
|
|
133 |
2
| if (temp_throws == null) {
|
|
134 |
0
| writer.print("null");
|
|
135 |
| } else { |
|
136 |
2
| temp_throws.outputHelp(writer);
|
|
137 |
| } |
|
138 |
| } |
|
139 |
44
| writer.unindent();
|
|
140 |
44
| if (getThrows().length > 0) {
|
|
141 |
2
| writer.startLine("");
|
|
142 |
| } |
|
143 |
44
| writer.print("}");
|
|
144 |
| |
|
145 |
44
| writer.startLine("");
|
|
146 |
44
| writer.print("body = ");
|
|
147 |
44
| BracedBody temp_body = getBody();
|
|
148 |
44
| if (temp_body == null) {
|
|
149 |
0
| writer.print("null");
|
|
150 |
| } else { |
|
151 |
44
| temp_body.outputHelp(writer);
|
|
152 |
| } |
|
153 |
44
| writer.unindent();
|
|
154 |
| } |
|
155 |
| |
|
156 |
| |
|
157 |
| |
|
158 |
| |
|
159 |
| |
|
160 |
| |
|
161 |
0
| public boolean equals(java.lang.Object obj) {
|
|
162 |
0
| if (obj == null) return false;
|
|
163 |
0
| if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
|
|
164 |
0
| return false;
|
|
165 |
| } else { |
|
166 |
0
| ConcreteMethodDef casted = (ConcreteMethodDef) obj;
|
|
167 |
0
| if (! (getMav().equals(casted.getMav()))) return false;
|
|
168 |
0
| if (this.getTypeParams().length != casted.getTypeParams().length) return false;
|
|
169 |
0
| for (int i = 0; i < getTypeParams().length; i++) if (! getTypeParams()[i].equals(casted.getTypeParams()[i])) return false;
|
|
170 |
0
| if (! (getResult().equals(casted.getResult()))) return false;
|
|
171 |
0
| if (! (getName().equals(casted.getName()))) return false;
|
|
172 |
0
| if (this.getParams().length != casted.getParams().length) return false;
|
|
173 |
0
| for (int i = 0; i < getParams().length; i++) if (! getParams()[i].equals(casted.getParams()[i])) return false;
|
|
174 |
0
| if (this.getThrows().length != casted.getThrows().length) return false;
|
|
175 |
0
| for (int i = 0; i < getThrows().length; i++) if (! getThrows()[i].equals(casted.getThrows()[i])) return false;
|
|
176 |
0
| if (! (getBody().equals(casted.getBody()))) return false;
|
|
177 |
0
| return true;
|
|
178 |
| } |
|
179 |
| } |
|
180 |
| |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
| |
|
186 |
| |
|
187 |
0
| protected int generateHashCode() {
|
|
188 |
0
| int code = getClass().hashCode();
|
|
189 |
0
| code ^= 0;
|
|
190 |
0
| code ^= getMav().hashCode();
|
|
191 |
0
| for (int i = 0; i < getTypeParams().length; i++) code ^= getTypeParams()[i].hashCode();
|
|
192 |
0
| code ^= getResult().hashCode();
|
|
193 |
0
| code ^= getName().hashCode();
|
|
194 |
0
| for (int i = 0; i < getParams().length; i++) code ^= getParams()[i].hashCode();
|
|
195 |
0
| for (int i = 0; i < getThrows().length; i++) code ^= getThrows()[i].hashCode();
|
|
196 |
0
| code ^= getBody().hashCode();
|
|
197 |
0
| return code;
|
|
198 |
| } |
|
199 |
| } |