Package com.google.gwt.dev.jjs.ast

Examples of com.google.gwt.dev.jjs.ast.JBinaryOperation


      }

      JExpression newLhs = checkAndReplace(x.getLhs(), lhsType);
      JExpression newRhs = checkAndReplace(x.getRhs(), rhsType);
      if (newLhs != x.getLhs() || newRhs != x.getRhs()) {
        JBinaryOperation binOp =
            new JBinaryOperation(x.getSourceInfo(), resultType, op, newLhs, newRhs);
        ctx.replaceMe(binOp);
      }
    }
View Full Code Here


      assert !x.getOp().isAssignment() || newLhs == x.getLhs() :
          "L-values can never be rewritten (CONCAT_ASG can not have an lhs of type char or long).";

      if (newLhs != x.getLhs() || newRhs != x.getRhs()) {
        JBinaryOperation newExpr =
            new JBinaryOperation(x.getSourceInfo(), program.getTypeJavaLangString(),
                x.getOp(), newLhs, newRhs);
        ctx.replaceMe(newExpr);
      }
    }
View Full Code Here

            new JLocalRef(catchInfo, exceptionVariable));
        // Handle the rest of the Exception types if any.
        for (int j = 1; j < exceptionsTypes.size(); j++) {
          JExpression orExp = new JInstanceOf(catchInfo, (JReferenceType) exceptionsTypes.get(j),
              new JLocalRef(catchInfo, exceptionVariable));
          ifTest = new JBinaryOperation(catchInfo, JPrimitiveType.BOOLEAN, JBinaryOperator.OR,
              ifTest, orExp);
        }
        JDeclarationStatement declaration =
            new JDeclarationStatement(catchInfo, arg, new JLocalRef(catchInfo, exceptionVariable));
        block.addStmt(0, declaration);
View Full Code Here

    @Override
    public boolean visit(JCaseStatement x, Context ctx) {
      pushNode(new CfgStatementNode<JStatement>(parent, x));
      if (x.getExpr() != null) {
        // case label
        JExpression condition = new JBinaryOperation(x.getSourceInfo(),
            program.getTypePrimitiveBoolean(),
            JBinaryOperator.EQ, switchStatement.getExpr(), x.getExpr());
        CfgCaseNode node = addNode(new CfgCaseNode(parent, x, condition));
        addExit(Exit.createCaseThen(node));
        addExit(Exit.createCaseElse(node));
View Full Code Here

    public void endVisit(JExpression x, Context ctx) {
      if (x != dontBother && !ctx.isLvalue()) {
        SourceInfo info = x.getSourceInfo();
        JType type = x.getType();
        JLocal local = createTempLocal(info, type);
        ctx.replaceMe(new JBinaryOperation(info, type, JBinaryOperator.ASG,
            new JLocalRef(info, local), x));
      }
    }
View Full Code Here

            multi.addExpressions(instance);
            JLocal var = JProgram.createLocal(instance.getSourceInfo(), "$t", instance.getType(),
                false, body);

            JLocalRef localRef = new JLocalRef(var.getSourceInfo(), var);
            instance = new JBinaryOperation(instance.getSourceInfo(), localRef.getType(),
                JBinaryOperator.ASG, localRef, instance);
          }
          clinit = createClinitCall(x.getSourceInfo(),
              ((JMethodCall) x).getTarget().getEnclosingType());
        } else if (x instanceof JFieldRef) {
View Full Code Here

        return elseExpr;
      }
    } else if (thenExpr instanceof JBooleanLiteral) {
      if (((JBooleanLiteral) thenExpr).getValue()) {
        // e.g. (cond ? true : else) -> cond || else
        JBinaryOperation binOp = new JBinaryOperation(program,
            original.getSourceInfo(), original.getType(), JBinaryOperator.OR,
            condExpr, elseExpr);
        return binOp;
      } else {
        // e.g. (cond ? false : else) -> !cond && else
        JPrefixOperation notCondExpr = new JPrefixOperation(program,
            condExpr.getSourceInfo(), JUnaryOperator.NOT, condExpr);
        JBinaryOperation binOp = new JBinaryOperation(program,
            original.getSourceInfo(), original.getType(), JBinaryOperator.AND,
            notCondExpr, elseExpr);
        return binOp;
      }
    } else if (elseExpr instanceof JBooleanLiteral) {
      if (((JBooleanLiteral) elseExpr).getValue()) {
        // e.g. (cond ? then : true) -> !cond || then
        JPrefixOperation notCondExpr = new JPrefixOperation(program,
            condExpr.getSourceInfo(), JUnaryOperator.NOT, condExpr);
        JBinaryOperation binOp = new JBinaryOperation(program,
            original.getSourceInfo(), original.getType(), JBinaryOperator.OR,
            notCondExpr, thenExpr);
        return binOp;
      } else {
        // e.g. (cond ? then : false) -> cond && then
        JBinaryOperation binOp = new JBinaryOperation(program,
            original.getSourceInfo(), original.getType(), JBinaryOperator.AND,
            condExpr, thenExpr);
        return binOp;
      }
    } else {
View Full Code Here

      // TODO(spoon): immediately simplify the newMulti
      return newMulti;
    }
    if (arg instanceof JBinaryOperation) {
      // try to invert the binary operator
      JBinaryOperation argOp = (JBinaryOperation) arg;
      JBinaryOperator op = argOp.getOp();
      JBinaryOperator newOp = null;
      if (op == JBinaryOperator.EQ) {
        // e.g. !(x == y) -> x != y
        newOp = JBinaryOperator.NEQ;
      } else if (op == JBinaryOperator.NEQ) {
        // e.g. !(x != y) -> x == y
        newOp = JBinaryOperator.EQ;
      } else if (op == JBinaryOperator.GT) {
        // e.g. !(x > y) -> x <= y
        newOp = JBinaryOperator.LTE;
      } else if (op == JBinaryOperator.LTE) {
        // e.g. !(x <= y) -> x > y
        newOp = JBinaryOperator.GT;
      } else if (op == JBinaryOperator.GTE) {
        // e.g. !(x >= y) -> x < y
        newOp = JBinaryOperator.LT;
      } else if (op == JBinaryOperator.LT) {
        // e.g. !(x < y) -> x >= y
        newOp = JBinaryOperator.GTE;
      }
      if (newOp != null) {
        JBinaryOperation newBinOp = new JBinaryOperation(program,
            argOp.getSourceInfo(), argOp.getType(), newOp, argOp.getLhs(),
            argOp.getRhs());
        return newBinOp;
      }
    } else if (arg instanceof JPrefixOperation) {
View Full Code Here

          return;
        }

        if (caseStatement.getExpr() != null) {
          // Create an if statement equivalent to the single-case switch.
          JBinaryOperation compareOperation = new JBinaryOperation(program,
              x.getSourceInfo(), program.getTypePrimitiveBoolean(),
              JBinaryOperator.EQ, x.getExpr(), caseStatement.getExpr());
          JBlock block = new JBlock(program, x.getSourceInfo());
          block.statements.add(statement);
          JIfStatement ifStatement = new JIfStatement(program,
View Full Code Here

      }

      JExpression newLhs = checkAndReplace(x.getLhs(), lhsType);
      JExpression newRhs = checkAndReplace(x.getRhs(), rhsType);
      if (newLhs != x.getLhs() || newRhs != x.getRhs()) {
        JBinaryOperation binOp = new JBinaryOperation(program,
            x.getSourceInfo(), resultType, x.getOp(), newLhs, newRhs);
        ctx.replaceMe(binOp);
      }
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.ast.JBinaryOperation

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.