toLLVM prettyprinter pour assign
This commit is contained in:
@@ -28,6 +28,7 @@ public interface Interface {
|
||||
public interface InstructionLLVMVisitor<H,S> {
|
||||
public S visitReturnLLVM(ReturnLLVMImp instr, H h);
|
||||
public S visitAssignLLVM(AssignLVMImp instr, H h);
|
||||
public S visitStoreLLVM(StoreLLVMImp instr, H h);
|
||||
}
|
||||
|
||||
//////////ExpressionLLVM (expression)
|
||||
|
||||
@@ -16,7 +16,7 @@ TypeLLVMVisitor<String,String>
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append("; Target\n");
|
||||
str.append("target triple = \"x86_64-pc-linux-gnu\"\n");
|
||||
str.append("; ; External declaration of the printf function\n");
|
||||
str.append("; External declaration of the printf function\n");
|
||||
str.append("declare i32 @printf (i8 * noalias nocapture, ...)\n");
|
||||
str.append("declare i32 @scanf (i8 * noalias nocapture, ...)\n");
|
||||
str.append("\n");
|
||||
@@ -87,7 +87,12 @@ TypeLLVMVisitor<String,String>
|
||||
|
||||
@Override
|
||||
public String visitAllocaLLVM(allocaLLVMImpl e, String h) {
|
||||
return "aloca" + " i" + e.type().getNbBit();
|
||||
return "alloca" + " i" + e.type().getNbBit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitStoreLLVM(StoreLLVMImp instr, String h) {
|
||||
return INDENT+"store " + instr.valType().accept(this, "") + " " + instr.e().accept(this, "") + ", " + instr.varType().accept(this, "") + "* " + instr.var().accept(this,"");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,4 +120,5 @@ TypeLLVMVisitor<String,String>
|
||||
return "void";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class ProgramLLVM {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public static record AssignLVMImp(VarLLVMImpl var, ExpressionLLVM e) implements InstructionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
@@ -56,6 +57,14 @@ public class ProgramLLVM {
|
||||
}
|
||||
}
|
||||
|
||||
public static record StoreLLVMImp(TypeLLVM valType, ExpressionLLVM e,TypeLLVM varType, ValLLVM var) implements InstructionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitStoreLLVM(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Expression :
|
||||
public static record BinOpLLVMImp(TypeLLVM type,Op op, ValLLVM val1,ValLLVM val2) implements ExpressionLLVM{
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user