Package com.google.javascript.rhino

Examples of com.google.javascript.rhino.Node.addChildToBack()


  private void testBinop(FlowScope blind, int binop, Node left, Node right,
      Collection<TypedName> trueOutcome,
      Collection<TypedName> falseOutcome) {
    Node condition = new Node(binop);
    condition.addChildToBack(left);
    condition.addChildToBack(right);

    // true outcome.
    FlowScope informedTrue = interpreter.
        getPreciserScopeKnowingConditionOutcome(condition, blind, true);
    for (TypedName p : trueOutcome) {
View Full Code Here


        int valueBudget =
            (int) (budget * getOwnConfig().get("valueBudget").getAsDouble());
        if (valueBudget == 0) {
          valueBudget = 1;
        }
        clause.addChildToBack(
            new ExpressionFuzzer(context).
            generate(valueBudget));
        budget -= valueBudget;
      }
      // increase budget by one to generate the synthetic block node for free
View Full Code Here

    Scope localScope = context.scopeManager.localScope();
    double toLabel = getOwnConfig().get("toLabel").getAsDouble();
    if (budget > 1 &&
        localScope.loopLabels.size() + localScope.otherLabels.size() > 0 &&
        context.random.nextDouble() < toLabel) {
      node.addChildToBack(
          Node.newString(Token.LABEL_NAME,
              localScope.randomLabelForBreak(context.random)));
    }
    return node;
  }
View Full Code Here

        fuzzers,
        new SourceElementFuzzer(context));
    Node[] components = distribute(paramBodyBudget, fuzzers);
    Node body = new Node(Token.BLOCK);
    for (int i = 0; i < numStmts; i++) {
      body.addChildToBack(components[i]);
    }
    scopeManager.removeScope();
    return new Node(Token.FUNCTION,
        name, params, body);
  }
View Full Code Here

     */
    @Override
    protected Node generate(int budget, Set<Type> types) {
      Node node = new Node(Token.PARAM_LIST);
      for (int i = 0; i < budget - 1; i++) {
        node.addChildToBack(getIdFuzzer().generate(1));
      }
      return node;
    }

    /* (non-Javadoc)
 
View Full Code Here

    }

    // The jsRoot needs a parent (in a normal compilation this would be the
    // node that contains jsRoot and the externs).
    Node syntheticExternsAndJsRoot = IR.block();
    syntheticExternsAndJsRoot.addChildToBack(syntheticModuleJsRoot);

    return syntheticModuleJsRoot;
  }

  /**
 
View Full Code Here

    if (arraySize > 0) {
      AbstractFuzzer[] fuzzers = new AbstractFuzzer[arraySize];
      Arrays.fill(fuzzers, new ExpressionFuzzer(context));
      Node[] elements = distribute(budget - 1, fuzzers);
      for (int i = 0; i < arraySize; i++) {
        node.addChildToBack(elements[i]);
      }
    }
    return node;
  }
View Full Code Here

    // Getters and setters and not supported in ES3 but if someone sets the
    // the ES3 output mode on an AST containing them we still produce them.
    languageMode = LanguageMode.ECMASCRIPT3;

    Node getter = Node.newString(Token.GETTER_DEF, "f");
    getter.addChildToBack(IR.function(IR.name(""), IR.paramList(), IR.block()));
    assertPrintNode("({get f(){}})",
        IR.exprResult(IR.objectlit(getter)));
  }

View Full Code Here

    // Getters and setters and not supported in ES3 but if someone sets the
    // the ES3 output mode on an AST containing them we still produce them.
    languageMode = LanguageMode.ECMASCRIPT3;

    Node getter = Node.newString(Token.SETTER_DEF, "f");
    getter.addChildToBack(IR.function(
        IR.name(""), IR.paramList(IR.name("a")), IR.block()));
    assertPrintNode("({set f(a){}})",
        IR.exprResult(IR.objectlit(getter)));
  }
View Full Code Here

      current = new Node(Token.COMMA, current);

      // 1000 is printed as 1E3, and screws up our test.
      int num = i % 1000;
      numbers.add(String.valueOf(num));
      current.addChildToBack(Node.newNumber(num));
    }

    String expected = Joiner.on(",").join(numbers);
    String actual = printNode(current).replace("\n", "");
    assertEquals(expected, actual);
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.