corrected behavior of statics
authoradam <adam@megacz.com>
Wed, 10 Mar 2004 05:33:29 +0000 (05:33 +0000)
committeradam <adam@megacz.com>
Wed, 10 Mar 2004 05:33:29 +0000 (05:33 +0000)
darcs-hash:20040310053329-5007d-db883cafb7a4fb58b1bb0f8f3dab33262332d004.gz

src/org/ibex/Template.java

index 0461dbc..fb9f4cc 100644 (file)
@@ -34,6 +34,7 @@ public class Template {
     Template prev;
     Template prev2;
     JSScope staticScope = null;         ///< the scope in which the static block is executed
     Template prev;
     Template prev2;
     JSScope staticScope = null;         ///< the scope in which the static block is executed
+    JS staticObject = null;
 
 
     // Only used during parsing /////////////////////////////////////////////////////////////////
 
 
     // Only used during parsing /////////////////////////////////////////////////////////////////
@@ -81,7 +82,7 @@ public class Template {
         // FIXME this dollar stuff is all wrong
         if (id != null) parentPis.putDollar(id, b);
 
         // FIXME this dollar stuff is all wrong
         if (id != null) parentPis.putDollar(id, b);
 
-        PerInstantiationScope pis = new PerInstantiationScope(b, ibex, parentPis, staticScope);
+        PerInstantiationScope pis = new PerInstantiationScope(b, ibex, parentPis, staticObject);
         for(int i=0; i<urikeys.length; i++) {
             if (urikeys[i] == null) continue;
             pis.declare(urikeys[i]);
         for(int i=0; i<urikeys.length; i++) {
             if (urikeys[i] == null) continue;
             pis.declare(urikeys[i]);
@@ -166,7 +167,8 @@ public class Template {
             initial_uri = "";
             parse(new InputStreamReader(is));
             JS staticScript = parseScript(static_content, static_content_start);
             initial_uri = "";
             parse(new InputStreamReader(is));
             JS staticScript = parseScript(static_content, static_content_start);
-            t.staticScope = new PerInstantiationScope(null, ibex, null, null);
+            t.staticObject = new JS();
+            t.staticScope = new PerInstantiationScope(null, ibex, null, t.staticObject);
             if (staticScript != null) JS.cloneWithNewParentScope(staticScript, t.staticScope).call(null, null, null, null, 0);
         }
 
             if (staticScript != null) JS.cloneWithNewParentScope(staticScript, t.staticScope).call(null, null, null, null, 0);
         }
 
@@ -326,13 +328,13 @@ public class Template {
     private static class PerInstantiationScope extends JSScope {
         Ibex ibex = null;
         PerInstantiationScope parentBoxPis = null;
     private static class PerInstantiationScope extends JSScope {
         Ibex ibex = null;
         PerInstantiationScope parentBoxPis = null;
-        JSScope myStatic = null;
+        JS myStatic = null;
         void putDollar(String key, Box target) throws JSExn {
             if (parentBoxPis != null) parentBoxPis.putDollar(key, target);
             declare("$" + key);
             put("$" + key, target);
         }
         void putDollar(String key, Box target) throws JSExn {
             if (parentBoxPis != null) parentBoxPis.putDollar(key, target);
             declare("$" + key);
             put("$" + key, target);
         }
-        public PerInstantiationScope(JSScope parentScope, Ibex ibex, PerInstantiationScope parentBoxPis, JSScope myStatic) {
+        public PerInstantiationScope(JSScope parentScope, Ibex ibex, PerInstantiationScope parentBoxPis, JS myStatic) {
             super(parentScope);
             this.parentBoxPis = parentBoxPis;
             this.ibex = ibex;
             super(parentScope);
             this.parentBoxPis = parentBoxPis;
             this.ibex = ibex;