public SyntheticArgumentBinding addSyntheticArgumentAndField(ReferenceBinding targetEnclosingType) { if (!isPrototype()) throw new IllegalStateException(); SyntheticArgumentBinding synthLocal = addSyntheticArgument(targetEnclosingType); if (synthLocal == null) return null; if (synthLocal.matchingField == null) synthLocal.matchingField = addSyntheticFieldForInnerclass(targetEnclosingType); return synthLocal; }
public void emulateOuterAccess(LocalVariableBinding outerLocalVariable) { BlockScope outerVariableScope = outerLocalVariable.declaringScope; if (outerVariableScope == null) return; // no need to further emulate as already inserted (val$this$0) MethodScope currentMethodScope = methodScope(); if (outerVariableScope.methodScope() != currentMethodScope) { NestedTypeBinding currentType = (NestedTypeBinding) enclosingSourceType(); //do nothing for member types, pre emulation was performed already if (!currentType.isLocalType()) { return; } // must also add a synthetic field if we're not inside a constructor if (!currentMethodScope.isInsideInitializerOrConstructor()) { currentType.addSyntheticArgumentAndField(outerLocalVariable); } else { currentType.addSyntheticArgument(outerLocalVariable); } } }
public SyntheticArgumentBinding addSyntheticArgument(ReferenceBinding targetEnclosingType) { if (!isPrototype()) throw new IllegalStateException(); SyntheticArgumentBinding synthLocal = null; if (this.enclosingInstances == null) { synthLocal = new SyntheticArgumentBinding(targetEnclosingType); this.enclosingInstances = new SyntheticArgumentBinding[] {synthLocal}; } else { int size = this.enclosingInstances.length; int newArgIndex = size; if (TypeBinding.equalsEquals(enclosingType(), targetEnclosingType)) newArgIndex = 0; SyntheticArgumentBinding[] newInstances = new SyntheticArgumentBinding[size + 1]; System.arraycopy(this.enclosingInstances, 0, newInstances, newArgIndex == 0 ? 1 : 0, size); newInstances[newArgIndex] = synthLocal = new SyntheticArgumentBinding(targetEnclosingType); this.enclosingInstances = newInstances; } //System.out.println("Adding synth arg for enclosing type: " + new String(enclosingType.readableName()) + " to: " + new String(this.readableName())); if (this.scope.referenceCompilationUnit().isPropagatingInnerClassEmulation) updateInnerEmulationDependents(); return synthLocal; }
public SyntheticArgumentBinding addSyntheticArgumentAndField(ReferenceBinding targetEnclosingType) { SyntheticArgumentBinding synthLocal = addSyntheticArgument(targetEnclosingType); if (synthLocal == null) return null; if (synthLocal.matchingField == null) synthLocal.matchingField = addSyntheticFieldForInnerclass(targetEnclosingType); return synthLocal; }
nestedType.addSyntheticArgumentAndField(nestedType.enclosingType()); if (nestedType.isAnonymousType()) { ReferenceBinding superclassBinding = (ReferenceBinding)nestedType.superclass.erasure(); if (superclassBinding.enclosingType() != null && !superclassBinding.isStatic()) { if (!superclassBinding.isLocalType() || ((NestedTypeBinding)superclassBinding).getSyntheticField(superclassBinding.enclosingType(), true) != null){ nestedType.addSyntheticArgument(superclassBinding.enclosingType()); ReferenceBinding enclosing = nestedType.enclosingType(); if (enclosing.isNestedType()) { NestedTypeBinding nestedEnclosing = (NestedTypeBinding)enclosing; SyntheticArgumentBinding syntheticEnclosingInstanceArgument = nestedEnclosing.getSyntheticArgument(nestedEnclosing.enclosingType(), true, false); if (syntheticEnclosingInstanceArgument != null) { nestedType.addSyntheticArgumentAndField(syntheticEnclosingInstanceArgument);
if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(targetEnclosingType, onlyExactMatch)) != null) { if (enclosingType.isNestedType()) { NestedTypeBinding nestedEnclosingType = (NestedTypeBinding) enclosingType; SyntheticArgumentBinding enclosingArgument = nestedEnclosingType.getSyntheticArgument(nestedEnclosingType.enclosingType(), onlyExactMatch); if (enclosingArgument != null) { FieldBinding syntheticField = sourceType.getSyntheticField(enclosingArgument); ReferenceBinding currentType = sourceType.enclosingType(); if (insideConstructor) { path[0] = ((NestedTypeBinding) sourceType).getSyntheticArgument(currentType, onlyExactMatch); } else { if (currentMethodScope.isConstructorCall){ syntheticField = ((NestedTypeBinding) currentType).getSyntheticField(currentEnclosingType, onlyExactMatch); if (syntheticField == null) break;
public SyntheticArgumentBinding addSyntheticArgument(ReferenceBinding targetEnclosingType) { SyntheticArgumentBinding synthLocal = null; if (this.enclosingInstances == null) { synthLocal = new SyntheticArgumentBinding(targetEnclosingType); this.enclosingInstances = new SyntheticArgumentBinding[] {synthLocal}; } else { int size = this.enclosingInstances.length; int newArgIndex = size; for (int i = size; --i >= 0;) { if (this.enclosingInstances[i].type == targetEnclosingType) return this.enclosingInstances[i]; // already exists if (enclosingType() == targetEnclosingType) newArgIndex = 0; } SyntheticArgumentBinding[] newInstances = new SyntheticArgumentBinding[size + 1]; System.arraycopy(this.enclosingInstances, 0, newInstances, newArgIndex == 0 ? 1 : 0, size); newInstances[newArgIndex] = synthLocal = new SyntheticArgumentBinding(targetEnclosingType); this.enclosingInstances = newInstances; } //System.out.println("Adding synth arg for enclosing type: " + new String(enclosingType.readableName()) + " to: " + new String(this.readableName())); if (this.scope.referenceCompilationUnit().isPropagatingInnerClassEmulation) updateInnerEmulationDependents(); return synthLocal; }
public char[] genericTypeSignature() { if (this.genericReferenceTypeSignature == null && this.constantPoolName == null) { if (isAnonymousType()) setConstantPoolName(superclass().sourceName()); else setConstantPoolName(sourceName()); } return super.genericTypeSignature(); }
/** * Access emulation for a local member type * force to emulation of access to direct enclosing instance. * By using the initializer scope, we actually only request an argument emulation, the * field is not added until actually used. However we will force allocations to be qualified * with an enclosing instance. * * Local member cannot be static. */ public void manageEnclosingInstanceAccessIfNecessary(ClassScope currentScope, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { NestedTypeBinding nestedType = (NestedTypeBinding) this.binding; nestedType.addSyntheticArgumentAndField(this.binding.enclosingType()); } }
/** * @see org.eclipse.jdt.internal.compiler.lookup.Binding#initializeDeprecatedAnnotationTagBits() */ public void initializeDeprecatedAnnotationTagBits() { if ((this.tagBits & TagBits.DeprecatedAnnotationResolved) == 0) { super.initializeDeprecatedAnnotationTagBits(); if ((this.tagBits & TagBits.AnnotationDeprecated) == 0) { // check enclosing type ReferenceBinding enclosing; if (((enclosing = enclosingType()).tagBits & TagBits.DeprecatedAnnotationResolved) == 0) { enclosing.initializeDeprecatedAnnotationTagBits(); } if (enclosing.isViewedAsDeprecated()) { this.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; } } } } public String toString() {
public VariableBinding[] getEmulationPath(LocalVariableBinding outerLocalVariable) { MethodScope currentMethodScope = methodScope(); SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType(); // identity check BlockScope variableScope = outerLocalVariable.declaringScope; if (variableScope == null /*val$this$0*/ || currentMethodScope == variableScope.methodScope()) { return new VariableBinding[] { outerLocalVariable }; // implicit this is good enough } // use synthetic constructor arguments if possible if (currentMethodScope.isInsideInitializerOrConstructor() && (sourceType.isNestedType())) { SyntheticArgumentBinding syntheticArg; if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(outerLocalVariable)) != null) { return new VariableBinding[] { syntheticArg }; } } // use a synthetic field then if (!currentMethodScope.isStatic) { FieldBinding syntheticField; if ((syntheticField = sourceType.getSyntheticField(outerLocalVariable)) != null) { return new VariableBinding[] { syntheticField }; } } return null; }
nestedType.addSyntheticArgumentAndField(nestedType.enclosingType()); if (nestedType.isAnonymousType()) { ReferenceBinding superclassBinding = (ReferenceBinding)nestedType.superclass.erasure(); if (superclassBinding.enclosingType() != null && !superclassBinding.isStatic()) { if (!superclassBinding.isLocalType() || ((NestedTypeBinding)superclassBinding).getSyntheticField(superclassBinding.enclosingType(), true) != null){ nestedType.addSyntheticArgument(superclassBinding.enclosingType()); ReferenceBinding enclosing = nestedType.enclosingType(); if (enclosing.isNestedType()) { NestedTypeBinding nestedEnclosing = (NestedTypeBinding)enclosing; SyntheticArgumentBinding syntheticEnclosingInstanceArgument = nestedEnclosing.getSyntheticArgument(nestedEnclosing.enclosingType(), true); if (syntheticEnclosingInstanceArgument != null) { nestedType.addSyntheticArgumentAndField(syntheticEnclosingInstanceArgument);
if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(targetEnclosingType, onlyExactMatch)) != null) { if (enclosingType.isNestedType()) { NestedTypeBinding nestedEnclosingType = (NestedTypeBinding) enclosingType; SyntheticArgumentBinding enclosingArgument = nestedEnclosingType.getSyntheticArgument(nestedEnclosingType.enclosingType(), onlyExactMatch); if (enclosingArgument != null) { FieldBinding syntheticField = sourceType.getSyntheticField(enclosingArgument); ReferenceBinding currentType = sourceType.enclosingType(); if (insideConstructor) { path[0] = ((NestedTypeBinding) sourceType).getSyntheticArgument(currentType, onlyExactMatch); } else { if (currentMethodScope.isConstructorCall){ syntheticField = ((NestedTypeBinding) currentType).getSyntheticField(currentEnclosingType, onlyExactMatch); if (syntheticField == null) break;
public SyntheticArgumentBinding addSyntheticArgumentAndField(LocalVariableBinding actualOuterLocalVariable) { SyntheticArgumentBinding synthLocal = addSyntheticArgument(actualOuterLocalVariable); if (synthLocal == null) return null; if (synthLocal.matchingField == null) synthLocal.matchingField = addSyntheticFieldForInnerclass(actualOuterLocalVariable); return synthLocal; }
public SyntheticArgumentBinding addSyntheticArgument(ReferenceBinding targetEnclosingType) { SyntheticArgumentBinding synthLocal = null; if (this.enclosingInstances == null) { synthLocal = new SyntheticArgumentBinding(targetEnclosingType); this.enclosingInstances = new SyntheticArgumentBinding[] {synthLocal}; } else { int size = this.enclosingInstances.length; int newArgIndex = size; for (int i = size; --i >= 0;) { if (this.enclosingInstances[i].type == targetEnclosingType) return this.enclosingInstances[i]; // already exists if (enclosingType() == targetEnclosingType) newArgIndex = 0; } SyntheticArgumentBinding[] newInstances = new SyntheticArgumentBinding[size + 1]; System.arraycopy(this.enclosingInstances, 0, newInstances, newArgIndex == 0 ? 1 : 0, size); newInstances[newArgIndex] = synthLocal = new SyntheticArgumentBinding(targetEnclosingType); this.enclosingInstances = newInstances; } //System.out.println("Adding synth arg for enclosing type: " + new String(enclosingType.readableName()) + " to: " + new String(this.readableName())); if (this.scope.referenceCompilationUnit().isPropagatingInnerClassEmulation) updateInnerEmulationDependents(); return synthLocal; }
public char[] genericTypeSignature() { if (this.genericReferenceTypeSignature == null && this.constantPoolName == null) { if (isAnonymousType()) setConstantPoolName(superclass().sourceName()); else setConstantPoolName(sourceName()); } return super.genericTypeSignature(); }
/** * Access emulation for a local member type * force to emulation of access to direct enclosing instance. * By using the initializer scope, we actually only request an argument emulation, the * field is not added until actually used. However we will force allocations to be qualified * with an enclosing instance. * * Local member cannot be static. */ public void manageEnclosingInstanceAccessIfNecessary(ClassScope currentScope, FlowInfo flowInfo) { if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) { NestedTypeBinding nestedType = (NestedTypeBinding) this.binding; nestedType.addSyntheticArgumentAndField(this.binding.enclosingType()); } }
/** * @see org.eclipse.jdt.internal.compiler.lookup.Binding#initializeDeprecatedAnnotationTagBits() */ public void initializeDeprecatedAnnotationTagBits() { if ((this.tagBits & TagBits.DeprecatedAnnotationResolved) == 0) { super.initializeDeprecatedAnnotationTagBits(); if ((this.tagBits & TagBits.AnnotationDeprecated) == 0) { // check enclosing type ReferenceBinding enclosing; if (((enclosing = enclosingType()).tagBits & TagBits.DeprecatedAnnotationResolved) == 0) { enclosing.initializeDeprecatedAnnotationTagBits(); } if (enclosing.isViewedAsDeprecated()) { this.modifiers |= ExtraCompilerModifiers.AccDeprecatedImplicitly; } } } } public String toString() {
public VariableBinding[] getEmulationPath(LocalVariableBinding outerLocalVariable) { MethodScope currentMethodScope = methodScope(); SourceTypeBinding sourceType = currentMethodScope.enclosingSourceType(); // identity check BlockScope variableScope = outerLocalVariable.declaringScope; if (variableScope == null /*val$this$0*/ || currentMethodScope == variableScope.methodScope()) { return new VariableBinding[] { outerLocalVariable }; // implicit this is good enough } // use synthetic constructor arguments if possible if (currentMethodScope.isInsideInitializerOrConstructor() && (sourceType.isNestedType())) { SyntheticArgumentBinding syntheticArg; if ((syntheticArg = ((NestedTypeBinding) sourceType).getSyntheticArgument(outerLocalVariable)) != null) { return new VariableBinding[] { syntheticArg }; } } // use a synthetic field then if (!currentMethodScope.isStatic) { FieldBinding syntheticField; if ((syntheticField = sourceType.getSyntheticField(outerLocalVariable)) != null) { return new VariableBinding[] { syntheticField }; } } return null; }
nestedType.addSyntheticArgumentAndField(nestedType.enclosingType()); if (nestedType.isAnonymousType()) { ReferenceBinding superclassBinding = (ReferenceBinding)nestedType.superclass.erasure(); if (superclassBinding.enclosingType() != null && !superclassBinding.isStatic()) { if (!superclassBinding.isLocalType() || ((NestedTypeBinding)superclassBinding).getSyntheticField(superclassBinding.enclosingType(), true) != null){ nestedType.addSyntheticArgument(superclassBinding.enclosingType()); ReferenceBinding enclosing = nestedType.enclosingType(); if (enclosing.isNestedType()) { NestedTypeBinding nestedEnclosing = (NestedTypeBinding)enclosing; SyntheticArgumentBinding syntheticEnclosingInstanceArgument = nestedEnclosing.getSyntheticArgument(nestedEnclosing.enclosingType(), true); if (syntheticEnclosingInstanceArgument != null) { nestedType.addSyntheticArgumentAndField(syntheticEnclosingInstanceArgument);