changes
authorjzhou <jzhou>
Thu, 24 Nov 2011 00:44:20 +0000 (00:44 +0000)
committerjzhou <jzhou>
Thu, 24 Nov 2011 00:44:20 +0000 (00:44 +0000)
Robust/src/ClassLibrary/MGC/gnu/ArrayDeque.java
Robust/src/IR/Tree/SemanticCheck.java

index ae09dc92b6247712d4d0d64cb4ec252f7d24aa67..667a4f152cbbc77e9220c500f0d7f51e3cb00228 100644 (file)
@@ -770,8 +770,8 @@ public class ArrayDeque extends AbstractCollection
     public /*<T> T*/Object[] toArray(Object/*T*/[] a) {
         int size = size();
         if (a.length < size)
-            a = /*(T[])java.lang.reflect.*/Array.newInstance(
-                    a.getClass().getComponentType(), size);
+            a = new Object[size]/*(T[])java.lang.reflect.Array.newInstance(
+                    a.getClass().getComponentType(), size)*/;
        copyElements(a);
         if (a.length > size)
             a[size] = null;
index edc4ce993ac87d568e19952973b3e243bb4c951b..7604773c5b08ecb3236ac3042eca10abecbd8c47 100644 (file)
@@ -334,7 +334,8 @@ public class SemanticCheck {
 
   public void checkMethodBody(ClassDescriptor cd, MethodDescriptor md) {
     ClassDescriptor superdesc=cd.getSuperDesc();
-    if (superdesc!=null) {
+    // for inline classes, it has done this during trial check
+    if ((!cd.getInline() || this.trialcheck) && (superdesc!=null)) {
       Set possiblematches=superdesc.getMethodTable().getSet(md.getSymbol());
       for(Iterator methodit=possiblematches.iterator(); methodit.hasNext(); ) {
         MethodDescriptor matchmd=(MethodDescriptor)methodit.next();
@@ -429,6 +430,8 @@ public class SemanticCheck {
     if ((d==null)||
         (d instanceof FieldDescriptor)) {
       nametable.add(vd);
+    } else if((md instanceof MethodDescriptor) && (((MethodDescriptor)md).getClassDesc().getInline()) && !this.trialcheck) {
+      // for inline classes, the var has been checked during trial check and added into the nametable
     } else
       throw new Error(vd.getSymbol()+" in "+md+" defined a second time");
     if (dn.getExpression()!=null)
@@ -441,6 +444,8 @@ public class SemanticCheck {
     if ((d==null)||
         (d instanceof FieldDescriptor)) {
       nametable.add(vd);
+    } else if((md instanceof MethodDescriptor) && (((MethodDescriptor)md).getClassDesc().getInline()) && !this.trialcheck) {
+      // for inline classes, the var has been checked during trial check and added into the nametable
     } else
       throw new Error(vd.getSymbol()+" defined a second time");
   }
@@ -911,15 +916,17 @@ public class SemanticCheck {
                        nn.setExpression(( ExpressionNode )theFieldNode);
                        checkExpressionNode(md,nametable,( ExpressionNode )theFieldNode,td);
                        return;         
-               } else if(cd.getInline() && this.trialcheck) {
+               } else if(cd.getInline() && (this.trialcheck)) {
                    // for the trial check of an inline class, cache the unknown var
                    d = cd.getSurroundingNameTable().get(varname);
-                   if(!this.inlineClass2LiveVars.containsKey(cd)) {
+                   if(null!=d) {
+                     if(!this.inlineClass2LiveVars.containsKey(cd)) {
                        this.inlineClass2LiveVars.put(cd, new Vector<VarDescriptor>());
-                   }
-                   Vector<VarDescriptor> vars = this.inlineClass2LiveVars.get(cd);
-                   if(!vars.contains((VarDescriptor)d)) {
-                     vars.add((VarDescriptor)d);
+                     }
+                     Vector<VarDescriptor> vars = this.inlineClass2LiveVars.get(cd);
+                     if(!vars.contains((VarDescriptor)d)) {
+                       vars.add((VarDescriptor)d);
+                     }
                    }
                }
        }