本文整理匯總了Python中rpython.rtyper.annlowlevel.MixLevelHelperAnnotator.delayedfunction方法的典型用法代碼示例。如果您正苦於以下問題:Python MixLevelHelperAnnotator.delayedfunction方法的具體用法?Python MixLevelHelperAnnotator.delayedfunction怎麽用?Python MixLevelHelperAnnotator.delayedfunction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rpython.rtyper.annlowlevel.MixLevelHelperAnnotator
的用法示例。
在下文中一共展示了MixLevelHelperAnnotator.delayedfunction方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_pseudohighlevelcallable
# 需要導入模塊: from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator [as 別名]
# 或者: from rpython.rtyper.annlowlevel.MixLevelHelperAnnotator import delayedfunction [as 別名]
def test_pseudohighlevelcallable():
t = TranslationContext()
t.buildannotator()
rtyper = t.buildrtyper()
rtyper.specialize()
a = MixLevelHelperAnnotator(rtyper)
class A:
value = 5
def double(self):
return self.value * 2
def fn1(a):
a2 = A()
a2.value = a.double()
return a2
s_A, r_A = a.s_r_instanceof(A)
fn1ptr = a.delayedfunction(fn1, [s_A], s_A)
pseudo = PseudoHighLevelCallable(fn1ptr, [s_A], s_A)
def fn2(n):
a = A()
a.value = n
a2 = pseudo(a)
return a2.value
graph = a.getgraph(fn2, [annmodel.SomeInteger()], annmodel.SomeInteger())
a.finish()
llinterp = LLInterpreter(rtyper)
res = llinterp.eval_graph(graph, [21])
assert res == 42
示例2: complete_destrptr
# 需要導入模塊: from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator [as 別名]
# 或者: from rpython.rtyper.annlowlevel.MixLevelHelperAnnotator import delayedfunction [as 別名]
def complete_destrptr(gctransformer):
translator = gctransformer.translator
mixlevelannotator = MixLevelHelperAnnotator(translator.rtyper)
args_s = [lltype_to_annotation(STACKLET_PTR)]
s_result = annmodel.s_None
destrptr = mixlevelannotator.delayedfunction(stacklet_destructor, args_s, s_result)
mixlevelannotator.finish()
lltype.attachRuntimeTypeInfo(STACKLET, destrptr=destrptr)
示例3: replace_force_virtualizable
# 需要導入模塊: from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator [as 別名]
# 或者: from rpython.rtyper.annlowlevel.MixLevelHelperAnnotator import delayedfunction [as 別名]
def replace_force_virtualizable(self, rtyper, graphs):
from rpython.annotator import model as annmodel
from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator
graph = graphs[0]
for block, op in graph.iterblockops():
if op.opname == 'jit_force_virtualizable':
v_inst_ll_type = op.args[0].concretetype
break
def mycall(vinst_ll):
if vinst_ll.vable_token:
raise ValueError
annhelper = MixLevelHelperAnnotator(rtyper)
s_vinst = SomePtr(v_inst_ll_type)
funcptr = annhelper.delayedfunction(mycall, [s_vinst], annmodel.s_None)
annhelper.finish()
replace_force_virtualizable_with_call(graphs, v_inst_ll_type, funcptr)
return funcptr