correction bug id des var temp dans le while

This commit is contained in:
Rochas
2025-04-13 12:36:39 +02:00
parent 99ca510bb1
commit 2f16120dae
5 changed files with 14 additions and 49 deletions

View File

@@ -32,9 +32,6 @@ public interface Interface {
public S visitStoreLLVM(StoreLLVMImpl instr, H h);
public S visitPrintLLVM(PrintLLVMImpl instr, H h);
public S visitReadLLVM(ReadLLVMImpl instr, H h);
public S visitIfThenElseLLVM(IfThenElseLLVMImp instr, H h);
public S visitIfThenLLVM(IfThenLLVMImp instr, H h);
public S visitWhileLLVM(WhileLLVMImp instr, H h);
public S visitLabelLLVM(LabelLLVMImp instr, H h);
public S visitBrLLVM(BrLLVMImp instr, H h);
public S visitBrCondLLVM(BrCondLLVMImp instr, H h);

View File

@@ -115,7 +115,7 @@ TypeLLVMVisitor<String,String>
@Override
public String visitReadLLVM(ReadLLVMImpl instr, String h) {
return INDENT+"call " + "...TODO..." +" scanf " + "...TODO...";
return INDENT+"call " + instr.var().type().accept(this,h) + "(" + "i8*, ..." + ")" + " scanf(i8* " + "...TODO..." + ")";
}
//label
@@ -134,24 +134,6 @@ TypeLLVMVisitor<String,String>
return INDENT+"br " + instr.var().type().accept(this, h) +" "+ instr.var().accept(this, h) + ", label %" + instr.label() + ", label %" + instr.labelElse() ;
}
@Override
public String visitIfThenElseLLVM(IfThenElseLLVMImp instr, String h) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'visitIfThenElseLLVM'");
}
@Override
public String visitIfThenLLVM(IfThenLLVMImp instr, String h) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'visitIfThenLLVM'");
}
@Override
public String visitWhileLLVM(WhileLLVMImp instr, String h) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'visitWhileLLVM'");
}
@Override

View File

@@ -81,7 +81,7 @@ public class ProgramLLVM {
}
}
public static record ReadLLVMImpl(ArrayList<VarLLVMImpl> l) implements InstructionLLVM{
public static record ReadLLVMImpl(VarLLVMImpl var) implements InstructionLLVM{
@Override
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
@@ -89,30 +89,6 @@ public class ProgramLLVM {
}
}
public static record IfThenLLVMImp(ExpressionLLVM cond, InstructionLLVM instr) implements InstructionLLVM{
@Override
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
return v.visitIfThenLLVM(this, h);
}
}
public static record IfThenElseLLVMImp(ExpressionLLVM cond, InstructionLLVM intr1, InstructionLLVM instr2) implements InstructionLLVM{
@Override
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
return v.visitIfThenElseLLVM(this, h);
}
}
public static record WhileLLVMImp(ExpressionLLVM cond, InstructionLLVM instr) implements InstructionLLVM{
@Override
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
return v.visitWhileLLVM(this, h);
}
}
//Expression :
public static record BinOpLLVMImpl(TypeLLVM type,Op op, ValLLVM val1,ValLLVM val2) implements ExpressionLLVM{
@Override