toLLVM en cours

This commit is contained in:
trochas
2025-04-03 13:08:07 +02:00
parent 8b2f8a6b8f
commit bd7b74461e
4 changed files with 54 additions and 6 deletions

View File

@@ -6,6 +6,8 @@ import java.util.Map;
import org.antlr.grammar.v3.ANTLRParser.defaultNodeOption_return;
import TP2.asd.Interface.*;
import TP2.llvm.ProgramLLVM.*;
import TP2.llvm.Interface.*;
@@ -26,6 +28,17 @@ public class Program{
}
return str;
}
@Override
public ProgramLLVMImpl toLLVM() {
ArrayList<DefineLLVM> fonctionLLVM = new ArrayList<>();
for(int i = 0; i<fonctions.size(); i++){
fonctionLLVM.add(fonctions.get(i).toLLVM());
}
return new ProgramLLVMImpl(0,new ArrayList<>(),fonctionLLVM);
}
}
public static record FunctionImp(Type type, String nom, ArrayList<Instruction> instructions)implements Function {
@@ -45,6 +58,15 @@ public class Program{
str+= indent+"}";
return str;
}
@Override
public DefineLLVM toLLVM() {
ArrayList<InstructionLLVM> instrLLVM = new ArrayList<>();
for(int i = 0; i<instructions.size(); i++){
instrLLVM.add(instructions.get(i).toLLVM());
}
return new DefineLLVMImpl(nom, 32, instrLLVM);
}
}
public static record ConstImp(int c) implements Expression{
@@ -85,6 +107,12 @@ public class Program{
public String prettyprinter(String indent){
return indent+"RETURN " + e.prettyprinter();
}
@Override
public InstructionLLVM toLLVM() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'toLLVM'");
}
}
public static record AssignImp(String t, Expression e) implements Instruction{
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
@@ -96,6 +124,12 @@ public class Program{
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'prettyprinter'");
}
@Override
public InstructionLLVM toLLVM() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'toLLVM'");
}
}
public static record Type_voidImp() implements Type{