def invoke(self, rdr, ch): meta = read_inner(rdr, True) obj = read_inner(rdr, True) if isinstance(meta, Keyword): meta = rt.hashmap(meta, true) if isinstance(meta, Symbol): meta = rt.hashmap(keyword(u"tag"), meta) if rt._satisfies_QMARK_(rt.IMeta.deref(), obj): return rt.with_meta(obj, rt.merge(meta, rt.meta(obj))) return obj
def test_hashmap_create(): acc = rt.hashmap(Integer(1), Integer(2)) val = rt._val_at(acc, Integer(1), nil) assert val.int_val() == 2
def test_hashmap_create(): acc = rt.hashmap(rt.wrap(1), rt.wrap(2)) val = rt._val_at(acc, rt.wrap(1), nil) assert val.int_val() == 2
def invoke(self, rdr, ch): meta = read(rdr, True) obj = read(rdr, True) if isinstance(meta, Keyword): meta = rt.hashmap(meta, true) if rt.satisfies_QMARK_(rt.IMeta.deref(), obj): return rt.with_meta(obj, rt.merge(meta, rt.meta(obj))) return obj
def ns_map(ns): from pixie.vm.symbol import Symbol affirm(isinstance(ns, code.Namespace) or isinstance(ns, Symbol), u"ns must be a symbol or a namespace") if isinstance(ns, Symbol): ns = rt.the_ns(ns) if ns is nil: return nil m = rt.hashmap() for name in ns._registry: var = ns._registry.get(name, nil) m = rt.assoc(m, rt.symbol(rt.wrap(name)), var) return m
def ns_aliases(ns): from pixie.vm.symbol import Symbol affirm(isinstance(ns, Namespace) or isinstance(ns, Symbol), u"ns must be a symbol or a namespace") if isinstance(ns, Symbol): ns = rt.the_ns(ns) if ns is nil: return nil if isinstance(ns, Namespace): m = rt.hashmap() for alias in ns._refers: refered_ns = ns._refers[alias]._namespace m = rt.assoc(m, rt.symbol(rt.wrap(alias)), refered_ns) return m return nil
def _seq(self): import pixie.vm.persistent_vector as vector import pixie.vm.persistent_hash_map as hmap from pixie.vm.keyword import keyword assert isinstance(self, RuntimeException) trace = vector.EMPTY trace_element = rt.hashmap(keyword(u"type"), keyword(u"runtime")) trace_element = rt.assoc(trace_element, keyword(u"data"), rt.wrap(self._data)) trace = rt.conj(trace, trace_element) for x in self._trace: tmap = x.trace_map() trace_element = hmap.EMPTY for key in tmap: val = tmap[key] trace_element = rt.assoc(trace_element, key, val) trace = rt.conj(trace, trace_element) return rt._seq(trace)
def ns_aliases(ns): from pixie.vm.symbol import Symbol affirm( isinstance(ns, Namespace) or isinstance(ns, Symbol), u"ns must be a symbol or a namespace") if isinstance(ns, Symbol): ns = rt.the_ns(ns) if ns is nil: return nil if isinstance(ns, Namespace): m = rt.hashmap() for alias in ns._refers: refered_ns = ns._refers[alias]._namespace m = rt.assoc(m, rt.symbol(rt.wrap(alias)), refered_ns) return m return nil
def ns_map(ns): from pixie.vm.symbol import Symbol affirm( isinstance(ns, Namespace) or isinstance(ns, Symbol), u"ns must be a symbol or a namespace") if isinstance(ns, Symbol): ns = rt.the_ns(ns) if ns is nil: return nil if isinstance(ns, Namespace): m = rt.hashmap() for name in ns._registry: var = ns._registry.get(name, nil) m = rt.assoc(m, rt.symbol(rt.wrap(name)), var) return m return nil
def get_metadata(self): return rt.hashmap(LINE_KW, rt.wrap(self._line), LINE_NUMBER_KW, rt.wrap(self._line_number), COLUMN_NUMBER_KW, rt.wrap(self._column_number), FILE_KW, rt.wrap(self._filename))
def __init__(self): self._vars = rt.cons(rt.hashmap(), nil)