From d14a37da2d2b2e62b23336832b96d85252554960 Mon Sep 17 00:00:00 2001 From: jzhou Date: Wed, 21 Dec 2011 02:00:30 +0000 Subject: [PATCH] Another bug fix for inner class code: when trying to find a field in the surrounding classes, the this was wrongly constructred. --- Robust/src/IR/Tree/SemanticCheck.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index 24254c2e..7851ae38 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -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 ); -- 2.34.1