Lines 62-68
Link Here
|
62 |
private SimpleLookupTable uniqueRawTypeBindings; |
62 |
private SimpleLookupTable uniqueRawTypeBindings; |
63 |
private SimpleLookupTable uniqueWildcardBindings; |
63 |
private SimpleLookupTable uniqueWildcardBindings; |
64 |
private SimpleLookupTable uniqueParameterizedGenericMethodBindings; |
64 |
private SimpleLookupTable uniqueParameterizedGenericMethodBindings; |
65 |
private SimpleLookupTable uniqueAnnotationBindings; |
|
|
66 |
|
65 |
|
67 |
public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units |
66 |
public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units |
68 |
public Object missingClassFileLocation = null; // only set when resolving certain references, to help locating problems |
67 |
public Object missingClassFileLocation = null; // only set when resolving certain references, to help locating problems |
Lines 82-88
Link Here
|
82 |
this.uniqueArrayBindings[0] = new ArrayBinding[50]; // start off the most common 1 dimension array @ 50 |
81 |
this.uniqueArrayBindings[0] = new ArrayBinding[50]; // start off the most common 1 dimension array @ 50 |
83 |
this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3); |
82 |
this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3); |
84 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
83 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
85 |
this.uniqueAnnotationBindings = new SimpleLookupTable(3); |
|
|
86 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
84 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
87 |
this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3); |
85 |
this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3); |
88 |
this.accessRestrictions = new HashMap(3); |
86 |
this.accessRestrictions = new HashMap(3); |
Lines 539-601
Link Here
|
539 |
* Used to guarantee annotation identity. |
537 |
* Used to guarantee annotation identity. |
540 |
*/ |
538 |
*/ |
541 |
public AnnotationBinding createAnnotation(ReferenceBinding annotationType, ElementValuePair[] pairs) { |
539 |
public AnnotationBinding createAnnotation(ReferenceBinding annotationType, ElementValuePair[] pairs) { |
542 |
// cached info is array of already created annotation binding for this type |
|
|
543 |
AnnotationBinding[] cachedInfo = (AnnotationBinding[])this.uniqueAnnotationBindings.get(annotationType); |
544 |
boolean needToGrow = false; |
545 |
int index = 0; |
546 |
if (pairs.length != 0) { |
540 |
if (pairs.length != 0) { |
547 |
AnnotationBinding.setMethodBindings(annotationType, pairs); |
541 |
AnnotationBinding.setMethodBindings(annotationType, pairs); |
548 |
} |
542 |
} |
549 |
if (cachedInfo != null){ |
543 |
return new AnnotationBinding(annotationType, pairs); |
550 |
nextCachedType : |
|
|
551 |
// iterate existing parameterized for reusing one with same type arguments if any |
552 |
for (int max = cachedInfo.length; index < max; index++){ |
553 |
AnnotationBinding cachedType = cachedInfo[index]; |
554 |
if (cachedType == null) break nextCachedType; |
555 |
ElementValuePair[] elementValuePairs = cachedType.pairs; |
556 |
int length2 = pairs.length; |
557 |
if (length2 != elementValuePairs.length) continue nextCachedType; |
558 |
loop: for (int i = 0; i < length2; i++) { |
559 |
ElementValuePair pair = elementValuePairs[i]; |
560 |
// loop on the given pair to make sure one will match |
561 |
for (int j = 0; j < length2; j++) { |
562 |
ElementValuePair pair2 = pairs[j]; |
563 |
if (pair.binding == pair2.binding) { |
564 |
if (pair.value == null) { |
565 |
if (pair2.value == null) { |
566 |
continue loop; |
567 |
} |
568 |
continue nextCachedType; |
569 |
} else { |
570 |
if (pair2.value == null |
571 |
|| !pair2.value.equals(pair.value)) { |
572 |
continue nextCachedType; |
573 |
} |
574 |
} |
575 |
continue loop; |
576 |
} |
577 |
} |
578 |
// no match found for pair so we create a new annotation binding |
579 |
continue nextCachedType; |
580 |
} |
581 |
// cached type match, reuse current |
582 |
return cachedType; |
583 |
} |
584 |
needToGrow = true; |
585 |
} else { |
586 |
cachedInfo = new AnnotationBinding[1]; |
587 |
this.uniqueAnnotationBindings.put(annotationType, cachedInfo); |
588 |
} |
589 |
// grow cache ? |
590 |
int length = cachedInfo.length; |
591 |
if (needToGrow && index == length){ |
592 |
System.arraycopy(cachedInfo, 0, cachedInfo = new AnnotationBinding[length*2], 0, length); |
593 |
this.uniqueAnnotationBindings.put(annotationType, cachedInfo); |
594 |
} |
595 |
// add new binding |
596 |
AnnotationBinding annotationBinding = new AnnotationBinding(annotationType, pairs); |
597 |
cachedInfo[index] = annotationBinding; |
598 |
return annotationBinding; |
599 |
} |
544 |
} |
600 |
|
545 |
|
601 |
/* |
546 |
/* |
Lines 1248-1254
Link Here
|
1248 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
1193 |
this.uniqueRawTypeBindings = new SimpleLookupTable(3); |
1249 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
1194 |
this.uniqueWildcardBindings = new SimpleLookupTable(3); |
1250 |
this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3); |
1195 |
this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3); |
1251 |
this.uniqueAnnotationBindings = new SimpleLookupTable(3); |
|
|
1252 |
|
1196 |
|
1253 |
for (int i = this.units.length; --i >= 0;) |
1197 |
for (int i = this.units.length; --i >= 0;) |
1254 |
this.units[i] = null; |
1198 |
this.units[i] = null; |