correction bug expression de toLLVM, tout les test fragment0 marchent
This commit is contained in:
@@ -4,14 +4,23 @@ import java.util.Stack;
|
||||
|
||||
import org.pcollections.*;
|
||||
import TP2.asd.Interface.Type;
|
||||
import TP2.asd.Program.Type_intImp;
|
||||
|
||||
public class SymTable {
|
||||
private Stack<PMap<String,Type>> stackMap;
|
||||
|
||||
private int id=1;
|
||||
public SymTable(){
|
||||
this.stackMap= new Stack<>();
|
||||
}
|
||||
|
||||
public String addNewTempVar(/*Type type*/){
|
||||
//TODO
|
||||
String newVar = "temp"+this.id;
|
||||
//this.addVar(newVar,new Type_intImp()); //TODO
|
||||
id++;
|
||||
return newVar;
|
||||
}
|
||||
|
||||
public void next_layer(){
|
||||
stackMap.push(HashTreePMap.empty());
|
||||
}
|
||||
@@ -29,7 +38,8 @@ public class SymTable {
|
||||
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);
|
||||
pmap= pmap.plus(s/*+"_"+this.id*/,t);
|
||||
//this.id++;
|
||||
//Delete old ones
|
||||
stackMap.pop();
|
||||
//Push the new one
|
||||
@@ -38,6 +48,7 @@ public class SymTable {
|
||||
|
||||
//Usually look for var in highest level , if not found research.
|
||||
public boolean searchVar(String s){
|
||||
//TOTO
|
||||
for(int i= stackMap.size()-1; i>=0; i--){
|
||||
if(stackMap.get(i).containsKey(s)){
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user