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

Examples of org.eclipse.jdt.internal.compiler.lookup.FieldBinding.constant()


    }
  } 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


    case Binding.FIELD :
      lastFieldBinding = ((FieldBinding) this.binding).original();
      lastGenericCast = this.genericCast;
      lastReceiverType = this.actualReceiverType;
      // if first field is actually constant, we can inline it
      if (lastFieldBinding.constant() != Constant.NotAConstant) {
        break;
      }
      if ((needValue && !lastFieldBinding.isStatic()) || lastGenericCast != null) {
        int pc = codeStream.position;
        if ((this.bits & ASTNode.DepthMASK) != 0) {
View Full Code Here

          if (fieldBinding.isStatic()) {
            // only last field is actually a write access if any
            // check if accessing enum static field in initializer
            if (declaringClass.isEnum()) {
              if ((sourceType == declaringClass || sourceType.superclass == declaringClass) // enum constant body
                  && fieldBinding.constant() == Constant.NotAConstant
                  && !methodScope.isStatic
                  && methodScope.isInsideInitializerOrConstructor()) {
                scope.problemReporter().enumStaticFieldUsedDuringInitialization(fieldBinding, this);
              }
            }
View Full Code Here

  return flowInfo;
}

public TypeBinding checkFieldAccess(BlockScope scope) {
  FieldBinding fieldBinding = (FieldBinding) this.binding;
  this.constant = fieldBinding.constant();

  this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
  this.bits |= Binding.FIELD;
  MethodScope methodScope = scope.methodScope();
  if (fieldBinding.isStatic()) {
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

    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

      resolveJsniRef(jsniRef, target);
      if (target.isDeprecated() &&
          !isEnclosingClass(method.binding.declaringClass, target.declaringClass)) {
        emitWarning("deprecation", WARN_DEPRECATED_FIELD, errorInfo, jsniRef);
      }
      if (isLvalue && target.constant() != Constant.NotAConstant) {
        emitError(ERR_ILLEGAL_ASSIGNMENT_TO_COMPILE_TIME_CONSTANT, errorInfo, jsniRef);
      }
      if (target.isStatic() && hasQualifier) {
        emitError(ERR_UNNECESSARY_QUALIFIER_STATIC_FIELD, errorInfo, jsniRef);
      } else if (!target.isStatic() && !hasQualifier) {
View Full Code Here

        } else if (binding instanceof FieldBinding) {
          FieldBinding fieldBinding = (FieldBinding) binding;
          if (isOptimizableCompileTimeConstant(fieldBinding)) {
            // Replace any compile-time constants with the constant value of the field.
            assert !ctx.isLvalue();
            JExpression constant = getConstant(info, fieldBinding.constant());
            JsExpression result = JjsUtils.translateLiteral((JLiteral) constant);
            assert (result != null);
            ctx.replaceMe(result);
          } else {
            // Normal: create a jsniRef.
View Full Code Here

          new JEnumField(info, intern(binding.name), binding.original().id,
              (JEnumType) enclosingType, (JClassType) type);
    } else {
      boolean isCompileTimeConstant =
          binding.isStatic() && (binding.isFinal())
              && (binding.constant() != Constant.NotAConstant) && (binding.type.isBaseType());
      assert (type instanceof JPrimitiveType || !isCompileTimeConstant);

      assert (!binding.isFinal() || !binding.isVolatile());
      Disposition disposition;
      if (isCompileTimeConstant) {
View Full Code Here

            annotationBinding.getElementValuePairs());

        return Lists.<JAnnotationArgument> create(toReturn);
      } else if (value instanceof FieldBinding) {
        FieldBinding fieldBinding = (FieldBinding) value;
        assert fieldBinding.constant() != null : "Expecting constant-valued field";
        return Lists.create((JAnnotationArgument) dispatch("processConstant",
            fieldBinding.constant()));
      }

      throw new InternalCompilerException("Unable to process value "
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.