Another bug fix for inner class code: when trying to find a field in the surrounding...
authorjzhou <jzhou>
Wed, 21 Dec 2011 02:00:30 +0000 (02:00 +0000)
committerjzhou <jzhou>
Wed, 21 Dec 2011 02:00:30 +0000 (02:00 +0000)
Robust/src/IR/Tree/SemanticCheck.java

index 24254c2e601d89819377673ccaf0af211b2607cd..7851ae38c6b9401bf3fd52023aef4dcba589c68f 100644 (file)
@@ -899,7 +899,7 @@ public class SemanticCheck {
            throw new Error("Error: access non-static field " + cd.getSymbol() + "." + fd.getSymbol() + " in an inner class " + icd.getSymbol() + " that is declared in a static context");
          }
        }
-       int depth = 1;
+       int depth = 0;
        int startingDepth = icd.getInnerDepth();
 
        if( true == cd.isInnerClass() ) 
@@ -908,12 +908,8 @@ public class SemanticCheck {
        String composed = "this";
        NameDescriptor runningDesc = new NameDescriptor( "this" );;
        
-       for ( int index = startingDepth; index > depth; --index ) {
-               composed = "this$" + String.valueOf( index - 1  );      
-               runningDesc = new NameDescriptor( runningDesc, composed );
-       }
-       if( false == cd.isInnerClass() )
-               runningDesc = new NameDescriptor( runningDesc, "this$" + String.valueOf(0) ); //all the way up.
+       composed = "this$" + String.valueOf(startingDepth-depth-1);
+       runningDesc = new NameDescriptor(runningDesc, composed);
        NameDescriptor idDesc = new NameDescriptor( runningDesc, varname );