use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.
the class UnsequencedExpressionRewriter method visit.
@Override
public boolean visit(ForStatement node) {
List<Expression> initializers = node.getInitializers();
// expression or a list of initializer expressions.
if (initializers.size() == 1 && initializers.get(0) instanceof VariableDeclarationExpression) {
VariableDeclarationExpression decl = (VariableDeclarationExpression) initializers.get(0);
extractVariableDeclarationFragments(decl.getFragments(), TreeUtil.asStatementList(node).subList(0, 0));
} else {
extractExpressionList(initializers, TreeUtil.asStatementList(node).subList(0, 0), false);
}
Expression expr = node.getExpression();
if (expr != null) {
newExpression(expr);
expr.accept(this);
List<VariableAccess> toExtract = getUnsequencedAccesses();
if (!toExtract.isEmpty()) {
// Convert "if (;cond;)" into "if (;;) { if (!(cond)) break; ...}".
List<Statement> stmtList = TreeUtil.asStatementList(node.getBody()).subList(0, 0);
extractOrderedAccesses(stmtList, currentTopNode, toExtract);
stmtList.add(createLoopTermination(node.getExpression()));
node.setExpression(null);
}
}
extractExpressionList(node.getUpdaters(), TreeUtil.asStatementList(node.getBody()), true);
node.getBody().accept(this);
return false;
}
use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.
the class NilCheckResolver method visit.
@Override
public boolean visit(ClassInstanceCreation node) {
Expression outerTarget = node.getExpression();
if (outerTarget != null) {
outerTarget.accept(this);
addNilCheck(outerTarget);
}
Expression superOuterArg = node.getSuperOuterArg();
if (superOuterArg != null) {
superOuterArg.accept(this);
addNilCheck(superOuterArg);
}
for (Expression arg : node.getArguments()) {
arg.accept(this);
}
// Don't need to visit AnonymousClassDeclaration child because it's removed by
// AnonymousClassConverter.
removeNonFinalFields();
handleThrows();
return false;
}
use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.
the class NilCheckResolver method visit.
@Override
public boolean visit(ForStatement node) {
for (Expression initializer : node.getInitializers()) {
initializer.accept(this);
}
pushLoopOrSwitchScope(getStatementLabel(node));
for (int i = 0; i < 2; i++) {
Expression expr = node.getExpression();
if (expr != null) {
expr.accept(this);
// Merge loop exit
scope.mergeInto(scope.next, getSafeVarsFalse(expr));
addSafeVars(getSafeVarsTrue(expr));
}
pushScope();
node.getBody().accept(this);
popAndMerge();
for (Expression updater : node.getUpdaters()) {
updater.accept(this);
}
}
popWithoutMerge();
return false;
}
use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.
the class NilCheckResolver method visit.
@Override
public boolean visit(SuperConstructorInvocation node) {
Expression outerTarget = node.getExpression();
if (outerTarget != null) {
outerTarget.accept(this);
addNilCheck(outerTarget);
}
for (Expression arg : node.getArguments()) {
arg.accept(this);
}
removeNonFinalFields();
handleThrows();
return false;
}
use of com.google.devtools.j2objc.ast.Expression in project j2objc by google.
the class NilCheckResolver method visit.
@Override
public boolean visit(DoStatement node) {
pushLoopOrSwitchScope(getStatementLabel(node));
for (int i = 0; i < 2; i++) {
pushScope();
node.getBody().accept(this);
popAndMerge();
Expression expr = node.getExpression();
expr.accept(this);
// Merge loop exit
scope.mergeInto(scope.next, getSafeVarsFalse(expr));
addSafeVars(getSafeVarsTrue(expr));
}
popWithoutMerge();
return false;
}
Aggregations