📄 constanttable.java
字号:
package CatDecaf.Optimizer;
import CatDecaf.IR.*;
import CatDecaf.Utilities.*;
import java6035.tools.ASM.*;
import java.io.*;
import java.util.*;
import CatDecaf.SymTable.*;
import parser.*;
public class ConstantTable{
public LinkedHashMap table;
public ConstantTable parent;
public ConstantTable child1;
public ConstantTable child2;
public HashSet loopKillSet;
public boolean optFlag;
public HashSet killSet; //an IDDescriptor in this killSet means it cannot be looked up from the parent table
public ConstantTable(){
table = new LinkedHashMap();
killSet = new HashSet();
//parent = p;
//optFlag = true;
}
public Object lookupValue(IDDescriptor idd){
if(table.containsKey(idd)) return table.get(idd);
if(parent != null && !killSet.contains(idd)) return parent.lookupValue(idd);;
return null;
}
public boolean checkIDDInParents(IDDescriptor idd){ //true if idd exists in ancestors
if(parent == null) return false;
if(parent.table.containsKey(idd)) return true;
else return parent.checkIDDInParents(idd);
}
public boolean checkIDDInParents(IDDescriptor idd, Object o){ //true if idd exists with same value in ancestors
if(parent == null) return false;
if(parent.table.containsKey(idd)){
Object o2 = parent.table.get(idd);
if(o instanceof LtrInt) return ( ((LtrInt)o).ltrInt_ == ((LtrInt)o2).ltrInt_ ) ;
else if(o instanceof LtrBoolFalse) return (o2 instanceof LtrBoolFalse);
else if(o instanceof LtrBoolTrue) return (o2 instanceof LtrBoolTrue);
return false;
}
else return parent.checkIDDInParents(idd, o);
}
public LinkedHashMap checkIDDInParentsAndGetTable(IDDescriptor idd, Object o){ //true if idd exists with same value in ancestors
if(parent == null) return null;
if(parent.table.containsKey(idd)){
Object o2 = parent.table.get(idd);
boolean equal = false;
if(o instanceof LtrInt) equal = ( ((LtrInt)o).ltrInt_ == ((LtrInt)o2).ltrInt_ ) ;
else if(o instanceof LtrBoolFalse) equal = (o2 instanceof LtrBoolFalse);
else if(o instanceof LtrBoolTrue) equal = (o2 instanceof LtrBoolTrue);
if(equal) return parent.table;
return null;
}
else return parent.checkIDDInParentsAndGetTable(idd, o);
}
private void kill(IDDescriptor idd){
if(table.containsKey(idd)) table.remove(idd);
if(parent != null) parent.kill(idd);
}
public void kill(HashSet ks){
for(Iterator i = ks.iterator(); i.hasNext(); )
kill((IDDescriptor)i.next());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -