tested print

This commit is contained in:
Vu Tuan Minh
2025-04-07 21:31:13 +02:00
parent 425e2d4088
commit b4bafcde5d
8 changed files with 33 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ import TP2.asd.Interface.*;
import TP2.llvm.ProgramLLVM.*;
public class Program{
//Prog
public static record ProgramImp(ArrayList<Function> fonctions) implements ProgramI{
public <H, S> S accept(ProgramVisitor<H, S> v, H h) {
return v.visitProgram(this, h);
@@ -23,7 +23,7 @@ public class Program{
}
}
//Fonction
public static record FunctionImp(Type type, String nom, ArrayList<Instruction> instructions)implements Function {
public FunctionImp(Type type, String name, Instruction instruction) {
this(type, name, new ArrayList<>() {{ add(instruction); }});
@@ -34,14 +34,13 @@ public class Program{
}
}
//Expression
public static record ConstImp(int c) implements Expression{
public <H, S> S accept(ExprVisitor<H, S> v, H h) {
return v.visitConst(this, h);
}
}
public static record BinopExpressionImp(Op op,Expression e1, Expression e2) implements Expression{
public <H, S> S accept(ExprVisitor<H, S> v, H h) {
return v.visitBinOp(this, h);
@@ -54,15 +53,13 @@ public class Program{
}
}
//Instructions
public static record Return_instrImp(Expression e) implements Instruction{
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitReturn(this,h);
}
}
public static record AssignImp(String t, Expression e) implements Instruction{
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitAssign(this, h);
@@ -76,6 +73,13 @@ public class Program{
}
}
public static record PrintImp(String t) implements Instruction{
@Override
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitPrint(this, h);
}
}
//Type
public static record Type_voidImp() implements Type{
@Override