Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
def test_hashmap_create():

    acc = rt.hashmap(Integer(1), Integer(2))

    val = rt._val_at(acc, Integer(1), nil)

    assert val.int_val() == 2
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
 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))
Ejemplo n.º 13
0
 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))
Ejemplo n.º 14
0
Archivo: code.py Proyecto: jmglov/pixie
 def __init__(self):
     self._vars = rt.cons(rt.hashmap(), nil)
Ejemplo n.º 15
0
 def __init__(self):
     self._vars = rt.cons(rt.hashmap(), nil)