当前位置: 首页>>代码示例>>Python>>正文


Python NS_VAR.deref方法代码示例

本文整理汇总了Python中pixie.vm.compiler.NS_VAR.deref方法的典型用法代码示例。如果您正苦于以下问题:Python NS_VAR.deref方法的具体用法?Python NS_VAR.deref怎么用?Python NS_VAR.deref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pixie.vm.compiler.NS_VAR的用法示例。


在下文中一共展示了NS_VAR.deref方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inner_invoke

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]
    def inner_invoke(self, args):
        import pixie.vm.rt as rt
        import pixie.vm.persistent_vector as vector

        with with_ns(u"user"):
            NS_VAR.deref().include_stdlib()

        acc = vector.EMPTY
        for x in self._argv:
            acc = rt.conj(acc, rt.wrap(x))

        PROGRAM_ARGUMENTS.set_root(acc)

        with with_ns(u"user"):
            try:
                f = None
                if self._file == '-':
                    f, _, _ = create_stdio()
                else:
                    if not path.isfile(self._file):
                        print "Error: Cannot open '" + self._file + "'"
                        os._exit(1)
                    f = open(self._file)
                data = f.read()
                f.close()

                if data.startswith("#!"):
                    newline_pos = data.find("\n")
                    if newline_pos > 0:
                        data = data[newline_pos:]

                rt.load_reader(StringReader(unicode_from_utf8(data)))
            except WrappedException as ex:
                print "Error: ", ex._ex.__repr__()
                os._exit(1)
开发者ID:gigasquid,项目名称:pixie,代码行数:37,代码来源:target.py

示例2: inner_invoke

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]
    def inner_invoke(self, args):
        import pixie.vm.rt as rt

        with with_ns(u"user"):
            NS_VAR.deref().include_stdlib()

            interpret(compile(read(StringReader(unicode(self._expr)), True)))
开发者ID:devn,项目名称:pixie,代码行数:9,代码来源:target.py

示例3: inner_invoke

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]
    def inner_invoke(self, args):
        from pixie.vm.keyword import keyword
        import pixie.vm.rt as rt
        from pixie.vm.string import String
        import pixie.vm.persistent_vector as vector

        with with_ns(u"user"):
            NS_VAR.deref().include_stdlib()

        acc = vector.EMPTY
        for x in self._argv:
            acc = rt.conj(acc, rt.wrap(x))

        PROGRAM_ARGUMENTS.set_root(acc)


        rdr = MetaDataReader(PromptReader())
        with with_ns(u"user"):
            while True:
                try:
                    val = read(rdr, False)
                    if val is eof:
                        break
                    val = interpret(compile(val))
                except WrappedException as ex:
                    print "Error: ", ex._ex.__repr__()
                    rdr.reset_line()
                    continue
                if val is keyword(u"exit-repl"):
                    break
                val = rt.str(val)
                assert isinstance(val, String), "str should always return a string"
                print val._str
开发者ID:squaremo,项目名称:pixie,代码行数:35,代码来源:target.py

示例4: in_ns

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]
def in_ns(ns_name):
    from pixie.vm.compiler import NS_VAR

    NS_VAR.set_value(code._ns_registry.find_or_make(rt.name(ns_name)))
    NS_VAR.deref().include_stdlib()

    return nil
开发者ID:nooga,项目名称:pixie,代码行数:9,代码来源:stdlib.py

示例5: inner_invoke

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]
    def inner_invoke(self, args):
        import pixie.vm.rt as rt
        import pixie.vm.persistent_vector as vector

        with with_ns(u"user"):
            NS_VAR.deref().include_stdlib()

        acc = vector.EMPTY
        for x in self._argv:
            acc = rt.conj(acc, rt.wrap(x))

        PROGRAM_ARGUMENTS.set_root(acc)

        with with_ns(u"user"):
            if self._file == '-':
                stdin, _, _ = create_stdio()
                code = stdin.read()
                interpret(compile(read(StringReader(unicode(code)), True)))
            else:
                rt.load_file(rt.wrap(self._file))
