stack
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
package TP2.asd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.plaf.synth.SynthLabelUI;
|
||||
|
||||
import TP2.asd.Interface.*;
|
||||
import TP2.llvm.ProgramLLVM.*;
|
||||
import TP2.llvm.Interface.*;
|
||||
|
||||
@@ -7,10 +7,10 @@ import TP2.asd.Interface.Type;
|
||||
import TP2.asd.Program.Type_intImp;
|
||||
|
||||
public class SymTable {
|
||||
private Stack<PMap<String,Type>> stackMap;
|
||||
private PStack<PMap<String,Type>> stackMap;
|
||||
private int id=1;
|
||||
public SymTable(){
|
||||
this.stackMap= new Stack<>();
|
||||
this.stackMap= ConsPStack.empty();
|
||||
}
|
||||
|
||||
public String addNewTempVar(/*Type type*/){
|
||||
@@ -22,17 +22,17 @@ public class SymTable {
|
||||
}
|
||||
|
||||
public void next_layer(){
|
||||
stackMap.push(HashTreePMap.empty());
|
||||
stackMap.plus(HashTreePMap.empty());
|
||||
}
|
||||
|
||||
public void quit_layer() throws Exception{
|
||||
if(stackMap.isEmpty()){
|
||||
throw new Exception();
|
||||
}
|
||||
stackMap.pop();
|
||||
stackMap.minus(stackMap.indexOf(stackMap.getLast()));
|
||||
}
|
||||
public PMap<String,Type> peppapeek(){
|
||||
return stackMap.peek();
|
||||
return stackMap.getLast();
|
||||
}
|
||||
|
||||
public void addVar(String s, Type t){
|
||||
@@ -41,9 +41,9 @@ public class SymTable {
|
||||
pmap= pmap.plus(s/*+"_"+this.id*/,t);
|
||||
//this.id++;
|
||||
//Delete old ones
|
||||
stackMap.pop();
|
||||
stackMap.minus(stackMap.indexOf(stackMap.getLast()));
|
||||
//Push the new one
|
||||
stackMap.push(pmap);
|
||||
stackMap.plus(pmap);
|
||||
}
|
||||
|
||||
//Usually look for var in highest level , if not found research.
|
||||
|
||||
Reference in New Issue
Block a user