示例#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
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
 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
    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
 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
 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)
     )