开发者ID:foodhype,项目名称:pixie,代码行数:22,代码来源:target.py

示例6: repl

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]
def repl():
    from pixie.vm.keyword import keyword
    import pixie.vm.rt as rt
    from pixie.vm.string import String

    with with_ns(u"user"):
        NS_VAR.deref().include_stdlib()

    rdr = PromptReader()
    while True:
        with with_ns(u"user"):
            try:
                val = interpret(compile(read(rdr, True)))
            except WrappedException as ex:
                print "Error: ", ex._ex.__repr__()
                continue
            if val is keyword(u"exit-repl"):
                break
            val = rt.str(val)
            assert isinstance(val, String), "str should always return a string"
            print val._str
开发者ID:cloudshill,项目名称:pixie,代码行数:23,代码来源:target.py

示例7: _defprotocol

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]
def _defprotocol(name, methods):
    from pixie.vm.compiler import NS_VAR
    from pixie.vm.persistent_vector import PersistentVector
    from pixie.vm.symbol import Symbol
    affirm(isinstance(name, Symbol), u"protocol name must be a symbol")
    affirm(isinstance(methods, PersistentVector), u"protocol methods must be a vector of symbols")
    method_list = []
    for i in range(0, rt.count(methods)):
        method_sym = rt.nth(methods, rt.wrap(i))
        affirm(isinstance(method_sym, Symbol), u"protocol methods must be a vector of symbols")
        method_list.append(rt.name(method_sym))

    proto =  Protocol(rt.name(name))
    ns = rt.name(NS_VAR.deref())
    intern_var(ns, rt.name(name)).set_root(proto)
    for method in method_list:
        method = unicode(method)
        poly = PolymorphicFn(method,  proto)
        intern_var(ns, method).set_root(poly)

    return name
开发者ID:discoverfly,项目名称:pixie,代码行数:23,代码来源:stdlib.py

示例8: interpret

# 需要导入模块: from pixie.vm.compiler import NS_VAR [as 别名]
# 或者: from pixie.vm.compiler.NS_VAR import deref [as 别名]

#.........这里部分代码省略.........

            for idx in range(argc - 1, -1, -1):
                lst[idx] = frame.pop()

            cobj = frame.pop()
            closure = code.Closure(cobj, lst)
            frame.push(closure)

            continue

        if inst == code.CLOSED_OVER:
            assert isinstance(frame.code_obj, code.Closure)
            idx = frame.get_inst()
            frame.push_closed_over(idx)
            continue

        if inst == code.SET_VAR:
            val = frame.pop()
            var = frame.pop()

            affirm(isinstance(var, code.Var), u"Can't set the value of a non-var")
            var.set_root(val)
            frame.push(var)
            continue

        if inst == code.POP:
            frame.pop()
            continue

        if inst == code.DEREF_VAR:
            debug_ip = frame.ip
            var = frame.pop()
            if not isinstance(var, code.Var):
                affirm(False, u"Can't deref " + var.type()._name)
            try:
                frame.push(var.deref())
                continue
            except WrappedException as ex:
                dp = frame.debug_points.get(debug_ip - 1, None)
                if dp:
                    ex._ex._trace.append(dp)
                raise


        if inst == code.RECUR:
            argc = frame.get_inst()
            args = frame.pop_n(argc)

            frame = Frame(frame.code_obj, args, frame.self_obj)

            jitdriver.can_enter_jit(bc=frame.bc,
                                  ip=frame.ip,
                                  sp=frame.sp,
                                  base_code=frame.base_code,
                                  frame=frame,
                                  is_continuation=frame._is_continuation)
            continue

        if inst == code.PUSH_SELF:
            frame.push(frame.self_obj)
            continue

        if inst == code.DUP_NTH:
            n = frame.nth(frame.get_inst())
            frame.push(n)
            continue
开发者ID:delonnewman,项目名称:pixie,代码行数:70,代码来源:interpreter.py


注:本文中的pixie.vm.compiler.NS_VAR.deref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。