minor generator changes

This commit is contained in:
laurenz 2024-05-07 13:01:28 +02:00
parent c2ce7ff80f
commit 535c712421
2 changed files with 5 additions and 14 deletions

View File

@ -37,16 +37,13 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
@Override @Override
public Expression visitExpression(DecafParser.ExpressionContext ctx) { public Expression visitExpression(DecafParser.ExpressionContext ctx) {
//ParseTree for ( expr ) //ParseTree for ( expr )
//Just pass it down to the inner expr: // pass it down to the inner expr:
return this.visit(ctx.expr()); return this.visit(ctx.expr());
} }
@Override @Override
public Expression visitIdentifier(DecafParser.IdentifierContext ctx){ public Expression visitIdentifier(DecafParser.IdentifierContext ctx){
Boolean isField = false; boolean isField = ctx.fieldId().THIS() != null;
if(ctx.fieldId().THIS() != null){
isField = true;
}
Expression recipient = null; Expression recipient = null;
if(ctx.fieldId().recipient() != null){ if(ctx.fieldId().recipient() != null){
List<DecafParser.RecipientContext> recipientList = ctx.fieldId().recipient(); List<DecafParser.RecipientContext> recipientList = ctx.fieldId().recipient();
@ -89,10 +86,7 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
@Override @Override
public Expression visitMethodCall(DecafParser.MethodCallContext ctx) { public Expression visitMethodCall(DecafParser.MethodCallContext ctx) {
Boolean isField = false; boolean isField = ctx.methCall().THIS() != null;
if(ctx.methCall().THIS() != null){
isField = true;
}
Expression recipient = null; Expression recipient = null;
if(ctx.methCall().recipient() != null){ if(ctx.methCall().recipient() != null){
List<DecafParser.RecipientContext> recipientList = ctx.methCall().recipient(); List<DecafParser.RecipientContext> recipientList = ctx.methCall().recipient();

View File

@ -77,14 +77,11 @@ public class StatementGenerator extends DecafBaseVisitor<Statement> {
//StatementExpression //StatementExpression
@Override @Override
public Statement visitMethodCall(DecafParser.MethodCallContext ctx) { public Statement visitMethodCall(DecafParser.MethodCallContext ctx) {
Boolean isField = false; boolean isField = ctx.methCall().THIS() != null;
if(ctx.methCall().THIS() != null){
isField = true;
}
Expression recipient = null; Expression recipient = null;
if(ctx.methCall().recipient() != null){ if(ctx.methCall().recipient() != null){
List<DecafParser.RecipientContext> recipientList = ctx.methCall().recipient(); List<DecafParser.RecipientContext> recipientList = ctx.methCall().recipient();
recipient = new ExpressionGenerator().generateRecipient(recipientList, null); recipient = ExpressionGenerator.generateRecipient(recipientList, null);
} }
Id id = new Id(ctx.methCall().methName().id().getText()); Id id = new Id(ctx.methCall().methName().id().getText());
List<Expression> args = new ArrayList<>(); List<Expression> args = new ArrayList<>();