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

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


   */
  Object resolveConstantExpressionValue(Expression expression) {
    org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression);
    if (node instanceof org.eclipse.jdt.internal.compiler.ast.Expression) {
      org.eclipse.jdt.internal.compiler.ast.Expression compilerExpression = (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


  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){
      attributesNumber += generateConstantValueAttribute(fieldConstant, fieldBinding, fieldAttributeOffset);
    }
    if (this.targetJDK < ClassFileConstants.JDK1_5 && fieldBinding.isSynthetic()) {
      attributesNumber += generateSyntheticAttribute();
View Full Code Here

  }
  private void generateElementValue(
      Expression defaultValue,
      TypeBinding memberValuePairReturnType,
      int attributeOffset) {
    Constant constant = defaultValue.constant;
    TypeBinding defaultValueBinding = defaultValue.resolvedType;
    if (defaultValueBinding == null) {
      this.contentsOffset = attributeOffset;
    } else {
      if (defaultValueBinding.isMemberType()) {
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

  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){
      attributesNumber += generateConstantValueAttribute(fieldConstant, fieldBinding, fieldAttributeOffset);
    }
    if (this.targetJDK < ClassFileConstants.JDK1_5 && fieldBinding.isSynthetic()) {
      attributesNumber += generateSyntheticAttribute();
View Full Code Here

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

*/
public void generateOptimizedBoolean(BlockScope currentScope, CodeStream codeStream, BranchLabel trueLabel, BranchLabel falseLabel, boolean valueRequired) {
  // a label valued to nil means: by default we fall through the case...
  // both nil means we leave the value on the stack

  Constant cst = optimizedBooleanConstant();
  generateCode(currentScope, codeStream, valueRequired && cst == Constant.NotAConstant);
  if ((cst != Constant.NotAConstant) && (cst.typeID() == TypeIds.T_boolean)) {
    int pc = codeStream.position;
    if (cst.booleanValue() == true) {
      // constant == true
      if (valueRequired) {
        if (falseLabel == null) {
          // implicit falling through the FALSE case
          if (trueLabel != null) {
View Full Code Here

      }
      if (this.receiver.resolvedType != null
          && this.receiver.resolvedType.id == TypeIds.T_OrgEclipseCoreRuntimeAssert
          && argument.resolvedType != null
          && argument.resolvedType.id == TypeIds.T_boolean) {
        Constant cst = argument.optimizedBooleanConstant();
        boolean isOptimizedTrueAssertion = cst != Constant.NotAConstant && cst.booleanValue() == true;
        boolean isOptimizedFalseAssertion = cst != Constant.NotAConstant && cst.booleanValue() == false;
        flowContext.tagBits |= FlowContext.HIDE_NULL_COMPARISON_WARNING;
        conditionFlowInfo = argument.analyseCode(currentScope, flowContext, flowInfo.copy());
        if (!wasInsideAssert) {
          flowContext.tagBits &= ~FlowContext.HIDE_NULL_COMPARISON_WARNING;
        }
View Full Code Here

    return;
  }
  FieldBinding codegenBinding = this.binding.original();
  boolean isStatic = codegenBinding.isStatic();
  boolean isThisReceiver = this.receiver instanceof ThisReference;
  Constant fieldConstant = codegenBinding.constant();
  if (fieldConstant != Constant.NotAConstant) {
    if (!isThisReceiver) {
      this.receiver.generateCode(currentScope, codeStream, !isStatic);
      if (!isStatic){
        codeStream.invokeObjectGetClass();
View Full Code Here

    return;
  } else {
    switch (this.bits & ASTNode.RestrictiveFlagMASK) {
      case Binding.FIELD : // reading a field
        FieldBinding codegenField = ((FieldBinding) this.binding).original();
        Constant fieldConstant = codegenField.constant();
        if (fieldConstant != Constant.NotAConstant) {
          // directly use inlined value for constant fields
          if (valueRequired) {
            codeStream.generateConstant(fieldConstant, this.implicitConversion);
          }
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.