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

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


    public void endVisit(JDeclarationStatement x, Context ctx) {
      JExpression init = x.getInitializer();
      if (init != null) {
        init = checkAndReplace(init, x.getVariableRef().getType());
        if (init != x.getInitializer()) {
          JDeclarationStatement newStmt =
              new JDeclarationStatement(x.getSourceInfo(), x.getVariableRef(), init);
          ctx.replaceMe(newStmt);
        }
      }
    }
View Full Code Here


          JExpression orExp = new JInstanceOf(catchInfo, (JReferenceType) exceptionsTypes.get(j),
              new JLocalRef(catchInfo, exceptionVariable));
          ifTest = new JBinaryOperation(catchInfo, JPrimitiveType.BOOLEAN, JBinaryOperator.OR,
              ifTest, orExp);
        }
        JDeclarationStatement declaration =
            new JDeclarationStatement(catchInfo, arg, new JLocalRef(catchInfo, exceptionVariable));
        block.addStmt(0, declaration);
        // nest the previous as an else for me
        cur = new JIfStatement(catchInfo, ifTest, block, cur);
      }
View Full Code Here

    // TODO: not a pretty assumption detection.
    for (JStatement stmt : statements) {
      if (!(stmt instanceof JDeclarationStatement)) {
        continue;
      }
      JDeclarationStatement decl = (JDeclarationStatement) stmt;
      if (decl.getInitializer() != null) {
        updater.set(decl.getVariableRef().getTarget(),
            (JValueLiteral) decl.getInitializer());
      }
    }

    JReturnStatement returnStatement =
      (JReturnStatement) statements.get(statements.size() - 1);
View Full Code Here

     * when the block contains no local declarations.
     */
    private boolean canPromoteBlock(JBlock block) {
      for (JStatement nestedStmt : block.statements) {
        if (nestedStmt instanceof JDeclarationStatement) {
          JDeclarationStatement decl = (JDeclarationStatement) nestedStmt;
          if (decl.getVariableRef() instanceof JLocalRef) {
            return false;
          }
        }
      }
      return true;
View Full Code Here

    public void endVisit(JDeclarationStatement x, Context ctx) {
      JExpression init = x.getInitializer();
      if (init != null) {
        init = checkAndReplace(init, x.getVariableRef().getType());
        if (init != x.getInitializer()) {
          JDeclarationStatement newStmt = new JDeclarationStatement(program,
              x.getSourceInfo(), x.getVariableRef(), init);
          ctx.replaceMe(newStmt);
        }
      }
    }
View Full Code Here

          if (!x.isStatic()) {
            instance = makeThisRef(info);
          }
          // JDeclarationStatement's ctor sets up the field's initializer.
          JStatement decl =
              new JDeclarationStatement(info, new JFieldRef(info, instance, field, curClass.type),
                  initialization);
          // will either be init or clinit
          curMethod.body.getBlock().addStmt(decl);
        }
        popMethodInfo();
View Full Code Here

      try {
        SourceInfo info = makeSourceInfo(x);

        JBlock body = popBlock(info, x.action);
        JExpression collection = pop(x.collection);
        JDeclarationStatement elementDecl = pop(x.elementVariable);
        assert (elementDecl.initializer == null);

        JLocal elementVar = (JLocal) curMethod.locals.get(x.elementVariable.binding);
        String elementVarName = elementVar.getName();
View Full Code Here

        SourceInfo info = makeSourceInfo(x);
        JLocal local = (JLocal) curMethod.locals.get(x.binding);
        assert local != null;
        JLocalRef localRef = new JLocalRef(info, local);
        JExpression initialization = pop(x.initialization);
        push(new JDeclarationStatement(info, localRef, initialization));
      } catch (Throwable e) {
        throw translateException(x, e);
      }
    }
View Full Code Here

      // add resource variables
      List<JLocal> resourceVariables = Lists.newArrayList();
      for (int i = x.resources.length - 1; i >= 0; i--) {
        // Needs to iterate back to front to be inline with the contents of the stack.

        JDeclarationStatement resourceDecl = pop(x.resources[i]);

        JLocal resourceVar = (JLocal) curMethod.locals.get(x.resources[i].binding);
        resourceVariables.add(0, resourceVar);
        innerBlock.addStmt(0, resourceDecl);
      }
View Full Code Here

      block.clear();
      block.addStmt(new JReturnStatement(info, returnValue));
    }

    private JDeclarationStatement makeDeclaration(SourceInfo info, JLocal local, JExpression value) {
      return new JDeclarationStatement(info, new JLocalRef(info, local), value);
    }
View Full Code Here

TOP

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

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.