コード例 #1
0
def lazy_function(f):
    return thunk.fromvalue(
        FunctionType(
            LazyTransformer().visit(f.__code__),
            f.__globals__,
            f.__name__,
            tuple(map(thunk.fromvalue, f.__defaults__ or ())),
            f.__closure__,
        ), )
コード例 #2
0
ファイル: bytecode.py プロジェクト: RogerThomas/lazy_python
def lazy_function(f):
    return thunk.fromvalue(
        FunctionType(
            LazyTransformer().visit(f.__code__),
            f.__globals__,
            f.__name__,
            tuple(map(thunk.fromvalue, f.__defaults__ or ())),
            f.__closure__,
        ),
    )
コード例 #3
0
ファイル: bytecode.py プロジェクト: pombredanne/lazy_python
 def __call__(self, f):
     return thunk.fromvalue(
         FunctionType(
             self.transform(Code.from_pycode(f.__code__)).to_pycode(),
             f.__globals__,
             f.__name__,
             tuple(map(thunk.fromvalue, f.__defaults__ or ())),
             f.__closure__,
         ),
     )
コード例 #4
0
 def __call__(self, f):
     return thunk.fromvalue(
         FunctionType(
             self.visit(f.__code__),
             f.__globals__,
             f.__name__,
             tuple(map(thunk.fromvalue, f.__defaults__ or ())),
             f.__closure__,
         ),
     )
コード例 #5
0
ファイル: bytecode.py プロジェクト: pombredanne/lazy_python
    def _build_set(self, instr):
        # TOS  v_0
        # ...
        # TOSn v_n

        yield instructions.BUILD_TUPLE(instr.arg).steal(instr)
        # TOS  (v_0, ..., v_n)

        yield instructions.LOAD_CONST(thunk.fromvalue(set))
        # TOS  thunk.fromvalue(set)
        # TOS1 (v_0, ..., v_n)

        yield instructions.ROT_TWO()
        # TOS  (v_0, ..., v_n)
        # TOS1 thunk.fromvalue(set)

        yield instructions.CALL_FUNCTION(1)
コード例 #6
0
ファイル: bytecode.py プロジェクト: RogerThomas/lazy_python
 def visit_const(self, const):
     const = super().visit_const(const)
     if not isinstance(const, CodeType):
         const = thunk.fromvalue(const)
     return const
コード例 #7
0
 def visit_const(self, const):
     const = super().visit_const(const)
     if not isinstance(const, CodeType):
         const = thunk.fromvalue(const)
     return const
コード例 #8
0
ファイル: bytecode.py プロジェクト: pombredanne/lazy_python
 def transform_consts(self, consts):
     return tuple(
         const if isinstance(const, CodeType) else thunk.fromvalue(const)
         for const in super().transform_consts(consts)
     )
コード例 #9
0
 def visit_consts(self, consts):
     return tuple(
         const if isinstance(const, CodeType) else thunk.fromvalue(const)
         for const in super().visit_consts(consts)
     )