Lines 19-36
Link Here
|
19 |
import org.eclipse.jdt.internal.compiler.codegen.CodeStream; |
19 |
import org.eclipse.jdt.internal.compiler.codegen.CodeStream; |
20 |
import org.eclipse.jdt.internal.compiler.codegen.Opcodes; |
20 |
import org.eclipse.jdt.internal.compiler.codegen.Opcodes; |
21 |
import org.eclipse.jdt.internal.compiler.flow.FlowInfo; |
21 |
import org.eclipse.jdt.internal.compiler.flow.FlowInfo; |
22 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
|
|
23 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
22 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
24 |
import org.eclipse.jdt.internal.compiler.lookup.Binding; |
23 |
import org.eclipse.jdt.internal.compiler.lookup.Binding; |
25 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
24 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
26 |
import org.eclipse.jdt.internal.compiler.lookup.ClassScope; |
|
|
27 |
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; |
25 |
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; |
28 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
26 |
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; |
|
|
27 |
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; |
29 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemBinding; |
28 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemBinding; |
30 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; |
29 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; |
31 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; |
30 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; |
32 |
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; |
31 |
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; |
33 |
import org.eclipse.jdt.internal.compiler.lookup.Scope; |
|
|
34 |
import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding; |
32 |
import org.eclipse.jdt.internal.compiler.lookup.SyntheticMethodBinding; |
35 |
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; |
33 |
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; |
36 |
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; |
34 |
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; |
Lines 50-323
Link Here
|
50 |
super(sources, positions, sourceStart, sourceEnd); |
48 |
super(sources, positions, sourceStart, sourceEnd); |
51 |
this.evaluationContext = evaluationContext; |
49 |
this.evaluationContext = evaluationContext; |
52 |
} |
50 |
} |
53 |
/** |
|
|
54 |
* Check and/or redirect the field access to the delegate receiver if any |
55 |
*/ |
56 |
public TypeBinding checkFieldAccess(BlockScope scope) { |
57 |
// check for forward references |
58 |
this.bits &= ~RestrictiveFlagMASK; // clear bits |
59 |
this.bits |= Binding.FIELD; |
60 |
return getOtherFieldBindings(scope); |
61 |
} |
62 |
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) { |
63 |
|
64 |
FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream); |
65 |
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { |
66 |
// the last field access is a write access |
67 |
assignment.expression.generateCode(currentScope, codeStream, true); |
68 |
fieldStore(codeStream, lastFieldBinding, null, valueRequired); |
69 |
} else { |
70 |
codeStream.generateEmulationForField(lastFieldBinding); |
71 |
codeStream.swap(); |
72 |
assignment.expression.generateCode(currentScope, codeStream, true); |
73 |
if (valueRequired) { |
74 |
if ((lastFieldBinding.type == TypeBinding.LONG) || (lastFieldBinding.type == TypeBinding.DOUBLE)) { |
75 |
codeStream.dup2_x2(); |
76 |
} else { |
77 |
codeStream.dup_x2(); |
78 |
} |
79 |
} |
80 |
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding); |
81 |
} |
82 |
if (valueRequired) { |
83 |
codeStream.generateImplicitConversion(assignment.implicitConversion); |
84 |
} |
85 |
} |
86 |
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { |
51 |
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { |
87 |
int pc = codeStream.position; |
52 |
int pc = codeStream.position; |
88 |
if (this.constant != Constant.NotAConstant) { |
53 |
if ((this.bits & Binding.VARIABLE) == 0) { // nothing to do if type ref |
89 |
if (valueRequired) { |
54 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
90 |
codeStream.generateConstant(this.constant, this.implicitConversion); |
55 |
return; |
91 |
} |
56 |
} |
92 |
} else { |
57 |
FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1]; |
93 |
FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream); |
58 |
if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) { |
94 |
if (valueRequired) { |
59 |
super.generateCode(currentScope, codeStream, valueRequired); |
95 |
if (lastFieldBinding.declaringClass == null) { // array length |
60 |
return; |
96 |
codeStream.arraylength(); |
61 |
} |
97 |
codeStream.generateImplicitConversion(this.implicitConversion); |
62 |
lastFieldBinding = generateReadSequence(currentScope, codeStream); |
98 |
} else { |
63 |
if (lastFieldBinding != null) { |
99 |
Constant fieldConstant = lastFieldBinding.constant(); |
64 |
boolean isStatic = lastFieldBinding.isStatic(); |
100 |
if (fieldConstant != Constant.NotAConstant) { |
65 |
Constant fieldConstant = lastFieldBinding.constant(); |
101 |
if (!lastFieldBinding.isStatic()){ |
66 |
if (fieldConstant != Constant.NotAConstant) { |
102 |
codeStream.invokeObjectGetClass(); |
67 |
if (!isStatic){ |
|
|
68 |
codeStream.invokeObjectGetClass(); |
69 |
codeStream.pop(); |
70 |
} |
71 |
if (valueRequired) { // inline the last field constant |
72 |
codeStream.generateConstant(fieldConstant, this.implicitConversion); |
73 |
} |
74 |
} else { |
75 |
boolean isFirst = lastFieldBinding == this.binding |
76 |
&& (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType()) |
77 |
&& this.otherBindings == null; // could be dup: next.next.next |
78 |
TypeBinding requiredGenericCast = getGenericCast(this.otherBindings == null ? 0 : this.otherBindings.length); |
79 |
if (valueRequired |
80 |
|| (!isFirst && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) |
81 |
|| ((this.implicitConversion & TypeIds.UNBOXING) != 0) |
82 |
|| requiredGenericCast != null) { |
83 |
int lastFieldPc = codeStream.position; |
84 |
if (lastFieldBinding.declaringClass == null) { // array length |
85 |
codeStream.arraylength(); |
86 |
if (valueRequired) { |
87 |
codeStream.generateImplicitConversion(this.implicitConversion); |
88 |
} else { |
89 |
// could occur if !valueRequired but compliance >= 1.4 |
103 |
codeStream.pop(); |
90 |
codeStream.pop(); |
104 |
} |
91 |
} |
105 |
// inline the last field constant |
|
|
106 |
codeStream.generateConstant(fieldConstant, this.implicitConversion); |
107 |
} else { |
92 |
} else { |
108 |
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { |
93 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
109 |
if (lastFieldBinding.isStatic()) { |
94 |
if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast); |
110 |
codeStream.getstatic(lastFieldBinding); |
95 |
if (valueRequired) { |
111 |
} else { |
96 |
codeStream.generateImplicitConversion(this.implicitConversion); |
112 |
codeStream.getfield(lastFieldBinding); |
|
|
113 |
} |
114 |
} else { |
97 |
} else { |
115 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
98 |
boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0; |
|
|
99 |
// conversion only generated if unboxing |
100 |
if (isUnboxing) codeStream.generateImplicitConversion(this.implicitConversion); |
101 |
switch (isUnboxing ? postConversionType(currentScope).id : lastFieldBinding.type.id) { |
102 |
case T_long : |
103 |
case T_double : |
104 |
codeStream.pop2(); |
105 |
break; |
106 |
default : |
107 |
codeStream.pop(); |
108 |
} |
116 |
} |
109 |
} |
117 |
codeStream.generateImplicitConversion(this.implicitConversion); |
|
|
118 |
} |
110 |
} |
119 |
} |
111 |
|
120 |
} else { |
112 |
int fieldPosition = (int) (this.sourcePositions[this.sourcePositions.length - 1] >>> 32); |
121 |
if (lastFieldBinding != null && !lastFieldBinding.isStatic()){ |
113 |
codeStream.recordPositionsFrom(lastFieldPc, fieldPosition); |
122 |
codeStream.invokeObjectGetClass(); // perform null check |
114 |
} else { |
123 |
codeStream.pop(); |
115 |
if (!isStatic){ |
|
|
116 |
codeStream.invokeObjectGetClass(); // perform null check |
117 |
codeStream.pop(); |
118 |
} |
124 |
} |
119 |
} |
125 |
} |
120 |
} |
126 |
} |
121 |
} |
127 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
122 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
128 |
} |
123 |
} |
129 |
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { |
124 |
/** |
130 |
|
125 |
* Check and/or redirect the field access to the delegate receiver if any |
131 |
FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream); |
126 |
*/ |
132 |
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { |
127 |
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) { |
133 |
if (lastFieldBinding.isStatic()){ |
128 |
FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1]; |
134 |
codeStream.getstatic(lastFieldBinding); |
129 |
if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) { |
135 |
} else { |
130 |
super.generateAssignment(currentScope, codeStream, assignment, valueRequired); |
136 |
codeStream.dup(); |
131 |
return; |
137 |
codeStream.getfield(lastFieldBinding); |
132 |
} |
138 |
} |
133 |
lastFieldBinding = generateReadSequence(currentScope, codeStream); |
139 |
// the last field access is a write access |
134 |
codeStream.generateEmulationForField(lastFieldBinding); |
140 |
// perform the actual compound operation |
135 |
codeStream.swap(); |
141 |
int operationTypeID; |
136 |
assignment.expression.generateCode(currentScope, codeStream, true); |
142 |
switch(operationTypeID = (this.implicitConversion & IMPLICIT_CONVERSION_MASK) >> 4) { |
137 |
if (valueRequired) { |
143 |
case T_JavaLangString : |
138 |
switch (lastFieldBinding.type.id) { |
144 |
case T_JavaLangObject : |
139 |
case TypeIds.T_long : |
145 |
case T_undefined : |
140 |
case TypeIds.T_double : |
146 |
codeStream.generateStringConcatenationAppend(currentScope, null, expression); |
141 |
codeStream.dup2_x2(); |
147 |
break; |
142 |
break; |
148 |
default : |
143 |
default : |
149 |
// promote the array reference to the suitable operation type |
144 |
codeStream.dup_x2(); |
150 |
codeStream.generateImplicitConversion(this.implicitConversion); |
145 |
break; |
151 |
// generate the increment value (will by itself be promoted to the operation value) |
146 |
} |
152 |
if (expression == IntLiteral.One){ // prefix operation |
147 |
} |
153 |
codeStream.generateConstant(expression.constant, this.implicitConversion); |
148 |
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding); |
154 |
} else { |
149 |
if (valueRequired) { |
155 |
expression.generateCode(currentScope, codeStream, true); |
150 |
codeStream.generateImplicitConversion(assignment.implicitConversion); |
156 |
} |
151 |
} |
157 |
// perform the operation |
152 |
} |
158 |
codeStream.sendOperator(operator, operationTypeID); |
153 |
|
159 |
// cast the value back to the array reference type |
154 |
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { |
160 |
codeStream.generateImplicitConversion(assignmentImplicitConversion); |
155 |
FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1]; |
161 |
} |
156 |
if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) { |
162 |
// actual assignment |
157 |
super.generateCompoundAssignment(currentScope, codeStream, expression, operator, assignmentImplicitConversion, valueRequired); |
163 |
fieldStore(codeStream, lastFieldBinding, null, valueRequired); |
158 |
return; |
|
|
159 |
} |
160 |
lastFieldBinding = generateReadSequence(currentScope, codeStream); |
161 |
if (lastFieldBinding.isStatic()){ |
162 |
codeStream.generateEmulationForField(lastFieldBinding); |
163 |
codeStream.swap(); |
164 |
codeStream.aconst_null(); |
165 |
codeStream.swap(); |
166 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
164 |
} else { |
167 |
} else { |
165 |
if (lastFieldBinding.isStatic()){ |
168 |
codeStream.generateEmulationForField(lastFieldBinding); |
166 |
codeStream.generateEmulationForField(lastFieldBinding); |
169 |
codeStream.swap(); |
167 |
codeStream.swap(); |
170 |
codeStream.dup(); |
168 |
codeStream.aconst_null(); |
|
|
169 |
codeStream.swap(); |
170 |
|
171 |
|
171 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
172 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
172 |
} else { |
173 |
} |
173 |
codeStream.generateEmulationForField(lastFieldBinding); |
174 |
// the last field access is a write access |
174 |
codeStream.swap(); |
175 |
// perform the actual compound operation |
175 |
codeStream.dup(); |
176 |
int operationTypeID; |
176 |
|
177 |
if ((operationTypeID = (this.implicitConversion & IMPLICIT_CONVERSION_MASK) >> 4) == T_JavaLangString) { |
177 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
178 |
codeStream.generateStringConcatenationAppend(currentScope, null, expression); |
178 |
} |
179 |
} else { |
179 |
// the last field access is a write access |
180 |
// promote the array reference to the suitable operation type |
180 |
// perform the actual compound operation |
181 |
codeStream.generateImplicitConversion(this.implicitConversion); |
181 |
int operationTypeID; |
182 |
// generate the increment value (will by itself be promoted to the operation value) |
182 |
if ((operationTypeID = (this.implicitConversion & IMPLICIT_CONVERSION_MASK) >> 4) == T_JavaLangString) { |
183 |
if (expression == IntLiteral.One){ // prefix operation |
183 |
codeStream.generateStringConcatenationAppend(currentScope, null, expression); |
184 |
codeStream.generateConstant(expression.constant, this.implicitConversion); |
184 |
} else { |
185 |
} else { |
185 |
// promote the array reference to the suitable operation type |
186 |
expression.generateCode(currentScope, codeStream, true); |
186 |
codeStream.generateImplicitConversion(this.implicitConversion); |
187 |
} |
187 |
// generate the increment value (will by itself be promoted to the operation value) |
188 |
// perform the operation |
188 |
if (expression == IntLiteral.One){ // prefix operation |
189 |
codeStream.sendOperator(operator, operationTypeID); |
189 |
codeStream.generateConstant(expression.constant, this.implicitConversion); |
190 |
// cast the value back to the array reference type |
190 |
} else { |
191 |
codeStream.generateImplicitConversion(assignmentImplicitConversion); |
191 |
expression.generateCode(currentScope, codeStream, true); |
192 |
} |
192 |
} |
193 |
// actual assignment |
193 |
// perform the operation |
194 |
|
194 |
codeStream.sendOperator(operator, operationTypeID); |
195 |
// current stack is: |
195 |
// cast the value back to the array reference type |
196 |
// field receiver value |
196 |
codeStream.generateImplicitConversion(assignmentImplicitConversion); |
197 |
if (valueRequired) { |
197 |
} |
198 |
switch (lastFieldBinding.type.id) { |
198 |
// actual assignment |
199 |
case TypeIds.T_long : |
199 |
|
200 |
case TypeIds.T_double : |
200 |
// current stack is: |
|
|
201 |
// field receiver value |
202 |
if (valueRequired) { |
203 |
if ((lastFieldBinding.type == TypeBinding.LONG) || (lastFieldBinding.type == TypeBinding.DOUBLE)) { |
204 |
codeStream.dup2_x2(); |
201 |
codeStream.dup2_x2(); |
205 |
} else { |
202 |
break; |
|
|
203 |
default : |
206 |
codeStream.dup_x2(); |
204 |
codeStream.dup_x2(); |
207 |
} |
205 |
break; |
208 |
} |
206 |
} |
209 |
// current stack is: |
|
|
210 |
// value field receiver value |
211 |
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding); |
212 |
} |
207 |
} |
|
|
208 |
// current stack is: |
209 |
// value field receiver value |
210 |
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding); |
213 |
} |
211 |
} |
214 |
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) { |
212 |
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) { |
215 |
|
213 |
FieldBinding lastFieldBinding = this.otherBindings == null ? (FieldBinding) this.binding : this.otherBindings[this.otherBindings.length-1]; |
216 |
FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream); |
214 |
if (lastFieldBinding.canBeSeenBy(getFinalReceiverType(), this, currentScope)) { |
217 |
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { |
215 |
super.generatePostIncrement(currentScope, codeStream, postIncrement, valueRequired); |
218 |
SyntheticMethodBinding accessor = |
216 |
return; |
219 |
this.syntheticReadAccessors == null |
217 |
} |
220 |
? null |
218 |
lastFieldBinding = generateReadSequence(currentScope, codeStream); |
221 |
: this.syntheticReadAccessors[this.syntheticReadAccessors.length - 1]; |
219 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
|
|
220 |
if (valueRequired) { |
221 |
switch (lastFieldBinding.type.id) { |
222 |
case TypeIds.T_long : |
223 |
case TypeIds.T_double : |
224 |
codeStream.dup2(); |
225 |
break; |
226 |
default : |
227 |
codeStream.dup(); |
228 |
break; |
229 |
} |
230 |
} |
231 |
codeStream.generateEmulationForField(lastFieldBinding); |
232 |
if ((lastFieldBinding.type == TypeBinding.LONG) || (lastFieldBinding.type == TypeBinding.DOUBLE)) { |
233 |
codeStream.dup_x2(); |
234 |
codeStream.pop(); |
222 |
if (lastFieldBinding.isStatic()) { |
235 |
if (lastFieldBinding.isStatic()) { |
223 |
if (accessor == null) { |
236 |
codeStream.aconst_null(); |
224 |
codeStream.getstatic(lastFieldBinding); |
|
|
225 |
} else { |
226 |
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); |
227 |
} |
228 |
} else { |
237 |
} else { |
229 |
codeStream.dup(); |
238 |
generateReadSequence(currentScope, codeStream); |
230 |
if (accessor == null) { |
|
|
231 |
codeStream.getfield(lastFieldBinding); |
232 |
} else { |
233 |
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); |
234 |
} |
235 |
} |
236 |
|
237 |
TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length); |
238 |
if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast); |
239 |
codeStream.generateImplicitConversion(this.implicitConversion); |
240 |
|
241 |
// duplicate the old field value |
242 |
int operandType = this.implicitConversion & TypeIds.COMPILE_TYPE_MASK; |
243 |
if (valueRequired) { |
244 |
if (lastFieldBinding.isStatic()) { |
245 |
if (operandType == T_long || operandType == T_double) { |
246 |
codeStream.dup2(); |
247 |
} else { |
248 |
codeStream.dup(); |
249 |
} |
250 |
} else { // Stack: [owner][old field value] ---> [old field value][owner][old field value] |
251 |
if (operandType == T_long || operandType == T_double) { |
252 |
codeStream.dup2_x1(); |
253 |
} else { |
254 |
codeStream.dup_x1(); |
255 |
} |
256 |
} |
257 |
} |
239 |
} |
258 |
codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion); |
240 |
codeStream.dup_x2(); |
259 |
codeStream.sendOperator(postIncrement.operator, operandType); |
241 |
codeStream.pop(); |
260 |
codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion); |
|
|
261 |
fieldStore(codeStream, lastFieldBinding, this.syntheticWriteAccessor, false); |
262 |
} else { |
242 |
} else { |
263 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
243 |
codeStream.dup_x1(); |
264 |
if (valueRequired) { |
244 |
codeStream.pop(); |
265 |
if ((lastFieldBinding.type == TypeBinding.LONG) || (lastFieldBinding.type == TypeBinding.DOUBLE)) { |
245 |
if (lastFieldBinding.isStatic()) { |
266 |
codeStream.dup2(); |
246 |
codeStream.aconst_null(); |
267 |
} else { |
|
|
268 |
codeStream.dup(); |
269 |
} |
270 |
} |
271 |
codeStream.generateEmulationForField(lastFieldBinding); |
272 |
if ((lastFieldBinding.type == TypeBinding.LONG) || (lastFieldBinding.type == TypeBinding.DOUBLE)) { |
273 |
codeStream.dup_x2(); |
274 |
codeStream.pop(); |
275 |
if (lastFieldBinding.isStatic()) { |
276 |
codeStream.aconst_null(); |
277 |
} else { |
278 |
generateReadSequence(currentScope, codeStream); |
279 |
} |
280 |
codeStream.dup_x2(); |
281 |
codeStream.pop(); |
282 |
} else { |
247 |
} else { |
283 |
codeStream.dup_x1(); |
248 |
generateReadSequence(currentScope, codeStream); |
284 |
codeStream.pop(); |
|
|
285 |
if (lastFieldBinding.isStatic()) { |
286 |
codeStream.aconst_null(); |
287 |
} else { |
288 |
generateReadSequence(currentScope, codeStream); |
289 |
} |
290 |
codeStream.dup_x1(); |
291 |
codeStream.pop(); |
292 |
} |
249 |
} |
293 |
codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion); |
250 |
codeStream.dup_x1(); |
294 |
codeStream.sendOperator(postIncrement.operator, lastFieldBinding.type.id); |
251 |
codeStream.pop(); |
295 |
codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion); |
|
|
296 |
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding); |
297 |
} |
252 |
} |
|
|
253 |
codeStream.generateConstant(postIncrement.expression.constant, this.implicitConversion); |
254 |
codeStream.sendOperator(postIncrement.operator, lastFieldBinding.type.id); |
255 |
codeStream.generateImplicitConversion(postIncrement.preAssignImplicitConversion); |
256 |
codeStream.generateEmulatedWriteAccessForField(lastFieldBinding); |
298 |
} |
257 |
} |
|
|
258 |
|
299 |
/* |
259 |
/* |
300 |
* Generate code for all bindings (local and fields) excluding the last one, which may then be generated code |
260 |
* Generate code for all bindings (local and fields) excluding the last one, which may then be generated code |
301 |
* for a read or write access. |
261 |
* for a read or write access. |
302 |
*/ |
262 |
*/ |
303 |
public FieldBinding generateReadSequence(BlockScope currentScope, CodeStream codeStream) { |
263 |
public FieldBinding generateReadSequence(BlockScope currentScope, CodeStream codeStream) { |
304 |
|
|
|
305 |
// determine the rank until which we now we do not need any actual value for the field access |
264 |
// determine the rank until which we now we do not need any actual value for the field access |
306 |
int otherBindingsCount = this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length; |
265 |
int otherBindingsCount = this.otherBindings == null ? 0 : this.otherBindings.length; |
307 |
boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic(); |
266 |
boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic(); |
308 |
FieldBinding lastFieldBinding = null; |
267 |
FieldBinding lastFieldBinding; |
309 |
TypeBinding lastGenericCast = null; |
268 |
TypeBinding lastGenericCast; |
310 |
|
269 |
TypeBinding lastReceiverType; |
|
|
270 |
boolean complyTo14 = currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4; |
271 |
|
311 |
switch (this.bits & RestrictiveFlagMASK) { |
272 |
switch (this.bits & RestrictiveFlagMASK) { |
312 |
case Binding.FIELD : |
273 |
case Binding.FIELD : |
313 |
lastFieldBinding = (FieldBinding) this.codegenBinding; |
274 |
lastFieldBinding = ((FieldBinding) this.binding).original(); |
314 |
lastGenericCast = this.genericCast; |
275 |
lastGenericCast = this.genericCast; |
|
|
276 |
lastReceiverType = this.actualReceiverType; |
315 |
// if first field is actually constant, we can inline it |
277 |
// if first field is actually constant, we can inline it |
316 |
if (lastFieldBinding.constant() != Constant.NotAConstant) { |
278 |
if (lastFieldBinding.constant() != Constant.NotAConstant) { |
317 |
break; |
279 |
break; |
318 |
} |
280 |
} |
319 |
if (needValue) { |
281 |
if (needValue) { |
320 |
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { |
282 |
if (lastFieldBinding.canBeSeenBy(this.actualReceiverType, this, currentScope)) { |
321 |
if (!lastFieldBinding.isStatic()) { |
283 |
if (!lastFieldBinding.isStatic()) { |
322 |
if ((this.bits & DepthMASK) != 0) { |
284 |
if ((this.bits & DepthMASK) != 0) { |
323 |
ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & DepthMASK) >> DepthSHIFT); |
285 |
ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & DepthMASK) >> DepthSHIFT); |
Lines 343-350
Link Here
|
343 |
} |
305 |
} |
344 |
break; |
306 |
break; |
345 |
case Binding.LOCAL : // reading the first local variable |
307 |
case Binding.LOCAL : // reading the first local variable |
|
|
308 |
lastFieldBinding = null; |
309 |
lastGenericCast = null; |
310 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; |
311 |
lastReceiverType = localBinding.type; |
346 |
if (!needValue) break; // no value needed |
312 |
if (!needValue) break; // no value needed |
347 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding; |
|
|
348 |
// regular local variable read |
313 |
// regular local variable read |
349 |
Constant localConstant = localBinding.constant(); |
314 |
Constant localConstant = localBinding.constant(); |
350 |
if (localConstant != Constant.NotAConstant) { |
315 |
if (localConstant != Constant.NotAConstant) { |
Lines 360-421
Link Here
|
360 |
codeStream.load(localBinding); |
325 |
codeStream.load(localBinding); |
361 |
} |
326 |
} |
362 |
} |
327 |
} |
|
|
328 |
break; |
329 |
default : // should not occur |
330 |
return null; |
363 |
} |
331 |
} |
364 |
|
|
|
365 |
// all intermediate field accesses are read accesses |
332 |
// all intermediate field accesses are read accesses |
366 |
// only the last field binding is a write access |
333 |
// only the last field binding is a write access |
367 |
if (this.otherCodegenBindings != null) { |
334 |
int positionsLength = this.sourcePositions.length; |
|
|
335 |
FieldBinding initialFieldBinding = lastFieldBinding; // can be null if initial was a local binding |
336 |
if (this.otherBindings != null) { |
368 |
for (int i = 0; i < otherBindingsCount; i++) { |
337 |
for (int i = 0; i < otherBindingsCount; i++) { |
369 |
FieldBinding nextField = this.otherCodegenBindings[i]; |
338 |
int pc = codeStream.position; |
|
|
339 |
FieldBinding nextField = this.otherBindings[i].original(); |
370 |
TypeBinding nextGenericCast = this.otherGenericCasts == null ? null : this.otherGenericCasts[i]; |
340 |
TypeBinding nextGenericCast = this.otherGenericCasts == null ? null : this.otherGenericCasts[i]; |
371 |
if (lastFieldBinding != null) { |
341 |
if (lastFieldBinding != null) { |
372 |
needValue = !nextField.isStatic(); |
342 |
needValue = !nextField.isStatic(); |
373 |
if (needValue) { |
343 |
Constant fieldConstant = lastFieldBinding.constant(); |
374 |
if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { |
344 |
if (fieldConstant != Constant.NotAConstant) { |
375 |
Constant fieldConstant = lastFieldBinding.constant(); |
345 |
if (i > 0 && !lastFieldBinding.isStatic()) { |
376 |
if (fieldConstant != Constant.NotAConstant) { |
346 |
codeStream.invokeObjectGetClass(); // perform null check |
377 |
if (lastFieldBinding != this.codegenBinding && !lastFieldBinding.isStatic()) { |
347 |
codeStream.pop(); |
378 |
codeStream.invokeObjectGetClass(); // perform null check |
348 |
} |
379 |
codeStream.pop(); |
349 |
if (needValue) { |
|
|
350 |
codeStream.generateConstant(fieldConstant, 0); |
351 |
} |
352 |
} else { |
353 |
if (needValue || (i > 0 && complyTo14) || lastGenericCast != null) { |
354 |
if (lastFieldBinding.canBeSeenBy(lastReceiverType, this, currentScope)) { |
355 |
MethodBinding accessor = this.syntheticReadAccessors == null ? null : this.syntheticReadAccessors[i]; |
356 |
if (accessor == null) { |
357 |
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, lastFieldBinding, lastReceiverType, i == 0 && this.indexOfFirstFieldBinding == 1); |
358 |
if (lastFieldBinding.isStatic()) { |
359 |
codeStream.fieldAccess(Opcodes.OPC_getstatic, lastFieldBinding, constantPoolDeclaringClass); |
360 |
} else { |
361 |
codeStream.fieldAccess(Opcodes.OPC_getfield, lastFieldBinding, constantPoolDeclaringClass); |
362 |
} |
363 |
} else { |
364 |
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); |
380 |
} |
365 |
} |
381 |
codeStream.generateConstant(fieldConstant, 0); |
|
|
382 |
} else if (lastFieldBinding.isStatic()) { |
383 |
codeStream.getstatic(lastFieldBinding); |
384 |
} else { |
366 |
} else { |
385 |
codeStream.getfield(lastFieldBinding); |
367 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
|
|
368 |
} |
369 |
if (lastGenericCast != null) { |
370 |
codeStream.checkcast(lastGenericCast); |
371 |
lastReceiverType = lastGenericCast; |
372 |
} else { |
373 |
lastReceiverType = lastFieldBinding.type; |
386 |
} |
374 |
} |
|
|
375 |
if (!needValue) codeStream.pop(); |
387 |
} else { |
376 |
} else { |
388 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
377 |
if (lastFieldBinding == initialFieldBinding) { |
|
|
378 |
if (lastFieldBinding.isStatic()){ |
379 |
// if no valueRequired, still need possible side-effects of <clinit> invocation, if field belongs to different class |
380 |
if (initialFieldBinding.declaringClass != this.actualReceiverType.erasure()) { |
381 |
if (lastFieldBinding.canBeSeenBy(lastReceiverType, this, currentScope)) { |
382 |
MethodBinding accessor = this.syntheticReadAccessors == null ? null : this.syntheticReadAccessors[i]; |
383 |
if (accessor == null) { |
384 |
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, lastFieldBinding, lastReceiverType, i == 0 && this.indexOfFirstFieldBinding == 1); |
385 |
codeStream.fieldAccess(Opcodes.OPC_getstatic, lastFieldBinding, constantPoolDeclaringClass); |
386 |
} else { |
387 |
codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */); |
388 |
} |
389 |
} else { |
390 |
codeStream.generateEmulatedReadAccessForField(lastFieldBinding); |
391 |
} |
392 |
codeStream.pop(); |
393 |
} |
394 |
} |
395 |
} else if (!lastFieldBinding.isStatic()){ |
396 |
codeStream.invokeObjectGetClass(); // perform null check |
397 |
codeStream.pop(); |
398 |
} |
399 |
lastReceiverType = lastFieldBinding.type; |
389 |
} |
400 |
} |
390 |
if (lastGenericCast != null) codeStream.checkcast(lastGenericCast); |
401 |
if ((positionsLength - otherBindingsCount + i - 1) >= 0) { |
391 |
} else { |
402 |
int fieldPosition = (int) (this.sourcePositions[positionsLength - otherBindingsCount + i - 1] >>>32); |
392 |
if (this.codegenBinding != lastFieldBinding && !lastFieldBinding.isStatic()){ |
403 |
codeStream.recordPositionsFrom(pc, fieldPosition); |
393 |
codeStream.invokeObjectGetClass(); // perform null check |
|
|
394 |
codeStream.pop(); |
395 |
} |
404 |
} |
396 |
} |
405 |
} |
397 |
} |
406 |
} |
398 |
lastFieldBinding = nextField; |
407 |
lastFieldBinding = nextField; |
399 |
lastGenericCast = nextGenericCast; |
408 |
lastGenericCast = nextGenericCast; |
400 |
if (lastFieldBinding != null && !lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { |
409 |
if (lastFieldBinding != null && !lastFieldBinding.canBeSeenBy(lastReceiverType, this, currentScope)) { |
401 |
if (lastFieldBinding.isStatic()) { |
410 |
if (lastFieldBinding.isStatic()) { |
402 |
codeStream.aconst_null(); |
411 |
codeStream.aconst_null(); |
403 |
} |
412 |
} |
404 |
} |
413 |
} |
405 |
} |
414 |
} |
406 |
} |
415 |
} |
407 |
return lastFieldBinding; |
416 |
return lastFieldBinding; |
408 |
} |
417 |
} |
409 |
|
418 |
|
|
|
419 |
|
410 |
public void generateReceiver(CodeStream codeStream) { |
420 |
public void generateReceiver(CodeStream codeStream) { |
411 |
codeStream.aload_0(); |
421 |
codeStream.aload_0(); |
412 |
if (this.delegateThis != null) { |
422 |
if (this.delegateThis != null) { |
413 |
codeStream.getfield(this.delegateThis); // delegated field access |
423 |
codeStream.fieldAccess(Opcodes.OPC_getfield, this.delegateThis, null /* default declaringClass */); // delegated field access |
414 |
} |
424 |
} |
415 |
} |
425 |
} |
|
|
426 |
|
416 |
public TypeBinding getOtherFieldBindings(BlockScope scope) { |
427 |
public TypeBinding getOtherFieldBindings(BlockScope scope) { |
417 |
// At this point restrictiveFlag may ONLY have two potential value : FIELD LOCAL (i.e cast <<(VariableBinding) binding>> is valid) |
428 |
// At this point restrictiveFlag may ONLY have two potential value : FIELD LOCAL (i.e cast <<(VariableBinding) binding>> is valid) |
418 |
|
|
|
419 |
int length = this.tokens.length; |
429 |
int length = this.tokens.length; |
420 |
if ((this.bits & Binding.FIELD) != 0) { |
430 |
if ((this.bits & Binding.FIELD) != 0) { |
421 |
if (!((FieldBinding) this.binding).isStatic()) { //must check for the static status.... |
431 |
if (!((FieldBinding) this.binding).isStatic()) { //must check for the static status.... |
Lines 445-451
Link Here
|
445 |
|
455 |
|
446 |
// allocation of the fieldBindings array and its respective constants |
456 |
// allocation of the fieldBindings array and its respective constants |
447 |
int otherBindingsLength = length - index; |
457 |
int otherBindingsLength = length - index; |
448 |
this.otherCodegenBindings = this.otherBindings = new FieldBinding[otherBindingsLength]; |
458 |
this.otherBindings = new FieldBinding[otherBindingsLength]; |
449 |
|
459 |
|
450 |
// fill the first constant (the one of the binding) |
460 |
// fill the first constant (the one of the binding) |
451 |
this.constant =((VariableBinding) this.binding).constant(); |
461 |
this.constant =((VariableBinding) this.binding).constant(); |
Lines 466-471
Link Here
|
466 |
if (this.delegateThis == null){ // if not found then internal error, field should have been found |
476 |
if (this.delegateThis == null){ // if not found then internal error, field should have been found |
467 |
return super.reportError(scope); |
477 |
return super.reportError(scope); |
468 |
} |
478 |
} |
|
|
479 |
this.actualReceiverType = this.delegateThis.type; |
469 |
} else { |
480 |
} else { |
470 |
this.constant = Constant.NotAConstant; //don't fill other constants slots... |
481 |
this.constant = Constant.NotAConstant; //don't fill other constants slots... |
471 |
scope.problemReporter().invalidField(this, field, index, type); |
482 |
scope.problemReporter().invalidField(this, field, index, type); |
Lines 494-586
Link Here
|
494 |
} |
505 |
} |
495 |
return (this.otherBindings[otherBindingsLength - 1]).type; |
506 |
return (this.otherBindings[otherBindingsLength - 1]).type; |
496 |
} |
507 |
} |
497 |
/** |
508 |
|
498 |
* Check and/or redirect the field access to the delegate receiver if any |
509 |
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FieldBinding fieldBinding, int index, FlowInfo flowInfo) { |
499 |
*/ |
510 |
// do nothing |
500 |
public TypeBinding getReceiverType(BlockScope currentScope) { |
511 |
} |
501 |
Scope scope = currentScope.parent; |
512 |
/** |
502 |
while (true) { |
513 |
* index is <0 to denote write access emulation |
503 |
switch (scope.kind) { |
514 |
*/ |
504 |
case Scope.CLASS_SCOPE : |
515 |
/* |
505 |
return ((ClassScope) scope).referenceContext.binding; |
516 |
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FieldBinding fieldBinding, int index, FlowInfo flowInfo) { |
506 |
default: |
517 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return; |
507 |
scope = scope.parent; |
518 |
|
508 |
} |
519 |
// if the binding declaring class is not visible, need special action |
509 |
} |
520 |
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding |
|
|
521 |
// NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type |
522 |
boolean useDelegate; |
523 |
if (index < 0) { // write-access? |
524 |
useDelegate = fieldBinding == this.binding && this.delegateThis != null; |
525 |
} else { |
526 |
useDelegate = index == 0 && this.delegateThis != null; |
510 |
} |
527 |
} |
511 |
/** |
|
|
512 |
* index is <0 to denote write access emulation |
513 |
*/ |
514 |
public void manageSyntheticAccessIfNecessary( |
515 |
BlockScope currentScope, |
516 |
FieldBinding fieldBinding, |
517 |
TypeBinding lastReceiverType, |
518 |
int index, |
519 |
FlowInfo flowInfo) { |
520 |
|
521 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return; |
522 |
|
523 |
// if the binding declaring class is not visible, need special action |
524 |
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding |
525 |
// NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type |
526 |
boolean useDelegate; |
527 |
if (index < 0) { // write-access? |
528 |
useDelegate = fieldBinding == this.binding && this.delegateThis != null; |
529 |
} else { |
530 |
useDelegate = index == 0 && this.delegateThis != null; |
531 |
} |
532 |
|
528 |
|
533 |
if (useDelegate) { |
529 |
if (useDelegate) { |
534 |
lastReceiverType = this.delegateThis.type; |
530 |
lastReceiverType = this.delegateThis.type; |
535 |
} |
531 |
} |
536 |
// if the binding declaring class is not visible, need special action |
532 |
// if the binding declaring class is not visible, need special action |
537 |
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding |
533 |
// for runtime compatibility on 1.2 VMs : change the declaring class of the binding |
538 |
// NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type |
534 |
// NOTE: from target 1.2 on, field's declaring class is touched if any different from receiver type |
539 |
// and not from Object or implicit static field access. |
535 |
// and not from Object or implicit static field access. |
540 |
if (fieldBinding.declaringClass != lastReceiverType |
536 |
if (fieldBinding.declaringClass != lastReceiverType |
541 |
&& !lastReceiverType.isArrayType() |
537 |
&& !lastReceiverType.isArrayType() |
542 |
&& fieldBinding.declaringClass != null // array.length |
538 |
&& fieldBinding.declaringClass != null // array.length |
543 |
&& fieldBinding.constant() == Constant.NotAConstant) { |
539 |
&& fieldBinding.constant() == Constant.NotAConstant) { |
544 |
CompilerOptions options = currentScope.compilerOptions(); |
540 |
CompilerOptions options = currentScope.compilerOptions(); |
545 |
if ((options.targetJDK >= ClassFileConstants.JDK1_2 |
541 |
if ((options.targetJDK >= ClassFileConstants.JDK1_2 |
546 |
&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || (index < 0 ? fieldBinding != this.binding : index > 0) || this.indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic()) |
542 |
&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || (index < 0 ? fieldBinding != this.binding : index > 0) || this.indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic()) |
547 |
&& fieldBinding.declaringClass.id != T_JavaLangObject) // no change for Object fields |
543 |
&& fieldBinding.declaringClass.id != T_JavaLangObject) // no change for Object fields |
548 |
|| !(useDelegate |
544 |
|| !(useDelegate |
549 |
? new CodeSnippetScope(currentScope).canBeSeenByForCodeSnippet(fieldBinding.declaringClass, (ReferenceBinding) this.delegateThis.type) |
545 |
? new CodeSnippetScope(currentScope).canBeSeenByForCodeSnippet(fieldBinding.declaringClass, (ReferenceBinding) this.delegateThis.type) |
550 |
: fieldBinding.declaringClass.canBeSeenBy(currentScope))) { |
546 |
: fieldBinding.declaringClass.canBeSeenBy(currentScope))) { |
551 |
|
547 |
|
552 |
if (index < 0) { // write-access? |
548 |
lastReceiverType |
553 |
if (fieldBinding == this.binding){ |
|
|
554 |
this.codegenBinding = currentScope.enclosingSourceType().getUpdatedFieldBinding(fieldBinding, (ReferenceBinding)lastReceiverType.erasure()); |
555 |
} else { |
556 |
if (this.otherCodegenBindings == this.otherBindings){ |
557 |
int l = this.otherBindings.length; |
558 |
System.arraycopy(this.otherBindings, 0, this.otherCodegenBindings = new FieldBinding[l], 0, l); |
559 |
} |
560 |
this.otherCodegenBindings[this.otherCodegenBindings.length-1] = currentScope.enclosingSourceType().getUpdatedFieldBinding(fieldBinding, (ReferenceBinding)lastReceiverType.erasure()); |
561 |
} |
562 |
} if (index == 0){ |
563 |
this.codegenBinding = currentScope.enclosingSourceType().getUpdatedFieldBinding(fieldBinding, (ReferenceBinding)lastReceiverType.erasure()); |
564 |
} else { |
565 |
if (this.otherCodegenBindings == this.otherBindings){ |
566 |
int l = this.otherBindings.length; |
567 |
System.arraycopy(this.otherBindings, 0, this.otherCodegenBindings = new FieldBinding[l], 0, l); |
568 |
} |
569 |
this.otherCodegenBindings[index-1] = currentScope.enclosingSourceType().getUpdatedFieldBinding(fieldBinding, (ReferenceBinding)lastReceiverType.erasure()); |
570 |
} |
571 |
} |
572 |
} |
549 |
} |
573 |
} |
550 |
} |
|
|
551 |
} |
552 |
*/ |
574 |
/** |
553 |
/** |
575 |
* Normal field binding did not work, try to bind to a field of the delegate receiver. |
554 |
* Normal field binding did not work, try to bind to a field of the delegate receiver. |
576 |
*/ |
555 |
*/ |
577 |
public TypeBinding reportError(BlockScope scope) { |
556 |
public TypeBinding reportError(BlockScope scope) { |
578 |
|
|
|
579 |
if (this.evaluationContext.declaringTypeName != null) { |
557 |
if (this.evaluationContext.declaringTypeName != null) { |
580 |
this.delegateThis = scope.getField(scope.enclosingSourceType(), DELEGATE_THIS, this); |
558 |
this.delegateThis = scope.getField(scope.enclosingSourceType(), DELEGATE_THIS, this); |
581 |
if (this.delegateThis == null){ // if not found then internal error, field should have been found |
559 |
if (this.delegateThis == null){ // if not found then internal error, field should have been found |
582 |
return super.reportError(scope); |
560 |
return super.reportError(scope); |
583 |
} |
561 |
} |
|
|
562 |
this.actualReceiverType = this.delegateThis.type; |
584 |
} else { |
563 |
} else { |
585 |
return super.reportError(scope); |
564 |
return super.reportError(scope); |
586 |
} |
565 |
} |
Lines 593-599
Link Here
|
593 |
if (((ProblemFieldBinding) fieldBinding).problemId() == NotVisible) { |
572 |
if (((ProblemFieldBinding) fieldBinding).problemId() == NotVisible) { |
594 |
// manage the access to a private field of the enclosing type |
573 |
// manage the access to a private field of the enclosing type |
595 |
CodeSnippetScope localScope = new CodeSnippetScope(scope); |
574 |
CodeSnippetScope localScope = new CodeSnippetScope(scope); |
596 |
this.codegenBinding = this.binding = localScope.getFieldForCodeSnippet(this.delegateThis.type, this.tokens[0], this); |
575 |
this.binding = localScope.getFieldForCodeSnippet(this.delegateThis.type, this.tokens[0], this); |
597 |
if (this.binding.isValidBinding()) { |
576 |
if (this.binding.isValidBinding()) { |
598 |
return checkFieldAccess(scope); |
577 |
return checkFieldAccess(scope); |
599 |
} else { |
578 |
} else { |
Lines 603-639
Link Here
|
603 |
return super.reportError(scope); |
582 |
return super.reportError(scope); |
604 |
} |
583 |
} |
605 |
} |
584 |
} |
606 |
this.codegenBinding = this.binding = fieldBinding; |
585 |
this.binding = fieldBinding; |
607 |
return checkFieldAccess(scope); |
586 |
return checkFieldAccess(scope); |
608 |
} |
587 |
} |
609 |
|
588 |
|
610 |
TypeBinding result; |
589 |
TypeBinding result; |
611 |
if (this.binding instanceof ProblemFieldBinding |
590 |
if (this.binding instanceof ProblemFieldBinding && ((ProblemFieldBinding) this.binding).problemId() == NotVisible) { |
612 |
&& ((ProblemFieldBinding) this.binding).problemId() == NotVisible) { |
591 |
// field and/or local are done before type lookups |
613 |
result = resolveTypeVisibility(scope); |
592 |
// the only available value for the restrictiveFlag BEFORE |
614 |
if (result == null) { |
593 |
// the TC is Flag_Type Flag_LocalField and Flag_TypeLocalField |
|
|
594 |
CodeSnippetScope localScope = new CodeSnippetScope(scope); |
595 |
if ((this.binding = localScope.getBinding(this.tokens, this.bits & RestrictiveFlagMASK, this, (ReferenceBinding) this.delegateThis.type)).isValidBinding()) { |
596 |
this.bits &= ~RestrictiveFlagMASK; // clear bits |
597 |
this.bits |= Binding.FIELD; |
598 |
result = getOtherFieldBindings(scope); |
599 |
} else { |
615 |
return super.reportError(scope); |
600 |
return super.reportError(scope); |
616 |
} |
601 |
} |
617 |
if (result.isValidBinding()) { |
602 |
if (result != null && result.isValidBinding()) { |
618 |
return result; |
603 |
return result; |
619 |
} |
604 |
} |
620 |
} |
605 |
} |
621 |
|
|
|
622 |
return super.reportError(scope); |
623 |
} |
624 |
public TypeBinding resolveTypeVisibility(BlockScope scope) { |
625 |
// field and/or local are done before type lookups |
626 |
|
627 |
// the only available value for the restrictiveFlag BEFORE |
628 |
// the TC is Flag_Type Flag_LocalField and Flag_TypeLocalField |
629 |
|
630 |
CodeSnippetScope localScope = new CodeSnippetScope(scope); |
631 |
if ((this.codegenBinding = this.binding = localScope.getBinding(this.tokens, this.bits & RestrictiveFlagMASK, this, (ReferenceBinding) this.delegateThis.type)).isValidBinding()) { |
632 |
this.bits &= ~RestrictiveFlagMASK; // clear bits |
633 |
this.bits |= Binding.FIELD; |
634 |
return getOtherFieldBindings(scope); |
635 |
} |
636 |
//========error cases=============== |
637 |
return super.reportError(scope); |
606 |
return super.reportError(scope); |
638 |
} |
607 |
} |
639 |
} |
608 |
} |