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

View File

@ -77,14 +77,11 @@ public class StatementGenerator extends DecafBaseVisitor<Statement> {
//StatementExpression
@Override
public Statement visitMethodCall(DecafParser.MethodCallContext ctx) {
Boolean isField = false;
if(ctx.methCall().THIS() != null){
isField = true;
}
boolean isField = ctx.methCall().THIS() != null;
Expression recipient = null;
if(ctx.methCall().recipient() != null){
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());
List<Expression> args = new ArrayList<>();