Lines 19-25
Link Here
|
19 |
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; |
19 |
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; |
20 |
|
20 |
|
21 |
/** |
21 |
/** |
22 |
* Particular block scope used for methods, constructors or clinits, representing |
22 |
* Specific block scope used for methods, constructors or clinits, representing |
23 |
* its outermost blockscope. Note also that such a scope will be provided to enclose |
23 |
* its outermost blockscope. Note also that such a scope will be provided to enclose |
24 |
* field initializers subscopes as well. |
24 |
* field initializers subscopes as well. |
25 |
*/ |
25 |
*/ |
Lines 49-497
Link Here
|
49 |
// inner-emulation |
49 |
// inner-emulation |
50 |
public SyntheticArgumentBinding[] extraSyntheticArguments; |
50 |
public SyntheticArgumentBinding[] extraSyntheticArguments; |
51 |
|
51 |
|
52 |
public MethodScope(ClassScope parent, ReferenceContext context, boolean isStatic) { |
52 |
public MethodScope(ClassScope parent, ReferenceContext context, boolean isStatic) { |
|
|
53 |
super(METHOD_SCOPE, parent); |
54 |
locals = new LocalVariableBinding[5]; |
55 |
this.referenceContext = context; |
56 |
this.isStatic = isStatic; |
57 |
this.startIndex = 0; |
58 |
} |
53 |
|
59 |
|
54 |
super(METHOD_SCOPE, parent); |
60 |
String basicToString(int tab) { |
55 |
locals = new LocalVariableBinding[5]; |
61 |
String newLine = "\n"; //$NON-NLS-1$ |
56 |
this.referenceContext = context; |
62 |
for (int i = tab; --i >= 0;) |
57 |
this.isStatic = isStatic; |
63 |
newLine += "\t"; //$NON-NLS-1$ |
58 |
this.startIndex = 0; |
64 |
|
59 |
} |
65 |
String s = newLine + "--- Method Scope ---"; //$NON-NLS-1$ |
60 |
|
66 |
newLine += "\t"; //$NON-NLS-1$ |
61 |
/* Spec : 8.4.3 & 9.4 |
67 |
s += newLine + "locals:"; //$NON-NLS-1$ |
62 |
*/ |
68 |
for (int i = 0; i < localIndex; i++) |
63 |
private void checkAndSetModifiersForConstructor(MethodBinding methodBinding) { |
69 |
s += newLine + "\t" + locals[i].toString(); //$NON-NLS-1$ |
64 |
|
70 |
s += newLine + "startIndex = " + startIndex; //$NON-NLS-1$ |
65 |
int modifiers = methodBinding.modifiers; |
71 |
s += newLine + "isConstructorCall = " + isConstructorCall; //$NON-NLS-1$ |
66 |
final ReferenceBinding declaringClass = methodBinding.declaringClass; |
72 |
s += newLine + "initializedField = " + initializedField; //$NON-NLS-1$ |
67 |
if ((modifiers & ExtraCompilerModifiers.AccAlternateModifierProblem) != 0) |
73 |
s += newLine + "lastVisibleFieldID = " + lastVisibleFieldID; //$NON-NLS-1$ |
68 |
problemReporter().duplicateModifierForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
74 |
s += newLine + "referenceContext = " + referenceContext; //$NON-NLS-1$ |
69 |
|
75 |
return s; |
70 |
if ((((ConstructorDeclaration) referenceContext).bits & ASTNode.IsDefaultConstructor) != 0) { |
76 |
} |
71 |
// certain flags are propagated from declaring class onto constructor |
77 |
|
72 |
final int DECLARING_FLAGS = ClassFileConstants.AccEnum|ClassFileConstants.AccPublic|ClassFileConstants.AccProtected; |
78 |
/** |
73 |
final int VISIBILITY_FLAGS = ClassFileConstants.AccPrivate|ClassFileConstants.AccPublic|ClassFileConstants.AccProtected; |
79 |
* Spec : 8.4.3 & 9.4 |
74 |
int flags; |
80 |
*/ |
75 |
if ((flags = declaringClass.modifiers & DECLARING_FLAGS) != 0) { |
81 |
private void checkAndSetModifiersForConstructor(MethodBinding methodBinding) { |
76 |
if ((flags & ClassFileConstants.AccEnum) != 0) { |
82 |
int modifiers = methodBinding.modifiers; |
77 |
modifiers &= ~VISIBILITY_FLAGS; |
83 |
final ReferenceBinding declaringClass = methodBinding.declaringClass; |
78 |
modifiers |= ClassFileConstants.AccPrivate; // default constructor is implicitly private in enum |
84 |
if ((modifiers & ExtraCompilerModifiers.AccAlternateModifierProblem) != 0) |
79 |
} else { |
85 |
problemReporter().duplicateModifierForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
80 |
modifiers &= ~VISIBILITY_FLAGS; |
86 |
|
81 |
modifiers |= flags; // propagate public/protected |
87 |
if ((((ConstructorDeclaration) referenceContext).bits & ASTNode.IsDefaultConstructor) != 0) { |
82 |
} |
88 |
// certain flags are propagated from declaring class onto constructor |
|
|
89 |
final int DECLARING_FLAGS = ClassFileConstants.AccEnum|ClassFileConstants.AccPublic|ClassFileConstants.AccProtected; |
90 |
final int VISIBILITY_FLAGS = ClassFileConstants.AccPrivate|ClassFileConstants.AccPublic|ClassFileConstants.AccProtected; |
91 |
int flags; |
92 |
if ((flags = declaringClass.modifiers & DECLARING_FLAGS) != 0) { |
93 |
if ((flags & ClassFileConstants.AccEnum) != 0) { |
94 |
modifiers &= ~VISIBILITY_FLAGS; |
95 |
modifiers |= ClassFileConstants.AccPrivate; // default constructor is implicitly private in enum |
96 |
} else { |
97 |
modifiers &= ~VISIBILITY_FLAGS; |
98 |
modifiers |= flags; // propagate public/protected |
83 |
} |
99 |
} |
84 |
} |
100 |
} |
|
|
101 |
} |
85 |
|
102 |
|
86 |
// after this point, tests on the 16 bits reserved. |
103 |
// after this point, tests on the 16 bits reserved. |
87 |
int realModifiers = modifiers & ExtraCompilerModifiers.AccJustFlag; |
104 |
int realModifiers = modifiers & ExtraCompilerModifiers.AccJustFlag; |
88 |
|
105 |
|
89 |
// check for abnormal modifiers |
106 |
// check for abnormal modifiers |
90 |
final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccStrictfp); |
107 |
final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccStrictfp); |
91 |
if (declaringClass.isEnum() && (((ConstructorDeclaration) referenceContext).bits & ASTNode.IsDefaultConstructor) == 0) { |
108 |
if (declaringClass.isEnum() && (((ConstructorDeclaration) referenceContext).bits & ASTNode.IsDefaultConstructor) == 0) { |
92 |
final int UNEXPECTED_ENUM_CONSTR_MODIFIERS = ~(ClassFileConstants.AccPrivate | ClassFileConstants.AccStrictfp); |
109 |
final int UNEXPECTED_ENUM_CONSTR_MODIFIERS = ~(ClassFileConstants.AccPrivate | ClassFileConstants.AccStrictfp); |
93 |
if ((realModifiers & UNEXPECTED_ENUM_CONSTR_MODIFIERS) != 0) { |
110 |
if ((realModifiers & UNEXPECTED_ENUM_CONSTR_MODIFIERS) != 0) { |
94 |
problemReporter().illegalModifierForEnumConstructor((AbstractMethodDeclaration) referenceContext); |
111 |
problemReporter().illegalModifierForEnumConstructor((AbstractMethodDeclaration) referenceContext); |
95 |
modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_ENUM_CONSTR_MODIFIERS; |
112 |
modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_ENUM_CONSTR_MODIFIERS; |
96 |
} else if ((((AbstractMethodDeclaration) referenceContext).modifiers & ClassFileConstants.AccStrictfp) != 0) { |
|
|
97 |
// must check the parse node explicitly |
98 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
99 |
} |
100 |
modifiers |= ClassFileConstants.AccPrivate; // enum constructor is implicitly private |
101 |
} else if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) { |
102 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
103 |
modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_MODIFIERS; |
104 |
} else if ((((AbstractMethodDeclaration) referenceContext).modifiers & ClassFileConstants.AccStrictfp) != 0) { |
113 |
} else if ((((AbstractMethodDeclaration) referenceContext).modifiers & ClassFileConstants.AccStrictfp) != 0) { |
105 |
// must check the parse node explicitly |
114 |
// must check the parse node explicitly |
106 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
115 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
107 |
} |
116 |
} |
108 |
|
117 |
modifiers |= ClassFileConstants.AccPrivate; // enum constructor is implicitly private |
109 |
// check for incompatible modifiers in the visibility bits, isolate the visibility bits |
118 |
} else if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) { |
110 |
int accessorBits = realModifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate); |
119 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
111 |
if ((accessorBits & (accessorBits - 1)) != 0) { |
120 |
modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_MODIFIERS; |
112 |
problemReporter().illegalVisibilityModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
121 |
} else if ((((AbstractMethodDeclaration) referenceContext).modifiers & ClassFileConstants.AccStrictfp) != 0) { |
113 |
|
122 |
// must check the parse node explicitly |
114 |
// need to keep the less restrictive so disable Protected/Private as necessary |
123 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
115 |
if ((accessorBits & ClassFileConstants.AccPublic) != 0) { |
124 |
} |
116 |
if ((accessorBits & ClassFileConstants.AccProtected) != 0) |
125 |
|
117 |
modifiers &= ~ClassFileConstants.AccProtected; |
126 |
// check for incompatible modifiers in the visibility bits, isolate the visibility bits |
118 |
if ((accessorBits & ClassFileConstants.AccPrivate) != 0) |
127 |
int accessorBits = realModifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate); |
119 |
modifiers &= ~ClassFileConstants.AccPrivate; |
128 |
if ((accessorBits & (accessorBits - 1)) != 0) { |
120 |
} else if ((accessorBits & ClassFileConstants.AccProtected) != 0 && (accessorBits & ClassFileConstants.AccPrivate) != 0) { |
129 |
problemReporter().illegalVisibilityModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
|
|
130 |
|
131 |
// need to keep the less restrictive so disable Protected/Private as necessary |
132 |
if ((accessorBits & ClassFileConstants.AccPublic) != 0) { |
133 |
if ((accessorBits & ClassFileConstants.AccProtected) != 0) |
134 |
modifiers &= ~ClassFileConstants.AccProtected; |
135 |
if ((accessorBits & ClassFileConstants.AccPrivate) != 0) |
121 |
modifiers &= ~ClassFileConstants.AccPrivate; |
136 |
modifiers &= ~ClassFileConstants.AccPrivate; |
122 |
} |
137 |
} else if ((accessorBits & ClassFileConstants.AccProtected) != 0 && (accessorBits & ClassFileConstants.AccPrivate) != 0) { |
|
|
138 |
modifiers &= ~ClassFileConstants.AccPrivate; |
123 |
} |
139 |
} |
|
|
140 |
} |
124 |
|
141 |
|
125 |
// // if the receiver's declaring class is a private nested type, then make sure the receiver is not private (causes problems for inner type emulation) |
142 |
// // if the receiver's declaring class is a private nested type, then make sure the receiver is not private (causes problems for inner type emulation) |
126 |
// if (declaringClass.isPrivate() && (modifiers & ClassFileConstants.AccPrivate) != 0) |
143 |
// if (declaringClass.isPrivate() && (modifiers & ClassFileConstants.AccPrivate) != 0) |
127 |
// modifiers &= ~ClassFileConstants.AccPrivate; |
144 |
// modifiers &= ~ClassFileConstants.AccPrivate; |
128 |
|
145 |
|
129 |
methodBinding.modifiers = modifiers; |
146 |
methodBinding.modifiers = modifiers; |
130 |
} |
147 |
} |
131 |
|
|
|
132 |
/* Spec : 8.4.3 & 9.4 |
133 |
*/ |
134 |
private void checkAndSetModifiersForMethod(MethodBinding methodBinding) { |
135 |
|
136 |
int modifiers = methodBinding.modifiers; |
137 |
final ReferenceBinding declaringClass = methodBinding.declaringClass; |
138 |
if ((modifiers & ExtraCompilerModifiers.AccAlternateModifierProblem) != 0) |
139 |
problemReporter().duplicateModifierForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
140 |
|
141 |
// after this point, tests on the 16 bits reserved. |
142 |
int realModifiers = modifiers & ExtraCompilerModifiers.AccJustFlag; |
143 |
|
144 |
// set the requested modifiers for a method in an interface/annotation |
145 |
if (declaringClass.isInterface()) { |
146 |
if ((realModifiers & ~(ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract)) != 0) { |
147 |
if ((declaringClass.modifiers & ClassFileConstants.AccAnnotation) != 0) |
148 |
problemReporter().illegalModifierForAnnotationMember((AbstractMethodDeclaration) referenceContext); |
149 |
else |
150 |
problemReporter().illegalModifierForInterfaceMethod((AbstractMethodDeclaration) referenceContext); |
151 |
} |
152 |
return; |
153 |
} |
154 |
|
155 |
// check for abnormal modifiers |
156 |
final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected |
157 |
| ClassFileConstants.AccAbstract | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccSynchronized | ClassFileConstants.AccNative | ClassFileConstants.AccStrictfp); |
158 |
if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) { |
159 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
160 |
modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_MODIFIERS; |
161 |
} |
162 |
|
148 |
|
163 |
// check for incompatible modifiers in the visibility bits, isolate the visibility bits |
149 |
/** |
164 |
int accessorBits = realModifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate); |
150 |
* Spec : 8.4.3 & 9.4 |
165 |
if ((accessorBits & (accessorBits - 1)) != 0) { |
151 |
*/ |
166 |
problemReporter().illegalVisibilityModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
152 |
private void checkAndSetModifiersForMethod(MethodBinding methodBinding) { |
167 |
|
153 |
int modifiers = methodBinding.modifiers; |
168 |
// need to keep the less restrictive so disable Protected/Private as necessary |
154 |
final ReferenceBinding declaringClass = methodBinding.declaringClass; |
169 |
if ((accessorBits & ClassFileConstants.AccPublic) != 0) { |
155 |
if ((modifiers & ExtraCompilerModifiers.AccAlternateModifierProblem) != 0) |
170 |
if ((accessorBits & ClassFileConstants.AccProtected) != 0) |
156 |
problemReporter().duplicateModifierForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
171 |
modifiers &= ~ClassFileConstants.AccProtected; |
157 |
|
172 |
if ((accessorBits & ClassFileConstants.AccPrivate) != 0) |
158 |
// after this point, tests on the 16 bits reserved. |
173 |
modifiers &= ~ClassFileConstants.AccPrivate; |
159 |
int realModifiers = modifiers & ExtraCompilerModifiers.AccJustFlag; |
174 |
} else if ((accessorBits & ClassFileConstants.AccProtected) != 0 && (accessorBits & ClassFileConstants.AccPrivate) != 0) { |
160 |
|
|
|
161 |
// set the requested modifiers for a method in an interface/annotation |
162 |
if (declaringClass.isInterface()) { |
163 |
if ((realModifiers & ~(ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract)) != 0) { |
164 |
if ((declaringClass.modifiers & ClassFileConstants.AccAnnotation) != 0) |
165 |
problemReporter().illegalModifierForAnnotationMember((AbstractMethodDeclaration) referenceContext); |
166 |
else |
167 |
problemReporter().illegalModifierForInterfaceMethod((AbstractMethodDeclaration) referenceContext); |
168 |
} |
169 |
return; |
170 |
} |
171 |
|
172 |
// check for abnormal modifiers |
173 |
final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected |
174 |
| ClassFileConstants.AccAbstract | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccSynchronized | ClassFileConstants.AccNative | ClassFileConstants.AccStrictfp); |
175 |
if ((realModifiers & UNEXPECTED_MODIFIERS) != 0) { |
176 |
problemReporter().illegalModifierForMethod((AbstractMethodDeclaration) referenceContext); |
177 |
modifiers &= ~ExtraCompilerModifiers.AccJustFlag | ~UNEXPECTED_MODIFIERS; |
178 |
} |
179 |
|
180 |
// check for incompatible modifiers in the visibility bits, isolate the visibility bits |
181 |
int accessorBits = realModifiers & (ClassFileConstants.AccPublic | ClassFileConstants.AccProtected | ClassFileConstants.AccPrivate); |
182 |
if ((accessorBits & (accessorBits - 1)) != 0) { |
183 |
problemReporter().illegalVisibilityModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
184 |
|
185 |
// need to keep the less restrictive so disable Protected/Private as necessary |
186 |
if ((accessorBits & ClassFileConstants.AccPublic) != 0) { |
187 |
if ((accessorBits & ClassFileConstants.AccProtected) != 0) |
188 |
modifiers &= ~ClassFileConstants.AccProtected; |
189 |
if ((accessorBits & ClassFileConstants.AccPrivate) != 0) |
175 |
modifiers &= ~ClassFileConstants.AccPrivate; |
190 |
modifiers &= ~ClassFileConstants.AccPrivate; |
176 |
} |
191 |
} else if ((accessorBits & ClassFileConstants.AccProtected) != 0 && (accessorBits & ClassFileConstants.AccPrivate) != 0) { |
|
|
192 |
modifiers &= ~ClassFileConstants.AccPrivate; |
177 |
} |
193 |
} |
|
|
194 |
} |
178 |
|
195 |
|
179 |
// check for modifiers incompatible with abstract modifier |
196 |
// check for modifiers incompatible with abstract modifier |
180 |
if ((modifiers & ClassFileConstants.AccAbstract) != 0) { |
197 |
if ((modifiers & ClassFileConstants.AccAbstract) != 0) { |
181 |
int incompatibleWithAbstract = ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccSynchronized | ClassFileConstants.AccNative | ClassFileConstants.AccStrictfp; |
198 |
int incompatibleWithAbstract = ClassFileConstants.AccPrivate | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccSynchronized | ClassFileConstants.AccNative | ClassFileConstants.AccStrictfp; |
182 |
if ((modifiers & incompatibleWithAbstract) != 0) |
199 |
if ((modifiers & incompatibleWithAbstract) != 0) |
183 |
problemReporter().illegalAbstractModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
200 |
problemReporter().illegalAbstractModifierCombinationForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
184 |
if (!methodBinding.declaringClass.isAbstract()) |
201 |
if (!methodBinding.declaringClass.isAbstract()) |
185 |
problemReporter().abstractMethodInAbstractClass((SourceTypeBinding) declaringClass, (AbstractMethodDeclaration) referenceContext); |
202 |
problemReporter().abstractMethodInAbstractClass((SourceTypeBinding) declaringClass, (AbstractMethodDeclaration) referenceContext); |
186 |
} |
|
|
187 |
|
188 |
/* DISABLED for backward compatibility with javac (if enabled should also mark private methods as final) |
189 |
// methods from a final class are final : 8.4.3.3 |
190 |
if (methodBinding.declaringClass.isFinal()) |
191 |
modifiers |= AccFinal; |
192 |
*/ |
193 |
// native methods cannot also be tagged as strictfp |
194 |
if ((modifiers & ClassFileConstants.AccNative) != 0 && (modifiers & ClassFileConstants.AccStrictfp) != 0) |
195 |
problemReporter().nativeMethodsCannotBeStrictfp(declaringClass, (AbstractMethodDeclaration) referenceContext); |
196 |
|
197 |
// static members are only authorized in a static member or top level type |
198 |
if (((realModifiers & ClassFileConstants.AccStatic) != 0) && declaringClass.isNestedType() && !declaringClass.isStatic()) |
199 |
problemReporter().unexpectedStaticModifierForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
200 |
|
201 |
methodBinding.modifiers = modifiers; |
202 |
} |
203 |
} |
203 |
|
204 |
|
204 |
/* Compute variable positions in scopes given an initial position offset |
205 |
/* DISABLED for backward compatibility with javac (if enabled should also mark private methods as final) |
205 |
* ignoring unused local variables. |
206 |
// methods from a final class are final : 8.4.3.3 |
206 |
* |
207 |
if (methodBinding.declaringClass.isFinal()) |
207 |
* Deal with arguments here, locals and subscopes are processed in BlockScope method |
208 |
modifiers |= AccFinal; |
208 |
*/ |
209 |
*/ |
209 |
public void computeLocalVariablePositions(int initOffset, CodeStream codeStream) { |
210 |
// native methods cannot also be tagged as strictfp |
210 |
|
211 |
if ((modifiers & ClassFileConstants.AccNative) != 0 && (modifiers & ClassFileConstants.AccStrictfp) != 0) |
211 |
boolean isReportingUnusedArgument = false; |
212 |
problemReporter().nativeMethodsCannotBeStrictfp(declaringClass, (AbstractMethodDeclaration) referenceContext); |
212 |
|
213 |
|
213 |
if (referenceContext instanceof AbstractMethodDeclaration) { |
214 |
// static members are only authorized in a static member or top level type |
214 |
AbstractMethodDeclaration methodDecl = (AbstractMethodDeclaration)referenceContext; |
215 |
if (((realModifiers & ClassFileConstants.AccStatic) != 0) && declaringClass.isNestedType() && !declaringClass.isStatic()) |
215 |
MethodBinding method = methodDecl.binding; |
216 |
problemReporter().unexpectedStaticModifierForMethod(declaringClass, (AbstractMethodDeclaration) referenceContext); |
216 |
if (!(method.isAbstract() |
217 |
|
217 |
|| (method.isImplementing() && !compilerOptions().reportUnusedParameterWhenImplementingAbstract) |
218 |
methodBinding.modifiers = modifiers; |
218 |
|| (method.isOverriding() && !method.isImplementing() && !compilerOptions().reportUnusedParameterWhenOverridingConcrete) |
219 |
} |
219 |
|| method.isMain())) { |
220 |
|
220 |
isReportingUnusedArgument = true; |
221 |
/** |
221 |
} |
222 |
* Compute variable positions in scopes given an initial position offset |
|
|
223 |
* ignoring unused local variables. |
224 |
* |
225 |
* Deal with arguments here, locals and subscopes are processed in BlockScope method |
226 |
*/ |
227 |
public void computeLocalVariablePositions(int initOffset, CodeStream codeStream) { |
228 |
|
229 |
boolean isReportingUnusedArgument = false; |
230 |
|
231 |
if (referenceContext instanceof AbstractMethodDeclaration) { |
232 |
AbstractMethodDeclaration methodDecl = (AbstractMethodDeclaration)referenceContext; |
233 |
MethodBinding method = methodDecl.binding; |
234 |
if (!(method.isAbstract() |
235 |
|| (method.isImplementing() && !compilerOptions().reportUnusedParameterWhenImplementingAbstract) |
236 |
|| (method.isOverriding() && !method.isImplementing() && !compilerOptions().reportUnusedParameterWhenOverridingConcrete) |
237 |
|| method.isMain())) { |
238 |
isReportingUnusedArgument = true; |
222 |
} |
239 |
} |
223 |
this.offset = initOffset; |
240 |
} |
224 |
this.maxOffset = initOffset; |
241 |
this.offset = initOffset; |
|
|
242 |
this.maxOffset = initOffset; |
225 |
|
243 |
|
226 |
// manage arguments |
244 |
// manage arguments |
227 |
int ilocal = 0, maxLocals = this.localIndex; |
245 |
int ilocal = 0, maxLocals = this.localIndex; |
228 |
while (ilocal < maxLocals) { |
246 |
while (ilocal < maxLocals) { |
229 |
LocalVariableBinding local = locals[ilocal]; |
247 |
LocalVariableBinding local = locals[ilocal]; |
230 |
if (local == null || ((local.tagBits & TagBits.IsArgument) == 0)) break; // done with arguments |
248 |
if (local == null || ((local.tagBits & TagBits.IsArgument) == 0)) break; // done with arguments |
231 |
|
249 |
|
232 |
// do not report fake used variable |
250 |
// do not report fake used variable |
233 |
if (isReportingUnusedArgument |
251 |
if (isReportingUnusedArgument |
234 |
&& local.useFlag == LocalVariableBinding.UNUSED |
252 |
&& local.useFlag == LocalVariableBinding.UNUSED |
235 |
&& ((local.declaration.bits & ASTNode.IsLocalDeclarationReachable) != 0)) { // declaration is reachable |
253 |
&& ((local.declaration.bits & ASTNode.IsLocalDeclarationReachable) != 0)) { // declaration is reachable |
236 |
this.problemReporter().unusedArgument(local.declaration); |
254 |
this.problemReporter().unusedArgument(local.declaration); |
237 |
} |
255 |
} |
238 |
|
256 |
|
239 |
// record user-defined argument for attribute generation |
257 |
// record user-defined argument for attribute generation |
240 |
codeStream.record(local); |
258 |
codeStream.record(local); |
241 |
|
259 |
|
242 |
// assign variable position |
260 |
// assign variable position |
243 |
local.resolvedPosition = this.offset; |
261 |
local.resolvedPosition = this.offset; |
244 |
|
262 |
|
245 |
if ((local.type == TypeBinding.LONG) || (local.type == TypeBinding.DOUBLE)) { |
263 |
if ((local.type == TypeBinding.LONG) || (local.type == TypeBinding.DOUBLE)) { |
|
|
264 |
this.offset += 2; |
265 |
} else { |
266 |
this.offset++; |
267 |
} |
268 |
// check for too many arguments/local variables |
269 |
if (this.offset > 0xFF) { // no more than 255 words of arguments |
270 |
this.problemReporter().noMoreAvailableSpaceForArgument(local, local.declaration); |
271 |
} |
272 |
ilocal++; |
273 |
} |
274 |
|
275 |
// sneak in extra argument before other local variables |
276 |
if (extraSyntheticArguments != null) { |
277 |
for (int iarg = 0, maxArguments = extraSyntheticArguments.length; iarg < maxArguments; iarg++){ |
278 |
SyntheticArgumentBinding argument = extraSyntheticArguments[iarg]; |
279 |
argument.resolvedPosition = this.offset; |
280 |
if ((argument.type == TypeBinding.LONG) || (argument.type == TypeBinding.DOUBLE)){ |
246 |
this.offset += 2; |
281 |
this.offset += 2; |
247 |
} else { |
282 |
} else { |
248 |
this.offset++; |
283 |
this.offset++; |
249 |
} |
284 |
} |
250 |
// check for too many arguments/local variables |
|
|
251 |
if (this.offset > 0xFF) { // no more than 255 words of arguments |
285 |
if (this.offset > 0xFF) { // no more than 255 words of arguments |
252 |
this.problemReporter().noMoreAvailableSpaceForArgument(local, local.declaration); |
286 |
this.problemReporter().noMoreAvailableSpaceForArgument(argument, (ASTNode)this.referenceContext); |
253 |
} |
287 |
} |
254 |
ilocal++; |
|
|
255 |
} |
288 |
} |
256 |
|
|
|
257 |
// sneak in extra argument before other local variables |
258 |
if (extraSyntheticArguments != null) { |
259 |
for (int iarg = 0, maxArguments = extraSyntheticArguments.length; iarg < maxArguments; iarg++){ |
260 |
SyntheticArgumentBinding argument = extraSyntheticArguments[iarg]; |
261 |
argument.resolvedPosition = this.offset; |
262 |
if ((argument.type == TypeBinding.LONG) || (argument.type == TypeBinding.DOUBLE)){ |
263 |
this.offset += 2; |
264 |
} else { |
265 |
this.offset++; |
266 |
} |
267 |
if (this.offset > 0xFF) { // no more than 255 words of arguments |
268 |
this.problemReporter().noMoreAvailableSpaceForArgument(argument, (ASTNode)this.referenceContext); |
269 |
} |
270 |
} |
271 |
} |
272 |
this.computeLocalVariablePositions(ilocal, this.offset, codeStream); |
273 |
} |
289 |
} |
|
|
290 |
this.computeLocalVariablePositions(ilocal, this.offset, codeStream); |
291 |
} |
274 |
|
292 |
|
275 |
/* Error management: |
293 |
/** |
276 |
* keep null for all the errors that prevent the method to be created |
294 |
* Error management: |
277 |
* otherwise return a correct method binding (but without the element |
295 |
* keep null for all the errors that prevent the method to be created |
278 |
* that caused the problem) : ie : Incorrect thrown exception |
296 |
* otherwise return a correct method binding (but without the element |
279 |
*/ |
297 |
* that caused the problem) : ie : Incorrect thrown exception |
280 |
MethodBinding createMethod(AbstractMethodDeclaration method) { |
298 |
*/ |
281 |
|
299 |
MethodBinding createMethod(AbstractMethodDeclaration method) { |
282 |
// is necessary to ensure error reporting |
300 |
// is necessary to ensure error reporting |
283 |
this.referenceContext = method; |
301 |
this.referenceContext = method; |
284 |
method.scope = this; |
302 |
method.scope = this; |
285 |
SourceTypeBinding declaringClass = referenceType().binding; |
303 |
SourceTypeBinding declaringClass = referenceType().binding; |
286 |
int modifiers = method.modifiers | ExtraCompilerModifiers.AccUnresolved; |
304 |
int modifiers = method.modifiers | ExtraCompilerModifiers.AccUnresolved; |
287 |
if (method.isConstructor()) { |
305 |
if (method.isConstructor()) { |
288 |
if (method.isDefaultConstructor()) |
306 |
if (method.isDefaultConstructor()) |
289 |
modifiers |= ExtraCompilerModifiers.AccIsDefaultConstructor; |
307 |
modifiers |= ExtraCompilerModifiers.AccIsDefaultConstructor; |
290 |
method.binding = new MethodBinding(modifiers, null, null, declaringClass); |
308 |
method.binding = new MethodBinding(modifiers, null, null, declaringClass); |
291 |
checkAndSetModifiersForConstructor(method.binding); |
309 |
checkAndSetModifiersForConstructor(method.binding); |
292 |
} else { |
310 |
} else { |
293 |
if (declaringClass.isInterface()) // interface or annotation type |
311 |
if (declaringClass.isInterface()) // interface or annotation type |
294 |
modifiers |= ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract; |
312 |
modifiers |= ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract; |
295 |
method.binding = |
313 |
method.binding = |
296 |
new MethodBinding(modifiers, method.selector, null, null, null, declaringClass); |
314 |
new MethodBinding(modifiers, method.selector, null, null, null, declaringClass); |
297 |
checkAndSetModifiersForMethod(method.binding); |
315 |
checkAndSetModifiersForMethod(method.binding); |
298 |
} |
316 |
} |
299 |
this.isStatic = method.binding.isStatic(); |
317 |
this.isStatic = method.binding.isStatic(); |
300 |
|
318 |
|
301 |
Argument[] argTypes = method.arguments; |
319 |
Argument[] argTypes = method.arguments; |
302 |
int argLength = argTypes == null ? 0 : argTypes.length; |
320 |
int argLength = argTypes == null ? 0 : argTypes.length; |
303 |
if (argLength > 0 && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { |
321 |
if (argLength > 0 && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { |
304 |
if (argTypes[--argLength].isVarArgs()) |
322 |
if (argTypes[--argLength].isVarArgs()) |
305 |
method.binding.modifiers |= ClassFileConstants.AccVarargs; |
323 |
method.binding.modifiers |= ClassFileConstants.AccVarargs; |
306 |
while (--argLength >= 0) { |
324 |
while (--argLength >= 0) { |
307 |
if (argTypes[argLength].isVarArgs()) |
325 |
if (argTypes[argLength].isVarArgs()) |
308 |
problemReporter().illegalVararg(argTypes[argLength], method); |
326 |
problemReporter().illegalVararg(argTypes[argLength], method); |
309 |
} |
|
|
310 |
} |
311 |
|
312 |
TypeParameter[] typeParameters = method.typeParameters(); |
313 |
// do not construct type variables if source < 1.5 |
314 |
if (typeParameters == null || compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) { |
315 |
method.binding.typeVariables = Binding.NO_TYPE_VARIABLES; |
316 |
} else { |
317 |
method.binding.typeVariables = createTypeVariables(typeParameters, method.binding); |
318 |
method.binding.modifiers |= ExtraCompilerModifiers.AccGenericSignature; |
319 |
} |
327 |
} |
320 |
return method.binding; |
|
|
321 |
} |
328 |
} |
322 |
|
|
|
323 |
/* Overridden to detect the error case inside an explicit constructor call: |
324 |
|
329 |
|
325 |
class X { |
330 |
TypeParameter[] typeParameters = method.typeParameters(); |
326 |
int i; |
331 |
// do not construct type variables if source < 1.5 |
327 |
X myX; |
332 |
if (typeParameters == null || compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) { |
328 |
X(X x) { |
333 |
method.binding.typeVariables = Binding.NO_TYPE_VARIABLES; |
329 |
this(i, myX.i, x.i); // same for super calls... only the first 2 field accesses are errors |
334 |
} else { |
330 |
} |
335 |
method.binding.typeVariables = createTypeVariables(typeParameters, method.binding); |
|
|
336 |
method.binding.modifiers |= ExtraCompilerModifiers.AccGenericSignature; |
331 |
} |
337 |
} |
332 |
*/ |
338 |
return method.binding; |
333 |
public FieldBinding findField( |
339 |
} |
334 |
TypeBinding receiverType, |
|
|
335 |
char[] fieldName, |
336 |
InvocationSite invocationSite, |
337 |
boolean needResolve) { |
338 |
|
339 |
FieldBinding field = super.findField(receiverType, fieldName, invocationSite, needResolve); |
340 |
if (field == null) |
341 |
return null; |
342 |
if (!field.isValidBinding()) |
343 |
return field; // answer the error field |
344 |
if (field.isStatic()) |
345 |
return field; // static fields are always accessible |
346 |
|
340 |
|
347 |
if (!isConstructorCall || receiverType != enclosingSourceType()) |
341 |
/** |
348 |
return field; |
342 |
* Overridden to detect the error case inside an explicit constructor call: |
|
|
343 |
class X { |
344 |
int i; |
345 |
X myX; |
346 |
X(X x) { |
347 |
this(i, myX.i, x.i); // same for super calls... only the first 2 field accesses are errors |
348 |
} |
349 |
} |
350 |
*/ |
351 |
public FieldBinding findField(TypeBinding receiverType, char[] fieldName, InvocationSite invocationSite, boolean needResolve) { |
352 |
|
353 |
FieldBinding field = super.findField(receiverType, fieldName, invocationSite, needResolve); |
354 |
if (field == null) |
355 |
return null; |
356 |
if (!field.isValidBinding()) |
357 |
return field; // answer the error field |
358 |
if (field.isStatic()) |
359 |
return field; // static fields are always accessible |
360 |
|
361 |
if (!isConstructorCall || receiverType != enclosingSourceType()) |
362 |
return field; |
349 |
|
363 |
|
350 |
if (invocationSite instanceof SingleNameReference) |
364 |
if (invocationSite instanceof SingleNameReference) |
|
|
365 |
return new ProblemFieldBinding( |
366 |
field, // closest match |
367 |
field.declaringClass, |
368 |
fieldName, |
369 |
ProblemReasons.NonStaticReferenceInConstructorInvocation); |
370 |
if (invocationSite instanceof QualifiedNameReference) { |
371 |
// look to see if the field is the first binding |
372 |
QualifiedNameReference name = (QualifiedNameReference) invocationSite; |
373 |
if (name.binding == null) |
374 |
// only true when the field is the fieldbinding at the beginning of name's tokens |
351 |
return new ProblemFieldBinding( |
375 |
return new ProblemFieldBinding( |
352 |
field, // closest match |
376 |
field, // closest match |
353 |
field.declaringClass, |
377 |
field.declaringClass, |
354 |
fieldName, |
378 |
fieldName, |
355 |
ProblemReasons.NonStaticReferenceInConstructorInvocation); |
379 |
ProblemReasons.NonStaticReferenceInConstructorInvocation); |
356 |
if (invocationSite instanceof QualifiedNameReference) { |
|
|
357 |
// look to see if the field is the first binding |
358 |
QualifiedNameReference name = (QualifiedNameReference) invocationSite; |
359 |
if (name.binding == null) |
360 |
// only true when the field is the fieldbinding at the beginning of name's tokens |
361 |
return new ProblemFieldBinding( |
362 |
field, // closest match |
363 |
field.declaringClass, |
364 |
fieldName, |
365 |
ProblemReasons.NonStaticReferenceInConstructorInvocation); |
366 |
} |
367 |
return field; |
368 |
} |
369 |
|
370 |
public boolean isInsideConstructor() { |
371 |
|
372 |
return (referenceContext instanceof ConstructorDeclaration); |
373 |
} |
374 |
|
375 |
public boolean isInsideInitializer() { |
376 |
|
377 |
return (referenceContext instanceof TypeDeclaration); |
378 |
} |
380 |
} |
|
|
381 |
return field; |
382 |
} |
379 |
|
383 |
|
380 |
public boolean isInsideInitializerOrConstructor() { |
384 |
public boolean isInsideConstructor() { |
|
|
385 |
return (referenceContext instanceof ConstructorDeclaration); |
386 |
} |
381 |
|
387 |
|
382 |
return (referenceContext instanceof TypeDeclaration) |
388 |
public boolean isInsideInitializer() { |
383 |
|| (referenceContext instanceof ConstructorDeclaration); |
389 |
return (referenceContext instanceof TypeDeclaration); |
384 |
} |
390 |
} |
385 |
|
391 |
|
386 |
/* Answer the problem reporter to use for raising new problems. |
392 |
public boolean isInsideInitializerOrConstructor() { |
387 |
* |
393 |
return (referenceContext instanceof TypeDeclaration) |
388 |
* Note that as a side-effect, this updates the current reference context |
394 |
|| (referenceContext instanceof ConstructorDeclaration); |
389 |
* (unit, type or method) in case the problem handler decides it is necessary |
395 |
} |
390 |
* to abort. |
|
|
391 |
*/ |
392 |
public ProblemReporter problemReporter() { |
393 |
|
396 |
|
394 |
MethodScope outerMethodScope; |
397 |
/** |
395 |
if ((outerMethodScope = outerMostMethodScope()) == this) { |
398 |
* Answer the problem reporter to use for raising new problems. |
396 |
ProblemReporter problemReporter = referenceCompilationUnit().problemReporter; |
399 |
* |
397 |
problemReporter.referenceContext = referenceContext; |
400 |
* Note that as a side-effect, this updates the current reference context |
398 |
return problemReporter; |
401 |
* (unit, type or method) in case the problem handler decides it is necessary |
399 |
} |
402 |
* to abort. |
400 |
return outerMethodScope.problemReporter(); |
403 |
*/ |
|
|
404 |
public ProblemReporter problemReporter() { |
405 |
MethodScope outerMethodScope; |
406 |
if ((outerMethodScope = outerMostMethodScope()) == this) { |
407 |
ProblemReporter problemReporter = referenceCompilationUnit().problemReporter; |
408 |
problemReporter.referenceContext = referenceContext; |
409 |
return problemReporter; |
401 |
} |
410 |
} |
|
|
411 |
return outerMethodScope.problemReporter(); |
412 |
} |
402 |
|
413 |
|
403 |
public final int recordInitializationStates(FlowInfo flowInfo) { |
414 |
public final int recordInitializationStates(FlowInfo flowInfo) { |
404 |
|
415 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return -1; |
405 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return -1; |
416 |
UnconditionalFlowInfo unconditionalFlowInfo = flowInfo.unconditionalInitsWithoutSideEffect(); |
406 |
|
417 |
long[] extraInits = unconditionalFlowInfo.extra == null ? |
407 |
UnconditionalFlowInfo unconditionalFlowInfo = flowInfo.unconditionalInitsWithoutSideEffect(); |
418 |
null : unconditionalFlowInfo.extra[0]; |
408 |
long[] extraInits = unconditionalFlowInfo.extra == null ? |
419 |
long inits = unconditionalFlowInfo.definiteInits; |
409 |
null : unconditionalFlowInfo.extra[0]; |
420 |
checkNextEntry : for (int i = lastIndex; --i >= 0;) { |
410 |
long inits = unconditionalFlowInfo.definiteInits; |
421 |
if (definiteInits[i] == inits) { |
411 |
checkNextEntry : for (int i = lastIndex; --i >= 0;) { |
422 |
long[] otherInits = extraDefiniteInits[i]; |
412 |
if (definiteInits[i] == inits) { |
423 |
if ((extraInits != null) && (otherInits != null)) { |
413 |
long[] otherInits = extraDefiniteInits[i]; |
424 |
if (extraInits.length == otherInits.length) { |
414 |
if ((extraInits != null) && (otherInits != null)) { |
425 |
int j, max; |
415 |
if (extraInits.length == otherInits.length) { |
426 |
for (j = 0, max = extraInits.length; j < max; j++) { |
416 |
int j, max; |
427 |
if (extraInits[j] != otherInits[j]) { |
417 |
for (j = 0, max = extraInits.length; j < max; j++) { |
428 |
continue checkNextEntry; |
418 |
if (extraInits[j] != otherInits[j]) { |
|
|
419 |
continue checkNextEntry; |
420 |
} |
421 |
} |
429 |
} |
422 |
return i; |
|
|
423 |
} |
424 |
} else { |
425 |
if ((extraInits == null) && (otherInits == null)) { |
426 |
return i; |
427 |
} |
430 |
} |
|
|
431 |
return i; |
432 |
} |
433 |
} else { |
434 |
if ((extraInits == null) && (otherInits == null)) { |
435 |
return i; |
428 |
} |
436 |
} |
429 |
} |
437 |
} |
430 |
} |
438 |
} |
431 |
|
|
|
432 |
// add a new entry |
433 |
if (definiteInits.length == lastIndex) { |
434 |
// need a resize |
435 |
System.arraycopy( |
436 |
definiteInits, |
437 |
0, |
438 |
(definiteInits = new long[lastIndex + 20]), |
439 |
0, |
440 |
lastIndex); |
441 |
System.arraycopy( |
442 |
extraDefiniteInits, |
443 |
0, |
444 |
(extraDefiniteInits = new long[lastIndex + 20][]), |
445 |
0, |
446 |
lastIndex); |
447 |
} |
448 |
definiteInits[lastIndex] = inits; |
449 |
if (extraInits != null) { |
450 |
extraDefiniteInits[lastIndex] = new long[extraInits.length]; |
451 |
System.arraycopy( |
452 |
extraInits, |
453 |
0, |
454 |
extraDefiniteInits[lastIndex], |
455 |
0, |
456 |
extraInits.length); |
457 |
} |
458 |
return lastIndex++; |
459 |
} |
460 |
|
461 |
/* Answer the reference method of this scope, or null if initialization scoope. |
462 |
*/ |
463 |
public AbstractMethodDeclaration referenceMethod() { |
464 |
|
465 |
if (referenceContext instanceof AbstractMethodDeclaration) return (AbstractMethodDeclaration) referenceContext; |
466 |
return null; |
467 |
} |
439 |
} |
468 |
|
440 |
|
469 |
/* Answer the reference type of this scope. |
441 |
// add a new entry |
470 |
* |
442 |
if (definiteInits.length == lastIndex) { |
471 |
* It is the nearest enclosing type of this scope. |
443 |
// need a resize |
472 |
*/ |
444 |
System.arraycopy( |
473 |
public TypeDeclaration referenceType() { |
445 |
definiteInits, |
474 |
|
446 |
0, |
475 |
return ((ClassScope) parent).referenceContext; |
447 |
(definiteInits = new long[lastIndex + 20]), |
|
|
448 |
0, |
449 |
lastIndex); |
450 |
System.arraycopy( |
451 |
extraDefiniteInits, |
452 |
0, |
453 |
(extraDefiniteInits = new long[lastIndex + 20][]), |
454 |
0, |
455 |
lastIndex); |
456 |
} |
457 |
definiteInits[lastIndex] = inits; |
458 |
if (extraInits != null) { |
459 |
extraDefiniteInits[lastIndex] = new long[extraInits.length]; |
460 |
System.arraycopy( |
461 |
extraInits, |
462 |
0, |
463 |
extraDefiniteInits[lastIndex], |
464 |
0, |
465 |
extraInits.length); |
476 |
} |
466 |
} |
|
|
467 |
return lastIndex++; |
468 |
} |
477 |
|
469 |
|
478 |
String basicToString(int tab) { |
470 |
/** |
479 |
|
471 |
* Answer the reference method of this scope, or null if initialization scoope. |
480 |
String newLine = "\n"; //$NON-NLS-1$ |
472 |
*/ |
481 |
for (int i = tab; --i >= 0;) |
473 |
public AbstractMethodDeclaration referenceMethod() { |
482 |
newLine += "\t"; //$NON-NLS-1$ |
474 |
if (referenceContext instanceof AbstractMethodDeclaration) return (AbstractMethodDeclaration) referenceContext; |
483 |
|
475 |
return null; |
484 |
String s = newLine + "--- Method Scope ---"; //$NON-NLS-1$ |
476 |
} |
485 |
newLine += "\t"; //$NON-NLS-1$ |
|
|
486 |
s += newLine + "locals:"; //$NON-NLS-1$ |
487 |
for (int i = 0; i < localIndex; i++) |
488 |
s += newLine + "\t" + locals[i].toString(); //$NON-NLS-1$ |
489 |
s += newLine + "startIndex = " + startIndex; //$NON-NLS-1$ |
490 |
s += newLine + "isConstructorCall = " + isConstructorCall; //$NON-NLS-1$ |
491 |
s += newLine + "initializedField = " + initializedField; //$NON-NLS-1$ |
492 |
s += newLine + "lastVisibleFieldID = " + lastVisibleFieldID; //$NON-NLS-1$ |
493 |
s += newLine + "referenceContext = " + referenceContext; //$NON-NLS-1$ |
494 |
return s; |
495 |
} |
496 |
|
477 |
|
|
|
478 |
/** |
479 |
* Answer the reference type of this scope. |
480 |
* It is the nearest enclosing type of this scope. |
481 |
*/ |
482 |
public TypeDeclaration referenceType() { |
483 |
return ((ClassScope) parent).referenceContext; |
484 |
} |
497 |
} |
485 |
} |