Merge branch 'main' of https://gitlab2.istic.univ-rennes1.fr/tuvu/tp2-vsl-pds
This commit is contained in:
@@ -131,10 +131,10 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
@Override
|
||||
public String visitWhile(WhileImp instr, String indent) {
|
||||
String str = indent+"WHILE ";
|
||||
str += (instr.e().accept(this, ""));
|
||||
str+= " DO ";
|
||||
str+= instr.i1().accept(this, "");
|
||||
str+= " DONE";
|
||||
str += (instr.e().accept(this, indent))+"\n";
|
||||
str+= indent+"DO ";
|
||||
str+= instr.i1().accept(this, indent)+"\n";
|
||||
str+= indent+"DONE";
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SymTable {
|
||||
|
||||
public int getNewIdLabel(){
|
||||
int a = this.idLabel;
|
||||
this.id++;
|
||||
this.idLabel++;
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public class SymTable {
|
||||
}
|
||||
|
||||
public String getVar(String nomVar){
|
||||
System.out.println("getVar(" + nomVar +") -------------------------------------------");
|
||||
return nomVar + this.stackMap.getLast().get(nomVar).id;
|
||||
}
|
||||
|
||||
|
||||
@@ -174,14 +174,21 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImpl>
|
||||
String labelDone = "done"+h.getNewIdLabel();
|
||||
|
||||
l.add(new LabelLLVMImp(labelWhile));
|
||||
InstrAndVal temp = instr.e().accept(this,h); //retourne les instruction pour optenir le résultat ainsi que la variable contenant le résultat final
|
||||
l.addAll(temp.instrs);
|
||||
InstrAndVal temp = instr.e().accept(this,h); //retourne les instructionz pour obtenir le résultat de l'expression ainsi que la variable contenant le résultat final
|
||||
l.addAll(temp.instrs); //instructions
|
||||
ValLLVM val = temp.val; //temp6
|
||||
//TODO : icmp et br
|
||||
ExpressionLLVM exTemp = new IcmpLLVMImp(val,new ValLLVMImpl(new IntLLVMImpl(), 0));
|
||||
Result temp2 = h.addNewTempVar();
|
||||
h = temp2.symTable;
|
||||
VarLLVMImpl varCond = new VarLLVMImpl(exTemp.getType(), temp2.var);
|
||||
l.add(new AssignLVMImpl(varCond,exTemp));
|
||||
l.add(new BrCondLLVMImp(varCond,labelDo,labelDone));
|
||||
|
||||
l.add(new LabelLLVMImp(labelDo));
|
||||
l.addAll(instr.i1().accept(this,h));
|
||||
//TODO br vers label while
|
||||
|
||||
l.add(new BrLLVMImp(labelWhile));
|
||||
|
||||
l.add(new LabelLLVMImp(labelDone));
|
||||
|
||||
return l;
|
||||
|
||||
Reference in New Issue
Block a user