diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-11-05 12:07:43 -0500 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-11-05 12:07:43 -0500 |
commit | 2e7e41c9788b9cc02fe070d8e5319929d996ee32 (patch) | |
tree | 2b3d0bcc814617397776af9d681fd69a174a3300 | |
parent | 73d51aef645c6103eb641dbc19a50dd868df64f1 (diff) |
install default lookup thunk for non-field accessors of IKeywordLookups
-rw-r--r-- | src/jvm/clojure/lang/KeywordLookupSite.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/jvm/clojure/lang/KeywordLookupSite.java b/src/jvm/clojure/lang/KeywordLookupSite.java index 813f754f..02ddfffa 100644 --- a/src/jvm/clojure/lang/KeywordLookupSite.java +++ b/src/jvm/clojure/lang/KeywordLookupSite.java @@ -29,15 +29,7 @@ public Object fault(Object target, ILookupHost host){ } else if(target instanceof ILookup) { - final Class c = target.getClass(); - host.swapThunk(n,new ILookupThunk(){ - - public Object get(Object target){ - if(target != null && target.getClass() == c) - return ((ILookup) target).valAt(k); - return this; - } - }); + host.swapThunk(n,ilookupThunk(target.getClass())); return ((ILookup) target).valAt(k); } host.swapThunk(n,this); @@ -50,9 +42,24 @@ public Object get(Object target){ return RT.get(target,k); } +private ILookupThunk ilookupThunk(final Class c){ + return new ILookupThunk(){ + public Object get(Object target){ + if(target != null && target.getClass() == c) + return ((ILookup) target).valAt(k); + return this; + } + }; +} + private Object install(Object target, ILookupHost host){ ILookupThunk t = ((IKeywordLookup)target).getLookupThunk(k); - host.swapThunk(n,t); - return t.get(target); + if(t != null) + { + host.swapThunk(n,t); + return t.get(target); + } + host.swapThunk(n,ilookupThunk(target.getClass())); + return ((ILookup) target).valAt(k); } } |