Package com.google.gwt.dev.jjs.ast

Examples of com.google.gwt.dev.jjs.ast.JStatement


      boolean removeBody = isOptimizedFalse(x.condition);

      List/* <? extends JStatement> */init = processStatements(x.initializations);
      JExpression expr = dispProcessExpression(x.condition);
      List/* <JExpressionStatement> */incr = processStatements(x.increments);
      JStatement body = removeBody ? null : dispProcessStatement(x.action);
      return new JForStatement(program, info, init, expr, incr, body);
    }
View Full Code Here


      boolean removeThen = isOptimizedFalse(x.condition);
      boolean removeElse = isOptimizedTrue(x.condition);

      SourceInfo info = makeSourceInfo(x);
      JExpression expr = dispProcessExpression(x.condition);
      JStatement thenStmt = removeThen ? null
          : dispProcessStatement(x.thenStatement);
      JStatement elseStmt = removeElse ? null
          : dispProcessStatement(x.elseStatement);
      JIfStatement ifStmt = new JIfStatement(program, info, expr, thenStmt,
          elseStmt);
      return ifStmt;
    }
View Full Code Here

          elseStmt);
      return ifStmt;
    }

    JStatement processStatement(LabeledStatement x) {
      JStatement body = dispProcessStatement(x.statement);
      if (body == null) {
        return null;
      }
      SourceInfo info = makeSourceInfo(x);
      return new JLabeledStatement(program, info, getOrCreateLabel(info,
View Full Code Here

      // If the condition is false, don't process the body
      boolean removeBody = isOptimizedFalse(x.condition);

      SourceInfo info = makeSourceInfo(x);
      JExpression loopTest = dispProcessExpression(x.condition);
      JStatement loopBody = removeBody ? null : dispProcessStatement(x.action);
      JWhileStatement stmt = new JWhileStatement(program, info, loopTest,
          loopBody);
      return stmt;
    }
View Full Code Here

    List/* <? extends JStatement> */processStatements(Statement[] statements) {
      List/* <JStatement> */jstatements = new ArrayList/* <JStatement> */();
      if (statements != null) {
        for (int i = 0, n = statements.length; i < n; ++i) {
          JStatement jstmt = dispProcessStatement(statements[i]);
          if (jstmt != null) {
            jstatements.add(jstmt);
          }
        }
      }
View Full Code Here

       * exception object against the type of the user's catch block.
       *
       * Go backwards so we can nest the else statements in the correct order!
       */
      // rethrow the current exception if no one caught it
      JStatement cur = new JThrowStatement(program, null, exRef);
      for (int i = x.getCatchBlocks().size() - 1; i >= 0; --i) {
        JBlock block = (JBlock) x.getCatchBlocks().get(i);
        JLocalRef arg = (JLocalRef) x.getCatchArgs().get(i);
        catchInfo = block.getSourceInfo();
        JReferenceType argType = (JReferenceType) arg.getType();
View Full Code Here

      List<JStatement> bodyStmts = x.getBody().getStatements();
      if (bodyStmts.size() > 0) {
        List<JsStatement> curStatements = null;
        for (int i = 0; i < bodyStmts.size(); ++i) {
          JStatement stmt = bodyStmts.get(i);
          accept(stmt);
          if (stmt instanceof JCaseStatement) {
            // create a new switch member
            JsSwitchMember switchMember = (JsSwitchMember) pop(); // stmt
            jsSwitch.getCases().add(switchMember);
View Full Code Here

      /*
       * Remove any dead statements after an abrupt change in code flow and
       * promote safe statements within nested blocks to this block.
       */
      for (int i = 0; i < x.statements.size(); i++) {
        JStatement stmt = x.statements.get(i);

        if (stmt instanceof JBlock) {
          /*
           * Promote a sub-block's children to the current block, unless the
           * sub-block contains local declarations as children.
           */
          JBlock block = (JBlock) stmt;
          if (canPromoteBlock(block)) {
            x.statements.remove(i);
            x.statements.addAll(i, block.statements);
            i--;
            didChange = true;
            continue;
          }
        }

        if (stmt.unconditionalControlBreak()) {
          // Abrupt change in flow, chop the remaining items from this block
          for (int j = i + 1; j < x.statements.size();) {
            x.statements.remove(j);
            didChange = true;
          }
View Full Code Here

     * Simplify if statements.
     */
    @Override
    public void endVisit(JIfStatement x, Context ctx) {
      JExpression expr = x.getIfExpr();
      JStatement thenStmt = x.getThenStmt();
      JStatement elseStmt = x.getElseStmt();
      if (expr instanceof JBooleanLiteral) {
        JBooleanLiteral booleanLiteral = (JBooleanLiteral) expr;
        boolean boolVal = booleanLiteral.getValue();
        if (boolVal && !isEmpty(thenStmt)) {
          // If true, replace myself with then statement
View Full Code Here

     */
    private void removeDoubleBreaks(JSwitchStatement x) {
      JBlock body = x.getBody();
      boolean lastWasBreak = true;
      for (Iterator<JStatement> it = body.statements.iterator(); it.hasNext();) {
        JStatement statement = it.next();
        boolean isBreak = isUnconditionalBreak(statement);
        if (isBreak && lastWasBreak) {
          it.remove();
          didChange = true;
        }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.jjs.ast.JStatement

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.