symtable works but not multiple variable

This commit is contained in:
Minh VU
2025-04-05 13:41:23 +02:00
parent 56df584b9f
commit bc7d1045ee
17 changed files with 104 additions and 1653 deletions

View File

@@ -184,6 +184,25 @@ public class Program{
}
}
public static record DeclarationImp(Type t, String s) implements Instruction{
@Override
public <H, S> S accept(InstrVisitor<H, S> v, H h) {
return v.visitDeclaration(this, h);
}
@Override
public String prettyprinter(String indent) {
return "declare "+t.toString()+s;
}
@Override
public ArrayList<InstructionLLVM> toLLVM() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'toLLVM'");
}
}
public static record Type_voidImp() implements Type{
public String prettyprinter() {
@@ -241,8 +260,7 @@ public class Program{
@Override
public Integer visitReturn(Return_instrImp e, Map<String, Integer> h) {
ExprEval exprEval = new ExprEval();
return e.e().accept(exprEval, h);
return e.accept(this, h);
}
@Override
public Integer visitAssign(AssignImp e, Map<String, Integer> h) {
@@ -250,6 +268,10 @@ public class Program{
//TODO
return 1;
}
@Override
public Integer visitDeclaration(DeclarationImp e, Map<String, Integer> h) {
return e.accept(this, h);
}
}