LLVM + interface visitor

This commit is contained in:
Vu Tuan Minh
2025-04-04 16:33:42 +02:00
parent bd7b74461e
commit 23b4accb7e
10 changed files with 198 additions and 109 deletions

View File

@@ -1,7 +1,48 @@
package TP2.asd;
import java.util.Stack;
import org.pcollections.*;
import TP2.asd.Interface.Type;
public class SymTable {
private Stack<PMap<String,Type>> stackMap;
public SymTable(){
this.stackMap= new Stack<>();
}
public void next_layer(){
stackMap.push(HashTreePMap.empty());
}
public void quit_layer() throws Exception{
if(stackMap.isEmpty()){
throw new Exception();
}
stackMap.pop();
}
public PMap<String,Type> peppapeek(){
return stackMap.peek();
}
public void addVar(String s, Type t){
//Save temporary if not PMap wont save
PMap<String, Type> pmap = this.peppapeek();
pmap= pmap.plus(s,t);
//Delete old ones
stackMap.pop();
//Push the new one
stackMap.push(pmap);
}
//Usually look for var in highest level , if not found research.
public boolean searchVar(String s){
for(int i= stackMap.size()-1; i>=0; i--){
if(stackMap.get(i).containsKey(s)){
return true;
}
}
return false;
}
}