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