push a bunch of old changes i had related to inner classes and such... hope this...
authorbdemsky <bdemsky>
Tue, 8 Nov 2011 00:10:25 +0000 (00:10 +0000)
committerbdemsky <bdemsky>
Tue, 8 Nov 2011 00:10:25 +0000 (00:10 +0000)
Robust/src/IR/ClassDescriptor.java
Robust/src/IR/Flat/FlatNew.java
Robust/src/IR/SymbolTable.java
Robust/src/IR/Tree/BuildIR.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/Parse/java14.cup
Robust/src/buildscript

index 1e66308d1ddb2799c6d516ff2f00fefadafe2376..ddd9e40a92a019658faad4923fc76f328eb16849 100644 (file)
@@ -19,7 +19,6 @@ public class ClassDescriptor extends Descriptor {
   SymbolTable flags;
   SymbolTable methods;
   boolean inline=false;
-  
 
   ChainHashMap mandatoryImports;
   ChainHashMap multiImports;
@@ -39,7 +38,8 @@ public class ClassDescriptor extends Descriptor {
   String surroundingclass=null;
   //adding another variable to indicate depth of this inner class 
   int innerDepth = 0;
-  ClassDescriptor surroudingdesc=null;
+  ClassDescriptor surroundingdesc=null;
+
   SymbolTable innerdescs;
 
   // for enum type
@@ -362,11 +362,11 @@ public class ClassDescriptor extends Descriptor {
   }
 
   public ClassDescriptor getSurroundingDesc() {
-    return this.surroudingdesc;
+    return this.surroundingdesc;
   }
 
   public void setSurrounding(ClassDescriptor scd) {
-    this.surroudingdesc=scd;
+    this.surroundingdesc=scd;
   }
 
   public void addInnerClass(ClassDescriptor icd) {
index c94684b1d6a3ed3d19c8da8c1bdeb286a4448696..e248782b7c6e4d66e3dc2a1a86c0b3c42ec0ebae 100644 (file)
@@ -9,6 +9,8 @@ public class FlatNew extends FlatNode {
   String disjointId;
 
   public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal) {
+    if (type==null)
+      throw new Error();
     this.type=type;
     this.dst=dst;
     this.size=null;
@@ -28,6 +30,8 @@ public class FlatNew extends FlatNode {
   }
 
   public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal, String disjointId) {
+    if (type==null)
+      throw new Error();
     this.type=type;
     this.dst=dst;
     this.size=null;
@@ -36,6 +40,8 @@ public class FlatNew extends FlatNode {
   }
 
   public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal) {
+    if (type==null)
+      throw new Error();
     this.type=type;
     this.dst=dst;
     this.size=size;
@@ -44,6 +50,8 @@ public class FlatNew extends FlatNode {
   }
 
   public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal, String disjointId) {
+    if (type==null)
+      throw new Error();
     this.type=type;
     this.dst=dst;
     this.size=size;
index 86ebe7b251dc80579e2955fe209f7c2d38a7a2ec..a47c63b20ddebef8540bafb5b0e9cf9714bfbbb7 100644 (file)
@@ -10,11 +10,12 @@ public class SymbolTable {
 
   private Vector<SymbolTable> parentIFs;
 
+
   public SymbolTable() {
     table = new Hashtable();
     valueset = new HashSet();
-    this.parent = null;
-    this.parentIFs = null;
+    parent = null;
+    parentIFs = null;
   }
 
   public SymbolTable(SymbolTable parent) {
@@ -39,11 +40,8 @@ public class SymbolTable {
   }
 
   private HashSet getPSet(String name) {
-    HashSet hs=null;
-    if (parent!=null)
-      hs=parent.getPSet(name);
-    else
-      hs=new HashSet();
+    HashSet hs=(parent!=null)?parent.getPSet(name):new HashSet();
+
     if(this.parentIFs != null) {
       for(int i = 0; i < parentIFs.size(); i++) {
        hs.addAll(parentIFs.elementAt(i).getPSet(name));
@@ -69,20 +67,25 @@ public class SymbolTable {
 
   public Descriptor get(String name) {
     Descriptor d = getFromSameScope(name);
-    if (d == null) {
-      if(parent != null) {
-        d = parent.get(name);
-      }
-      if((d == null) && (this.parentIFs != null)) {
-        for(int i = 0; i < this.parentIFs.size(); i++) {
-          d = this.parentIFs.elementAt(i).get(name);
-          if(d != null) {
-            return d;
-          }
-        }
+    if (d != null)
+      return d;
+
+    if(parent != null) {
+      d = parent.get(name);
+      if (d!=null)
+       return d;
+    }
+    
+    if(parentIFs != null) {
+      for(int i = 0; i < parentIFs.size(); i++) {
+       d = parentIFs.elementAt(i).get(name);
+       if(d != null) {
+         return d;
+       }
       }
     }
-    return d;
+    
+    return null;
   }
 
   public Descriptor getFromSameScope(String name) {
@@ -116,11 +119,12 @@ public class SymbolTable {
       hs=(HashSet) parent.getAllValueSet();
     else
       hs=new HashSet();
-    if (this.parentIFs != null) {
-      for(int i = 0; i < this.parentIFs.size(); i++) {
-        hs.addAll(this.parentIFs.elementAt(i).getAllValueSet());
+    if (parentIFs != null) {
+      for(int i = 0; i < parentIFs.size(); i++) {
+        hs.addAll(parentIFs.elementAt(i).getAllValueSet());
       }
     }
+
     hs.addAll(valueset);
     return hs;
   }
@@ -142,17 +146,16 @@ public class SymbolTable {
   }
 
   public Vector<SymbolTable> getParentIFs() {
-    return this.parentIFs;
+    return parentIFs;
   }
 
   public void addParentIF(SymbolTable parentif) {
-    if(this.parentIFs == null) {
-      this.parentIFs = new Vector<SymbolTable>();
+    if(parentIFs == null) {
+      parentIFs = new Vector<SymbolTable>();
     }
-    this.parentIFs.addElement(parentif);
+    parentIFs.addElement(parentif);
   }
 
-
   public String toString() {
     return "ST: " + table.toString();
   }
index 4f4a4ee5b95081913a365d17513ae1af56a243ad..483677543811773d7785d06dd0389408d0a798f0 100644 (file)
@@ -764,7 +764,6 @@ private void addOuterClassReferences( ClassDescriptor cn, int depth )
     ClassDescriptor icn=new ClassDescriptor(cn.getPackage(), classname, false);
     pushChainMaps();
     icn.setImports(mandatoryImports, multiimports);
-    icn.setAsInnerClass();
     icn.setSurroundingClass(cn.getSymbol());
     icn.setSurrounding(cn);
     cn.addInnerClass(icn);
@@ -794,6 +793,9 @@ private void addOuterClassReferences( ClassDescriptor cn, int depth )
     }
     icn.setModifiers(parseModifiersList(pn.getChild("modifiers")));
 
+   if (!icn.isStatic())
+     icn.setAsInnerClass();
+
     parseClassBody(icn, pn.getChild("classbody"));
 
     boolean hasConstructor = false;
index dddee6338422be0279b164a0e271da88fbe95ed3..7b505875eb17e54436a13776623f5af554ae0ad4 100644 (file)
@@ -56,6 +56,9 @@ public class SemanticCheck {
         //Set superclass link up
         if (cd.getSuper()!=null) {
          ClassDescriptor superdesc=getClass(cd, cd.getSuper(), fullcheck);
+         if (superdesc.isInnerClass()) {
+           cd.setAsInnerClass();
+         }
          if (superdesc.isInterface()) {
            if (cd.getInline()) {
              cd.setSuper(null);
@@ -91,6 +94,12 @@ public class SemanticCheck {
         }
       }
       if (oldstatus<INIT&&fullcheck>=INIT) {
+       if (cd.isInnerClass()) {
+          Modifiers fdmodifiers=new Modifiers();
+         FieldDescriptor enclosingfd=new FieldDescriptor(fdmodifiers,new TypeDescriptor(cd.getSurroundingDesc()),"this___enclosing",null,false);
+         cd.addField(enclosingfd);
+       }
+
         /* Check to see that fields are well typed */
         for(Iterator field_it=cd.getFields(); field_it.hasNext(); ) {
           FieldDescriptor fd=(FieldDescriptor)field_it.next();
@@ -654,10 +663,24 @@ public class SemanticCheck {
     FieldDescriptor fd=null;
     if (ltd.isArray()&&fieldname.equals("length"))
       fd=FieldDescriptor.arrayLength;
-    else
+    else {
       fd=(FieldDescriptor) ltd.getClassDesc().getFieldTable().get(fieldname);
+    }
     if(ltd.isClassNameRef()) {
       // the field access is using a class name directly
+      if (fd==null) {
+       ClassDescriptor surroundingCls=ltd.getClassDesc().getSurroundingDesc();
+       
+       while(surroundingCls!=null) {
+         fd=(FieldDescriptor) surroundingCls.getFieldTable().get(fieldname);
+         if (fd!=null) {
+           fan.left=new ClassTypeNode(new TypeDescriptor(surroundingCls));
+           break;
+         }
+         surroundingCls=surroundingCls.getSurroundingDesc();
+       }
+      }
+
       if(ltd.getClassDesc().isEnum()) {
         int value = ltd.getClassDesc().getEnumConstant(fieldname);
         if(-1 == value) {
@@ -679,8 +702,30 @@ public class SemanticCheck {
       }
     }
 
-    if (fd==null)
-      throw new Error("Unknown field "+fieldname + " in "+fan.printNode(0)+" in "+md);
+    if (fd==null) {
+      ClassDescriptor surroundingCls=ltd.getClassDesc().getSurroundingDesc();
+      int numencloses=1;
+      while(surroundingCls!=null) {
+       fd=(FieldDescriptor)surroundingCls.getFieldTable().get(fieldname);
+       if (fd!=null) {
+         surroundingCls=ltd.getClassDesc().getSurroundingDesc();
+         FieldAccessNode ftmp=fan;
+         for(;numencloses>0;numencloses--) {
+           FieldAccessNode fnew=new FieldAccessNode(ftmp.left, "this___enclosing");
+           fnew.setField((FieldDescriptor)surroundingCls.getFieldTable().get("this___enclosing"));
+           ftmp.left=fnew;
+           ftmp=fnew;
+           surroundingCls=surroundingCls.getSurroundingDesc();
+         }
+         break;
+       }
+       surroundingCls=surroundingCls.getSurroundingDesc();
+       numencloses++;
+      }
+
+      if (fd==null)
+       throw new Error("Unknown field "+fieldname + " in "+fan.printNode(0)+" in "+md);
+    }
 
     if (fd.getType().iswrapper()) {
       FieldAccessNode fan2=new FieldAccessNode(left, fieldname);
@@ -956,47 +1001,13 @@ public class SemanticCheck {
   void checkArrayInitializerNode(Descriptor md, SymbolTable nametable, ArrayInitializerNode ain, TypeDescriptor td) {
     Vector<TypeDescriptor> vec_type = new Vector<TypeDescriptor>();
     for( int i = 0; i < ain.numVarInitializers(); ++i ) {
-      checkExpressionNode(md, nametable, ain.getVarInitializer(i), td==null?td:td.dereference());
+      checkExpressionNode(md, nametable, ain.getVarInitializer(i), td.dereference());
       vec_type.add(ain.getVarInitializer(i).getType());
     }
-    // descide the type of this variableInitializerNode
-    TypeDescriptor out_type = null;
-    for(int i = 0; i < vec_type.size(); i++) {
-      TypeDescriptor tmp_type = vec_type.elementAt(i);
-      if(out_type == null) {
-        if(tmp_type != null) {
-          out_type = tmp_type;
-        }
-      } else if(out_type.isNull()) {
-        if(!tmp_type.isNull() ) {
-          if(!tmp_type.isArray()) {
-            throw new Error("Error: mixed type in var initializer list");
-          } else {
-            out_type = tmp_type;
-          }
-        }
-      } else if(out_type.isArray()) {
-        if(tmp_type.isArray()) {
-          if(tmp_type.getArrayCount() > out_type.getArrayCount()) {
-            out_type = tmp_type;
-          }
-        } else if((tmp_type != null) && (!tmp_type.isNull())) {
-          throw new Error("Error: mixed type in var initializer list");
-        }
-      } else if(out_type.isInt()) {
-        if(!tmp_type.isInt()) {
-          throw new Error("Error: mixed type in var initializer list");
-        }
-      } else if(out_type.isString()) {
-        if(!tmp_type.isString()) {
-          throw new Error("Error: mixed type in var initializer list");
-        }
-      }
-    }
-    if(out_type != null) {
-      out_type = out_type.makeArray(state);
-    }
-    ain.setType(out_type);
+    if (td==null)
+      throw new Error();
+
+    ain.setType(td);
   }
 
   void checkAssignmentNode(Descriptor md, SymbolTable nametable, AssignmentNode an, TypeDescriptor td) {
@@ -1145,7 +1156,7 @@ public class SemanticCheck {
 
     /* Check Array Initializers */
     if ((con.getArrayInitializer() != null)) {
-      checkArrayInitializerNode(md, nametable, con.getArrayInitializer(), td);
+      checkArrayInitializerNode(md, nametable, con.getArrayInitializer(), typetolookin);
     }
 
     /* Check flag effects */
index 6dde3b9dacdc2f7c148e57e676c6317ec6550842..9416a94bd4a742cd8e65e64563f3e50fd34c1979 100644 (file)
@@ -1939,17 +1939,21 @@ primary_no_new_array ::=
                pn.addChild(id);
                RESULT=pn;
        :}
-//     |       primitive_type:pt DOT CLASS {:
-//         ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
-//         pn.addChild(pt);
-//         RESULT=pn;
-//     :}
-//     |       VOID DOT CLASS
-//     |       array_type:at DOT CLASS {:
-//         ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
-//         pn.addChild(at);
-//         RESULT=pn;
-//     :}
+       |       primitive_type:pt DOT CLASS {:
+           ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
+           pn.addChild(pt);
+           RESULT=pn;
+       :}
+       |       VOID DOT CLASS {: 
+           ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
+           pn.addChild("type").addChild("void");
+           RESULT=pn;
+        :}
+       |       array_type:at DOT CLASS {:
+           ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
+           pn.addChild(at);
+           RESULT=pn;
+       :}
        |       name:name DOT CLASS {:
            ParseNode pn=new ParseNode("class_type",parser.lexer.line_num);
            pn.addChild("type").addChild("class").addChild(name);
index 1cdf1d92e6afaa66b191978acd27589a77f11ff6..4ea2b894da3c7f6cc4b4d7b8300cf5607f01ac84 100755 (executable)
@@ -868,8 +868,7 @@ fi
 
 if $JNI
   then
-  JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/classpath/ -classlibrary $ROBUSTROOT/classpath/vm/reference"
-
+  JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/classpath/ -classlibrary $ROBUSTROOT/classpath/vm/reference/"
 elif $MGCINTELFLAG
   then
   JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/MGC/ -classlibrary $ROBUSTROOT/ClassLibrary/MGC/gnu/"
@@ -884,6 +883,8 @@ elif $USE_SSJAVA_CLASSPATH
   JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/SSJava"  
 
 else
+  JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/"
+
   if $RECOVERFLAG
     then
     if $FASTCHECK