correction bug pour SemanticError

This commit is contained in:
Rochas
2025-04-30 18:07:59 +02:00
parent 5a86f474bc
commit d6301bad2d
41 changed files with 28 additions and 7 deletions

View File

@@ -96,7 +96,11 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
@Override
public DefineLLVMImp visitPrototype(PrototypeImp fun, SymTable h) {
return new DefineLLVMImp(fun.nom(), fun.type().accept(this, h), null,null);
ArrayList<VarLLVMImp> params = new ArrayList<>();
for(VarImp param: fun.params()){
params.add(new VarLLVMImp(new IntLLVMImp(),param.name(),false));
}
return new DefineLLVMImp(fun.nom(), fun.type().accept(this, h), params,null);
}
//DECLARATION
@@ -196,6 +200,10 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
ArrayList<InstructionLLVM> result = new ArrayList<>();
result.addAll(res.instrs);
//InstructionLLVM r = new AssignLLVMImp(new VarLLVMImpl(var.getType(),instr.t()),var);
if(var.getType().getClass() != h.getType(instr.t()).getClass()){
System.err.println("[VSL compile error] : Erreur de typage");
System.exit(1);
}
InstructionLLVM r = new StoreLLVMImp(var.getType(),var,new VarLLVMImp(var.getType(),h.getVar(instr.t()),false));
result.add(r);
return result;