Lines 24-65
Link Here
|
24 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
24 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
25 |
import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor; |
25 |
import org.eclipse.jdt.internal.compiler.impl.ITypeRequestor; |
26 |
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; |
26 |
import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; |
|
|
27 |
import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; |
27 |
import org.eclipse.jdt.internal.compiler.util.HashtableOfPackage; |
28 |
import org.eclipse.jdt.internal.compiler.util.HashtableOfPackage; |
28 |
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; |
29 |
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; |
29 |
|
30 |
|
30 |
public class LookupEnvironment implements ProblemReasons, TypeConstants { |
31 |
public class LookupEnvironment implements ProblemReasons, TypeConstants { |
31 |
|
32 |
|
32 |
final static int BUILD_FIELDS_AND_METHODS = 4; |
|
|
33 |
final static int BUILD_TYPE_HIERARCHY = 1; |
34 |
final static int CHECK_AND_SET_IMPORTS = 2; |
35 |
final static int CONNECT_TYPE_HIERARCHY = 3; |
36 |
static final ProblemPackageBinding TheNotFoundPackage = new ProblemPackageBinding(CharOperation.NO_CHAR, NotFound); |
37 |
static final ProblemReferenceBinding TheNotFoundType = new ProblemReferenceBinding(CharOperation.NO_CHAR, null, NotFound); |
38 |
|
39 |
/** |
33 |
/** |
40 |
* Map from typeBinding -> accessRestriction rule |
34 |
* Map from typeBinding -> accessRestriction rule |
41 |
*/ |
35 |
*/ |
42 |
private Map accessRestrictions; |
36 |
private Map accessRestrictions; |
43 |
ImportBinding[] defaultImports; |
37 |
ImportBinding[] defaultImports; |
44 |
|
|
|
45 |
public PackageBinding defaultPackage; |
38 |
public PackageBinding defaultPackage; |
46 |
HashtableOfPackage knownPackages; |
39 |
HashtableOfPackage knownPackages; |
47 |
private int lastCompletedUnitIndex = -1; |
40 |
private int lastCompletedUnitIndex = -1; |
48 |
private int lastUnitIndex = -1; |
41 |
private int lastUnitIndex = -1; |
49 |
|
42 |
|
50 |
public INameEnvironment nameEnvironment; |
43 |
public INameEnvironment nameEnvironment; |
51 |
public CompilerOptions globalOptions; |
44 |
public CompilerOptions globalOptions; |
52 |
public ProblemReporter problemReporter; |
|
|
53 |
|
45 |
|
|
|
46 |
public ProblemReporter problemReporter; |
54 |
public ClassFilePool classFilePool; |
47 |
public ClassFilePool classFilePool; |
55 |
|
|
|
56 |
// indicate in which step on the compilation we are. |
48 |
// indicate in which step on the compilation we are. |
57 |
// step 1 : build the reference binding |
49 |
// step 1 : build the reference binding |
58 |
// step 2 : conect the hierarchy (connect bindings) |
50 |
// step 2 : conect the hierarchy (connect bindings) |
59 |
// step 3 : build fields and method bindings. |
51 |
// step 3 : build fields and method bindings. |
60 |
private int stepCompleted; |
52 |
private int stepCompleted; |
61 |
public ITypeRequestor typeRequestor; |
53 |
public ITypeRequestor typeRequestor; |
|
|
54 |
|
62 |
private ArrayBinding[][] uniqueArrayBindings; |
55 |
private ArrayBinding[][] uniqueArrayBindings; |
|
|
56 |
private HashtableOfObject uniqueMissingTypeBindings; |
63 |
private SimpleLookupTable uniqueParameterizedTypeBindings; |
57 |
private SimpleLookupTable uniqueParameterizedTypeBindings; |
64 |
private SimpleLookupTable uniqueRawTypeBindings; |
58 |
private SimpleLookupTable uniqueRawTypeBindings; |
65 |
private SimpleLookupTable uniqueWildcardBindings; |
59 |
private SimpleLookupTable uniqueWildcardBindings; |
Lines 67-75
Link Here
|
67 |
|
61 |
|
68 |
public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units |
62 |
public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units |
69 |
public Object missingClassFileLocation = null; // only set when resolving certain references, to help locating problems |
63 |
public Object missingClassFileLocation = null; // only set when resolving certain references, to help locating problems |
70 |
|
|
|
71 |
private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4]; |
64 |
private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4]; |
72 |
private MethodVerifier verifier; |
65 |
private MethodVerifier verifier; |
|
|
66 |
|
67 |
final static int BUILD_FIELDS_AND_METHODS = 4; |
68 |
final static int BUILD_TYPE_HIERARCHY = 1; |
69 |
final static int CHECK_AND_SET_IMPORTS = 2; |
70 |
final static int CONNECT_TYPE_HIERARCHY = 3; |
71 |
|
72 |
static final ProblemPackageBinding TheNotFoundPackage = new ProblemPackageBinding(CharOperation.NO_CHAR, NotFound); |
73 |
static final ProblemReferenceBinding TheNotFoundType = new ProblemReferenceBinding(CharOperation.NO_CHAR_CHAR, null, NotFound); |
73 |
|
74 |
|
74 |
public LookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions globalOptions, ProblemReporter problemReporter, INameEnvironment nameEnvironment) { |
75 |
public LookupEnvironment(ITypeRequestor typeRequestor, CompilerOptions globalOptions, ProblemReporter problemReporter, INameEnvironment nameEnvironment) { |
75 |
this.typeRequestor = typeRequestor; |
76 |
this.typeRequestor = typeRequestor; |
Lines 81-86
Link Here
|
81 |
this.knownPackages = new HashtableOfPackage(); |
82 |
this.knownPackages = new HashtableOfPackage(); |
82 |
this.uniqueArrayBindings = new ArrayBinding[5][]; |
83 |
this.uniqueArrayBindings = new ArrayBinding[5][]; |
83 |
this.uniqueArrayBindings[0] = new ArrayBinding[50]; // start off the most common 1 dimension array @ 50 |
84 |
this.uniqueArrayBindings[0] = new ArrayBinding[50]; // start off the most common 1 dimension array @ 50 |
|
|
85 |
this.uniqueMissingTypeBindings = new HashtableOfObject(3); |
84 |
this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3); |
86 |
this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3); |
85 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
87 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
86 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
88 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
Lines 96-114
Link Here
|
96 |
|
98 |
|
97 |
public ReferenceBinding askForType(char[][] compoundName) { |
99 |
public ReferenceBinding askForType(char[][] compoundName) { |
98 |
NameEnvironmentAnswer answer = nameEnvironment.findType(compoundName); |
100 |
NameEnvironmentAnswer answer = nameEnvironment.findType(compoundName); |
99 |
if (answer == null) |
101 |
if (answer == null) return null; |
100 |
return null; |
|
|
101 |
|
102 |
|
102 |
if (answer.isBinaryType()) |
103 |
if (answer.isBinaryType()) { |
103 |
// the type was found as a .class file |
104 |
// the type was found as a .class file |
104 |
typeRequestor.accept(answer.getBinaryType(), computePackageFrom(compoundName), answer.getAccessRestriction()); |
105 |
typeRequestor.accept(answer.getBinaryType(), computePackageFrom(compoundName, false /* valid pkg */), answer.getAccessRestriction()); |
105 |
else if (answer.isCompilationUnit()) |
106 |
} else if (answer.isCompilationUnit()) { |
106 |
// the type was found as a .java file, try to build it then search the cache |
107 |
// the type was found as a .java file, try to build it then search the cache |
107 |
typeRequestor.accept(answer.getCompilationUnit(), answer.getAccessRestriction()); |
108 |
typeRequestor.accept(answer.getCompilationUnit(), answer.getAccessRestriction()); |
108 |
else if (answer.isSourceType()) |
109 |
} else if (answer.isSourceType()) { |
109 |
// the type was found as a source model |
110 |
// the type was found as a source model |
110 |
typeRequestor.accept(answer.getSourceTypes(), computePackageFrom(compoundName), answer.getAccessRestriction()); |
111 |
typeRequestor.accept(answer.getSourceTypes(), computePackageFrom(compoundName, false /* valid pkg */), answer.getAccessRestriction()); |
111 |
|
112 |
} |
112 |
return getCachedType(compoundName); |
113 |
return getCachedType(compoundName); |
113 |
} |
114 |
} |
114 |
/* Ask the oracle for a type named name in the packageBinding. |
115 |
/* Ask the oracle for a type named name in the packageBinding. |
Lines 125-212
Link Here
|
125 |
if (answer == null) |
126 |
if (answer == null) |
126 |
return null; |
127 |
return null; |
127 |
|
128 |
|
128 |
if (answer.isBinaryType()) |
129 |
if (answer.isBinaryType()) { |
129 |
// the type was found as a .class file |
130 |
// the type was found as a .class file |
130 |
typeRequestor.accept(answer.getBinaryType(), packageBinding, answer.getAccessRestriction()); |
131 |
typeRequestor.accept(answer.getBinaryType(), packageBinding, answer.getAccessRestriction()); |
131 |
else if (answer.isCompilationUnit()) |
132 |
} else if (answer.isCompilationUnit()) { |
132 |
// the type was found as a .java file, try to build it then search the cache |
133 |
// the type was found as a .java file, try to build it then search the cache |
133 |
typeRequestor.accept(answer.getCompilationUnit(), answer.getAccessRestriction()); |
134 |
typeRequestor.accept(answer.getCompilationUnit(), answer.getAccessRestriction()); |
134 |
else if (answer.isSourceType()) |
135 |
} else if (answer.isSourceType()) { |
135 |
// the type was found as a source model |
136 |
// the type was found as a source model |
136 |
typeRequestor.accept(answer.getSourceTypes(), packageBinding, answer.getAccessRestriction()); |
137 |
typeRequestor.accept(answer.getSourceTypes(), packageBinding, answer.getAccessRestriction()); |
137 |
|
138 |
} |
138 |
return packageBinding.getType0(name); |
139 |
return packageBinding.getType0(name); |
139 |
} |
140 |
} |
|
|
141 |
|
140 |
/* Create the initial type bindings for the compilation unit. |
142 |
/* Create the initial type bindings for the compilation unit. |
141 |
* |
143 |
* |
142 |
* See completeTypeBindings() for a description of the remaining steps |
144 |
* See completeTypeBindings() for a description of the remaining steps |
143 |
* |
145 |
* |
144 |
* NOTE: This method can be called multiple times as additional source files are needed |
146 |
* NOTE: This method can be called multiple times as additional source files are needed |
145 |
*/ |
147 |
*/ |
146 |
|
|
|
147 |
public void buildTypeBindings(CompilationUnitDeclaration unit, AccessRestriction accessRestriction) { |
148 |
public void buildTypeBindings(CompilationUnitDeclaration unit, AccessRestriction accessRestriction) { |
148 |
CompilationUnitScope scope = new CompilationUnitScope(unit, this); |
149 |
CompilationUnitScope scope = new CompilationUnitScope(unit, this); |
149 |
scope.buildTypeBindings(accessRestriction); |
150 |
scope.buildTypeBindings(accessRestriction); |
150 |
|
|
|
151 |
int unitsLength = units.length; |
151 |
int unitsLength = units.length; |
152 |
if (++lastUnitIndex >= unitsLength) |
152 |
if (++lastUnitIndex >= unitsLength) |
153 |
System.arraycopy(units, 0, units = new CompilationUnitDeclaration[2 * unitsLength], 0, unitsLength); |
153 |
System.arraycopy(units, 0, units = new CompilationUnitDeclaration[2 * unitsLength], 0, unitsLength); |
154 |
units[lastUnitIndex] = unit; |
154 |
units[lastUnitIndex] = unit; |
155 |
} |
155 |
} |
|
|
156 |
|
156 |
/* Cache the binary type since we know it is needed during this compile. |
157 |
/* Cache the binary type since we know it is needed during this compile. |
157 |
* |
158 |
* |
158 |
* Answer the created BinaryTypeBinding or null if the type is already in the cache. |
159 |
* Answer the created BinaryTypeBinding or null if the type is already in the cache. |
159 |
*/ |
160 |
*/ |
160 |
|
|
|
161 |
public BinaryTypeBinding cacheBinaryType(IBinaryType binaryType, AccessRestriction accessRestriction) { |
161 |
public BinaryTypeBinding cacheBinaryType(IBinaryType binaryType, AccessRestriction accessRestriction) { |
162 |
return cacheBinaryType(binaryType, true, accessRestriction); |
162 |
return cacheBinaryType(binaryType, true, accessRestriction); |
163 |
} |
163 |
} |
|
|
164 |
|
164 |
/* Cache the binary type since we know it is needed during this compile. |
165 |
/* Cache the binary type since we know it is needed during this compile. |
165 |
* |
166 |
* |
166 |
* Answer the created BinaryTypeBinding or null if the type is already in the cache. |
167 |
* Answer the created BinaryTypeBinding or null if the type is already in the cache. |
167 |
*/ |
168 |
*/ |
168 |
|
|
|
169 |
public BinaryTypeBinding cacheBinaryType(IBinaryType binaryType, boolean needFieldsAndMethods, AccessRestriction accessRestriction) { |
169 |
public BinaryTypeBinding cacheBinaryType(IBinaryType binaryType, boolean needFieldsAndMethods, AccessRestriction accessRestriction) { |
170 |
char[][] compoundName = CharOperation.splitOn('/', binaryType.getName()); |
170 |
char[][] compoundName = CharOperation.splitOn('/', binaryType.getName()); |
171 |
ReferenceBinding existingType = getCachedType(compoundName); |
171 |
ReferenceBinding existingType = getCachedType(compoundName); |
172 |
|
172 |
|
173 |
if (existingType == null || existingType instanceof UnresolvedReferenceBinding) |
173 |
if (existingType == null || existingType instanceof UnresolvedReferenceBinding) |
174 |
// only add the binary type if its not already in the cache |
174 |
// only add the binary type if its not already in the cache |
175 |
return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName), needFieldsAndMethods, accessRestriction); |
175 |
return createBinaryTypeFrom(binaryType, computePackageFrom(compoundName, false /* valid pkg */), needFieldsAndMethods, accessRestriction); |
176 |
return null; // the type already exists & can be retrieved from the cache |
176 |
return null; // the type already exists & can be retrieved from the cache |
177 |
} |
177 |
} |
178 |
public BinaryTypeBinding cacheMissingBinaryType(char[][] compoundName, CompilationUnitDeclaration unit) { |
|
|
179 |
// report the missing class file first |
180 |
problemReporter.isClassPathCorrect( |
181 |
compoundName, |
182 |
unit == null ? this.unitBeingCompleted : unit, |
183 |
this.missingClassFileLocation); |
184 |
|
185 |
PackageBinding packageBinding = computePackageFrom(compoundName); |
186 |
// create a proxy for the missing BinaryType |
187 |
MissingBinaryTypeBinding type = new MissingBinaryTypeBinding(packageBinding, compoundName, this); |
188 |
if (type.id != TypeIds.T_JavaLangObject) { |
189 |
// make Object be its superclass - it could in turn be missing as well |
190 |
ReferenceBinding objectType = getType(TypeConstants.JAVA_LANG_OBJECT); |
191 |
if (objectType == null) |
192 |
objectType = cacheMissingBinaryType(TypeConstants.JAVA_LANG_OBJECT, unit); // create a proxy for the missing Object type |
193 |
type.setMissingSuperclass(objectType); |
194 |
} |
195 |
packageBinding.addType(type); |
196 |
return type; |
197 |
} |
198 |
/* |
199 |
* 1. Connect the type hierarchy for the type bindings created for parsedUnits. |
200 |
* 2. Create the field bindings |
201 |
* 3. Create the method bindings |
202 |
*/ |
203 |
|
204 |
/* We know each known compilationUnit is free of errors at this point... |
205 |
* |
206 |
* Each step will create additional bindings unless a problem is detected, in which |
207 |
* case either the faulty import/superinterface/field/method will be skipped or a |
208 |
* suitable replacement will be substituted (such as Object for a missing superclass) |
209 |
*/ |
210 |
|
178 |
|
211 |
public void completeTypeBindings() { |
179 |
public void completeTypeBindings() { |
212 |
stepCompleted = BUILD_TYPE_HIERARCHY; |
180 |
stepCompleted = BUILD_TYPE_HIERARCHY; |
Lines 231-248
Link Here
|
231 |
this.lastCompletedUnitIndex = this.lastUnitIndex; |
199 |
this.lastCompletedUnitIndex = this.lastUnitIndex; |
232 |
this.unitBeingCompleted = null; |
200 |
this.unitBeingCompleted = null; |
233 |
} |
201 |
} |
|
|
202 |
|
234 |
/* |
203 |
/* |
235 |
* 1. Connect the type hierarchy for the type bindings created for parsedUnits. |
204 |
* 1. Connect the type hierarchy for the type bindings created for parsedUnits. |
236 |
* 2. Create the field bindings |
205 |
* 2. Create the field bindings |
237 |
* 3. Create the method bindings |
206 |
* 3. Create the method bindings |
238 |
*/ |
207 |
*/ |
239 |
|
208 |
|
240 |
/* |
209 |
/* We know each known compilationUnit is free of errors at this point... |
|
|
210 |
* |
241 |
* Each step will create additional bindings unless a problem is detected, in which |
211 |
* Each step will create additional bindings unless a problem is detected, in which |
242 |
* case either the faulty import/superinterface/field/method will be skipped or a |
212 |
* case either the faulty import/superinterface/field/method will be skipped or a |
243 |
* suitable replacement will be substituted (such as Object for a missing superclass) |
213 |
* suitable replacement will be substituted (such as Object for a missing superclass) |
244 |
*/ |
214 |
*/ |
245 |
|
|
|
246 |
public void completeTypeBindings(CompilationUnitDeclaration parsedUnit) { |
215 |
public void completeTypeBindings(CompilationUnitDeclaration parsedUnit) { |
247 |
if (stepCompleted == BUILD_FIELDS_AND_METHODS) { |
216 |
if (stepCompleted == BUILD_FIELDS_AND_METHODS) { |
248 |
// This can only happen because the original set of units are completely built and |
217 |
// This can only happen because the original set of units are completely built and |
Lines 261-266
Link Here
|
261 |
this.unitBeingCompleted = null; |
230 |
this.unitBeingCompleted = null; |
262 |
} |
231 |
} |
263 |
} |
232 |
} |
|
|
233 |
|
264 |
/* |
234 |
/* |
265 |
* Used by other compiler tools which do not start by calling completeTypeBindings(). |
235 |
* Used by other compiler tools which do not start by calling completeTypeBindings(). |
266 |
* |
236 |
* |
Lines 269-274
Link Here
|
269 |
* 3. Create the method bindings |
239 |
* 3. Create the method bindings |
270 |
*/ |
240 |
*/ |
271 |
|
241 |
|
|
|
242 |
/* |
243 |
* Each step will create additional bindings unless a problem is detected, in which |
244 |
* case either the faulty import/superinterface/field/method will be skipped or a |
245 |
* suitable replacement will be substituted (such as Object for a missing superclass) |
246 |
*/ |
272 |
public void completeTypeBindings(CompilationUnitDeclaration parsedUnit, boolean buildFieldsAndMethods) { |
247 |
public void completeTypeBindings(CompilationUnitDeclaration parsedUnit, boolean buildFieldsAndMethods) { |
273 |
if (parsedUnit.scope == null) return; // parsing errors were too severe |
248 |
if (parsedUnit.scope == null) return; // parsing errors were too severe |
274 |
|
249 |
|
Lines 279-284
Link Here
|
279 |
parsedUnit.scope.buildFieldsAndMethods(); |
254 |
parsedUnit.scope.buildFieldsAndMethods(); |
280 |
this.unitBeingCompleted = null; |
255 |
this.unitBeingCompleted = null; |
281 |
} |
256 |
} |
|
|
257 |
|
282 |
public TypeBinding computeBoxingType(TypeBinding type) { |
258 |
public TypeBinding computeBoxingType(TypeBinding type) { |
283 |
TypeBinding boxedType; |
259 |
TypeBinding boxedType; |
284 |
switch (type.id) { |
260 |
switch (type.id) { |
Lines 373-386
Link Here
|
373 |
} |
349 |
} |
374 |
} |
350 |
} |
375 |
return type; |
351 |
return type; |
376 |
} |
352 |
} |
377 |
private PackageBinding computePackageFrom(char[][] constantPoolName) { |
353 |
|
|
|
354 |
private PackageBinding computePackageFrom(char[][] constantPoolName, boolean isMissing) { |
378 |
if (constantPoolName.length == 1) |
355 |
if (constantPoolName.length == 1) |
379 |
return defaultPackage; |
356 |
return defaultPackage; |
380 |
|
357 |
|
381 |
PackageBinding packageBinding = getPackage0(constantPoolName[0]); |
358 |
PackageBinding packageBinding = getPackage0(constantPoolName[0]); |
382 |
if (packageBinding == null || packageBinding == TheNotFoundPackage) { |
359 |
if (packageBinding == null || packageBinding == TheNotFoundPackage) { |
383 |
packageBinding = new PackageBinding(constantPoolName[0], this); |
360 |
packageBinding = new PackageBinding(constantPoolName[0], this); |
|
|
361 |
if (isMissing) packageBinding.tagBits |= TagBits.HasMissingType; |
384 |
knownPackages.put(constantPoolName[0], packageBinding); |
362 |
knownPackages.put(constantPoolName[0], packageBinding); |
385 |
} |
363 |
} |
386 |
|
364 |
|
Lines 388-421
Link Here
|
388 |
PackageBinding parent = packageBinding; |
366 |
PackageBinding parent = packageBinding; |
389 |
if ((packageBinding = parent.getPackage0(constantPoolName[i])) == null || packageBinding == TheNotFoundPackage) { |
367 |
if ((packageBinding = parent.getPackage0(constantPoolName[i])) == null || packageBinding == TheNotFoundPackage) { |
390 |
packageBinding = new PackageBinding(CharOperation.subarray(constantPoolName, 0, i + 1), parent, this); |
368 |
packageBinding = new PackageBinding(CharOperation.subarray(constantPoolName, 0, i + 1), parent, this); |
|
|
369 |
if (isMissing) { |
370 |
packageBinding.tagBits |= TagBits.HasMissingType; |
371 |
} |
391 |
parent.addPackage(packageBinding); |
372 |
parent.addPackage(packageBinding); |
392 |
} |
373 |
} |
393 |
} |
374 |
} |
394 |
return packageBinding; |
375 |
return packageBinding; |
395 |
} |
376 |
} |
396 |
|
|
|
397 |
/** |
398 |
* Convert a given source type into a parameterized form if generic. |
399 |
* generic X<E> --> param X<E> |
400 |
*/ |
401 |
public ReferenceBinding convertToParameterizedType(ReferenceBinding originalType) { |
402 |
if (originalType != null) { |
403 |
boolean isGeneric = originalType.isGenericType(); |
404 |
ReferenceBinding originalEnclosingType = originalType.enclosingType(); |
405 |
ReferenceBinding convertedEnclosingType = originalEnclosingType; |
406 |
boolean needToConvert = isGeneric; |
407 |
if (originalEnclosingType != null) { |
408 |
convertedEnclosingType = originalType.isStatic() |
409 |
? (ReferenceBinding) convertToRawType(originalEnclosingType, false /*do not force conversion of enclosing types*/) |
410 |
: convertToParameterizedType(originalEnclosingType); |
411 |
needToConvert |= originalEnclosingType != convertedEnclosingType; |
412 |
} |
413 |
if (needToConvert) { |
414 |
return createParameterizedType(originalType, isGeneric ? originalType.typeVariables() : null, convertedEnclosingType); |
415 |
} |
416 |
} |
417 |
return originalType; |
418 |
} |
419 |
|
377 |
|
420 |
public TypeBinding convertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, Set eliminatedVariables) { |
378 |
public TypeBinding convertEliminatingTypeVariables(TypeBinding originalType, ReferenceBinding genericType, int rank, Set eliminatedVariables) { |
421 |
if ((originalType.tagBits & TagBits.HasTypeVariable) != 0) { |
379 |
if ((originalType.tagBits & TagBits.HasTypeVariable) != 0) { |
Lines 535-540
Link Here
|
535 |
} |
493 |
} |
536 |
|
494 |
|
537 |
/** |
495 |
/** |
|
|
496 |
* Convert a given source type into a parameterized form if generic. |
497 |
* generic X<E> --> param X<E> |
498 |
*/ |
499 |
public ReferenceBinding convertToParameterizedType(ReferenceBinding originalType) { |
500 |
if (originalType != null) { |
501 |
boolean isGeneric = originalType.isGenericType(); |
502 |
ReferenceBinding originalEnclosingType = originalType.enclosingType(); |
503 |
ReferenceBinding convertedEnclosingType = originalEnclosingType; |
504 |
boolean needToConvert = isGeneric; |
505 |
if (originalEnclosingType != null) { |
506 |
convertedEnclosingType = originalType.isStatic() |
507 |
? (ReferenceBinding) convertToRawType(originalEnclosingType, false /*do not force conversion of enclosing types*/) |
508 |
: convertToParameterizedType(originalEnclosingType); |
509 |
needToConvert |= originalEnclosingType != convertedEnclosingType; |
510 |
} |
511 |
if (needToConvert) { |
512 |
return createParameterizedType(originalType, isGeneric ? originalType.typeVariables() : null, convertedEnclosingType); |
513 |
} |
514 |
} |
515 |
return originalType; |
516 |
} |
517 |
|
518 |
/** |
538 |
* Returns the given binding's raw type binding. |
519 |
* Returns the given binding's raw type binding. |
539 |
* @param type the TypeBinding to raw convert |
520 |
* @param type the TypeBinding to raw convert |
540 |
* @param forceRawEnclosingType forces recursive raw conversion of enclosing types (used in Javadoc references only) |
521 |
* @param forceRawEnclosingType forces recursive raw conversion of enclosing types (used in Javadoc references only) |
Lines 606-611
Link Here
|
606 |
return type; |
587 |
return type; |
607 |
} |
588 |
} |
608 |
|
589 |
|
|
|
590 |
|
609 |
// variation for unresolved types in binaries (consider generic type as raw) |
591 |
// variation for unresolved types in binaries (consider generic type as raw) |
610 |
public TypeBinding convertUnresolvedBinaryToRawType(TypeBinding type) { |
592 |
public TypeBinding convertUnresolvedBinaryToRawType(TypeBinding type) { |
611 |
int dimension; |
593 |
int dimension; |
Lines 664-669
Link Here
|
664 |
} |
646 |
} |
665 |
return type; |
647 |
return type; |
666 |
} |
648 |
} |
|
|
649 |
|
667 |
/* |
650 |
/* |
668 |
* Used to guarantee annotation identity. |
651 |
* Used to guarantee annotation identity. |
669 |
*/ |
652 |
*/ |
Lines 673-679
Link Here
|
673 |
} |
656 |
} |
674 |
return new AnnotationBinding(annotationType, pairs); |
657 |
return new AnnotationBinding(annotationType, pairs); |
675 |
} |
658 |
} |
676 |
|
|
|
677 |
/* |
659 |
/* |
678 |
* Used to guarantee array type identity. |
660 |
* Used to guarantee array type identity. |
679 |
*/ |
661 |
*/ |
Lines 715-720
Link Here
|
715 |
uniqueArrayBindings[dimIndex] = arrayBindings; |
697 |
uniqueArrayBindings[dimIndex] = arrayBindings; |
716 |
return arrayBindings[length] = new ArrayBinding(leafComponentType, dimensionCount, this); |
698 |
return arrayBindings[length] = new ArrayBinding(leafComponentType, dimensionCount, this); |
717 |
} |
699 |
} |
|
|
700 |
|
718 |
public BinaryTypeBinding createBinaryTypeFrom(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) { |
701 |
public BinaryTypeBinding createBinaryTypeFrom(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) { |
719 |
return createBinaryTypeFrom(binaryType, packageBinding, true, accessRestriction); |
702 |
return createBinaryTypeFrom(binaryType, packageBinding, true, accessRestriction); |
720 |
} |
703 |
} |
Lines 740-748
Link Here
|
740 |
binaryBinding.cachePartsFrom(binaryType, needFieldsAndMethods); |
723 |
binaryBinding.cachePartsFrom(binaryType, needFieldsAndMethods); |
741 |
return binaryBinding; |
724 |
return binaryBinding; |
742 |
} |
725 |
} |
743 |
/* Used to create packages from the package statement. |
726 |
|
|
|
727 |
/* |
728 |
* Used to create types denoting missing types. |
729 |
* If package is given, then reuse the package; if not then infer a package from compound name. |
730 |
* If the package is existing, then install the missing type in type cache |
744 |
*/ |
731 |
*/ |
|
|
732 |
public MissingTypeBinding createMissingType(PackageBinding packageBinding, char[][] compoundName) { |
733 |
if (false) { // TODO remove (also remove field #uniqueMissingTypeBindings |
734 |
int nameLength = compoundName.length; |
735 |
char[] simpleName = nameLength == 0 ? CharOperation.NO_CHAR : compoundName[nameLength-1]; |
736 |
// cached info is array of already created missing types for this simple name |
737 |
MissingTypeBinding[] cachedInfo = (MissingTypeBinding[])this.uniqueMissingTypeBindings.get(simpleName); |
738 |
boolean needToGrow = false; |
739 |
int index = 0; |
740 |
if (cachedInfo != null){ |
741 |
nextCachedType : |
742 |
// iterate existing parameterized for reusing one with same type arguments if any |
743 |
for (int max = cachedInfo.length; index < max; index++){ |
744 |
MissingTypeBinding cachedType = cachedInfo[index]; |
745 |
if (cachedType == null) break nextCachedType; |
746 |
if (!CharOperation.equals(cachedType.compoundName, compoundName)) continue nextCachedType; |
747 |
// reuse current |
748 |
return cachedType; |
749 |
} |
750 |
needToGrow = true; |
751 |
} else { |
752 |
cachedInfo = new MissingTypeBinding[5]; |
753 |
this.uniqueMissingTypeBindings.put(simpleName, cachedInfo); |
754 |
} |
755 |
// grow cache ? |
756 |
int length = cachedInfo.length; |
757 |
if (needToGrow && index == length){ |
758 |
System.arraycopy(cachedInfo, 0, cachedInfo = new MissingTypeBinding[length*2], 0, length); |
759 |
this.uniqueParameterizedTypeBindings.put(simpleName, cachedInfo); |
760 |
} |
761 |
} |
762 |
// create a proxy for the missing BinaryType |
763 |
if (packageBinding == null) { |
764 |
packageBinding = computePackageFrom(compoundName, true /* missing */); |
765 |
if (packageBinding == TheNotFoundPackage) packageBinding = this.defaultPackage; |
766 |
} |
767 |
MissingTypeBinding missingType = new MissingTypeBinding(packageBinding, compoundName, this); |
768 |
if (missingType.id != TypeIds.T_JavaLangObject) { |
769 |
// make Object be its superclass - it could in turn be missing as well |
770 |
ReferenceBinding objectType = getType(TypeConstants.JAVA_LANG_OBJECT); |
771 |
if (objectType == null) { |
772 |
objectType = createMissingType(null, TypeConstants.JAVA_LANG_OBJECT); // create a proxy for the missing Object type |
773 |
} |
774 |
missingType.setMissingSuperclass(objectType); |
775 |
} |
776 |
packageBinding.addType(missingType); |
777 |
return missingType; |
778 |
} |
745 |
|
779 |
|
|
|
780 |
/* |
781 |
* 1. Connect the type hierarchy for the type bindings created for parsedUnits. |
782 |
* 2. Create the field bindings |
783 |
* 3. Create the method bindings |
784 |
*/ |
746 |
public PackageBinding createPackage(char[][] compoundName) { |
785 |
public PackageBinding createPackage(char[][] compoundName) { |
747 |
PackageBinding packageBinding = getPackage0(compoundName[0]); |
786 |
PackageBinding packageBinding = getPackage0(compoundName[0]); |
748 |
if (packageBinding == null || packageBinding == TheNotFoundPackage) { |
787 |
if (packageBinding == null || packageBinding == TheNotFoundPackage) { |
Lines 778-784
Link Here
|
778 |
} |
817 |
} |
779 |
|
818 |
|
780 |
public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, RawTypeBinding rawType) { |
819 |
public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, RawTypeBinding rawType) { |
781 |
|
|
|
782 |
// cached info is array of already created parameterized types for this type |
820 |
// cached info is array of already created parameterized types for this type |
783 |
ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod); |
821 |
ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod); |
784 |
boolean needToGrow = false; |
822 |
boolean needToGrow = false; |
Lines 811-817
Link Here
|
811 |
} |
849 |
} |
812 |
|
850 |
|
813 |
public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, TypeBinding[] typeArguments) { |
851 |
public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, TypeBinding[] typeArguments) { |
814 |
|
|
|
815 |
// cached info is array of already created parameterized types for this type |
852 |
// cached info is array of already created parameterized types for this type |
816 |
ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod); |
853 |
ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod); |
817 |
int argLength = typeArguments == null ? 0: typeArguments.length; |
854 |
int argLength = typeArguments == null ? 0: typeArguments.length; |
Lines 851-857
Link Here
|
851 |
} |
888 |
} |
852 |
|
889 |
|
853 |
public ParameterizedTypeBinding createParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) { |
890 |
public ParameterizedTypeBinding createParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) { |
854 |
|
|
|
855 |
// cached info is array of already created parameterized types for this type |
891 |
// cached info is array of already created parameterized types for this type |
856 |
ParameterizedTypeBinding[] cachedInfo = (ParameterizedTypeBinding[])this.uniqueParameterizedTypeBindings.get(genericType); |
892 |
ParameterizedTypeBinding[] cachedInfo = (ParameterizedTypeBinding[])this.uniqueParameterizedTypeBindings.get(genericType); |
857 |
int argLength = typeArguments == null ? 0: typeArguments.length; |
893 |
int argLength = typeArguments == null ? 0: typeArguments.length; |
Lines 926-932
Link Here
|
926 |
} |
962 |
} |
927 |
|
963 |
|
928 |
public WildcardBinding createWildcard(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind) { |
964 |
public WildcardBinding createWildcard(ReferenceBinding genericType, int rank, TypeBinding bound, TypeBinding[] otherBounds, int boundKind) { |
929 |
|
|
|
930 |
// cached info is array of already created wildcard types for this type |
965 |
// cached info is array of already created wildcard types for this type |
931 |
if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation |
966 |
if (genericType == null) // pseudo wildcard denoting composite bounds for lub computation |
932 |
genericType = ReferenceBinding.LUB_GENERIC; |
967 |
genericType = ReferenceBinding.LUB_GENERIC; |
Lines 986-999
Link Here
|
986 |
* NOTE: Do not use for nested types... the answer is NOT the same for a.b.C or a.b.C.D.E |
1021 |
* NOTE: Do not use for nested types... the answer is NOT the same for a.b.C or a.b.C.D.E |
987 |
* assuming C is a type in both cases. In the a.b.C.D.E case, null is the answer. |
1022 |
* assuming C is a type in both cases. In the a.b.C.D.E case, null is the answer. |
988 |
*/ |
1023 |
*/ |
989 |
|
|
|
990 |
public ReferenceBinding getCachedType(char[][] compoundName) { |
1024 |
public ReferenceBinding getCachedType(char[][] compoundName) { |
991 |
if (compoundName.length == 1) { |
1025 |
if (compoundName.length == 1) { |
992 |
if (defaultPackage == null) |
1026 |
if (defaultPackage == null) |
993 |
return null; |
1027 |
return null; |
994 |
return defaultPackage.getType0(compoundName[0]); |
1028 |
return defaultPackage.getType0(compoundName[0]); |
995 |
} |
1029 |
} |
996 |
|
|
|
997 |
PackageBinding packageBinding = getPackage0(compoundName[0]); |
1030 |
PackageBinding packageBinding = getPackage0(compoundName[0]); |
998 |
if (packageBinding == null || packageBinding == TheNotFoundPackage) |
1031 |
if (packageBinding == null || packageBinding == TheNotFoundPackage) |
999 |
return null; |
1032 |
return null; |
Lines 1003-1008
Link Here
|
1003 |
return null; |
1036 |
return null; |
1004 |
return packageBinding.getType0(compoundName[compoundName.length - 1]); |
1037 |
return packageBinding.getType0(compoundName[compoundName.length - 1]); |
1005 |
} |
1038 |
} |
|
|
1039 |
|
1006 |
/* Answer the top level package named name if it exists in the cache. |
1040 |
/* Answer the top level package named name if it exists in the cache. |
1007 |
* Answer theNotFoundPackage if it could not be resolved the first time |
1041 |
* Answer theNotFoundPackage if it could not be resolved the first time |
1008 |
* it was looked up, otherwise answer null. |
1042 |
* it was looked up, otherwise answer null. |
Lines 1010-1019
Link Here
|
1010 |
* NOTE: Senders must convert theNotFoundPackage into a real problem |
1044 |
* NOTE: Senders must convert theNotFoundPackage into a real problem |
1011 |
* package if its to returned. |
1045 |
* package if its to returned. |
1012 |
*/ |
1046 |
*/ |
1013 |
|
|
|
1014 |
PackageBinding getPackage0(char[] name) { |
1047 |
PackageBinding getPackage0(char[] name) { |
1015 |
return knownPackages.get(name); |
1048 |
return knownPackages.get(name); |
1016 |
} |
1049 |
} |
|
|
1050 |
|
1017 |
/* Answer the type corresponding to the compoundName. |
1051 |
/* Answer the type corresponding to the compoundName. |
1018 |
* Ask the name environment for the type if its not in the cache. |
1052 |
* Ask the name environment for the type if its not in the cache. |
1019 |
* Fail with a classpath error if the type cannot be found. |
1053 |
* Fail with a classpath error if the type cannot be found. |
Lines 1023-1037
Link Here
|
1023 |
if (type != null) return type; |
1057 |
if (type != null) return type; |
1024 |
|
1058 |
|
1025 |
// create a proxy for the missing BinaryType |
1059 |
// create a proxy for the missing BinaryType |
1026 |
return cacheMissingBinaryType( |
1060 |
// report the missing class file first |
|
|
1061 |
problemReporter.isClassPathCorrect( |
1027 |
compoundName, |
1062 |
compoundName, |
1028 |
scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit()); |
1063 |
scope == null ? this.unitBeingCompleted : scope.referenceCompilationUnit(), |
|
|
1064 |
this.missingClassFileLocation); |
1065 |
return createMissingType(null, compoundName); |
1029 |
} |
1066 |
} |
|
|
1067 |
|
1030 |
/* Answer the top level package named name. |
1068 |
/* Answer the top level package named name. |
1031 |
* Ask the oracle for the package if its not in the cache. |
1069 |
* Ask the oracle for the package if its not in the cache. |
1032 |
* Answer null if the package cannot be found. |
1070 |
* Answer null if the package cannot be found. |
1033 |
*/ |
1071 |
*/ |
1034 |
|
|
|
1035 |
PackageBinding getTopLevelPackage(char[] name) { |
1072 |
PackageBinding getTopLevelPackage(char[] name) { |
1036 |
PackageBinding packageBinding = getPackage0(name); |
1073 |
PackageBinding packageBinding = getPackage0(name); |
1037 |
if (packageBinding != null) { |
1074 |
if (packageBinding != null) { |
Lines 1048-1058
Link Here
|
1048 |
knownPackages.put(name, TheNotFoundPackage); // saves asking the oracle next time |
1085 |
knownPackages.put(name, TheNotFoundPackage); // saves asking the oracle next time |
1049 |
return null; |
1086 |
return null; |
1050 |
} |
1087 |
} |
|
|
1088 |
|
1051 |
/* Answer the type corresponding to the compoundName. |
1089 |
/* Answer the type corresponding to the compoundName. |
1052 |
* Ask the name environment for the type if its not in the cache. |
1090 |
* Ask the name environment for the type if its not in the cache. |
1053 |
* Answer null if the type cannot be found. |
1091 |
* Answer null if the type cannot be found. |
1054 |
*/ |
1092 |
*/ |
1055 |
|
|
|
1056 |
public ReferenceBinding getType(char[][] compoundName) { |
1093 |
public ReferenceBinding getType(char[][] compoundName) { |
1057 |
ReferenceBinding referenceBinding; |
1094 |
ReferenceBinding referenceBinding; |
1058 |
|
1095 |
|
Lines 1095-1100
Link Here
|
1095 |
return new ProblemReferenceBinding(compoundName, referenceBinding, InternalNameProvided); |
1132 |
return new ProblemReferenceBinding(compoundName, referenceBinding, InternalNameProvided); |
1096 |
return referenceBinding; |
1133 |
return referenceBinding; |
1097 |
} |
1134 |
} |
|
|
1135 |
|
1098 |
private TypeBinding[] getTypeArgumentsFromSignature(SignatureWrapper wrapper, TypeVariableBinding[] staticVariables, ReferenceBinding enclosingType, ReferenceBinding genericType) { |
1136 |
private TypeBinding[] getTypeArgumentsFromSignature(SignatureWrapper wrapper, TypeVariableBinding[] staticVariables, ReferenceBinding enclosingType, ReferenceBinding genericType) { |
1099 |
java.util.ArrayList args = new java.util.ArrayList(2); |
1137 |
java.util.ArrayList args = new java.util.ArrayList(2); |
1100 |
int rank = 0; |
1138 |
int rank = 0; |
Lines 1106-1140
Link Here
|
1106 |
args.toArray(typeArguments); |
1144 |
args.toArray(typeArguments); |
1107 |
return typeArguments; |
1145 |
return typeArguments; |
1108 |
} |
1146 |
} |
|
|
1147 |
|
1109 |
/* Answer the type corresponding to the compound name. |
1148 |
/* Answer the type corresponding to the compound name. |
1110 |
* Does not ask the oracle for the type if its not found in the cache... instead an |
1149 |
* Does not ask the oracle for the type if its not found in the cache... instead an |
1111 |
* unresolved type is returned which must be resolved before used. |
1150 |
* unresolved type is returned which must be resolved before used. |
1112 |
* |
1151 |
* |
1113 |
* NOTE: Does NOT answer base types nor array types! |
1152 |
* NOTE: Does NOT answer base types nor array types! |
1114 |
*/ |
1153 |
*/ |
1115 |
|
|
|
1116 |
ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean isParameterized) { |
1154 |
ReferenceBinding getTypeFromCompoundName(char[][] compoundName, boolean isParameterized) { |
1117 |
ReferenceBinding binding = getCachedType(compoundName); |
1155 |
ReferenceBinding binding = getCachedType(compoundName); |
1118 |
if (binding == null) { |
1156 |
if (binding == null) { |
1119 |
PackageBinding packageBinding = computePackageFrom(compoundName); |
1157 |
PackageBinding packageBinding = computePackageFrom(compoundName, false /* valid pkg */); |
1120 |
binding = new UnresolvedReferenceBinding(compoundName, packageBinding); |
1158 |
binding = new UnresolvedReferenceBinding(compoundName, packageBinding); |
1121 |
packageBinding.addType(binding); |
1159 |
packageBinding.addType(binding); |
1122 |
} else if (binding == TheNotFoundType) { |
1160 |
} else if (binding == TheNotFoundType) { |
|
|
1161 |
// report the missing class file first |
1162 |
problemReporter.isClassPathCorrect( |
1163 |
compoundName, |
1164 |
this.unitBeingCompleted, |
1165 |
this.missingClassFileLocation); |
1123 |
// create a proxy for the missing BinaryType |
1166 |
// create a proxy for the missing BinaryType |
1124 |
binding = cacheMissingBinaryType(compoundName, this.unitBeingCompleted); |
1167 |
binding = createMissingType(null, compoundName); |
1125 |
} else if (!isParameterized) { |
1168 |
} else if (!isParameterized) { |
1126 |
// check raw type, only for resolved types |
1169 |
// check raw type, only for resolved types |
1127 |
binding = (ReferenceBinding) convertUnresolvedBinaryToRawType(binding); |
1170 |
binding = (ReferenceBinding) convertUnresolvedBinaryToRawType(binding); |
1128 |
} |
1171 |
} |
1129 |
return binding; |
1172 |
return binding; |
1130 |
} |
1173 |
} |
|
|
1174 |
|
1131 |
/* Answer the type corresponding to the name from the binary file. |
1175 |
/* Answer the type corresponding to the name from the binary file. |
1132 |
* Does not ask the oracle for the type if its not found in the cache... instead an |
1176 |
* Does not ask the oracle for the type if its not found in the cache... instead an |
1133 |
* unresolved type is returned which must be resolved before used. |
1177 |
* unresolved type is returned which must be resolved before used. |
1134 |
* |
1178 |
* |
1135 |
* NOTE: Does NOT answer base types nor array types! |
1179 |
* NOTE: Does NOT answer base types nor array types! |
1136 |
*/ |
1180 |
*/ |
1137 |
|
|
|
1138 |
ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end, boolean isParameterized) { |
1181 |
ReferenceBinding getTypeFromConstantPoolName(char[] signature, int start, int end, boolean isParameterized) { |
1139 |
if (end == -1) |
1182 |
if (end == -1) |
1140 |
end = signature.length; |
1183 |
end = signature.length; |
Lines 1142-1154
Link Here
|
1142 |
char[][] compoundName = CharOperation.splitOn('/', signature, start, end); |
1185 |
char[][] compoundName = CharOperation.splitOn('/', signature, start, end); |
1143 |
return getTypeFromCompoundName(compoundName, isParameterized); |
1186 |
return getTypeFromCompoundName(compoundName, isParameterized); |
1144 |
} |
1187 |
} |
|
|
1188 |
|
1145 |
/* Answer the type corresponding to the signature from the binary file. |
1189 |
/* Answer the type corresponding to the signature from the binary file. |
1146 |
* Does not ask the oracle for the type if its not found in the cache... instead an |
1190 |
* Does not ask the oracle for the type if its not found in the cache... instead an |
1147 |
* unresolved type is returned which must be resolved before used. |
1191 |
* unresolved type is returned which must be resolved before used. |
1148 |
* |
1192 |
* |
1149 |
* NOTE: Does answer base types & array types. |
1193 |
* NOTE: Does answer base types & array types. |
1150 |
*/ |
1194 |
*/ |
1151 |
|
|
|
1152 |
TypeBinding getTypeFromSignature(char[] signature, int start, int end, boolean isParameterized, TypeBinding enclosingType) { |
1195 |
TypeBinding getTypeFromSignature(char[] signature, int start, int end, boolean isParameterized, TypeBinding enclosingType) { |
1153 |
int dimension = 0; |
1196 |
int dimension = 0; |
1154 |
while (signature[start] == '[') { |
1197 |
while (signature[start] == '[') { |
Lines 1201-1206
Link Here
|
1201 |
return binding; |
1244 |
return binding; |
1202 |
return createArrayType(binding, dimension); |
1245 |
return createArrayType(binding, dimension); |
1203 |
} |
1246 |
} |
|
|
1247 |
|
1204 |
TypeBinding getTypeFromTypeSignature(SignatureWrapper wrapper, TypeVariableBinding[] staticVariables, ReferenceBinding enclosingType) { |
1248 |
TypeBinding getTypeFromTypeSignature(SignatureWrapper wrapper, TypeVariableBinding[] staticVariables, ReferenceBinding enclosingType) { |
1205 |
// TypeVariableSignature = 'T' Identifier ';' |
1249 |
// TypeVariableSignature = 'T' Identifier ';' |
1206 |
// ArrayTypeSignature = '[' TypeSignature |
1250 |
// ArrayTypeSignature = '[' TypeSignature |
Lines 1212-1218
Link Here
|
1212 |
wrapper.start++; |
1256 |
wrapper.start++; |
1213 |
dimension++; |
1257 |
dimension++; |
1214 |
} |
1258 |
} |
1215 |
|
|
|
1216 |
if (wrapper.signature[wrapper.start] == 'T') { |
1259 |
if (wrapper.signature[wrapper.start] == 'T') { |
1217 |
int varStart = wrapper.start + 1; |
1260 |
int varStart = wrapper.start + 1; |
1218 |
int varEnd = wrapper.computeEnd(); |
1261 |
int varEnd = wrapper.computeEnd(); |
Lines 1267-1278
Link Here
|
1267 |
wrapper.start++; // skip ';' |
1310 |
wrapper.start++; // skip ';' |
1268 |
return dimension == 0 ? (TypeBinding) parameterizedType : createArrayType(parameterizedType, dimension); |
1311 |
return dimension == 0 ? (TypeBinding) parameterizedType : createArrayType(parameterizedType, dimension); |
1269 |
} |
1312 |
} |
|
|
1313 |
|
1270 |
TypeBinding getTypeFromVariantTypeSignature( |
1314 |
TypeBinding getTypeFromVariantTypeSignature( |
1271 |
SignatureWrapper wrapper, |
1315 |
SignatureWrapper wrapper, |
1272 |
TypeVariableBinding[] staticVariables, |
1316 |
TypeVariableBinding[] staticVariables, |
1273 |
ReferenceBinding enclosingType, |
1317 |
ReferenceBinding enclosingType, |
1274 |
ReferenceBinding genericType, |
1318 |
ReferenceBinding genericType, |
1275 |
int rank) { |
1319 |
int rank) { |
1276 |
// VariantTypeSignature = '-' TypeSignature |
1320 |
// VariantTypeSignature = '-' TypeSignature |
1277 |
// or '+' TypeSignature |
1321 |
// or '+' TypeSignature |
1278 |
// or TypeSignature |
1322 |
// or TypeSignature |
Lines 1304-1311
Link Here
|
1304 |
return nameEnvironment.isPackage(null, name); |
1348 |
return nameEnvironment.isPackage(null, name); |
1305 |
return nameEnvironment.isPackage(compoundName, name); |
1349 |
return nameEnvironment.isPackage(compoundName, name); |
1306 |
} |
1350 |
} |
1307 |
// The method verifier is lazily initialized to guarantee the receiver, the compiler & the oracle are ready. |
|
|
1308 |
|
1351 |
|
|
|
1352 |
// The method verifier is lazily initialized to guarantee the receiver, the compiler & the oracle are ready. |
1309 |
public MethodVerifier methodVerifier() { |
1353 |
public MethodVerifier methodVerifier() { |
1310 |
if (verifier == null) |
1354 |
if (verifier == null) |
1311 |
verifier = this.globalOptions.sourceLevel < ClassFileConstants.JDK1_5 |
1355 |
verifier = this.globalOptions.sourceLevel < ClassFileConstants.JDK1_5 |
Lines 1313-1318
Link Here
|
1313 |
: new MethodVerifier15(this); // covariance only if sourceLevel is >= 1.5 |
1357 |
: new MethodVerifier15(this); // covariance only if sourceLevel is >= 1.5 |
1314 |
return verifier; |
1358 |
return verifier; |
1315 |
} |
1359 |
} |
|
|
1360 |
|
1316 |
public void reset() { |
1361 |
public void reset() { |
1317 |
this.defaultPackage = new PackageBinding(this); // assume the default package always exists |
1362 |
this.defaultPackage = new PackageBinding(this); // assume the default package always exists |
1318 |
this.defaultImports = null; |
1363 |
this.defaultImports = null; |
Lines 1327-1332
Link Here
|
1327 |
arrayBindings[j] = null; |
1372 |
arrayBindings[j] = null; |
1328 |
} |
1373 |
} |
1329 |
// NOTE: remember to fix #updateCaches(...) when adding unique binding caches |
1374 |
// NOTE: remember to fix #updateCaches(...) when adding unique binding caches |
|
|
1375 |
this.uniqueMissingTypeBindings = new HashtableOfObject(3); |
1330 |
this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3); |
1376 |
this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3); |
1331 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
1377 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
1332 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
1378 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
Lines 1342-1347
Link Here
|
1342 |
// name environment has a longer life cycle, and must be reset in |
1388 |
// name environment has a longer life cycle, and must be reset in |
1343 |
// the code which created it. |
1389 |
// the code which created it. |
1344 |
} |
1390 |
} |
|
|
1391 |
|
1345 |
/** |
1392 |
/** |
1346 |
* Associate a given type with some access restriction |
1393 |
* Associate a given type with some access restriction |
1347 |
* (did not store the restriction directly into binding, since sparse information) |
1394 |
* (did not store the restriction directly into binding, since sparse information) |