This commit is contained in:
Vu Tuan Minh
2025-04-11 13:56:02 +02:00
parent 99b6cbc08a
commit 162d793ab1
2 changed files with 21 additions and 4 deletions

View File

@@ -143,8 +143,20 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImpl>
@Override
public ArrayList<InstructionLLVM> visitIfThen(IfThenImp instr, SymTable h) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'visitIfThen'");
ArrayList<InstructionLLVM> l = new ArrayList<>();
String labelIf= "if"+h.getNewIdLabel();
String labelThen= "then"+h.getNewIdLabel();
String labelEnd= "end"+h.getNewIdLabel();
l.add(new LabelLLVMImp(labelIf));
//TODO
//Je t'attends Tibo
l.add(new LabelLLVMImp(labelThen));
//TODO
l.add(new LabelLLVMImp(labelEnd));
return l;
}
@Override
@@ -157,8 +169,8 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImpl>
public ArrayList<InstructionLLVM> visitWhile(WhileImp instr, SymTable h) {
ArrayList<InstructionLLVM> l = new ArrayList<>();
String labelWhile = "while"+h.getNewIdLabel();
String labelDo = "do"+h.getNewIdLabel();
String labelWhile = "while"+h.getNewIdLabel()+":";
String labelDo = "do"+h.getNewIdLabel()+":";
String labelDone = "done"+h.getNewIdLabel();
l.add(new LabelLLVMImp(labelWhile));

View File

@@ -151,4 +151,9 @@ TypeLLVMVisitor<String,String>
public String visitVoidLLVM(VoidLLVMImpl e, String h) {
return "void";
}
@Override
public String visitLabelLLVM(LabelLLVMImp instr, String h) {
return "";
}
}