Examples of JsBinaryOperator


Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

    @Override
    public void endVisit(JBinaryOperation x, Context ctx) {
      JsExpression rhs = pop(); // rhs
      JsExpression lhs = pop(); // lhs
      JsBinaryOperator myOp = JavaToJsOperatorMap.get(x.getOp());

      /*
       * Use === and !== on reference types, or else you can get wrong answers
       * when Object.toString() == 'some string'.
       */
 
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

     * Due to the way clinits are constructed, you can end up with a comma
     * operation as the argument to a modifying operation, which is illegal.
     * Juggle things to put the operator inside of the comma expression.
     */
    private void maybeShuffleModifyingBinary(JsBinaryOperation x, JsContext ctx) {
      JsBinaryOperator myOp = x.getOperator();
      JsExpression lhs = x.getArg1();

      if (myOp.isAssignment() && (lhs instanceof JsBinaryOperation)) {
        // Find the rightmost comma operation
        JsBinaryOperation curLhs = (JsBinaryOperation) lhs;
        assert (curLhs.getOperator() == JsBinaryOperator.COMMA);
        while (curLhs.getArg2() instanceof JsBinaryOperation) {
          curLhs = (JsBinaryOperation) curLhs.getArg2();
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

    }
    return applySourceInfo(n, x);
  }

  private Node transform(JsBinaryOperation x) {
    JsBinaryOperator op = x.getOperator();
    Node n = new Node(getTokenForOp(op), transform(x.getArg1()), transform(x.getArg2()));
    return applySourceInfo(n, x);
  }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

   */
  private static JsExpression simplifyOp(JsBinaryOperation expr) {
    SourceInfo info = expr.getSourceInfo();
    JsExpression arg1 = expr.getArg1();
    JsExpression arg2 = expr.getArg2();
    JsBinaryOperator op = expr.getOperator();

    if (op == JsBinaryOperator.ADD &&
        (arg1 instanceof JsStringLiteral || arg2 instanceof JsStringLiteral)) {
      // cases: number + string or string + number
      StringBuilder result = new StringBuilder();
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

    if (!(x instanceof JsBinaryOperation)) {
      return x;
    }

    JsBinaryOperation expr = (JsBinaryOperation) x;
    JsBinaryOperator outerOp = expr.getOperator();

    if (!REORDERABLE_OPERATORS.contains(outerOp)) {
      return expr;
    }
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

     */
    private Map<JsExpression, Boolean> coercesToStringMap = new IdentityHashMap<JsExpression, Boolean>();

    @Override
    public void endVisit(JsBinaryOperation x, JsContext ctx) {
      JsBinaryOperator op = x.getOperator();
      JsExpression arg1 = x.getArg1();
      JsExpression arg2 = x.getArg2();

      JsExpression result = x;

View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

      this.unevaluated = new ArrayList<JsName>(toEvaluate);
    }

    @Override
    public void endVisit(JsBinaryOperation x, JsContext ctx) {
      JsBinaryOperator op = x.getOperator();

      /*
       * We don't care about the left-hand expression, because it is guaranteed
       * to be evaluated.
       */
 
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

    @Override
    public void endVisit(JBinaryOperation x, Context ctx) {
      JsExpression rhs = (JsExpression) pop(); // rhs
      JsExpression lhs = (JsExpression) pop(); // lhs
      JsBinaryOperator myOp = JavaToJsOperatorMap.get(x.getOp());

      /*
       * Use === and !== on reference types, or else you can get wrong answers
       * when Object.toString() == 'some string'.
       */
 
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

    @Override
    public void endVisit(JBinaryOperation x, Context ctx) {
      JsExpression rhs = pop(); // rhs
      JsExpression lhs = pop(); // lhs
      JsBinaryOperator myOp = JavaToJsOperatorMap.get(x.getOp());

      /*
       * Use === and !== on reference types, or else you can get wrong answers
       * when Object.toString() == 'some string'.
       */
 
View Full Code Here

Examples of com.google.gwt.dev.js.ast.JsBinaryOperator

    _rsquare();
    return false;
  }

  public boolean visit(JsBinaryOperation x, JsContext ctx) {
    JsBinaryOperator op = x.getOperator();
    JsExpression arg1 = x.getArg1();
    _parenPush(x, arg1, !op.isLeftAssociative());
    accept(arg1);
    boolean needSpace = op.isKeyword() || arg1 instanceof JsPostfixOperation;
    if (needSpace) {
      _parenPopOrSpace(x, arg1, !op.isLeftAssociative());
    } else {
      _parenPop(x, arg1, !op.isLeftAssociative());
      _spaceOpt();
    }
    p.print(op.getSymbol());
    JsExpression arg2 = x.getArg2();
    needSpace = op.isKeyword() || arg2 instanceof JsPrefixOperation;
    if (needSpace) {
      _parenPushOrSpace(x, arg2, op.isLeftAssociative());
    } else {
      _spaceOpt();
      _parenPush(x, arg2, op.isLeftAssociative());
    }
    accept(arg2);
    _parenPop(x, arg2, op.isLeftAssociative());
    return false;
  }
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.