change fmt to .fmt
This commit is contained in:
@@ -56,12 +56,12 @@ public class Main {
|
||||
//System.err.println("todo " + ast);
|
||||
|
||||
//System.out.println("\n\n PRETTYPRINTER VSL : \n--------------\n");
|
||||
System.out.println(ast.prettyprinter());
|
||||
//System.out.println(ast.prettyprinter());
|
||||
//System.out.println("\n\n PRETTYPRINTER VSL : \n--------------\n");
|
||||
// Verify the program semantic
|
||||
|
||||
// Generate the intermediate representation
|
||||
System.out.println("\n\n");
|
||||
//System.out.println("\n\n");
|
||||
|
||||
ProgramLLVMImp astLLVM = ast.toLLVM();
|
||||
//System.out.println("\n\n PRETTYPRINTER LLVM : \n--------------\n");
|
||||
|
||||
@@ -132,7 +132,7 @@ public class SymTable {
|
||||
}
|
||||
|
||||
public String getGlobalDeclName(){;
|
||||
return "fmt"+id[2];
|
||||
return ".fmt"+id[2];
|
||||
}
|
||||
|
||||
public void addGlobalDecl(DeclarGlobalLLVMImp decl){
|
||||
|
||||
@@ -78,6 +78,8 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
if(!(instrLLVM.getLast() instanceof ReturnLLVMImp || instrLLVM.getLast() instanceof BrLLVMImp)){
|
||||
instrLLVM.add(new ReturnLLVMImp(type, new ValLLVMImp(type,0)));
|
||||
}
|
||||
}else {
|
||||
//TODO
|
||||
}
|
||||
DefineLLVMImp define = new DefineLLVMImp(fun.nom(), type, paramsLLVM, instrLLVM);
|
||||
return define;
|
||||
@@ -225,7 +227,6 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
h.addGlobalDecl(globalDecl);
|
||||
|
||||
l.add(new ScanLLVMImp(globalDecl,params));
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -257,9 +258,9 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
@Override
|
||||
public ArrayList<InstructionLLVM> visitIfThen(IfThenImp instr, SymTable h) {
|
||||
ArrayList<InstructionLLVM> l = new ArrayList<>();
|
||||
String labelIf= "if"+h.getNewIdLabel()+":";
|
||||
String labelThen= "then"+h.getNewIdLabel()+":";
|
||||
String labelFin= "fin"+h.getNewIdLabel();
|
||||
String labelIf= "if"+h.getNewIdLabel();
|
||||
String labelThen= "then"+h.getNewIdLabel();
|
||||
String labelFin= "fi"+h.getNewIdLabel();
|
||||
|
||||
l.add(new LabelLLVMImp(labelIf));
|
||||
InstrAndVal temp = instr.e().accept(this,h);
|
||||
@@ -406,12 +407,17 @@ public class toLLVM_Visitor implements ProgramVisitor<SymTable,ProgramLLVMImp>,
|
||||
//}
|
||||
|
||||
//Pour c=func(x,y)
|
||||
Result res = h.addNewTempVar();
|
||||
h = res.symTable;
|
||||
VarLLVMImp var = new VarLLVMImp(fLLVM.define.type(), res.var,false);
|
||||
|
||||
l.add(new AssignLLVMImp(var, new CallLLVMImp(fLLVM.define,paramsLLVM,"")));
|
||||
return new InstrAndVal(l, var);
|
||||
if (fLLVM.define.type() instanceof VoidLLVMImp) {
|
||||
l.add(new CallVoidLLVMImp(fLLVM.define, paramsLLVM, ""));
|
||||
return new InstrAndVal(l, null);
|
||||
} else {
|
||||
Result res = h.addNewTempVar();
|
||||
h = res.symTable;
|
||||
VarLLVMImp var = new VarLLVMImp(fLLVM.define.type(), res.var, false);
|
||||
|
||||
l.add(new AssignLLVMImp(var, new CallLLVMImp(fLLVM.define, paramsLLVM, "")));
|
||||
return new InstrAndVal(l, var);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
BIN
tests/fragment1/if1
Executable file
BIN
tests/fragment1/if1
Executable file
Binary file not shown.
BIN
tests/fragment1/if2
Executable file
BIN
tests/fragment1/if2
Executable file
Binary file not shown.
BIN
tests/fragment1/while1
Executable file
BIN
tests/fragment1/while1
Executable file
Binary file not shown.
Reference in New Issue
Block a user