This commit is contained in:
Vu Tuan Minh
2025-04-30 16:34:31 +02:00
50 changed files with 229 additions and 27 deletions

View File

@@ -78,7 +78,7 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
paramsLLVM.add(var);
VarLLVMImp newVar =new VarLLVMImp(type, nameVar,false);
setParam.add(new AssignLLVMImp(newVar,new allocaLLVMImp(type)));
setParam.add(new StoreLLVMImp(type,var,type,newVar));
setParam.add(new StoreLLVMImp(type,var,newVar));
}
instrLLVM.addAll(setParam);
instrLLVM.addAll(fun.instruction().accept(this, h));
@@ -115,7 +115,7 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
h = r.symTable;
list.add(new AssignLLVMImp(new VarLLVMImp(t2, r.var,false),new allocaLLVMImp(t2)));
}else {
TypeLLVM arrayType = new ArrayLLVMImp(t2, size);
TypeLLVM arrayType = new PointerLLVMImp(t2);
//Alloca
Result r_size= h.addNewTempVar();
@@ -196,7 +196,7 @@ 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);
InstructionLLVM r = new StoreLLVMImp(var.getType(),var,var.getType(),new VarLLVMImp(var.getType(),h.getVar(instr.t()),false));
InstructionLLVM r = new StoreLLVMImp(var.getType(),var,new VarLLVMImp(var.getType(),h.getVar(instr.t()),false));
result.add(r);
return result;
}