Package com.google.gwt.dev.js.ast

Examples of com.google.gwt.dev.js.ast.JsBlock


  private JsNode<?> map(Node node) throws JsParserException {

    switch (node.getType()) {
      case TokenStream.SCRIPT: {
        JsBlock block = new JsBlock(makeSourceInfo(node));
        mapStatements(block.getStatements(), node);
        return block;
      }

      case TokenStream.DEBUGGER:
        return mapDebuggerStatement();
View Full Code Here


    return new JsBinaryOperation(makeSourceInfo(node), op, to1, to2);
  }

  private JsBlock mapBlock(Node nodeStmts) throws JsParserException {
    SourceInfo info = makeSourceInfo(nodeStmts);
    JsBlock block = new JsBlock(info);
    pushSourceInfo(info);
    mapStatements(block.getStatements(), nodeStmts);
    popSourceInfo();
    return block;
  }
View Full Code Here

      fromParamNode = fromParamNode.getNext();
    }

    // Map the function's body.
    //
    JsBlock toBody = mapBlock(fromBodyNode);
    toFn.setBody(toBody);

    // Pop the new function's scope off of the scope stack.
    //
    popScope();
View Full Code Here

    }

    // now install the new statements in the program fragments
    jsprogram.setFragmentCount(fragmentStats.size());
    for (int i = 0; i < fragmentStats.size(); i++) {
      JsBlock fragBlock = jsprogram.getFragmentBlock(i);
      fragBlock.getStatements().clear();
      fragBlock.getStatements().addAll(fragmentStats.get(i));
    }

    PerfLogger.end();
  }
View Full Code Here

    _spaceOpt();
    accept(x.getTryBlock());

    acceptList(x.getCatches());

    JsBlock finallyBlock = x.getFinallyBlock();
    if (finallyBlock != null) {
      _spaceOpt();
      _finally();
      _spaceOpt();
      accept(finallyBlock);
View Full Code Here

  }

  private void assertInFragment(String functionName, int expectedFragmentNumber) {
    Set<Integer> fragments = Sets.newHashSet();
    for (int fragmentNumber = 0; fragmentNumber < jsProgram.getFragmentCount(); fragmentNumber++) {
      JsBlock fragment = jsProgram.getFragmentBlock(fragmentNumber);
      if (findFunctionIn(functionName, fragment)) {
        fragments.add(fragmentNumber);
      }
    }
    assertTrue("function " + functionName + " should be in fragments " + expectedFragmentNumber +
View Full Code Here

    assertTrue("function " + functionName + " should be in fragments " + expectedFragmentNumber +
        " but is in " + fragments, fragments.equals(Sets.newHashSet(expectedFragmentNumber)));
  }

  private void assertNotInFragment(String functionName, int fragmentNum) {
    JsBlock fragment = jsProgram.getFragmentBlock(fragmentNum);
    assertFalse("function " + functionName + " should not be in fragment " + fragmentNum,
        findFunctionIn(functionName, fragment));
  }
View Full Code Here

  private Result parse(String js) {
    try {
      JsProgram program = new JsProgram();
      SourceInfo rootSourceInfo = program.createSourceInfo(1, "test.js");
      JsBlock block = program.getGlobalBlock();
      JsParser.parseInto(rootSourceInfo, program.getScope(), block,
          new StringReader(js));
      return new Result(block);
    } catch (IOException e) {
      throw new RuntimeException("Unexpected error reading in-memory stream", e);
View Full Code Here

    // Function declaration statement.
    JsName name = scope.declareName("package-info", "package-info");
    List<JsStatement> statements = jsProgram.getFragment(0).getGlobalBlock().getStatements();
    final SourceOrigin sourceInfo = SourceOrigin.UNKNOWN;
    JsFunction function = new JsFunction(sourceInfo, scope, name);
    function.setBody(new JsBlock(sourceInfo));
    statements.add(new JsExprStmt(sourceInfo, function));

    // Function invocation statement.
    statements.add(new JsInvocation(sourceInfo, new JsNameRef(sourceInfo, name)).makeStmt());
View Full Code Here

  public void setUp() {
    program = new JsProgram();
    SourceInfo info = program.createSourceInfo(1, "Test.java");
    program.setIndexedFields(fields("CoverageUtil.coverage"));
    program.setIndexedFunctions(functions("CoverageUtil.cover", "CoverageUtil.onBeforeUnload"));
    JsBlock globalBlock = program.getGlobalBlock();
    JsFunction function = new JsFunction(info, program.getScope());
    functionBody = new JsBlock(info);
    function.setBody(functionBody);
    globalBlock.getStatements().add(new JsExprStmt(info, function));
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.js.ast.JsBlock

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.