Package org.eclipse.jdt.internal.compiler.ast

Examples of org.eclipse.jdt.internal.compiler.ast.BinaryExpression


}
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
  // optimizing assignment like: i = i + 1 or i = 1 + i
  if (assignment.expression.isCompactableOperation()) {
    BinaryExpression operation = (BinaryExpression) assignment.expression;
    int operator = (operation.bits & OperatorMASK) >> OperatorSHIFT;
    SingleNameReference variableReference;
    if ((operation.left instanceof SingleNameReference) && ((variableReference = (SingleNameReference) operation.left).binding == this.binding)) {
      // i = i + value, then use the variable on the right hand side, since it has the correct implicit conversion
      variableReference.generateCompoundAssignment(currentScope, codeStream, this.syntheticAccessors == null ? null : this.syntheticAccessors[WRITE], operation.right, operator, operation.implicitConversion, valueRequired);
View Full Code Here


      addRealFragment(combinedBinaryExpression.left);
      this.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
      addRealFragment(combinedBinaryExpression.right);
      return false;
    }
    BinaryExpression cursor = combinedBinaryExpression.referencesTable[0];
    if (cursor.left instanceof CombinedBinaryExpression) {
      this.visit((CombinedBinaryExpression) cursor.left, scope);
    } else {
      addRealFragment(cursor.left);
    }
View Full Code Here

                ((StringLiteral) expr1).extendWith((CharLiteral) expr2);
            } else if (expr2 instanceof StringLiteral) { //string+string
              this.expressionStack[this.expressionPtr] =
                ((StringLiteral) expr1).extendWith((StringLiteral) expr2);
            } else {
              this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
            }
          } else {
            this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
          }
        } else if (expr1 instanceof CombinedBinaryExpression) {
          CombinedBinaryExpression cursor;
          // left branch is comprised of PLUS BEs
          // cursor is shifted upwards, while needed BEs are added
          // on demand; past the arityMax-th
          // consecutive BE, a CBE is inserted that holds a
          // full-fledged references table
          if ((cursor = (CombinedBinaryExpression)expr1).arity < cursor.arityMax) {
            cursor.left = new BinaryExpression(cursor);
            cursor.arity++;
          } else {
            cursor.left = new CombinedBinaryExpression(cursor);
            cursor.arity = 0;
            cursor.tuneArityMax();
          }
          cursor.right = expr2;
          cursor.sourceEnd = expr2.sourceEnd;
          this.expressionStack[this.expressionPtr] = cursor;
          // BE_INSTRUMENTATION: neutralized in the released code
//          cursor.depthTracker = ((BinaryExpression)cursor.left).
//            depthTracker + 1;
        } else if (expr1 instanceof BinaryExpression &&
              // single out the a + b case, which is a BE
              // instead of a CBE (slightly more than a half of
              // strings concatenation are one-deep binary
              // expressions)
            ((expr1.bits & ASTNode.OperatorMASK) >>
              ASTNode.OperatorSHIFT) == OperatorIds.PLUS) {
          this.expressionStack[this.expressionPtr] =
            new CombinedBinaryExpression(expr1, expr2, PLUS, 1);
        } else {
          this.expressionStack[this.expressionPtr] =
            new BinaryExpression(expr1, expr2, PLUS);
        }
      } else if (expr1 instanceof StringLiteral) {
        if (expr2 instanceof StringLiteral
            && ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) {
          // string + string
          this.expressionStack[this.expressionPtr] =
            ((StringLiteral) expr1).extendsWith((StringLiteral) expr2);
        } else {
          // single out the a + b case
          this.expressionStack[this.expressionPtr] =
            new BinaryExpression(expr1, expr2, PLUS);
        }
      } else if (expr1 instanceof CombinedBinaryExpression) {
          CombinedBinaryExpression cursor;
          // shift cursor; create BE/CBE as needed
          if ((cursor = (CombinedBinaryExpression)expr1).arity < cursor.arityMax) {
            cursor.left = new BinaryExpression(cursor);
            // clear the bits on cursor
            cursor.bits &= ~ASTNode.ParenthesizedMASK;
            cursor.arity++;
          } else {
            cursor.left = new CombinedBinaryExpression(cursor);
            // clear the bits on cursor
            cursor.bits &= ~ASTNode.ParenthesizedMASK;
            cursor.arity = 0;
            cursor.tuneArityMax();
          }
          cursor.right = expr2;
          cursor.sourceEnd = expr2.sourceEnd;
          // BE_INSTRUMENTATION: neutralized in the released code
//          cursor.depthTracker = ((BinaryExpression)cursor.left).
//            depthTracker + 1;
          this.expressionStack[this.expressionPtr] = cursor;
      } else if (expr1 instanceof BinaryExpression
          && ((expr1.bits & ASTNode.OperatorMASK) >>
              ASTNode.OperatorSHIFT) == OperatorIds.PLUS) {
        // single out the a + b case
        this.expressionStack[this.expressionPtr] =
          new CombinedBinaryExpression(expr1, expr2, PLUS, 1);
      } else {
        this.expressionStack[this.expressionPtr] =
          new BinaryExpression(expr1, expr2, PLUS);
      }
      break;
    case LESS :
    case MULTIPLY :
      this.intPtr--; // star end position or starting position of angle bracket
      this.expressionStack[this.expressionPtr] =
        new BinaryExpression(
          expr1,
          expr2,
          op);
      break;
    default :
      this.expressionStack[this.expressionPtr] =
        new BinaryExpression(
          expr1,
          expr2,
          op);
  }
}
View Full Code Here

              ((StringLiteral) expr1).extendWith((CharLiteral) expr2);
          } else if (expr2 instanceof StringLiteral) { //string+string
            this.expressionStack[this.expressionPtr] =
              ((StringLiteral) expr1).extendWith((StringLiteral) expr2);
          } else {
            this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
          }
        } else {
          this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
        }
      } else if (expr1 instanceof StringLiteral) {
        if (expr2 instanceof StringLiteral
            && ((expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT) == 0) {
          // string + string
          this.expressionStack[this.expressionPtr] =
            ((StringLiteral) expr1).extendsWith((StringLiteral) expr2);
        } else {
          this.expressionStack[this.expressionPtr] =
            new BinaryExpression(
              expr1,
              expr2,
              op);
        }
      } else {
        this.expressionStack[this.expressionPtr] =
          new BinaryExpression(
            expr1,
            expr2,
            op);
      }
      break;
    case LESS :
    case MULTIPLY :
      this.intPtr--; // star end position or starting position of angle bracket
      this.expressionStack[this.expressionPtr] =
        new BinaryExpression(
          expr1,
          expr2,
          op);
      break;
    default :
      this.expressionStack[this.expressionPtr] =
        new BinaryExpression(
          expr1,
          expr2,
          op);
  }
}
View Full Code Here

      addRealFragment(combinedBinaryExpression.left);
      this.operatorsList.add(new Integer(TerminalTokens.TokenNamePLUS));
      addRealFragment(combinedBinaryExpression.right);
      return false;
    }
    BinaryExpression cursor = combinedBinaryExpression.referencesTable[0];
    if (cursor.left instanceof CombinedBinaryExpression) {
      this.visit((CombinedBinaryExpression) cursor.left, scope);
    } else {
      addRealFragment(cursor.left);
    }
View Full Code Here

}
public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
  // optimizing assignment like: i = i + 1 or i = 1 + i
  if (assignment.expression.isCompactableOperation()) {
    BinaryExpression operation = (BinaryExpression) assignment.expression;
    int operator = (operation.bits & OperatorMASK) >> OperatorSHIFT;
    SingleNameReference variableReference;
    if ((operation.left instanceof SingleNameReference) && ((variableReference = (SingleNameReference) operation.left).binding == this.binding)) {
      // i = i + value, then use the variable on the right hand side, since it has the correct implicit conversion
      variableReference.generateCompoundAssignment(currentScope, codeStream, this.syntheticAccessors == null ? null : this.syntheticAccessors[WRITE], operation.right, operator, operation.implicitConversion, valueRequired);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ast.BinaryExpression

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.