From 735781a63c24875aba2e61532eafc3085f85475f Mon Sep 17 00:00:00 2001 From: ahmad Date: Thu, 9 May 2024 18:39:44 +0200 Subject: [PATCH] renamed the static method --- .../de/maishai/typedast/Util/TypedExpressionUtil.java | 8 ++++---- .../de/maishai/typedast/typedclass/TypedAssignment.java | 4 ++-- .../java/de/maishai/typedast/typedclass/TypedBinary.java | 7 +++---- .../java/de/maishai/typedast/typedclass/TypedBlock.java | 5 ++--- .../java/de/maishai/typedast/typedclass/TypedDoWhile.java | 6 ++++-- .../maishai/typedast/typedclass/TypedFieldVarAccess.java | 4 ++-- .../java/de/maishai/typedast/typedclass/TypedFor.java | 4 ++-- .../java/de/maishai/typedast/typedclass/TypedIfElse.java | 4 ++-- .../de/maishai/typedast/typedclass/TypedMethodCall.java | 3 ++- .../java/de/maishai/typedast/typedclass/TypedReturn.java | 4 ++-- .../java/de/maishai/typedast/typedclass/TypedUnary.java | 4 ++-- .../java/de/maishai/typedast/typedclass/TypedWhile.java | 4 ++-- 12 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/main/java/de/maishai/typedast/Util/TypedExpressionUtil.java b/src/main/java/de/maishai/typedast/Util/TypedExpressionUtil.java index 72f3dd9..58872ee 100644 --- a/src/main/java/de/maishai/typedast/Util/TypedExpressionUtil.java +++ b/src/main/java/de/maishai/typedast/Util/TypedExpressionUtil.java @@ -9,7 +9,7 @@ import java.util.Map; public class TypedExpressionUtil { - public static TypedExpression GET_KIND_OF_EXPRESSION(Map localVar, Map classes, Expression expression) { + public static TypedExpression getKindOfExpression(Map localVar, Map classes, Expression expression) { if (expression instanceof BoolLiteral boolLiteral) { TypedBoolLiteral typedBoolLiteral = new TypedBoolLiteral(); typedBoolLiteral.setValue(boolLiteral.value()); @@ -44,7 +44,7 @@ public class TypedExpressionUtil { typedFieldVarAccess.setField(methodCall.recipient().field()); typedMethodCall.setRecipient(typedFieldVarAccess); for (var arg : methodCall.args()) { - typedMethodCall.getArgs().add(GET_KIND_OF_EXPRESSION(localVar, classes, arg)); + typedMethodCall.getArgs().add(getKindOfExpression(localVar, classes, arg)); } return typedMethodCall; } @@ -52,14 +52,14 @@ public class TypedExpressionUtil { TypedNew typedNew = new TypedNew(); typedNew.setType(newStmt.type()); for (var arg : newStmt.args()) { - typedNew.getArgs().add(GET_KIND_OF_EXPRESSION(localVar, classes, arg)); + typedNew.getArgs().add(getKindOfExpression(localVar, classes, arg)); } return typedNew; } else if (expression instanceof Unary unary) { TypedUnary typedUnary = new TypedUnary(); typedUnary.setOp(unary.op()); - typedUnary.setRight(GET_KIND_OF_EXPRESSION(localVar, classes, unary.right())); + typedUnary.setRight(getKindOfExpression(localVar, classes, unary.right())); return typedUnary; } else { return null; diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java b/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java index bfe08a0..a62b1c8 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java @@ -12,7 +12,7 @@ import org.objectweb.asm.Opcodes; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedAssignment implements TypedStatement { @@ -22,7 +22,7 @@ public class TypedAssignment implements TypedStatement { public TypedAssignment convertToTypedAssignment(Map localVar, Map classes, Assignment untyped) { varName = untyped.location().id(); - value = GET_KIND_OF_EXPRESSION(localVar, classes, untyped.value()); + value = getKindOfExpression(localVar, classes, untyped.value()); return this; } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedBinary.java b/src/main/java/de/maishai/typedast/typedclass/TypedBinary.java index 6f5a1bd..f502f4e 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedBinary.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedBinary.java @@ -3,7 +3,6 @@ package de.maishai.typedast.typedclass; import de.maishai.ast.Operator; import de.maishai.ast.records.Binary; import de.maishai.typedast.MethodContext; -import de.maishai.ast.records.*; import de.maishai.typedast.TypedExpression; import de.maishai.typedast.TypedNode; import de.maishai.typedast.Type; @@ -12,7 +11,7 @@ import org.objectweb.asm.MethodVisitor; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedBinary implements TypedExpression { @@ -22,8 +21,8 @@ public class TypedBinary implements TypedExpression { private Type type; public TypedBinary convertToTypedBinary(Map localVar, Map classes, Binary unTypedBinary) { - left = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedBinary.left()); - right = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedBinary.right()); + left = getKindOfExpression(localVar, classes, unTypedBinary.left()); + right = getKindOfExpression(localVar, classes, unTypedBinary.right()); op = unTypedBinary.op(); return this; } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java b/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java index 2f2b3c8..c4c0461 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedBlock.java @@ -52,8 +52,7 @@ public class TypedBlock implements TypedNode { continue; } if (stmt instanceof For forStmt) { - TypedFor typedFor = new TypedFor() - .convertToTypedFor(localVar, classes, forStmt); + TypedFor typedFor = new TypedFor().convertToTypedFor(localVar, classes, forStmt); typedFor.typeCheck(localVar, classes); typedBlock.getStmts().add(typedFor); continue; @@ -105,7 +104,7 @@ public class TypedBlock implements TypedNode { } } } - + System.out.println("typedBlock: " + typedBlock.toString()); return typedBlock; } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedDoWhile.java b/src/main/java/de/maishai/typedast/typedclass/TypedDoWhile.java index c57fbc8..08de32e 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedDoWhile.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedDoWhile.java @@ -7,16 +7,18 @@ import org.objectweb.asm.MethodVisitor; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedDoWhile implements TypedStatement { private TypedBlock typedBlock; private TypedExpression cond; + public TypedDoWhile() { + } public TypedDoWhile convertToTypedDoWhile(Map localVar, Map classes, DoWhile unTypedDoWhile) { typedBlock = new TypedBlock().blockToTypedBlock(localVar, classes, unTypedDoWhile.block()); - cond = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedDoWhile.cond()); + cond = getKindOfExpression(localVar, classes, unTypedDoWhile.cond()); return this; } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedFieldVarAccess.java b/src/main/java/de/maishai/typedast/typedclass/TypedFieldVarAccess.java index 425f66a..5352360 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedFieldVarAccess.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedFieldVarAccess.java @@ -10,7 +10,7 @@ import org.objectweb.asm.MethodVisitor; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedFieldVarAccess implements TypedExpression { @@ -21,7 +21,7 @@ public class TypedFieldVarAccess implements TypedExpression { public TypedFieldVarAccess convertToTypedFieldVarAccess(Map localVar, Map classes, FieldVarAccess unTypedFieldVarAccess) { field = unTypedFieldVarAccess.field(); - recursiveOwnerChain = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedFieldVarAccess.recursiveOwnerChain()); + recursiveOwnerChain = getKindOfExpression(localVar, classes, unTypedFieldVarAccess.recursiveOwnerChain()); name = unTypedFieldVarAccess.id(); type = localVar.get(unTypedFieldVarAccess.id()); return this; diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedFor.java b/src/main/java/de/maishai/typedast/typedclass/TypedFor.java index 5295f9f..93ef00a 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedFor.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedFor.java @@ -9,7 +9,7 @@ import org.objectweb.asm.MethodVisitor; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data @AllArgsConstructor @@ -22,7 +22,7 @@ public class TypedFor implements TypedStatement { public TypedFor convertToTypedFor(Map localVar, Map classes, For unTypedFor) { assign = new TypedAssignment().convertToTypedAssignment(localVar, classes, unTypedFor.assign()); - cond = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedFor.cond()); + cond = getKindOfExpression(localVar, classes, unTypedFor.cond()); inc = new TypedAssignment().convertToTypedAssignment(localVar, classes, unTypedFor.inc()); typedBlock = new TypedBlock().blockToTypedBlock(localVar, classes, unTypedFor.block()); return this; diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedIfElse.java b/src/main/java/de/maishai/typedast/typedclass/TypedIfElse.java index 47ce416..97d3c6a 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedIfElse.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedIfElse.java @@ -9,7 +9,7 @@ import org.objectweb.asm.Opcodes; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedIfElse implements TypedStatement { @@ -20,7 +20,7 @@ public class TypedIfElse implements TypedStatement { public TypedIfElse convertToTypedIfElse(Map localVar, Map classes, IfElse unTypedIfElse) { ifTypedBlock = new TypedBlock().blockToTypedBlock(localVar, classes, unTypedIfElse.ifBlock()); elseTypedBlock = new TypedBlock().blockToTypedBlock(localVar, classes, unTypedIfElse.elseBlock()); - typedCon = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedIfElse.cond()); + typedCon = getKindOfExpression(localVar, classes, unTypedIfElse.cond()); return this; } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java b/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java index 2f6f6a0..08b76e5 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedMethodCall.java @@ -18,7 +18,8 @@ public class TypedMethodCall implements TypedExpression, TypedStatement { //TODO: Implement this return null; } - @Override + + @Override public Type typeCheck(Map localVar, Map classes) { //TODO: Implement typeCheck for MethodCall return null; diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedReturn.java b/src/main/java/de/maishai/typedast/typedclass/TypedReturn.java index 0930aa6..66ca53e 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedReturn.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedReturn.java @@ -9,14 +9,14 @@ import org.objectweb.asm.Opcodes; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedReturn implements TypedStatement { private TypedExpression ret; public TypedReturn convertToTypedReturn(Map localVar, Map classes, Return unTypedReturn) { - ret = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedReturn.ret()); + ret = getKindOfExpression(localVar, classes, unTypedReturn.ret()); return this; } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedUnary.java b/src/main/java/de/maishai/typedast/typedclass/TypedUnary.java index e594629..48df0a7 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedUnary.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedUnary.java @@ -12,7 +12,7 @@ import org.objectweb.asm.Opcodes; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedUnary implements TypedExpression { @@ -22,7 +22,7 @@ public class TypedUnary implements TypedExpression { public TypedUnary convertToTypedUnary(Map localVar, Map classes, Unary unTypedUnary) { op = unTypedUnary.op(); - right = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedUnary.right()); + right = getKindOfExpression(localVar, classes, unTypedUnary.right()); return this; } @Override diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedWhile.java b/src/main/java/de/maishai/typedast/typedclass/TypedWhile.java index 91a4e87..244499c 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedWhile.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedWhile.java @@ -7,7 +7,7 @@ import org.objectweb.asm.MethodVisitor; import java.util.Map; -import static de.maishai.typedast.Util.TypedExpressionUtil.GET_KIND_OF_EXPRESSION; +import static de.maishai.typedast.Util.TypedExpressionUtil.getKindOfExpression; @Data public class TypedWhile implements TypedStatement { @@ -15,7 +15,7 @@ public class TypedWhile implements TypedStatement { private TypedBlock typedBlock; public TypedWhile convertToTypedWhile(Map localVar, Map classes, While unTypedWhile) { - cond = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedWhile.cond()); + cond = getKindOfExpression(localVar, classes, unTypedWhile.cond()); typedBlock = new TypedBlock().blockToTypedBlock(localVar, classes, unTypedWhile.block()); return this; }