package TP2.asd; import java.util.ArrayList; import TP2.asd.Interface.*; import TP2.llvm.ProgramLLVM.*; public class Program{ //Prog public static record ProgramImp(ArrayList fonctions,ArrayList protos) implements ProgramI{ public S accept(ProgramVisitor v, H h) { return v.visitProgram(this, h); } public String prettyprinter(){ PrettyprinterVisitor ppVisitor = new PrettyprinterVisitor(); return this.accept(ppVisitor, ""); } @Override public ProgramLLVMImpl toLLVM() { toLLVM_Visitor llvmVisitor = new toLLVM_Visitor(); return this.accept(llvmVisitor,new SymTable()); } } //Prototype public static record PrototypeImp(Type type, String nom, ArrayList s) implements Prototype{ @Override public S accept(PrototypeVisitor v, H h) { return v.visitPrototype(this,h); } } //Fonction public static record FunctionImp(Type type, String nom, ArrayList s,Instruction instruction)implements Function { //public FunctionImp(Type type, String name, Instruction instruction) { // this(type, name, new ArrayList<>() {{ add(instruction); }}); C KOI ? //} public S accept(FunctionVisitor v, H h) { return v.visitFunction(this, h); } } //Expression public static record ConstImp(int c) implements Expression{ public S accept(ExprVisitor v, H h) { return v.visitConst(this, h); } } public static record BinopExpressionImp(Op op,Expression e1, Expression e2) implements Expression{ public S accept(ExprVisitor v, H h) { return v.visitBinOp(this, h); } } public static record VarImp(String name) implements Expression { public S accept(ExprVisitor v, H h) { return v.visitVar(this, h); } } //Declaration public static record DeclarationImp(Type t, ArrayList s) implements Declaration{ @Override public S accept(DeclVisitor v, H h) { return v.visitDeclaration(this, h); } } //Instructions public static record Return_instrImp(Expression e) implements Instruction{ public S accept(InstrVisitor v, H h) { return v.visitReturn(this,h); } } public static record BlocDecImp(ArrayList decls, ArrayList instrs) implements Instruction{ public S accept(InstrVisitor v, H h) { return v.visitBlocDec(this, h); } } public static record BlocImp(ArrayList instrs) implements Instruction{ public S accept(InstrVisitor v, H h) { return v.visitBloc(this, h); } } public static record AssignImp(String t, Expression e) implements Instruction{ public S accept(InstrVisitor v, H h) { return v.visitAssign(this, h); } } public static record PrintImp(ArrayList t) implements Instruction{ @Override public S accept(InstrVisitor v, H h) { return v.visitPrint(this, h); } } public static record ReadImp(ArrayList t) implements Instruction{ @Override public S accept(InstrVisitor v, H h) { return v.visitRead(this, h); } } public static record IfThenImp(Expression e, Instruction i1) implements Instruction { @Override public S accept(InstrVisitor v, H h) { return v.visitIfThen(this, h); } } public static record IfThenElseImp(Expression e, Instruction i1, Instruction i2) implements Instruction { @Override public S accept(InstrVisitor v, H h) { return v.visitIfThenElse(this, h); } } public static record WhileImp(Expression e, Instruction i1) implements Instruction { @Override public S accept(InstrVisitor v, H h) { return v.visitWhile(this, h); } } //Type public static record Type_voidImp() implements Type{ @Override public S accept(TypeVisitor v, H h) { return v.visitVoid(this, h); } } public static record Type_intImp() implements Type{ @Override public S accept(TypeVisitor v, H h) { return v.visitInt(this, h); } } }