IStatement statement;
switch (statements.size()) {
case 0:
// 块语句没有内容等同于空语句
statement = new EmptyStatement(node, root, scope);
statement.setNext(blockStatement.getNext());
statement.setParent(blockStatement.getParent());
return statement;
case 1:
// 块语句只有一条语句等同于那一条语句
statement = statements.get(0);
statement.setNext(blockStatement.getNext());
statement.setParent(blockStatement.getParent());
return statement;
default:
return blockStatement;
}
}
case Token.VAR:
return new VariableStatement(node, root, scope);
case Token.EMPTY:
return new EmptyStatement(node, root, scope);
case Token.EXPR_RESULT:
case Token.EXPR_VOID:
return new ExpressionStatement(node, root, scope);