call réparé
This commit is contained in:
@@ -205,7 +205,7 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
System.err.println("Fonction n'est pas un void");
|
||||
}
|
||||
|
||||
l.add(new CallLLVMImp(fun.define,paramsLLVM,""));
|
||||
l.add(new CallVoidLLVMImp(fun.define,paramsLLVM,""));
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -356,6 +356,7 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
}
|
||||
|
||||
public InstrAndVal visitAppeal(AppealImp instr,SymTable h){
|
||||
SymTable prevSymTable = h;
|
||||
ArrayList<InstructionLLVM> l = new ArrayList<>();
|
||||
ArrayList<ValLLVM> paramsLLVM = new ArrayList<>();
|
||||
for(Expression param : instr.params()){
|
||||
@@ -374,7 +375,8 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
h = res.symTable;
|
||||
VarLLVMImp var = new VarLLVMImp(fLLVM.define.type(), res.var);
|
||||
|
||||
l.add(new CallLLVMImp(fLLVM.define,paramsLLVM,""));
|
||||
l.add(new AssignLLVMImp(var, new CallLLVMImp(fLLVM.define,paramsLLVM,"")));
|
||||
prevSymTable.updateId(h);
|
||||
return new InstrAndVal(l, var);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface Interface {
|
||||
public S visitLabelLLVM(LabelLLVMImp instr, H h);
|
||||
public S visitBrLLVM(BrLLVMImp instr, H h);
|
||||
public S visitBrCondLLVM(BrCondLLVMImp instr, H h);
|
||||
public S visitCallLLVM(CallLLVMImp instr, H h);
|
||||
public S visitCallVoidLLVM(CallVoidLLVMImp instr, H h);
|
||||
}
|
||||
|
||||
//////////ExpressionLLVM (expression)
|
||||
@@ -53,6 +53,7 @@ public interface Interface {
|
||||
public S visitValLLVM(ValLLVMImp e,H h);
|
||||
public S visitVarLLVM(VarLLVMImp e,H h);
|
||||
public S visitIcmpLLVM(IcmpLLVMImp e, H h);
|
||||
public S visitCallLLVM(CallLLVMImp e, H h);
|
||||
}
|
||||
|
||||
/*public interface IdentifierLLVM{ //globaux @ et local %
|
||||
|
||||
@@ -69,6 +69,16 @@ TypeLLVMVisitor<String,String>
|
||||
return INDENT+instr.var().accept(this, h) + " = " + instr.e().accept(this, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitCallVoidLLVM(CallVoidLLVMImp instr, String h) {
|
||||
String str = INDENT+ "call " + instr.str() + instr.f().type().accept(this, h) + " @"+instr.f().name() + "(";
|
||||
for(int i = 0; i<instr.params().size(); i++){
|
||||
str += instr.params().get(i).getType().accept(this, h) + " " + instr.params().get(i).accept(this,h);
|
||||
if(i<instr.params().size()-1) str += ", ";
|
||||
}
|
||||
return str + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitBinOpLLVM(BinOpLLVMImp e, String h) {
|
||||
String str = "";
|
||||
@@ -187,4 +197,5 @@ TypeLLVMVisitor<String,String>
|
||||
return "i8*";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -74,10 +74,10 @@ public class ProgramLLVM {
|
||||
}
|
||||
}
|
||||
|
||||
public static record CallLLVMImp(DefineLLVMImp f, ArrayList<ValLLVM> params, String str) implements InstructionLLVM{ //une expression ?
|
||||
public static record CallVoidLLVMImp(DefineLLVMImp f, ArrayList<ValLLVM> params, String str) implements InstructionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(InstructionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitCallLLVM(this, h);
|
||||
return v.visitCallVoidLLVM(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +148,18 @@ public class ProgramLLVM {
|
||||
|
||||
}
|
||||
|
||||
public static record CallLLVMImp(DefineLLVMImp f, ArrayList<ValLLVM> params, String str) implements ExpressionLLVM{
|
||||
@Override
|
||||
public <H, S> S accept(ExpressionLLVMVisitor<H, S> v, H h) {
|
||||
return v.visitCallLLVM(this, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeLLVM getType() {
|
||||
return f.type();
|
||||
}
|
||||
}
|
||||
|
||||
//Val
|
||||
|
||||
public static record ValLLVMImp(TypeLLVM type, int val) implements ValLLVM{
|
||||
|
||||
Reference in New Issue
Block a user