Refine search
public IPersistentMap assoc(Object k, Object v) { if (k instanceof Keyword) return assoc(((Keyword) k).getName(), v); return new IndifferentAccessMap(getMap().assoc(k, v)); }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable{ Class rt = method.getReturnType(); IFn fn = (IFn) fns.valAt(method.getName()); if(fn == null)
public IPersistentMap without(Object k) { if (k instanceof Keyword) return without(((Keyword) k).getName()); return new IndifferentAccessMap(getMap().without(k)); }
public void removeAlias(Symbol alias) { IPersistentMap map = getAliases(); while(map.containsKey(alias)) { IPersistentMap newMap = map.without(alias); aliases.compareAndSet(map, newMap); map = getAliases(); } }
public void addAlias(Symbol alias, Namespace ns){ if (alias == null || ns == null) throw new NullPointerException("Expecting Symbol + Namespace"); IPersistentMap map = getAliases(); while(!map.containsKey(alias)) { IPersistentMap newMap = map.assoc(alias, ns); aliases.compareAndSet(map, newMap); map = getAliases(); } // you can rebind an alias, but only to the initially-aliased namespace. if(!map.valAt(alias).equals(ns)) throw new IllegalStateException("Alias " + alias + " already exists in namespace " + name + ", aliasing " + map.valAt(alias)); }
Class referenceClass(Symbol sym, Class val){ if(sym.ns != null) { throw new IllegalArgumentException("Can't intern namespace-qualified symbol"); } IPersistentMap map = getMappings(); Class c = (Class) map.valAt(sym); while((c == null) || (areDifferentInstancesOfSameClassName(c, val))) { IPersistentMap newMap = map.assoc(sym, val); mappings.compareAndSet(map, newMap); map = getMappings(); c = (Class) map.valAt(sym); } if(c == val) return c; throw new IllegalStateException(sym + " already refers to: " + c + " in namespace: " + name); }
private boolean prefers(Object x, Object y) { IPersistentSet xprefs = (IPersistentSet) getPreferTable().valAt(x); if(xprefs != null && xprefs.contains(y)) return true; for(ISeq ps = RT.seq(parents.invoke(y)); ps != null; ps = ps.next()) { if(prefers(x, ps.first())) return true; } for(ISeq ps = RT.seq(parents.invoke(x)); ps != null; ps = ps.next()) { if(prefers(ps.first(), y)) return true; } return false; }
static private Object installPlatformFeature(Object opts) { if(opts == null) return RT.mapUniqueKeys(LispReader.OPT_FEATURES, PLATFORM_FEATURES); else { IPersistentMap mopts = (IPersistentMap) opts; Object features = mopts.valAt(OPT_FEATURES); if (features == null) return mopts.assoc(LispReader.OPT_FEATURES, PLATFORM_FEATURES); else return mopts.assoc(LispReader.OPT_FEATURES, RT.conj((IPersistentSet) RT.conj((IPersistentSet) features, PLATFORM_KEY), DUNAJ_KEY)); } }
static boolean isPreserveReadCond(Object opts) { if(RT.booleanCast(READ_COND_ENV.deref()) && opts instanceof IPersistentMap) { Object readCond = ((IPersistentMap) opts).valAt(OPT_READ_COND); return COND_PRESERVE.equals(readCond); } else return false; }
public boolean isMacro(){ return RT.booleanCast(meta().valAt(macroKey)); }
public ISeq seq() { return getMap().seq(); }
public Iterator iterator() { return getMap().iterator(); }
static public PersistentTreeMap create(ISeq items){ IPersistentMap ret = EMPTY; for(; items != null; items = items.next().next()) { if(items.next() == null) throw new IllegalArgumentException(String.format("No value supplied for key: %s", items.first())); ret = ret.assoc(items.first(), RT.second(items)); } return (PersistentTreeMap) ret; }
@Override public Expression substitute(IPersistentMap bindings) { if(bindings.containsKey(sym)) { return Constant.create(bindings.valAt(sym)); } return this; }
public IPersistentMap assocEx(Object k, Object v) { if (k instanceof Keyword) return assocEx(((Keyword) k).getName(), v); return new IndifferentAccessMap(getMap().assocEx(k, v)); }