private HashSet valueset;
private Vector<SymbolTable> parentIFs;
+ private SymbolTable surrounding;
public SymbolTable() {
valueset = new HashSet();
parent = null;
parentIFs = null;
+ this.surrounding = null;
}
public SymbolTable(SymbolTable parent) {
hs.addAll(parentIFs.elementAt(i).getPSet(name));
}
}
+ if(this.surrounding != null) {
+ hs.addAll(this.surrounding.getPSet(name));
+ }
if (table.containsKey(name)) {
hs.addAll((HashSet)table.get(name));
}
}
}
+ if(this.surrounding != null) {
+ d = this.surrounding.get(name);
+ if(d != null) {
+ return d;
+ }
+ }
+
return null;
}
hs.addAll(parentIFs.elementAt(i).getAllValueSet());
}
}
+ if(this.surrounding != null) {
+ hs.addAll(this.surrounding.getAllValueSet());
+ }
hs.addAll(valueset);
return hs;
public void setParent(SymbolTable parent) {
this.parent = parent;
}
+
+ public SymbolTable getSurrounding() {
+ return this.surrounding;
+ }
+
+ public void setSurrounding(SymbolTable surrounding) {
+ this.surrounding = surrounding;
+ }
public Vector<SymbolTable> getParentIFs() {
return parentIFs;
cd.getFieldTable().setParent(cd.getSuperDesc().getFieldTable());
cd.getMethodTable().setParent(cd.getSuperDesc().getMethodTable());
cd.getFlagTable().setParent(cd.getSuperDesc().getFlagTable());
+ // if this is an inner class, link together Field, Method and Flag
+ // tables from its surrounding class
+ if(cd.isInnerClass()) {
+ cd.getFieldTable().setSurrounding(cd.getSurroundingDesc().getFieldTable());
+ cd.getMethodTable().setSurrounding(cd.getSurroundingDesc().getMethodTable());
+ cd.getFlagTable().setSurrounding(cd.getSurroundingDesc().getFlagTable());
+ }
}
}
}
}
}
- FieldDescriptor recurseSurroundingClasses( ClassDescriptor icd, String varname ) {
- if( null == icd || false == icd.isInnerClass() )
- return null;
-
- ClassDescriptor surroundingDesc = icd.getSurroundingDesc();
- if( null == surroundingDesc )
- return null;
-
- SymbolTable fieldTable = surroundingDesc.getFieldTable();
- FieldDescriptor fd = ( FieldDescriptor ) fieldTable.get( varname );
- if( null != fd )
- return fd;
- return recurseSurroundingClasses( surroundingDesc, varname );
- }
-
FieldAccessNode fieldAccessExpression( ClassDescriptor icd, String varname, int linenum ) {
- FieldDescriptor fd = recurseSurroundingClasses( icd, varname );
+ // first check if the field is belong to the icd or its parent class
+ FieldDescriptor fd = (FieldDescriptor)icd.getFieldTable().get(varname);
if( null == fd )
return null;
int f2;
public inner() {
- super.outer=31;
+ /*super.*/outer=31;
}
public static void main(String x[]) {
public void dotest() {
outer=35;
+ outerprint();
t tmp=new t();
tmp.print();
}
+
+ public void outerprint() {
+ System.out.println("Outer class print: " + this.outer + "; " + this.f2);
+ }
public class t extends innerpt {
int outer;
public void print() {
//should print 4 0 35
+ System.out.println("Inner class print: ");
System.out.println(outer);
- System.out.println(super.outer);
+ //System.out.println(super.outer);
System.out.println(inner.this.outer);
- System.out.println(inner.super.outer);
+ //System.out.println(inner.super.outer);
System.out.println(f1);
System.out.println(f2);
System.out.println(f3);
-
+ outerprint();
}
}