toLLVM en cours
This commit is contained in:
@@ -3,20 +3,24 @@ package TP2.asd;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import TP2.asd.Program.*;
|
||||
|
||||
import TP2.llvm.Interface.*;
|
||||
import TP2.llvm.ProgramLLVM.*;
|
||||
|
||||
public interface Interface{
|
||||
public interface ProgramI {
|
||||
public <H,S> S accept(ProgramVisitor<H,S> v, H h);
|
||||
public String prettyprinter();
|
||||
public ProgramLLVMImpl toLLVM();
|
||||
}
|
||||
public interface Function {
|
||||
public <H,S> S accept(FunctionVisitor<H,S> v, H h);
|
||||
public String prettyprinter(String indent);
|
||||
public String prettyprinter(String indent);
|
||||
public DefineLLVM toLLVM();
|
||||
}
|
||||
public interface Instruction {
|
||||
public <H,S> S accept(InstrVisitor<H,S> v, H h);
|
||||
public String prettyprinter(String indent);
|
||||
public InstructionLLVM toLLVM();
|
||||
}
|
||||
|
||||
public interface Expression {
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user