Fix args null in New

This commit is contained in:
Boolean-True 2024-05-14 23:03:34 +02:00
parent f5cc94316e
commit 3e64278624

View File

@ -106,9 +106,11 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
public Expression visitNew(DecafParser.NewContext ctx) {
Type type = ASTGenerator.getType(ctx.type());
List<Expression> args = new ArrayList<>();
for (var expr : ctx.args().expr()) {
Expression astExpr = expr.accept(this);
args.add(astExpr);
if (ctx.args() != null) {
for (var expr : ctx.args().expr()) {
Expression astExpr = expr.accept(this);
args.add(astExpr);
}
}
return new New(type, args);
}