error LL1 in function and proto in Parser. too weird.

This commit is contained in:
Vu Tuan Minh
2025-04-28 06:20:11 +02:00
parent 85a693acbd
commit 19af482a32
4 changed files with 46 additions and 27 deletions

View File

@@ -336,15 +336,22 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
ArrayList<ValLLVM> paramsLLVM = new ArrayList<>();
for(Expression param : instr.params()){
InstrAndVal result = param.accept(this,h);
l.add((InstructionLLVM) result.instrs);
l.addAll( result.instrs);
paramsLLVM.add(result.val);
}
ValueFunMap fLLVM = h.getFunction(instr.fName()); //on récupère la fonction LLVM dans la table des Symboles
if(fLLVM == null){
System.err.println("[VSL compile error] : la fonction n'existe pas, veuillez vous assurer de l'avoir déclarée avant l'appel");
return new InstrAndVal(l, null);
}
//Pour c=func(x,y)
Result res = h.addNewTempVar();
h = res.symTable;
VarLLVMImp var = new VarLLVMImp(fLLVM.define.type(), res.var);
l.add(new CallLLVMImp(fLLVM.define,paramsLLVM,""));
return new InstrAndVal(l, null);
return new InstrAndVal(l, var);
}
@Override