Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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