add ret void pour func void
This commit is contained in:
@@ -62,7 +62,11 @@ TypeLLVMVisitor<String,String>
|
||||
|
||||
@Override
|
||||
public String visitReturnLLVM(ReturnLLVMImp instr, String h) {
|
||||
return INDENT+"ret " + instr.type().accept(this, h) + " " + instr.e().accept(this, h);
|
||||
if (instr.e() == null) {
|
||||
return INDENT + "ret " + instr.type().accept(this, h);
|
||||
} else {
|
||||
return INDENT + "ret " + instr.type().accept(this, h) + " " + instr.e().accept(this, h);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,31 +132,32 @@ TypeLLVMVisitor<String,String>
|
||||
|
||||
@Override
|
||||
public String visitCallLLVM(CallLLVMImp instr, String h) {
|
||||
String str = "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 += ", ";
|
||||
String str = "call " + instr.f().type().accept(this, h) + " (" + instr.str() + ") @" + 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 + ")";
|
||||
return str + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitPrintLLVM(PrintLLVMImp instr, String h) { //TODO
|
||||
DefineLLVMImp printLLVM = new DefineLLVMImp("printf", new IntLLVMImp(), new ArrayList<>(), new ArrayList<>());
|
||||
CallLLVMImp callPrint = new CallLLVMImp(printLLVM, instr.l(),"(i8*,...) ");
|
||||
CallLLVMImp callPrint = new CallLLVMImp(printLLVM, instr.l(),"i8*, ...");
|
||||
return callPrint.accept(this, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitScanLLVM(ScanLLVMImp instr, String h) { //TODO
|
||||
DefineLLVMImp readLLVM = new DefineLLVMImp("scanf", new IntLLVMImp(), new ArrayList<>(), new ArrayList<>());
|
||||
CallLLVMImp callRead = new CallLLVMImp(readLLVM, instr.l(),"(i8*,...) ");
|
||||
CallLLVMImp callRead = new CallLLVMImp(readLLVM, instr.l(),"i8*, ...");
|
||||
return callRead.accept(this, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String visitDeclarGlobalLLVM(DeclarGlobalLLVMImp instr, String h) {
|
||||
String str = "@."+instr.var().nom() + " = global";
|
||||
String str = "@"+instr.var().nom() + " = global";
|
||||
str += " [" + instr.size() + " x "+ instr.type().accept(this, h) + "] ";
|
||||
str+= "c\""+ instr.str()+"\"\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user