blocks en cours

This commit is contained in:
trochas
2025-04-10 12:04:42 +02:00
8 changed files with 144 additions and 42 deletions

View File

@@ -25,10 +25,10 @@ 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); }});
}
public static record FunctionImp(Type type, String nom, Instruction instruction)implements Function {
//public FunctionImp(Type type, String name, Instruction instruction) {
// this(type, name, new ArrayList<>() {{ add(instruction); }}); C KOI ?
//}
public <H, S> S accept(FunctionVisitor<H, S> v, H h) {
return v.visitFunction(this, h);
@@ -69,7 +69,19 @@ public class Program{
return v.visitReturn(this,h);
}
}
public static record BlocDecImp(ArrayList<Declaration> decls, ArrayList<Instruction> instrs) implements Instruction{
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitBlocDec(this, h);
}
}
public static record BlocImp(ArrayList<Instruction> instrs) implements Instruction{
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitBloc(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);
@@ -90,21 +102,21 @@ public class Program{
}
}
public static record IfThenImp(Expression e, Instruction i1) implements Instruction {
public static record IfThenImp(Expression e, ArrayList<Instruction> i1) implements Instruction {
@Override
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitIfThen(this, h);
}
}
public static record IfThenElseImp(Expression e, Instruction i1, Instruction i2) implements Instruction {
public static record IfThenElseImp(Expression e, ArrayList<Instruction> i1, ArrayList<Instruction> i2) implements Instruction {
@Override
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitIfThenElse(this, h);
}
}
public static record WhileImp(Expression e, Instruction i1) implements Instruction {
public static record WhileImp(Expression e, ArrayList<Instruction> i1) implements Instruction {
@Override
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitWhile(this, h);