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

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


    if (initializations != null) {
      for (int i = 0, max = initializations.length; i < max; i++) {
        initializations[i].generateCode(scope, codeStream);
      }
    }
    Constant cst = this.condition == null ? null : this.condition.optimizedBooleanConstant();
    boolean isConditionOptimizedFalse = cst != null && (cst != Constant.NotAConstant && cst.booleanValue() == false);
    if (isConditionOptimizedFalse) {
      condition.generateCode(scope, codeStream, false);
      // May loose some local variable initializations : affecting the local variable attributes
      if ((this.bits & ASTNode.NeededScope) != 0) {
        codeStream.exitUserScope(scope);
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

      break;
    case Binding.LOCAL : // reading the first local variable
      if (!needValue) break; // no value needed
      LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
      // 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);
        }
      }
  }
         
  // all intermediate field accesses are read accesses
  // only the last field binding is a write access
  int positionsLength = this.sourcePositions.length;
  if (this.otherCodegenBindings != null) {
    for (int i = 0; i < otherBindingsCount; i++) {
      int pc = codeStream.position;
      FieldBinding nextField = this.otherCodegenBindings[i];
      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

        if (value instanceof ArrayInitializer) {
          ArrayInitializer initializer = (ArrayInitializer) value;
          Expression[] inits = initializer.expressions;
          if (inits != null) {
            for (int j = 0, initsLength = inits.length; j < initsLength; j++) {
              Constant cst = inits[j].constant;
              if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
                long irritant = CompilerOptions.warningTokenToIrritant(cst.stringValue());
                if (irritant != 0) {
                  suppressWarningIrritants |= irritant;
                  if (~suppressWarningIrritants == 0) break pairLoop;
                } else {
                  scope.problemReporter().unhandledWarningToken(inits[j]);
                }
              }
            }
          }
        } else {
          Constant cst = value.constant;
          if (cst != Constant.NotAConstant && cst.typeID() == T_JavaLangString) {
            long irritant = CompilerOptions.warningTokenToIrritant(cst.stringValue());
            if (irritant != 0) {
              suppressWarningIrritants |= irritant;
              if (~suppressWarningIrritants == 0) break pairLoop;
            } else {
              scope.problemReporter().unhandledWarningToken(value);
View Full Code Here

    switch (this.bits & RestrictiveFlagMASK) {
      case Binding.FIELD : // reading a field
        if (!valueRequired)
          break;
        FieldBinding fieldBinding = (FieldBinding) this.codegenBinding;
        Constant fieldConstant = fieldBinding.constant();
        if (fieldConstant == Constant.NotAConstant) { // directly use inlined value for constant fields
          if (fieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) {
             // directly use inlined value for constant fields
            boolean isStatic;
            if (!(isStatic = fieldBinding.isStatic())) {
View Full Code Here

        }
      }
      break;
    case Binding.LOCAL : // assigning to a local variable (cannot assign to outer local)
      LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
      Constant assignConstant;
      int increment;
      // using incr bytecode if possible
      switch (localBinding.type.id) {
        case T_JavaLangString :
          codeStream.generateStringConcatenationAppend(currentScope, this, expression);
          if (valueRequired) {
            codeStream.dup();
          }
          codeStream.store(localBinding, false);
          return;
        case T_int :
          if (((assignConstant = expression.constant) != Constant.NotAConstant)
            && (assignConstant.typeID() != T_float) // only for integral types
            && (assignConstant.typeID() != T_double)   
            && ((increment = assignConstant.intValue()) == (short) increment)) { // 16 bits value
            switch (operator) {
              case PLUS :
                codeStream.iinc(localBinding.resolvedPosition, increment);
                if (valueRequired) {
                  codeStream.load(localBinding);
View Full Code Here

        location[1] = sv.sourceEnd;
        return new String(sv.source());
      } else if (sma.memberValue instanceof NameReference
          && (((NameReference) sma.memberValue).binding instanceof FieldBinding)) {
        Binding b = ((NameReference) sma.memberValue).binding;
        Constant c = ((FieldBinding) b).constant;
        return c.stringValue();
      }
    }
    if (!(inAnnotation instanceof NormalAnnotation))
      return null;
    NormalAnnotation ann = (NormalAnnotation) inAnnotation;
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

  System.arraycopy(returnTypeKey, 0, uniqueKey, index, returnTypeLength);
  return uniqueKey;
}

public Constant constant() {
  Constant fieldConstant = this.constant;
  if (fieldConstant == null) {
    if (this.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

  public MethodBinding binding;

public static Object getValue(Expression expression) {
  if (expression == null)
    return null;
  Constant constant = expression.constant;
  // literals would hit this case.
  if (constant != null && constant != Constant.NotAConstant)
    return constant;

  if (expression instanceof Annotation)
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.