2004/01/13 10:27:47
[org.ibex.core.git] / src / org / xwt / js / JSScope.java
index 3e797f3..a504d8d 100644 (file)
@@ -1,10 +1,11 @@
-// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] 
+// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] 
 package org.xwt.js; 
 
 import org.xwt.util.*; 
 import java.io.*;
 import java.util.*;
 
+// FIXME: should allow parentScope to be a JS, not a JSScope
 /** Implementation of a JavaScript Scope */
 public class JSScope extends JS { 
 
@@ -27,6 +28,12 @@ public class JSScope extends JS {
         if (parentScope != null && !has(key)) parentScope.put(key, val);
         else super.put(key, val == null ? NULL_PLACEHOLDER : val);
     }
+    
+    public JSScope top() { 
+        JSScope s = this;
+        while(s.parentScope != null) s = s.parentScope;
+        return s;
+    }
 
     public static class Global extends JSScope {
         private final static Double NaN = new Double(Double.NaN);