mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 17:28:03 +00:00
renamed the static method
This commit is contained in:
parent
903f9e8d4e
commit
735781a63c
@ -9,7 +9,7 @@ import java.util.Map;
|
||||
|
||||
public class TypedExpressionUtil {
|
||||
|
||||
public static TypedExpression GET_KIND_OF_EXPRESSION(Map<String, Type> localVar, Map<String, TypedClass> classes, Expression expression) {
|
||||
public static TypedExpression getKindOfExpression(Map<String, Type> localVar, Map<String, TypedClass> 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;
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> classes, Assignment untyped) {
|
||||
varName = untyped.location().id();
|
||||
value = GET_KIND_OF_EXPRESSION(localVar, classes, untyped.value());
|
||||
value = getKindOfExpression(localVar, classes, untyped.value());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> 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;
|
||||
}
|
||||
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> 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;
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> 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;
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> 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;
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ public class TypedMethodCall implements TypedExpression, TypedStatement {
|
||||
//TODO: Implement this
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type typeCheck(Map<String, Type> localVar, Map<String, TypedClass> classes) {
|
||||
//TODO: Implement typeCheck for MethodCall
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> classes, Return unTypedReturn) {
|
||||
ret = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedReturn.ret());
|
||||
ret = getKindOfExpression(localVar, classes, unTypedReturn.ret());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> classes, Unary unTypedUnary) {
|
||||
op = unTypedUnary.op();
|
||||
right = GET_KIND_OF_EXPRESSION(localVar, classes, unTypedUnary.right());
|
||||
right = getKindOfExpression(localVar, classes, unTypedUnary.right());
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
|
@ -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<String, Type> localVar, Map<String, TypedClass> 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user