Package org.eclipse.jdt.internal.compiler.impl

Examples of org.eclipse.jdt.internal.compiler.impl.Constant


              if (value instanceof ArrayInitializer) {
                ArrayInitializer initializer = (ArrayInitializer) value;
                Expression[] inits = initializer.expressions;
                if (inits != null) {
                  for (int iToken = 0, tokenCount = inits.length; iToken < tokenCount; iToken++) {
                    Constant cst = inits[iToken].constant;
                    if (cst != Constant.NotAConstant && cst.typeID() == TypeIds.T_JavaLangString) {
                      IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
                      if (tokenIrritants != null
                          && !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
                          && options.isAnyEnabled(tokenIrritants) // if irritant is effectively enabled
                          && (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
                        if (unusedWarningTokenIsWarning) {
                          int start = value.sourceStart, end = value.sourceEnd;
                          nextSuppress: for (int jSuppress = iSuppress - 1; jSuppress >= 0; jSuppress--) {
                            long position = this.suppressWarningScopePositions[jSuppress];
                            int startSuppress = (int) (position >>> 32);
                            int endSuppress = (int) position;
                            if (start < startSuppress) continue nextSuppress;
                            if (end > endSuppress) continue nextSuppress;
                            if (this.suppressWarningIrritants[jSuppress].areAllSet()) break pairLoop; // suppress all?
                          }
                        }
                        this.scope.problemReporter().unusedWarningToken(inits[iToken]);
                      }
                    }
                  }
                }
              } else {
                Constant cst = value.constant;
                if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
                  IrritantSet tokenIrritants = CompilerOptions.warningTokenToIrritants(cst.stringValue());
                  if (tokenIrritants != null
                      && !tokenIrritants.areAllSet() // no complaint against @SuppressWarnings("all")
                      && options.isAnyEnabled(tokenIrritants) // if irritant is effectively enabled
                      && (foundIrritants[iSuppress] == null || !foundIrritants[iSuppress].isAnySet(tokenIrritants))) { // if irritant had no matching problem
                    if (unusedWarningTokenIsWarning) {
View Full Code Here


  uniqueKey[index++] = ')';
  System.arraycopy(returnTypeKey, 0, uniqueKey, index, returnTypeLength);
  return uniqueKey;
}
public Constant constant() {
  Constant fieldConstant = this.constant;
  if (fieldConstant == null) {
    if (isFinal()) {
      //The field has not been yet type checked.
      //It also means that the field is not coming from a class that
      //has already been compiled. It can only be from a class within
View Full Code Here

  /* (non-Javadoc)
   * @see IVariableBinding#getConstantValue()
   * @since 3.0
   */
  public Object getConstantValue() {
    Constant c = this.binding.constant();
    if (c == null || c == Constant.NotAConstant) return null;
    switch (c.typeID()) {
      case TypeIds.T_boolean:
        return Boolean.valueOf(c.booleanValue());
      case TypeIds.T_byte:
        return new Byte(c.byteValue());
      case TypeIds.T_char:
        return new Character(c.charValue());
      case TypeIds.T_double:
        return new Double(c.doubleValue());
      case TypeIds.T_float:
        return new Float(c.floatValue());
      case TypeIds.T_int:
        return new Integer(c.intValue());
      case TypeIds.T_long:
        return new Long(c.longValue());
      case TypeIds.T_short:
        return new Short(c.shortValue());
      case TypeIds.T_JavaLangString:
        return c.stringValue();
    }
    return null;
  }
View Full Code Here

        } else {
          this.stringConstants = new String[length];
        }
        int counter = 0;
        for (int i = 0; i < length; i++) {
          Constant constant;
          final Statement statement = this.statements[i];
          if ((constant = statement.resolveCase(this.scope, expressionType, this)) != Constant.NotAConstant) {
            if (!isStringSwitch) {
              int key = constant.intValue();
              //----check for duplicate case statement------------
              for (int j = 0; j < counter; j++) {
                if (this.constants[j] == key) {
                  reportDuplicateCase((CaseStatement) statement, this.cases[j], length);
                }
              }
              this.constants[counter++] = key;
            } else {
              String key = constant.stringValue();
              //----check for duplicate case statement------------
              for (int j = 0; j < counter; j++) {
                if (this.stringConstants[j].equals(key)) {
                  reportDuplicateCase((CaseStatement) statement, this.cases[j], length);
                }
View Full Code Here

    }
  } else {
    FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
    if (lastFieldBinding != null) {
      boolean isStatic = lastFieldBinding.isStatic();
      Constant fieldConstant = lastFieldBinding.constant();
      if (fieldConstant != Constant.NotAConstant) {
        if (!isStatic){
          codeStream.invokeObjectGetClass();
          codeStream.pop();
        }
View Full Code Here

      lastGenericCast = null;
      LocalVariableBinding localBinding = (LocalVariableBinding) this.binding;
      lastReceiverType = localBinding.type;
      if (!needValue) break; // no value needed
      // regular local variable read
      Constant localConstant = localBinding.constant();
      if (localConstant != Constant.NotAConstant) {
        codeStream.generateConstant(localConstant, 0);
        // no implicit conversion
      } else {
        // outer local?
        if ((this.bits & ASTNode.DepthMASK) != 0) {
          // outer local can be reached either through a synthetic arg or a synthetic field
          VariableBinding[] path = currentScope.getEmulationPath(localBinding);
          codeStream.generateOuterAccess(path, this, localBinding, currentScope);
        } else {
          codeStream.load(localBinding);
        }
      }
      break;
    default : // should not occur
      return null;
  }

  // all intermediate field accesses are read accesses
  // only the last field binding is a write access
  int positionsLength = this.sourcePositions.length;
  FieldBinding initialFieldBinding = lastFieldBinding; // can be null if initial was a local binding
  if (this.otherBindings != null) {
    for (int i = 0; i < otherBindingsCount; i++) {
      int pc = codeStream.position;
      FieldBinding nextField = this.otherBindings[i].original();
      TypeBinding nextGenericCast = this.otherGenericCasts == null ? null : this.otherGenericCasts[i];
      if (lastFieldBinding != null) {
        needValue = !nextField.isStatic();
        Constant fieldConstant = lastFieldBinding.constant();
        if (fieldConstant != Constant.NotAConstant) {
          if (i > 0 && !lastFieldBinding.isStatic()) {
            codeStream.invokeObjectGetClass(); // perform null check
            codeStream.pop();
          }
View Full Code Here

    final int numberOfParens = (doubleLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
      manageOpeningParenthesizedExpression(doubleLiteral, numberOfParens);
    }
    Constant constant = doubleLiteral.constant;
    if (constant != null && constant.doubleValue() < 0) {
      this.scribe.printNextToken(TerminalTokens.TokenNameMINUS);
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameDoubleLiteral);

    if (numberOfParens > 0) {
View Full Code Here

    final int numberOfParens = (floatLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
      manageOpeningParenthesizedExpression(floatLiteral, numberOfParens);
    }
    Constant constant = floatLiteral.constant;
    if (constant != null && floatLiteral.constant.floatValue() < 0) {
      this.scribe.printNextToken(TerminalTokens.TokenNameMINUS);
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameFloatingPointLiteral);
View Full Code Here

    final int numberOfParens = (intLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
      manageOpeningParenthesizedExpression(intLiteral, numberOfParens);
    }
    Constant constant = intLiteral.constant;
    if (constant != null && constant.intValue() < 0) {
      this.scribe.printNextToken(TerminalTokens.TokenNameMINUS);
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameIntegerLiteral);

    if (numberOfParens > 0) {
View Full Code Here

    final int numberOfParens = (longLiteral.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
    if (numberOfParens > 0) {
      manageOpeningParenthesizedExpression(longLiteral, numberOfParens);
    }
    Constant constant = longLiteral.constant;
    if (constant != null && constant.longValue() < 0) {
      this.scribe.printNextToken(TerminalTokens.TokenNameMINUS);
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameLongLiteral);

    if (numberOfParens > 0) {
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.impl.Constant

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.