Examples of JPrefixOperation


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

        default:
          throw new InternalCompilerException(
              "Unexpected operator for unary expression");
      }

      JPrefixOperation preOp = new JPrefixOperation(program, info, op,
          dispProcessExpression(x.expression));
      return preOp;
    }
View Full Code Here

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

              x.getSourceInfo(), x.getType(), JBinaryOperator.OR, condExpr,
              elseExpr);
          ctx.replaceMe(binOp);
        } else {
          // e.g. (cond ? false : else) -> !cond && else
          JPrefixOperation notCondExpr = new JPrefixOperation(program,
              condExpr.getSourceInfo(), JUnaryOperator.NOT, condExpr);
          JBinaryOperation binOp = new JBinaryOperation(program,
              x.getSourceInfo(), x.getType(), JBinaryOperator.AND, notCondExpr,
              elseExpr);
          ctx.replaceMe(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,
              x.getSourceInfo(), x.getType(), JBinaryOperator.OR, notCondExpr,
              thenExpr);
          ctx.replaceMe(binOp);
View Full Code Here

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

    public void endVisit(JPostfixOperation x, Context ctx) {
      if (x.getOp().isModifying()) {
        lvalues.remove(x.getArg());
      }
      if (ignoringExpressionOutput.contains(x)) {
        JPrefixOperation newOp = new JPrefixOperation(program,
            x.getSourceInfo(), x.getOp(), x.getArg());
        ctx.replaceMe(newOp);
      }
    }
View Full Code Here

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

                argOp.getRhs());
            ctx.replaceMe(newBinOp);
          }
        } else if (arg instanceof JPrefixOperation) {
          // try to invert the unary operator
          JPrefixOperation argOp = (JPrefixOperation) arg;
          JUnaryOperator op = argOp.getOp();
          // e.g. !!x -> x
          if (op == JUnaryOperator.NOT) {
            ctx.replaceMe(argOp.getArg());
          }
        }
      } else if (x.getOp() == JUnaryOperator.NEG) {
        JExpression updated = simplifyNegate(x, x.getArg());
        if (updated != x) {
View Full Code Here

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

     */
    private void simplifyBooleanEq(JExpression exp, boolean bool, Context ctx) {
      if (bool) {
        ctx.replaceMe(exp);
      } else {
        ctx.replaceMe(new JPrefixOperation(program, exp.getSourceInfo(),
            JUnaryOperator.NOT, exp));
      }
    }
View Full Code Here

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

     * @return A simplified expression equivalent to <code>- exp</code>.
     */
    private JExpression simplifyNegate(JExpression original, JExpression exp) {
      // - -x -> x
      if (exp instanceof JPrefixOperation) {
        JPrefixOperation prefarg = (JPrefixOperation) exp;
        if (prefarg.getOp() == JUnaryOperator.NEG) {
          return prefarg.getArg();
        }
      }

      // no change
      if (original != null) {
        return original;
      }
      return new JPrefixOperation(program, exp.getSourceInfo(),
          JUnaryOperator.NEG, exp);
    }
View Full Code Here

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

      return false;
    }

    private void simplifyXor(JExpression lhs, JBooleanLiteral rhs, Context ctx) {
      if (rhs.getValue()) {
        ctx.replaceMe(new JPrefixOperation(program, lhs.getSourceInfo(),
            JUnaryOperator.NOT, lhs));
      } else {
        ctx.replaceMe(lhs);
      }
    }
View Full Code Here

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

        default:
          throw new InternalCompilerException("Unexpected prefix operator");
      }

      JPrefixOperation preOp = new JPrefixOperation(program, info, op,
          dispProcessExpression(x.lhs));
      return preOp;
    }
View Full Code Here

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

        default:
          throw new InternalCompilerException(
              "Unexpected operator for unary expression");
      }

      JPrefixOperation preOp = new JPrefixOperation(program, info, op,
          dispProcessExpression(x.expression));
      return preOp;
    }
View Full Code Here

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

            createVariableRef(info, indexVar), createVariableRef(info, maxVar));

        // ++i$index
        List<JExpressionStatement> increments = new ArrayList<JExpressionStatement>(
            1);
        increments.add(new JPrefixOperation(program, info, JUnaryOperator.INC,
            createVariableRef(info, indexVar)).makeStatement());

        // T elementVar = i$array[i$index];
        elementDecl.initializer = new JArrayRef(program, info,
            createVariableRef(info, arrayVar),
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.