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

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


  static Object buildDOMValue(final Object internalObject, BindingResolver resolver) {
    if (internalObject == null)
      return null;

    if (internalObject instanceof Constant) {
      Constant constant = (Constant) internalObject;
      switch (constant.typeID()) {
        case TypeIds.T_boolean:
          return Boolean.valueOf(constant.booleanValue());
        case TypeIds.T_byte:
          return new Byte(constant.byteValue());
        case TypeIds.T_char:
          return new Character(constant.charValue());
        case TypeIds.T_double:
          return new Double(constant.doubleValue());
        case TypeIds.T_float:
          return new Float(constant.floatValue());
        case TypeIds.T_int:
          return new Integer(constant.intValue());
        case TypeIds.T_long:
          return new Long(constant.longValue());
        case TypeIds.T_short:
          return new Short(constant.shortValue());
        case TypeIds.T_JavaLangString:
          return constant.stringValue();
      }
    } else if (internalObject instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
      return resolver.getTypeBinding((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding) internalObject);
    } else if (internalObject instanceof org.aspectj.org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding) {
      return resolver.getAnnotationInstance((org.aspectj.org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding) internalObject);
View Full Code Here


        if (expr instanceof StringLiteral) {
          StringLiteral sLit = ((StringLiteral) expr);
          return new String(sLit.source());
        } else if (expr instanceof NameReference && (((NameReference) expr).binding instanceof FieldBinding)) {
          Binding b = ((NameReference) expr).binding;
          Constant c = ((FieldBinding) b).constant;
          return c.stringValue();
        } else {
          throw new BCException("Do not know how to recover pointcut definition from " + expr + " (type "
              + expr.getClass().getName() + ")");
        }
      }
View Full Code Here

          "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation [" + annotation + "]");
    }
  }

  private AnnotationValue generateElementValue(Expression defaultValue, TypeBinding memberValuePairReturnType) {
    Constant constant = defaultValue.constant;
    TypeBinding defaultValueBinding = defaultValue.resolvedType;
    if (defaultValueBinding == null) {
      throw new MissingImplementationException(
          "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value [" + defaultValue
              + "]");
View Full Code Here

          "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation [" + annotation + "]");
    }
  }

  private static AnnotationValue generateElementValue(Expression defaultValue, TypeBinding memberValuePairReturnType) {
    Constant constant = defaultValue.constant;
    TypeBinding defaultValueBinding = defaultValue.resolvedType;
    if (defaultValueBinding == null) {
      throw new MissingImplementationException(
          "Please raise an AspectJ bug.  AspectJ does not know how to convert this annotation value [" + defaultValue
              + "]");
View Full Code Here

    }
  }

  public static AnnotationValue generateElementValueForConstantExpression(Expression defaultValue, TypeBinding defaultValueBinding) {
    if (defaultValueBinding != null) {
      Constant c = defaultValue.constant;
      if (c instanceof IntConstant) {
        IntConstant iConstant = (IntConstant) c;
        return new SimpleAnnotationValue(ElementValue.PRIMITIVE_INT, new Integer(iConstant.intValue()));
      } else if (c instanceof BooleanConstant) {
        BooleanConstant iConstant = (BooleanConstant) c;
View Full Code Here

   */
  Object resolveConstantExpressionValue(Expression expression) {
    org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression);
    if (node != null && (node instanceof org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression)) {
      org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression compilerExpression = (org.aspectj.org.eclipse.jdt.internal.compiler.ast.Expression) node;
      Constant constant = compilerExpression.constant;
      if (constant != null && constant != Constant.NotAConstant) {
        switch (constant.typeID()) {
          case TypeIds.T_int : return new Integer(constant.intValue());
          case TypeIds.T_byte : return new Byte(constant.byteValue());
          case TypeIds.T_short : return new Short(constant.shortValue());
          case TypeIds.T_char : return new Character(constant.charValue());
          case TypeIds.T_float : return new Float(constant.floatValue());
          case TypeIds.T_double : return new Double(constant.doubleValue());
          case TypeIds.T_boolean : return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE;
          case TypeIds.T_long : return new Long(constant.longValue());
          case TypeIds.T_JavaLangString : return constant.stringValue();
        }
        return null;
      }
    }
    return null;
View Full Code Here

        this.constants = new int[length];
        CaseStatement[] duplicateCaseStatements = null;
        int duplicateCaseStatementsCounter = 0;
        int counter = 0;
        for (int i = 0; i < length; i++) {
          Constant constant;
          final Statement statement = statements[i];
          if ((constant = statement.resolveCase(scope, expressionType, this)) != Constant.NotAConstant) {
            int key = constant.intValue();
            //----check for duplicate case statement------------
            for (int j = 0; j < counter; j++) {
              if (this.constants[j] == key) {
                final CaseStatement currentCaseStatement = (CaseStatement) statement;
                if (duplicateCaseStatements == null) {
View Full Code Here

      }
    }
    preCondInitStateIndex =
      currentScope.methodScope().recordInitializationStates(flowInfo);

    Constant cst = this.condition == null ? null : this.condition.constant;
    boolean isConditionTrue = cst == null || (cst != Constant.NotAConstant && cst.booleanValue() == true);
    boolean isConditionFalse = cst != null && (cst != Constant.NotAConstant && cst.booleanValue() == false);

    cst = this.condition == null ? null : this.condition.optimizedBooleanConstant();
    boolean isConditionOptimizedTrue = cst == null ||  (cst != Constant.NotAConstant && cst.booleanValue() == true);
    boolean isConditionOptimizedFalse = cst != null && (cst != Constant.NotAConstant && cst.booleanValue() == false);
   
    // process the condition
    LoopingFlowContext condLoopContext = null;
    FlowInfo condInfo = flowInfo.nullInfoLessUnconditionalCopy();
    if (condition != null) {
View Full Code Here

 
  private int addFieldAttributes(FieldBinding fieldBinding, int fieldAttributeOffset) {
    int attributesNumber = 0;
    // 4.7.2 only static constant fields get a ConstantAttribute
    // Generate the constantValueAttribute
    Constant fieldConstant = fieldBinding.constant();
    if (fieldConstant != Constant.NotAConstant){
      if (contentsOffset + 8 >= contents.length) {
        resizeContents(8);
      }
      // Now we generate the constant attribute corresponding to the fieldBinding
      int constantValueNameIndex =
        constantPool.literalIndex(AttributeNamesConstants.ConstantValueName);
      contents[contentsOffset++] = (byte) (constantValueNameIndex >> 8);
      contents[contentsOffset++] = (byte) constantValueNameIndex;
      // The attribute length = 2 in case of a constantValue attribute
      contents[contentsOffset++] = 0;
      contents[contentsOffset++] = 0;
      contents[contentsOffset++] = 0;
      contents[contentsOffset++] = 2;
      attributesNumber++;
      // Need to add the constant_value_index
      switch (fieldConstant.typeID()) {
        case T_boolean :
          int booleanValueIndex =
            constantPool.literalIndex(fieldConstant.booleanValue() ? 1 : 0);
          contents[contentsOffset++] = (byte) (booleanValueIndex >> 8);
          contents[contentsOffset++] = (byte) booleanValueIndex;
          break;
        case T_byte :
        case T_char :
        case T_int :
        case T_short :
          int integerValueIndex =
            constantPool.literalIndex(fieldConstant.intValue());
          contents[contentsOffset++] = (byte) (integerValueIndex >> 8);
          contents[contentsOffset++] = (byte) integerValueIndex;
          break;
        case T_float :
          int floatValueIndex =
            constantPool.literalIndex(fieldConstant.floatValue());
          contents[contentsOffset++] = (byte) (floatValueIndex >> 8);
          contents[contentsOffset++] = (byte) floatValueIndex;
          break;
        case T_double :
          int doubleValueIndex =
            constantPool.literalIndex(fieldConstant.doubleValue());
          contents[contentsOffset++] = (byte) (doubleValueIndex >> 8);
          contents[contentsOffset++] = (byte) doubleValueIndex;
          break;
        case T_long :
          int longValueIndex =
            constantPool.literalIndex(fieldConstant.longValue());
          contents[contentsOffset++] = (byte) (longValueIndex >> 8);
          contents[contentsOffset++] = (byte) longValueIndex;
          break;
        case T_JavaLangString :
          int stringValueIndex =
View Full Code Here

  private void generateElementValue(
      Expression defaultValue,
      TypeBinding memberValuePairReturnType,
      int attributeOffset) {
    Constant constant = defaultValue.constant;
    TypeBinding defaultValueBinding = defaultValue.resolvedType;
    if (defaultValueBinding == null) {
      contentsOffset = attributeOffset;
    } else {
      if (memberValuePairReturnType.isArrayType() && !defaultValueBinding.isArrayType()) {
View Full Code Here

TOP

Related Classes of org.aspectj.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.