Package com.google.caja.parser.js

Examples of com.google.caja.parser.js.ExpressionStmt


              // if (foo() && 0) { ... } else { baz(); }  =>  { foo(); baz(); }
            } else {
              optimizeConditional(s, c, i + 2, out);
            }
            List<Statement> stmts = Lists.newArrayList();
            stmts.add(new ExpressionStmt(sideEffect));
            if (out.node instanceof Block) {
              stmts.addAll(((Block) out.node).children());
            } else if (!(out.node instanceof Noop)) {
              stmts.add((Statement) out.node);
            }
View Full Code Here


        public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
          if (node instanceof Expression && scope == null) {
            Expression e = (Expression) node;
            Block bl = new Block(
                e.getFilePosition(),
                Collections.singletonList(new ExpressionStmt(e)));
            scope = Scope.fromProgram(bl, AlphaRenamingRewriter.this);
            contexts.put(scope, rootContext);
            return expand(e, scope);
          }
          return NONE;
View Full Code Here

  public static Reference newReference(FilePosition pos, String name) {
    return new Reference(s(new Identifier(pos, name)));
  }

  protected static ExpressionStmt newExprStmt(Expression e) {
    return new ExpressionStmt(e.getFilePosition(), e);
  }
View Full Code Here

          Declaration d = (Declaration) expandAll(node, scope);
          Statement s;
          if (d.getInitializer() == null) {
            s = new Noop(d.getFilePosition());
          } else {
            s = new ExpressionStmt(
                Operation.createInfix(
                    Operator.ASSIGN, new Reference(d.getIdentifier()),
                    d.getInitializer()));
            getRewriter().markTreeForSideEffect(s);
            d.removeChild(d.getInitializer());
View Full Code Here

    ParseTreeNode result = null;
    // Code translated from another language should not be used as the module
    // result.
    if (isForSideEffect(node)) { return node; }
    if (node instanceof ExpressionStmt) {
      result = new ExpressionStmt(
          node.getFilePosition(),
          (Expression) QuasiBuilder.substV(
              "moduleResult___ = @result;",
              "result", ((ExpressionStmt) node).getExpression()));
    } else if (node instanceof ParseTreeNodeContainer) {
View Full Code Here

TOP

Related Classes of com.google.caja.parser.js.ExpressionStmt

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.