X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FScopeImpl.java;h=a01b3bb22e52e247fc4b0bd63bfd398946aa2ae9;hb=5e8485ac88b45693b5cdb8e70f346b92732eb91f;hp=5162c0e8e2aa61a7bd6c52f527b6d0871062df80;hpb=77f51cd3e157cf6fd2ae85ce774444bb85ea7b81;p=org.ibex.core.git diff --git a/src/org/xwt/js/ScopeImpl.java b/src/org/xwt/js/ScopeImpl.java index 5162c0e..a01b3bb 100644 --- a/src/org/xwt/js/ScopeImpl.java +++ b/src/org/xwt/js/ScopeImpl.java @@ -8,7 +8,7 @@ import java.util.*; /** Implementation of a JavaScript Scope */ class ScopeImpl extends JS.Obj { private JS.Scope parentScope; - private static Object NULL = new Object(); + private static final Object NULL_PLACEHOLDER = new Object(); public ScopeImpl(JS.Scope parentScope, boolean sealed) { super(sealed); if (parentScope == this) throw new Error("can't make a scope its own parent!"); @@ -16,17 +16,19 @@ class ScopeImpl extends JS.Obj { } public Object[] keys() { throw new Error("you can't enumerate the properties of a Scope"); } public boolean has(Object key) { return super.get(key) != null; } - public Object get(Object key) { - if (!has(key)) return parentScope == null ? null : parentScope.get(key); - Object ret = super.get(key); return ret == NULL ? null : ret; + // we use _get instead of get solely to work around a GCJ bug + public Object _get(Object key) { + Object o = super.get(key); + if (o != null) return o == NULL_PLACEHOLDER ? null : o; + else return parentScope == null ? null : parentScope.get(key); } - public void put(Object key, Object val) { - if (!has(key) && parentScope != null) parentScope.put(key, val); - else super.put(key, val == null ? NULL : val); + // we use _put instead of put solely to work around a GCJ bug + public void _put(Object key, Object val) { + if (parentScope != null && !has(key)) parentScope.put(key, val); + else super.put(key, val == null ? NULL_PLACEHOLDER : val); } public boolean isTransparent() { return false; } - public void declare(String s) { - if (isTransparent()) parentScope.declare(s); - else super.put(s, NULL); - } -} + public void declare(String s) { super.put(s, NULL_PLACEHOLDER); } + public Scope getParentScope() { return parentScope; } +} +