use of com.strobel.decompiler.languages.java.ast.AstType in project j2objc by google.
the class MethodTranslator method visitVariableDeclaration.
@Override
public TreeNode visitVariableDeclaration(com.strobel.decompiler.languages.java.ast.VariableDeclarationStatement node, Void data) {
VariableDeclarationStatement varDecl = new VariableDeclarationStatement().setModifiers(ElementUtil.fromModifierSet(new HashSet<>(node.getModifiers())));
AstType astType = node.getType();
Type type = (Type) astType.acceptVisitor(this, null);
for (VariableInitializer init : node.getVariables()) {
Expression expr = (Expression) init.acceptVisitor(this, null);
String varName = init.getName();
GeneratedVariableElement elem = GeneratedVariableElement.newLocalVar(varName, type.getTypeMirror(), executableElement);
elem.addModifiers(node.getModifiers());
localVariableTable.put(varName, elem);
varDecl.addFragment(new VariableDeclarationFragment(elem, expr));
}
return varDecl;
}
use of com.strobel.decompiler.languages.java.ast.AstType in project j2objc by google.
the class MethodTranslator method visitForEachStatement.
@Override
public TreeNode visitForEachStatement(ForEachStatement node, Void data) {
EnhancedForStatement forStatement = new EnhancedForStatement();
AstType astType = node.getVariableType();
Type type = (Type) astType.acceptVisitor(this, null);
String varName = node.getVariableName();
GeneratedVariableElement elem = GeneratedVariableElement.newLocalVar(varName, type.getTypeMirror(), executableElement);
elem.addModifiers(node.getVariableModifiers());
localVariableTable.put(varName, elem);
return forStatement.setParameter(new SingleVariableDeclaration(elem)).setExpression((Expression) node.getInExpression().acceptVisitor(this, null)).setBody((Statement) node.getEmbeddedStatement().acceptVisitor(this, null));
}
Aggregations