Search in sources :

Example 1 with DoStatement

use of com.google.devtools.j2objc.ast.DoStatement in project j2objc by google.

the class UnsequencedExpressionRewriter method visit.

@Override
public boolean visit(DoStatement node) {
    node.getBody().accept(this);
    newExpression(node.getExpression());
    node.getExpression().accept(this);
    List<VariableAccess> toExtract = getUnsequencedAccesses();
    if (!toExtract.isEmpty()) {
        // Convert "while (cond)" into "while (true) { if (!(cond)) break; ... }".
        List<Statement> stmtList = TreeUtil.asStatementList(node.getBody());
        extractOrderedAccesses(stmtList, currentTopNode, toExtract);
        stmtList.add(createLoopTermination(node.getExpression()));
        node.setExpression(new BooleanLiteral(true, typeUtil));
    }
    return false;
}
Also used : ExpressionStatement(com.google.devtools.j2objc.ast.ExpressionStatement) AssertStatement(com.google.devtools.j2objc.ast.AssertStatement) ForStatement(com.google.devtools.j2objc.ast.ForStatement) SynchronizedStatement(com.google.devtools.j2objc.ast.SynchronizedStatement) DoStatement(com.google.devtools.j2objc.ast.DoStatement) EnhancedForStatement(com.google.devtools.j2objc.ast.EnhancedForStatement) VariableDeclarationStatement(com.google.devtools.j2objc.ast.VariableDeclarationStatement) WhileStatement(com.google.devtools.j2objc.ast.WhileStatement) BreakStatement(com.google.devtools.j2objc.ast.BreakStatement) IfStatement(com.google.devtools.j2objc.ast.IfStatement) Statement(com.google.devtools.j2objc.ast.Statement) ReturnStatement(com.google.devtools.j2objc.ast.ReturnStatement) ThrowStatement(com.google.devtools.j2objc.ast.ThrowStatement) SwitchStatement(com.google.devtools.j2objc.ast.SwitchStatement) BooleanLiteral(com.google.devtools.j2objc.ast.BooleanLiteral)

Aggregations

AssertStatement (com.google.devtools.j2objc.ast.AssertStatement)1 BooleanLiteral (com.google.devtools.j2objc.ast.BooleanLiteral)1 BreakStatement (com.google.devtools.j2objc.ast.BreakStatement)1 DoStatement (com.google.devtools.j2objc.ast.DoStatement)1 EnhancedForStatement (com.google.devtools.j2objc.ast.EnhancedForStatement)1 ExpressionStatement (com.google.devtools.j2objc.ast.ExpressionStatement)1 ForStatement (com.google.devtools.j2objc.ast.ForStatement)1 IfStatement (com.google.devtools.j2objc.ast.IfStatement)1 ReturnStatement (com.google.devtools.j2objc.ast.ReturnStatement)1 Statement (com.google.devtools.j2objc.ast.Statement)1 SwitchStatement (com.google.devtools.j2objc.ast.SwitchStatement)1 SynchronizedStatement (com.google.devtools.j2objc.ast.SynchronizedStatement)1 ThrowStatement (com.google.devtools.j2objc.ast.ThrowStatement)1 VariableDeclarationStatement (com.google.devtools.j2objc.ast.VariableDeclarationStatement)1 WhileStatement (com.google.devtools.j2objc.ast.WhileStatement)1