Examples of JsStatements


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

    }

    // @Override
    public void endVisit(JBlock x, Context ctx) {
      JsBlock jsBlock = new JsBlock();
      JsStatements stmts = jsBlock.getStatements();
      popList(stmts, x.statements.size()); // stmts
      Iterator iterator = stmts.iterator();
      while (iterator.hasNext()) {
        JsStatement stmt = (JsStatement) iterator.next();
        if (stmt == jsProgram.getEmptyStmt()) {
          iterator.remove();
        }
View Full Code Here

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

        handleClinit((JsFunction) jsFuncs.get(0), superType);
      } else {
        jsFuncs.set(0, null);
      }

      JsStatements globalStmts = jsProgram.getGlobalBlock().getStatements();

      // declare all methods into the global scope
      for (int i = 0; i < jsFuncs.size(); ++i) {
        JsFunction func = (JsFunction) jsFuncs.get(i);
        if (func != null) {
          globalStmts.add(func.makeStmt());
        }
      }

      if (typeOracle.isInstantiatedType(x)) {
        generateClassSetup(x, globalStmts);
      }

      // setup fields
      JsVars vars = new JsVars();
      for (int i = 0; i < jsFields.size(); ++i) {
        JsNode node = (JsNode) jsFields.get(i);
        if (node instanceof JsVar) {
          vars.add((JsVar) node);
        } else {
          assert (node instanceof JsStatement);
          JsStatement stmt = (JsStatement) jsFields.get(i);
          globalStmts.add(stmt);
        }
      }
      if (!vars.isEmpty()) {
        globalStmts.add(vars);
      }
    }
View Full Code Here

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

    // @Override
    public void endVisit(JInterfaceType x, Context ctx) {
      List/* <JsFunction> */jsFuncs = popList(x.methods.size()); // methods
      List/* <JsStatement> */jsFields = popList(x.fields.size()); // fields

      JsStatements globalStmts = jsProgram.getGlobalBlock().getStatements();

      if (typeOracle.hasDirectClinit(x)) {
        JsFunction clinitFunc = (JsFunction) jsFuncs.get(0);
        handleClinit(clinitFunc, null);
        globalStmts.add(clinitFunc.makeStmt());
      }

      // setup fields
      JsVars vars = new JsVars();
      for (int i = 0; i < jsFields.size(); ++i) {
        JsNode node = (JsNode) jsFields.get(i);
        assert (node instanceof JsVar);
        vars.add((JsVar) node);
      }
      if (!vars.isEmpty()) {
        globalStmts.add(vars);
      }
    }
View Full Code Here

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

      push(op);
    }

    // @Override
    public void endVisit(JProgram x, Context ctx) {
      JsStatements globalStmts = jsProgram.getGlobalBlock().getStatements();

      // types don't push

      // Generate entry methods
      List/* <JsFunction> */entryFuncs = popList(x.entryMethods.size()); // entryMethods
      for (int i = 0; i < entryFuncs.size(); ++i) {
        JsFunction func = (JsFunction) entryFuncs.get(i);
        if (func != null) {
          globalStmts.add(func.makeStmt());
        }
      }

      generateGwtOnLoad(entryFuncs, globalStmts);

      // a few more vars on the very end
      JsVars vars = new JsVars();
      generateTypeTable(vars);
      generateClassLiterals(vars);
      globalStmts.add(vars);
    }
View Full Code Here

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

      return true;
    }

    // @Override
    public boolean visit(JProgram x, Context ctx) {
      JsStatements globalStatements = jsProgram.getGlobalBlock().getStatements();

      // declare some global vars
      JsVars vars = new JsVars();

      // reserve the "_" identifier
      vars.add(new JsVar(globalTemp));
      generatePackageNames(vars);
      globalStatements.add(vars);

      generateNullFunc(globalStatements);
      return true;
    }
View Full Code Here

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

      accept(x.getExpr());
      jsSwitch.setExpr((JsExpression) pop()); // expr

      List/* <JStatement> */bodyStmts = x.getBody().statements;
      if (bodyStmts.size() > 0) {
        JsStatements curStatements = null;
        for (int i = 0; i < bodyStmts.size(); ++i) {
          JStatement stmt = (JStatement) bodyStmts.get(i);
          accept(stmt);
          if (stmt instanceof JCaseStatement) {
            // create a new switch member
            JsSwitchMember switchMember = (JsSwitchMember) pop(); // stmt
            jsSwitch.getCases().add(switchMember);
            curStatements = switchMember.getStmts();
          } else {
            // add to statements for current case
            assert (curStatements != null);
            JsStatement newStmt = (JsStatement) pop(); // stmt
            if (newStmt != null) {
              // Empty JLocalDeclarationStatement produces a null
              curStatements.add(newStmt);
            }
          }
        }
      }

View Full Code Here

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

        }
      }
    }

    private void handleClinit(JsFunction clinitFunc, JReferenceType chainTo) {
      JsStatements statements = clinitFunc.getBody().getStatements();
      // self-assign to the null method immediately (to prevent reentrancy)
      JsExpression asg = createAssignment(clinitFunc.getName().makeRef(),
          nullMethodName.makeRef());
      statements.add(0, asg.makeStmt());
      if (chainTo != null) {
        JMethod chainToMeth = (JMethod) chainTo.methods.get(0);
        JsInvocation jsInvocation = new JsInvocation();
        JsNameRef qualifier = getName(chainToMeth).makeRef();
        jsInvocation.setQualifier(qualifier);
        statements.add(1, jsInvocation.makeStmt());
      }
    }
View Full Code Here

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

          StringReader sr = new StringReader(syntheticFnHeader + '\n'
              + jsniCode);
          try {
            // start at -1 to avoid counting our synthetic header
            // TODO: get the character position start correct
            JsStatements result = jsParser.parse(jsProgram.getScope(), sr, -1);
            JsExprStmt jsExprStmt = (JsExprStmt) result.get(0);
            JsFunction jsFunction = (JsFunction) jsExprStmt.getExpression();
            ((JsniMethod) newMethod).setFunc(jsFunction);
          } catch (IOException e) {
            throw new InternalCompilerException(
                "Internal error parsing JSNI in method '" + newMethod
View Full Code Here

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

    JsParser jsParser = new JsParser();
    JsProgram jsPgm = new JsProgram();
    StringReader r = new StringReader(js);

    try {
      JsStatements stmts = jsParser.parse(jsPgm.getScope(), r, startLine);

      // Rip the body out of the parsed function and attach the JavaScript
      // AST to the method.
      //
      JsFunction fn = (JsFunction) ((JsExprStmt) stmts.get(0)).getExpression();
      return fn.getBody();
    } catch (IOException e) {
      logger.log(TreeLogger.ERROR, "Error reading JavaScript source", e);
      throw new UnableToCompleteException();
    } catch (JsParserException e) {
View Full Code Here

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

    }
    syntheticFnHeader += ')';
    StringReader sr = new StringReader(syntheticFnHeader + '\n' + jsniCode);
    try {
      // start at -1 to avoid counting our synthetic header
      JsStatements result = jsParser.parse(jsProgram.getScope(), sr, -1);
      new JsVisitor() {
        public void endVisit(JsNameRef x, JsContext ctx) {
          String ident = x.getIdent();
          if (ident.charAt(0) == '@') {
            String className = ident.substring(1, ident.indexOf(':'));
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.