Package com.google.caja.parser.js

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


      if (newChildren.size() < 2) {
        out.node = newChildren.isEmpty()
            ? new Noop(UNK) : (Statement) newChildren.get(0);
        out.digest = optNodeDigest(out.node);
      } else {
        out.node = new Conditional(UNK, null, newChildren);
        out.digest = sb != null ? sb.toString() : null;
      }
    } else {
      out.node = c;
      out.digest = sb != null ? sb.toString() : null;
View Full Code Here


          if (allExit) {
            //    if (foo) return bar; else baz();
            // => if (foo) return bar; baz();
            return combine(
                n.getFilePosition(),
                new Conditional(
                    FilePosition.span(
                        n.getFilePosition(),
                        condParts.get(nCondParts - 1).getFilePosition()),
                null, condParts.subList(0, nCondParts - 1)),
                (Statement) condParts.get(nCondParts - 1));
View Full Code Here

          // where the statement following the if, is implicitly an else
          // statement since the if always returns or throws.
          // We create a fake conditional, and try to optimize it in isolation,
          // which would yield (return baz ? boo() : far()) for the above.
          // This feeds into the tail handling for expression runs below.
          Conditional combined = condAndImplicitElse((Conditional) last, next);
          if (combined != null) {
            ParseTreeNode optCond = optimize(combined, false);
            if (isExpressionListTerminator(optCond)) {
              stmts.subList(i - 1, i + 1).clear();
              stmts.add(i - 1, last = (Statement) optCond);
View Full Code Here

    for (int i = children.size() - 1; i >= 3; i -= 2) {
      if (children.get(i).getClass() != commonType) { return null; }
    }
    List<ParseTreeNode> allChildren = Lists.newArrayList(children);
    allChildren.add(follower);
    return new Conditional(
        FilePosition.span(cond.getFilePosition(), follower.getFilePosition()),
        null, allChildren);
  }
View Full Code Here

        nodes.set(i, returnLast(nodes.get(i)));
      }
      if ((lasti & 1) == 0) {  // else clause
        nodes.set(lasti, returnLast(nodes.get(lasti)));
      }
      result = new Conditional(node.getFilePosition(), null, nodes);
    } else if (node instanceof TryStmt) {
      TryStmt tryer = (TryStmt) node;
      result = new TryStmt(
          node.getFilePosition(),
          (Block) returnLast(tryer.getBody()),
View Full Code Here

          if (allExit) {
            //    if (foo) return bar; else baz();
            // => if (foo) return bar; baz();
            return combine(
                n.getFilePosition(),
                new Conditional(
                    FilePosition.span(
                        n.getFilePosition(),
                        condParts.get(nCondParts - 1).getFilePosition()),
                null, condParts.subList(0, nCondParts - 1)),
                (Statement) condParts.get(nCondParts - 1));
View Full Code Here

          // where the statement following the if, is implicitly an else
          // statement since the if always returns or throws.
          // We create a fake conditional, and try to optimize it in isolation,
          // which would yield (return baz ? boo() : far()) for the above.
          // This feeds into the tail handling for expression runs below.
          Conditional combined = condAndImplicitElse((Conditional) last, next);
          if (combined != null) {
            ParseTreeNode optCond = optimize(combined, false);
            if (isExpressionListTerminator(optCond)) {
              stmts.subList(i - 1, i + 1).clear();
              stmts.add(i - 1, last = (Statement) optCond);
View Full Code Here

    for (int i = children.size() - 1; i >= 3; i -= 2) {
      if (children.get(i).getClass() != commonType) { return null; }
    }
    List<ParseTreeNode> allChildren = Lists.newArrayList(children);
    allChildren.add(follower);
    return new Conditional(
        FilePosition.span(cond.getFilePosition(), follower.getFilePosition()),
        null, allChildren);
  }
View Full Code Here

      if (newChildren.size() < 2) {
        out.node = newChildren.isEmpty()
            ? new Noop(UNK) : (Statement) newChildren.get(0);
        out.digest = optNodeDigest(out.node);
      } else {
        out.node = new Conditional(UNK, null, newChildren);
        out.digest = sb != null ? sb.toString() : null;
      }
    } else {
      out.node = c;
      out.digest = sb != null ? sb.toString() : null;
View Full Code Here

        nodes.set(i, returnLast(nodes.get(i)));
      }
      if ((lasti & 1) == 0) {  // else clause
        nodes.set(lasti, returnLast(nodes.get(lasti)));
      }
      result = new Conditional(node.getFilePosition(), null, nodes);
    } else if (node instanceof TryStmt) {
      TryStmt tryer = (TryStmt) node;
      result = new TryStmt(
          node.getFilePosition(),
          (Block) returnLast(tryer.getBody()),
View Full Code Here

TOP

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

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.