fix localvardecl
This commit is contained in:
parent
d4cc24239d
commit
a97548c3ee
@ -39,7 +39,7 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
hasMain = false;
|
||||
}
|
||||
for (DecafParser.LocalVarDeclContext fieldDecl: ctx.localVarDecl()) {
|
||||
fieldDecls.add((FieldDecl) visit(fieldDecl));
|
||||
fieldDecls.add((FieldDecl) generateFieldDecl(fieldDecl));
|
||||
}
|
||||
for (DecafParser.ConstuctorDeclContext constDecl: ctx.constuctorDecl()) {
|
||||
MethodDecl constructor = ((MethodDecl) visit(constDecl));
|
||||
@ -54,9 +54,13 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
return new RefType(name,fieldDecls, methodDecls, hasMain);
|
||||
}
|
||||
|
||||
public Node generateFieldDecl(DecafParser.LocalVarDeclContext ctx) {
|
||||
return new FieldDecl(ctx.type().getText(), ctx.Identifier().getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node visitLocalVarDecl(DecafParser.LocalVarDeclContext ctx) {
|
||||
return new FieldDecl(ctx.type().getText(), ctx.Identifier().getText());
|
||||
return new LocalVarDecl(ctx.type().getText(), ctx.Identifier().getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,6 +112,8 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
return visitStmtExpr(ctx.stmtExpr());
|
||||
} else if (ctx.emptyStatement() != null) {
|
||||
return visitEmptyStatement(ctx.emptyStatement());
|
||||
} else if (ctx.localVarDecl() != null) {
|
||||
return visitLocalVarDecl(ctx.localVarDecl());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user