2002/05/16 04:00:52
[org.ibex.core.git] / src / org / xwt / Static.java
index 59450a7..4117892 100644 (file)
@@ -11,7 +11,10 @@ public class Static extends JSObject {
         Static ret = (Static)cache.get(resourcename);
         if (ret == null) {
             Template t = Template.getTemplate(resourcename, null);
-            if (t == null) return null;
+
+            // FIXME: ugly
+            if (t == null) return new Static(resourcename, true);
+
             ret = new Static(resourcename, false);
             t.link();
             return ret;
@@ -36,9 +39,7 @@ public class Static extends JSObject {
     }
     
     /** creates a new static representing a package */
-    public Static(String resourcename) {
-        this(resourcename, true);
-    }
+    public Static(String resourcename) { this(resourcename, true); }
 
     public Object get(String name, Scriptable start) {
         if (name == null) return null;
@@ -49,7 +50,12 @@ public class Static extends JSObject {
         if (name.equals("Function")) return JSObject.defaultObjects.get("Function", null);
         if (name.equals("TypeError")) return JSObject.defaultObjects.get("TypeError", null);
 
-        if ("xwt".equals(name)) return XWT.singleton;
+        if ("xwt".equals(name))
+            for(Scriptable cur = Context.enter().currentFunction; cur != null; cur = cur.getParentScope())
+                if (cur == this) return XWT.singleton;
+
+        System.out.println("casc up " + (resourcename + (resourcename.length() == 0 ? "" : ".") + name));
+
         if (!ispackage) return super.get(name, start);
         return getStatic(resourcename + (resourcename.length() == 0 ? "" : ".") + name);
     }