Package org.eclipse.jdt.internal.compiler.lookup

Examples of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding


      int localVariableNameIndex =
        this.constantPool.literalIndex(AttributeNamesConstants.LocalVariableTableName);
      final boolean methodDeclarationIsStatic = this.codeStream.methodDeclaration.isStatic();
      int maxOfEntries = 8 + 10 * (methodDeclarationIsStatic ? 0 : 1);
      for (int i = 0; i < this.codeStream.allLocalsCounter; i++) {
        LocalVariableBinding localVariableBinding = this.codeStream.locals[i];
        maxOfEntries += 10 * localVariableBinding.initializationCount;
      }
      // reserve enough space
      if (localContentsOffset + maxOfEntries >= this.contents.length) {
        resizeContents(maxOfEntries);
      }
      this.contents[localContentsOffset++] = (byte) (localVariableNameIndex >> 8);
      this.contents[localContentsOffset++] = (byte) localVariableNameIndex;
      int localVariableTableOffset = localContentsOffset;
      // leave space for attribute_length and local_variable_table_length
      localContentsOffset += 6;
      int nameIndex;
      int descriptorIndex;
      SourceTypeBinding declaringClassBinding = null;
      if (!methodDeclarationIsStatic) {
        numberOfEntries++;
        this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
        this.contents[localContentsOffset++] = 0;
        this.contents[localContentsOffset++] = (byte) (code_length >> 8);
        this.contents[localContentsOffset++] = (byte) code_length;
        nameIndex = this.constantPool.literalIndex(ConstantPool.This);
        this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
        this.contents[localContentsOffset++] = (byte) nameIndex;
        declaringClassBinding = (SourceTypeBinding) this.codeStream.methodDeclaration.binding.declaringClass;
        descriptorIndex =
          this.constantPool.literalIndex(
            declaringClassBinding.signature());
        this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
        this.contents[localContentsOffset++] = (byte) descriptorIndex;
        this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
        this.contents[localContentsOffset++] = 0;
      }
      // used to remember the local variable with a generic type
      int genericLocalVariablesCounter = 0;
      LocalVariableBinding[] genericLocalVariables = null;
      int numberOfGenericEntries = 0;

      for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
        LocalVariableBinding localVariable = this.codeStream.locals[i];
        if (localVariable.declaration == null) continue;
        final TypeBinding localVariableTypeBinding = localVariable.type;
        boolean isParameterizedType = localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable();
        if (localVariable.initializationCount != 0 && isParameterizedType) {
          if (genericLocalVariables == null) {
            // we cannot have more than max locals
            genericLocalVariables = new LocalVariableBinding[max];
          }
          genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
        }
        for (int j = 0; j < localVariable.initializationCount; j++) {
          int startPC = localVariable.initializationPCs[j << 1];
          int endPC = localVariable.initializationPCs[(j << 1) + 1];
          if (startPC != endPC) { // only entries for non zero length
            if (endPC == -1) {
              localVariable.declaringScope.problemReporter().abortDueToInternalError(
                  Messages.bind(Messages.abort_invalidAttribute, new String(localVariable.name)),
                  (ASTNode) localVariable.declaringScope.methodScope().referenceContext);
            }
            if (isParameterizedType) {
              numberOfGenericEntries++;
            }
            // now we can safely add the local entry
            numberOfEntries++;
            this.contents[localContentsOffset++] = (byte) (startPC >> 8);
            this.contents[localContentsOffset++] = (byte) startPC;
            int length = endPC - startPC;
            this.contents[localContentsOffset++] = (byte) (length >> 8);
            this.contents[localContentsOffset++] = (byte) length;
            nameIndex = this.constantPool.literalIndex(localVariable.name);
            this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
            this.contents[localContentsOffset++] = (byte) nameIndex;
            descriptorIndex = this.constantPool.literalIndex(localVariableTypeBinding.signature());
            this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
            this.contents[localContentsOffset++] = (byte) descriptorIndex;
            int resolvedPosition = localVariable.resolvedPosition;
            this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
            this.contents[localContentsOffset++] = (byte) resolvedPosition;
          }
        }
      }
      int value = numberOfEntries * 10 + 2;
      this.contents[localVariableTableOffset++] = (byte) (value >> 24);
      this.contents[localVariableTableOffset++] = (byte) (value >> 16);
      this.contents[localVariableTableOffset++] = (byte) (value >> 8);
      this.contents[localVariableTableOffset++] = (byte) value;
      this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
      this.contents[localVariableTableOffset] = (byte) numberOfEntries;
      attributeNumber++;

      final boolean currentInstanceIsGeneric =
        !methodDeclarationIsStatic
        && declaringClassBinding != null
        && declaringClassBinding.typeVariables != Binding.NO_TYPE_VARIABLES;
      if (genericLocalVariablesCounter != 0 || currentInstanceIsGeneric) {
        // add the local variable type table attribute
        numberOfGenericEntries += (currentInstanceIsGeneric ? 1 : 0);
        maxOfEntries = 8 + numberOfGenericEntries * 10;
        // reserve enough space
        if (localContentsOffset + maxOfEntries >= this.contents.length) {
          resizeContents(maxOfEntries);
        }
        int localVariableTypeNameIndex =
          this.constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
        this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
        this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
        value = numberOfGenericEntries * 10 + 2;
        this.contents[localContentsOffset++] = (byte) (value >> 24);
        this.contents[localContentsOffset++] = (byte) (value >> 16);
        this.contents[localContentsOffset++] = (byte) (value >> 8);
        this.contents[localContentsOffset++] = (byte) value;
        this.contents[localContentsOffset++] = (byte) (numberOfGenericEntries >> 8);
        this.contents[localContentsOffset++] = (byte) numberOfGenericEntries;
        if (currentInstanceIsGeneric) {
          this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
          this.contents[localContentsOffset++] = 0;
          this.contents[localContentsOffset++] = (byte) (code_length >> 8);
          this.contents[localContentsOffset++] = (byte) code_length;
          nameIndex = this.constantPool.literalIndex(ConstantPool.This);
          this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
          this.contents[localContentsOffset++] = (byte) nameIndex;
          descriptorIndex = this.constantPool.literalIndex(declaringClassBinding.genericTypeSignature());
          this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
          this.contents[localContentsOffset++] = (byte) descriptorIndex;
          this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
          this.contents[localContentsOffset++] = 0;
        }

        for (int i = 0; i < genericLocalVariablesCounter; i++) {
          LocalVariableBinding localVariable = genericLocalVariables[i];
          for (int j = 0; j < localVariable.initializationCount; j++) {
            int startPC = localVariable.initializationPCs[j << 1];
            int endPC = localVariable.initializationPCs[(j << 1) + 1];
            if (startPC != endPC) {
              // only entries for non zero length
View Full Code Here


        int genericLocalVariablesCounter = 0;
        LocalVariableBinding[] genericLocalVariables = null;
        int numberOfGenericEntries = 0;

        for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
          LocalVariableBinding localVariable = this.codeStream.locals[i];
          if (localVariable.declaration == null) continue;
          final TypeBinding localVariableTypeBinding = localVariable.type;
          boolean isParameterizedType = localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable();
          if (localVariable.initializationCount != 0 && isParameterizedType) {
            if (genericLocalVariables == null) {
              // we cannot have more than max locals
              genericLocalVariables = new LocalVariableBinding[max];
            }
            genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
          }
          for (int j = 0; j < localVariable.initializationCount; j++) {
            int startPC = localVariable.initializationPCs[j << 1];
            int endPC = localVariable.initializationPCs[(j << 1) + 1];
            if (startPC != endPC) { // only entries for non zero length
              if (endPC == -1) {
                localVariable.declaringScope.problemReporter().abortDueToInternalError(
                  Messages.bind(Messages.abort_invalidAttribute, new String(localVariable.name)),
                  (ASTNode) localVariable.declaringScope.methodScope().referenceContext);
              }
              if (localContentsOffset + 10 >= this.contents.length) {
                resizeContents(10);
              }
              // now we can safely add the local entry
              numberOfEntries++;
              if (isParameterizedType) {
                numberOfGenericEntries++;
              }
              this.contents[localContentsOffset++] = (byte) (startPC >> 8);
              this.contents[localContentsOffset++] = (byte) startPC;
              int length = endPC - startPC;
              this.contents[localContentsOffset++] = (byte) (length >> 8);
              this.contents[localContentsOffset++] = (byte) length;
              nameIndex = this.constantPool.literalIndex(localVariable.name);
              this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
              this.contents[localContentsOffset++] = (byte) nameIndex;
              descriptorIndex = this.constantPool.literalIndex(localVariableTypeBinding.signature());
              this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
              this.contents[localContentsOffset++] = (byte) descriptorIndex;
              int resolvedPosition = localVariable.resolvedPosition;
              this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
              this.contents[localContentsOffset++] = (byte) resolvedPosition;
            }
          }
        }
        int value = numberOfEntries * 10 + 2;
        this.contents[localVariableTableOffset++] = (byte) (value >> 24);
        this.contents[localVariableTableOffset++] = (byte) (value >> 16);
        this.contents[localVariableTableOffset++] = (byte) (value >> 8);
        this.contents[localVariableTableOffset++] = (byte) value;
        this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
        this.contents[localVariableTableOffset] = (byte) numberOfEntries;
        attributeNumber++;

        if (genericLocalVariablesCounter != 0) {
          // add the local variable type table attribute
          // reserve enough space
          int maxOfEntries = 8 + numberOfGenericEntries * 10;

          if (localContentsOffset + maxOfEntries >= this.contents.length) {
            resizeContents(maxOfEntries);
          }
          int localVariableTypeNameIndex =
            this.constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
          this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
          this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
          value = numberOfGenericEntries * 10 + 2;
          this.contents[localContentsOffset++] = (byte) (value >> 24);
          this.contents[localContentsOffset++] = (byte) (value >> 16);
          this.contents[localContentsOffset++] = (byte) (value >> 8);
          this.contents[localContentsOffset++] = (byte) value;
          this.contents[localContentsOffset++] = (byte) (numberOfGenericEntries >> 8);
          this.contents[localContentsOffset++] = (byte) numberOfGenericEntries;
          for (int i = 0; i < genericLocalVariablesCounter; i++) {
            LocalVariableBinding localVariable = genericLocalVariables[i];
            for (int j = 0; j < localVariable.initializationCount; j++) {
              int startPC = localVariable.initializationPCs[j << 1];
              int endPC = localVariable.initializationPCs[(j << 1) + 1];
              if (startPC != endPC) { // only entries for non zero length
                // now we can safely add the local entry
View Full Code Here

          NestedTypeBinding methodDeclaringClass = (NestedTypeBinding) declaringClass;
          argSize = methodDeclaringClass.getEnclosingInstancesSlotSize();
          SyntheticArgumentBinding[] syntheticArguments;
          if ((syntheticArguments = methodDeclaringClass.syntheticEnclosingInstances()) != null) {
            for (int i = 0, max = syntheticArguments.length; i < max; i++) {
              LocalVariableBinding localVariable = syntheticArguments[i];
              final TypeBinding localVariableTypeBinding = localVariable.type;
              if (localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable()) {
                if (genericLocalVariables == null) {
                  // we cannot have more than max locals
                  genericLocalVariables = new LocalVariableBinding[max];
                }
                genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
                numberOfGenericEntries++;
              }
              if (localContentsOffset + 10 >= this.contents.length) {
                resizeContents(10);
              }
              // now we can safely add the local entry
              numberOfEntries++;
              this.contents[localContentsOffset++] = 0;
              this.contents[localContentsOffset++] = 0;
              this.contents[localContentsOffset++] = (byte) (code_length >> 8);
              this.contents[localContentsOffset++] = (byte) code_length;
              nameIndex = this.constantPool.literalIndex(localVariable.name);
              this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
              this.contents[localContentsOffset++] = (byte) nameIndex;
              descriptorIndex = this.constantPool.literalIndex(localVariableTypeBinding.signature());
              this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
              this.contents[localContentsOffset++] = (byte) descriptorIndex;
              int resolvedPosition = localVariable.resolvedPosition;
              this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
              this.contents[localContentsOffset++] = (byte) resolvedPosition;
            }
          }
        } else {
          argSize = 1;
        }
      } else {
        argSize = binding.isStatic() ? 0 : 1;
      }

      int genericArgumentsCounter = 0;
      int[] genericArgumentsNameIndexes = null;
      int[] genericArgumentsResolvedPositions = null;
      TypeBinding[] genericArgumentsTypeBindings = null;

      if (method.binding != null) {
        TypeBinding[] parameters = method.binding.parameters;
        Argument[] arguments = method.arguments;
        if ((parameters != null) && (arguments != null)) {
          for (int i = 0, max = parameters.length; i < max; i++) {
            TypeBinding argumentBinding = parameters[i];
            if (localContentsOffset + 10 >= this.contents.length) {
              resizeContents(10);
            }
            // now we can safely add the local entry
            numberOfEntries++;
            this.contents[localContentsOffset++] = 0;
            this.contents[localContentsOffset++] = 0;
            this.contents[localContentsOffset++] = (byte) (code_length >> 8);
            this.contents[localContentsOffset++] = (byte) code_length;
            nameIndex = this.constantPool.literalIndex(arguments[i].name);
            this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
            this.contents[localContentsOffset++] = (byte) nameIndex;
            int resolvedPosition = argSize;
            if (argumentBinding.isParameterizedType() || argumentBinding.isTypeVariable()) {
              if (genericArgumentsCounter == 0) {
                // we cannot have more than max locals
                genericArgumentsNameIndexes = new int[max];
                genericArgumentsResolvedPositions = new int[max];
                genericArgumentsTypeBindings = new TypeBinding[max];
              }
              genericArgumentsNameIndexes[genericArgumentsCounter] = nameIndex;
              genericArgumentsResolvedPositions[genericArgumentsCounter] = resolvedPosition;
              genericArgumentsTypeBindings[genericArgumentsCounter++] = argumentBinding;
            }
            descriptorIndex = this.constantPool.literalIndex(argumentBinding.signature());
            this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
            this.contents[localContentsOffset++] = (byte) descriptorIndex;
            switch(argumentBinding.id) {
              case TypeIds.T_long :
              case TypeIds.T_double :
                argSize += 2;
                break;
              default :
                argSize++;
                break;
            }
            this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
            this.contents[localContentsOffset++] = (byte) resolvedPosition;
          }
        }
      }
      int value = numberOfEntries * 10 + 2;
      this.contents[localVariableTableOffset++] = (byte) (value >> 24);
      this.contents[localVariableTableOffset++] = (byte) (value >> 16);
      this.contents[localVariableTableOffset++] = (byte) (value >> 8);
      this.contents[localVariableTableOffset++] = (byte) value;
      this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
      this.contents[localVariableTableOffset] = (byte) numberOfEntries;
      attributeNumber++;

      final boolean currentInstanceIsGeneric =
        !methodDeclarationIsStatic
        && declaringClassBinding != null
        && declaringClassBinding.typeVariables != Binding.NO_TYPE_VARIABLES;
      if (genericLocalVariablesCounter != 0 || genericArgumentsCounter != 0 || currentInstanceIsGeneric) {
        // add the local variable type table attribute
        numberOfEntries = numberOfGenericEntries + genericArgumentsCounter + (currentInstanceIsGeneric ? 1 : 0);
        // reserve enough space
        int maxOfEntries = 8 + numberOfEntries * 10;
        if (localContentsOffset + maxOfEntries >= this.contents.length) {
          resizeContents(maxOfEntries);
        }
        int localVariableTypeNameIndex =
          this.constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
        this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
        this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
        value = numberOfEntries * 10 + 2;
        this.contents[localContentsOffset++] = (byte) (value >> 24);
        this.contents[localContentsOffset++] = (byte) (value >> 16);
        this.contents[localContentsOffset++] = (byte) (value >> 8);
        this.contents[localContentsOffset++] = (byte) value;
        this.contents[localContentsOffset++] = (byte) (numberOfEntries >> 8);
        this.contents[localContentsOffset++] = (byte) numberOfEntries;
        if (currentInstanceIsGeneric) {
          numberOfEntries++;
          this.contents[localContentsOffset++] = 0; // the startPC for this is always 0
          this.contents[localContentsOffset++] = 0;
          this.contents[localContentsOffset++] = (byte) (code_length >> 8);
          this.contents[localContentsOffset++] = (byte) code_length;
          nameIndex = this.constantPool.literalIndex(ConstantPool.This);
          this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
          this.contents[localContentsOffset++] = (byte) nameIndex;
          descriptorIndex = this.constantPool.literalIndex(declaringClassBinding.genericTypeSignature());
          this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
          this.contents[localContentsOffset++] = (byte) descriptorIndex;
          this.contents[localContentsOffset++] = 0;// the resolved position for this is always 0
          this.contents[localContentsOffset++] = 0;
        }

        for (int i = 0; i < genericLocalVariablesCounter; i++) {
          LocalVariableBinding localVariable = genericLocalVariables[i];
          this.contents[localContentsOffset++] = 0;
          this.contents[localContentsOffset++] = 0;
          this.contents[localContentsOffset++] = (byte) (code_length >> 8);
          this.contents[localContentsOffset++] = (byte) code_length;
          nameIndex = this.constantPool.literalIndex(localVariable.name);
View Full Code Here

      int genericLocalVariablesCounter = 0;
      LocalVariableBinding[] genericLocalVariables = null;
      int numberOfGenericEntries = 0;

      for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
        LocalVariableBinding localVariable = this.codeStream.locals[i];
        if (localVariable.declaration == null) continue;
        final TypeBinding localVariableTypeBinding = localVariable.type;
        boolean isParameterizedType = localVariableTypeBinding.isParameterizedType() || localVariableTypeBinding.isTypeVariable();
        if (localVariable.initializationCount != 0 && isParameterizedType) {
          if (genericLocalVariables == null) {
            // we cannot have more than max locals
            genericLocalVariables = new LocalVariableBinding[max];
          }
          genericLocalVariables[genericLocalVariablesCounter++] = localVariable;
        }
        for (int j = 0; j < localVariable.initializationCount; j++) {
          int startPC = localVariable.initializationPCs[j << 1];
          int endPC = localVariable.initializationPCs[(j << 1) + 1];
          if (startPC != endPC) { // only entries for non zero length
            if (endPC == -1) {
              localVariable.declaringScope.problemReporter().abortDueToInternalError(
                Messages.bind(Messages.abort_invalidAttribute, new String(localVariable.name)),
                (ASTNode) localVariable.declaringScope.methodScope().referenceContext);
            }
            if (localContentsOffset + 10 > this.contents.length) {
              resizeContents(10);
            }
            // now we can safely add the local entry
            numberOfEntries++;
            if (isParameterizedType) {
              numberOfGenericEntries++;
            }
            this.contents[localContentsOffset++] = (byte) (startPC >> 8);
            this.contents[localContentsOffset++] = (byte) startPC;
            int length = endPC - startPC;
            this.contents[localContentsOffset++] = (byte) (length >> 8);
            this.contents[localContentsOffset++] = (byte) length;
            nameIndex = this.constantPool.literalIndex(localVariable.name);
            this.contents[localContentsOffset++] = (byte) (nameIndex >> 8);
            this.contents[localContentsOffset++] = (byte) nameIndex;
            descriptorIndex = this.constantPool.literalIndex(localVariableTypeBinding.signature());
            this.contents[localContentsOffset++] = (byte) (descriptorIndex >> 8);
            this.contents[localContentsOffset++] = (byte) descriptorIndex;
            int resolvedPosition = localVariable.resolvedPosition;
            this.contents[localContentsOffset++] = (byte) (resolvedPosition >> 8);
            this.contents[localContentsOffset++] = (byte) resolvedPosition;
          }
        }
      }
      int value = numberOfEntries * 10 + 2;
      this.contents[localVariableTableOffset++] = (byte) (value >> 24);
      this.contents[localVariableTableOffset++] = (byte) (value >> 16);
      this.contents[localVariableTableOffset++] = (byte) (value >> 8);
      this.contents[localVariableTableOffset++] = (byte) value;
      this.contents[localVariableTableOffset++] = (byte) (numberOfEntries >> 8);
      this.contents[localVariableTableOffset] = (byte) numberOfEntries;
      attributeNumber++;

      if (genericLocalVariablesCounter != 0) {
        // add the local variable type table attribute
        int maxOfEntries = 8 + numberOfGenericEntries * 10;
        // reserve enough space
        if (localContentsOffset + maxOfEntries >= this.contents.length) {
          resizeContents(maxOfEntries);
        }
        int localVariableTypeNameIndex =
          this.constantPool.literalIndex(AttributeNamesConstants.LocalVariableTypeTableName);
        this.contents[localContentsOffset++] = (byte) (localVariableTypeNameIndex >> 8);
        this.contents[localContentsOffset++] = (byte) localVariableTypeNameIndex;
        value = numberOfGenericEntries * 10 + 2;
        this.contents[localContentsOffset++] = (byte) (value >> 24);
        this.contents[localContentsOffset++] = (byte) (value >> 16);
        this.contents[localContentsOffset++] = (byte) (value >> 8);
        this.contents[localContentsOffset++] = (byte) value;
        this.contents[localContentsOffset++] = (byte) (numberOfGenericEntries >> 8);
        this.contents[localContentsOffset++] = (byte) numberOfGenericEntries;

        for (int i = 0; i < genericLocalVariablesCounter; i++) {
          LocalVariableBinding localVariable = genericLocalVariables[i];
          for (int j = 0; j < localVariable.initializationCount; j++) {
            int startPC = localVariable.initializationPCs[j << 1];
            int endPC = localVariable.initializationPCs[(j << 1) + 1];
            if (startPC != endPC) { // only entries for non zero length
              // now we can safely add the local entry
View Full Code Here

    if (maxLocals != 0) {
      int resolvedPosition = 0;
      // take into account enum constructor synthetic name+ordinal
      final boolean isConstructor = methodBinding.isConstructor();
      if (isConstructor) {
        LocalVariableBinding localVariableBinding = new LocalVariableBinding("this".toCharArray(), methodBinding.declaringClass, 0, false); //$NON-NLS-1$
        localVariableBinding.resolvedPosition = 0;
        this.codeStream.record(localVariableBinding);
        localVariableBinding.recordInitializationStartPC(0);
        localVariableBinding.recordInitializationEndPC(codeLength);
        frame.putLocal(resolvedPosition, new VerificationTypeInfo(
            VerificationTypeInfo.ITEM_UNINITIALIZED_THIS,
            methodBinding.declaringClass));
        resolvedPosition++;
      } else if (!methodBinding.isStatic()) {
        LocalVariableBinding localVariableBinding = new LocalVariableBinding("this".toCharArray(), methodBinding.declaringClass, 0, false); //$NON-NLS-1$
        localVariableBinding.resolvedPosition = 0;
        this.codeStream.record(localVariableBinding);
        localVariableBinding.recordInitializationStartPC(0);
        localVariableBinding.recordInitializationEndPC(codeLength);
        frame.putLocal(resolvedPosition, new VerificationTypeInfo(
            VerificationTypeInfo.ITEM_OBJECT,
            methodBinding.declaringClass));
        resolvedPosition++;
      }

      if (isConstructor) {
        if (methodBinding.declaringClass.isEnum()) {
          LocalVariableBinding localVariableBinding = new LocalVariableBinding(" name".toCharArray(), this.referenceBinding.scope.getJavaLangString(), 0, false); //$NON-NLS-1$
          localVariableBinding.resolvedPosition = resolvedPosition;
          this.codeStream.record(localVariableBinding);
          localVariableBinding.recordInitializationStartPC(0);
          localVariableBinding.recordInitializationEndPC(codeLength);

          frame.putLocal(resolvedPosition, new VerificationTypeInfo(
              TypeIds.T_JavaLangString,
              ConstantPool.JavaLangStringConstantPoolName));
          resolvedPosition++;

          localVariableBinding = new LocalVariableBinding(" ordinal".toCharArray(), TypeBinding.INT, 0, false); //$NON-NLS-1$
          localVariableBinding.resolvedPosition = resolvedPosition;
          this.codeStream.record(localVariableBinding);
          localVariableBinding.recordInitializationStartPC(0);
          localVariableBinding.recordInitializationEndPC(codeLength);
          frame.putLocal(resolvedPosition, new VerificationTypeInfo(
              TypeBinding.INT));
          resolvedPosition++;
        }

        // take into account the synthetic parameters
        if (methodBinding.declaringClass.isNestedType()) {
          ReferenceBinding enclosingInstanceTypes[];
          if ((enclosingInstanceTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes()) != null) {
            for (int i = 0, max = enclosingInstanceTypes.length; i < max; i++) {
              // an enclosingInstanceType can only be a reference
              // binding. It cannot be
              // LongBinding or DoubleBinding
              LocalVariableBinding localVariableBinding = new LocalVariableBinding((" enclosingType" + i).toCharArray(), enclosingInstanceTypes[i], 0, false); //$NON-NLS-1$
              localVariableBinding.resolvedPosition = resolvedPosition;
              this.codeStream.record(localVariableBinding);
              localVariableBinding.recordInitializationStartPC(0);
              localVariableBinding.recordInitializationEndPC(codeLength);

              frame.putLocal(resolvedPosition,
                  new VerificationTypeInfo(enclosingInstanceTypes[i]));
              resolvedPosition++;
            }
          }

          TypeBinding[] arguments;
          if ((arguments = methodBinding.parameters) != null) {
            for (int i = 0, max = arguments.length; i < max; i++) {
              final TypeBinding typeBinding = arguments[i];
              frame.putLocal(resolvedPosition,
                  new VerificationTypeInfo(typeBinding));
              switch (typeBinding.id) {
                case TypeIds.T_double:
                case TypeIds.T_long:
                  resolvedPosition += 2;
                  break;
                default:
                  resolvedPosition++;
              }
            }
          }

          SyntheticArgumentBinding syntheticArguments[];
          if ((syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables()) != null) {
            for (int i = 0, max = syntheticArguments.length; i < max; i++) {
              final TypeBinding typeBinding = syntheticArguments[i].type;
              LocalVariableBinding localVariableBinding = new LocalVariableBinding((" synthetic" + i).toCharArray(), typeBinding, 0, false); //$NON-NLS-1$
              localVariableBinding.resolvedPosition = resolvedPosition;
              this.codeStream.record(localVariableBinding);
              localVariableBinding.recordInitializationStartPC(0);
              localVariableBinding.recordInitializationEndPC(codeLength);

              frame.putLocal(resolvedPosition,
                  new VerificationTypeInfo(typeBinding));
              switch (typeBinding.id) {
                case TypeIds.T_double:
View Full Code Here

* @param scope the scope of the analysis
* @param flowContext the current flow context
* @param flowInfo the upstream flow info; caveat: may get modified
*/
public void checkNPE(BlockScope scope, FlowContext flowContext, FlowInfo flowInfo) {
  LocalVariableBinding local = localVariableBinding();
  if (local != null &&
      (local.type.tagBits & TagBits.IsBaseType) == 0) {
    if ((this.bits & ASTNode.IsNonNull) == 0) {
      flowContext.recordUsingNullReference(scope, local, this,
          FlowContext.MAY_NULL, flowInfo);
View Full Code Here

    if (/* (this.bits & IsNonNull) != 0 || */
      this.constant != null && this.constant != Constant.NotAConstant)
    return FlowInfo.NON_NULL; // constant expression cannot be null

  LocalVariableBinding local = localVariableBinding();
  if (local != null) {
    if (flowInfo.isDefinitelyNull(local))
      return FlowInfo.NULL;
    if (flowInfo.isDefinitelyNonNull(local))
      return FlowInfo.NON_NULL;
View Full Code Here

    for (; i < localsLength; i++) {
      locals[i] = null;
    }
    i = 0;
    locals: for (int max = this.codeStream.allLocalsCounter; i < max; i++) {
      LocalVariableBinding localVariable = this.codeStream.locals[i];
      if (localVariable == null) continue;
      int resolvedPosition = localVariable.resolvedPosition;
      final TypeBinding localVariableTypeBinding = localVariable.type;
      inits: for (int j = 0; j < localVariable.initializationCount; j++) {
        int startPC = localVariable.initializationPCs[j << 1];
View Full Code Here

    System.arraycopy(this.contents, 0, this.contents = new byte[length + toAdd], 0, length);
  }

  private VerificationTypeInfo retrieveLocal(int currentPC, int resolvedPosition) {
    for (int i = 0, max = this.codeStream.allLocalsCounter; i < max; i++) {
      LocalVariableBinding localVariable = this.codeStream.locals[i];
      if (localVariable == null) continue;
      if (resolvedPosition == localVariable.resolvedPosition) {
        inits: for (int j = 0; j < localVariable.initializationCount; j++) {
          int startPC = localVariable.initializationPCs[j << 1];
          int endPC = localVariable.initializationPCs[(j << 1) + 1];
View Full Code Here

        }
        manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
        break;
      case Binding.LOCAL : // reading a local variable
        // check if assigning a final blank field
        LocalVariableBinding localBinding;
        if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
          currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
          // we could improve error msg here telling "cannot use compound assignment on final local variable"
        }
        if (isReachable) {
          localBinding.useFlag = LocalVariableBinding.USED;
        } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
          localBinding.useFlag = LocalVariableBinding.FAKE_USED;
        }
    }
  }
  if (assignment.expression != null) {
    flowInfo = assignment.expression.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits();
  }
  switch (this.bits & ASTNode.RestrictiveFlagMASK) {
    case Binding.FIELD : // assigning to a field
      manageSyntheticAccessIfNecessary(currentScope, flowInfo, false /*write-access*/);

      // check if assigning a final field
      FieldBinding fieldBinding = (FieldBinding) this.binding;
      if (fieldBinding.isFinal()) {
        // inside a context where allowed
        if (!isCompound && fieldBinding.isBlankFinal() && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) {
          if (flowInfo.isPotentiallyAssigned(fieldBinding)) {
            currentScope.problemReporter().duplicateInitializationOfBlankFinalField(fieldBinding, this);
          } else {
            flowContext.recordSettingFinal(fieldBinding, this, flowInfo);
          }
          flowInfo.markAsDefinitelyAssigned(fieldBinding);
        } else {
          currentScope.problemReporter().cannotAssignToFinalField(fieldBinding, this);
        }
      }
      break;
    case Binding.LOCAL : // assigning to a local variable
      LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
      if (!flowInfo.isDefinitelyAssigned(localBinding)){// for local variable debug attributes
        this.bits |= ASTNode.FirstAssignmentToLocal;
      } else {
        this.bits &= ~ASTNode.FirstAssignmentToLocal;
      }
      if (localBinding.isFinal()) {
        if ((this.bits & ASTNode.DepthMASK) == 0) {
          // tolerate assignment to final local in unreachable code (45674)
          if ((isReachable && isCompound) || !localBinding.isBlankFinal()){
            currentScope.problemReporter().cannotAssignToFinalLocal(localBinding, this);
          } else if (flowInfo.isPotentiallyAssigned(localBinding)) {
            currentScope.problemReporter().duplicateInitializationOfFinalLocal(localBinding, this);
          } else {
            flowContext.recordSettingFinal(localBinding, this, flowInfo);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.