mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-29 08:28:03 +00:00
update the TypedMethod
This commit is contained in:
parent
85171ce95d
commit
a16ee38ce8
@ -1,28 +0,0 @@
|
|||||||
package de.maishai.typedast.typedclass;
|
|
||||||
|
|
||||||
import de.maishai.typedast.MethodContext;
|
|
||||||
import de.maishai.typedast.TypedNode;
|
|
||||||
import de.maishai.typedast.TypedStatement;
|
|
||||||
import de.maishai.typedast.Type;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.objectweb.asm.MethodVisitor;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
@Data
|
|
||||||
public class TypedContinue implements TypedStatement {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type typeCheck(Map<String, Type> localVar, Map<String, TypedClass> classes) {
|
|
||||||
return Type.VOID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypedNode convertToTypedAST(Map<String, Type> localVar, Map<String, TypedClass> classes, de.maishai.ast.records.Node unTypedAST) {
|
|
||||||
return new TypedContinue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void codeGen(MethodVisitor mv, MethodContext ctx) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package de.maishai.typedast.typedclass;
|
|
||||||
|
|
||||||
import de.maishai.ast.records.FieldVarAccess;
|
|
||||||
import de.maishai.typedast.TypedExpression;
|
|
||||||
import de.maishai.typedast.TypedNode;
|
|
||||||
import de.maishai.typedast.Type;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
@Data
|
|
||||||
public class TypedFieldId implements TypedExpression {
|
|
||||||
private Boolean field;
|
|
||||||
private TypedExpression recipient;
|
|
||||||
private String name;
|
|
||||||
@Override
|
|
||||||
public Type typeCheck(Map<String, Type> localVar, Map<String, TypedClass> classes) {
|
|
||||||
//TODO: Implement typeCheck for FieldVarAccess
|
|
||||||
if(field){
|
|
||||||
return null;
|
|
||||||
}else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypedNode convertToTypedAST(Map<String, Type> localVar, Map<String, TypedClass> classes, de.maishai.ast.records.Node unTypedAST) {
|
|
||||||
FieldVarAccess untypedFieldVarAccess = (FieldVarAccess) unTypedAST;
|
|
||||||
TypedFieldId typedFieldId = new TypedFieldId();
|
|
||||||
typedFieldId.setField(untypedFieldVarAccess.field());
|
|
||||||
typedFieldId.setRecipient((TypedExpression) recipient.convertToTypedAST(localVar, classes, untypedFieldVarAccess.recursiveOwnerChain()));
|
|
||||||
typedFieldId.setName(untypedFieldVarAccess.id());
|
|
||||||
|
|
||||||
return typedFieldId;
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,7 +19,7 @@ public class TypedMethod implements TypedNode {
|
|||||||
private List<TypedParameter> typedParameters;
|
private List<TypedParameter> typedParameters;
|
||||||
private TypedBlock typedBlock;
|
private TypedBlock typedBlock;
|
||||||
|
|
||||||
public TypedMethod unTypedMethodToTypedMethod(Method unTypedMethod) {
|
public TypedMethod convertToTypedMethod(Map<String, Type> localVar, Map<String, TypedClass> classes, Method unTypedMethod) {
|
||||||
TypedMethod typedMethod = new TypedMethod();
|
TypedMethod typedMethod = new TypedMethod();
|
||||||
typedMethod.setName(unTypedMethod.methodName());
|
typedMethod.setName(unTypedMethod.methodName());
|
||||||
typedMethod.setTypedParameters(new ArrayList<>());
|
typedMethod.setTypedParameters(new ArrayList<>());
|
||||||
@ -35,7 +35,7 @@ public class TypedMethod implements TypedNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
TypedBlock block = new TypedBlock();
|
TypedBlock block = new TypedBlock();
|
||||||
typedMethod.setTypedBlock(block.unTypedBlockToTypedBlock(unTypedMethod.block()));
|
typedMethod.setTypedBlock(block.blockToTypedBlock(localVar, classes, unTypedMethod.block()));
|
||||||
return typedMethod;
|
return typedMethod;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -67,28 +67,11 @@ public class TypedMethod implements TypedNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypedBlock typedBlock = new TypedBlock();
|
TypedBlock typedBlock = new TypedBlock();
|
||||||
typedMethod.setTypedBlock(typedBlock.unTypedBlockToTypedBlock(untypedMethod.block()));
|
typedMethod.setTypedBlock(typedBlock.blockToTypedBlock(localVar, classes,untypedMethod.block()));
|
||||||
|
|
||||||
return typedMethod;
|
return typedMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypedParameter getTypedParameter(Parameter parameter) {
|
|
||||||
TypedParameter typedParameter = new TypedParameter();
|
|
||||||
typedParameter.setParaName(parameter.name());
|
|
||||||
|
|
||||||
if(parameter.type() == Type.CHAR){
|
|
||||||
typedParameter.setType(Type.CHAR);
|
|
||||||
}
|
|
||||||
if(parameter.type() == Type.BOOL){
|
|
||||||
typedParameter.setType(Type.BOOL);
|
|
||||||
}
|
|
||||||
if(parameter.type() == Type.INT){
|
|
||||||
typedParameter.setType(Type.INT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return typedParameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void codeGen(ClassWriter cw) {
|
public void codeGen(ClassWriter cw) {
|
||||||
int accessModifier = Opcodes.ACC_PUBLIC; // ist laut Andi ok
|
int accessModifier = Opcodes.ACC_PUBLIC; // ist laut Andi ok
|
||||||
MethodVisitor mv = cw.visitMethod(accessModifier, name,
|
MethodVisitor mv = cw.visitMethod(accessModifier, name,
|
||||||
|
Loading…
Reference in New Issue
Block a user