本文整理汇总了Python中frame.Frame.push方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.push方法的具体用法?Python Frame.push怎么用?Python Frame.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frame.Frame
的用法示例。
在下文中一共展示了Frame.push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrap_run_method
# 需要导入模块: from frame import Frame [as 别名]
# 或者: from frame.Frame import push [as 别名]
def wrap_run_method(self, instance, method, *args):
klass = instance
frame = Frame(max_locals=1)
if isinstance(instance, ClassInstance):
klass = instance._klass
frame.push(instance)
if args:
frame.stack += args
self.frame_stack.append(frame)
self.run_method(klass, method)
self.run_bytecode()
self.frame_stack.pop()
if frame.stack:
return frame.stack.pop()
return void
示例2: __init__
# 需要导入模块: from frame import Frame [as 别名]
# 或者: from frame.Frame import push [as 别名]
class Compiler:
def __init__(self, assembler, rt, ctx):
self.assembler = AssemblerWrapper(assembler)
self.frame = Frame(self.assembler)
self.rt = rt # runtime
self.ctx = ctx
self.state = {
'with': False,
'eval': False
}
def declare_vars(self, vars):
for var in vars:
self.ctx.object.addProperty(var.name, Value(Value.undefined))
def compile(self, ast):
assert ast.type == 'SCRIPT'
self.declare_vars(ast.varDecls)
self.ptr_to_spill = c_int(0)
self.assembler.push(ebp)
self.assembler.mov(ebp, esp)
self.assembler.push(esi)
self.assembler.mov(esi, addressof(self.ptr_to_spill))
self.assembler.mov(esi, esi.addr + 0)
self.op_block(ast)
self.assembler.pop(esi)
self.assembler.pop(ebp)
self.assembler.ret()
self.spill_memory = (c_int * self.frame.spill_index)()
self.ptr_to_spill.value = addressof(self.spill_memory)
print self.assembler.assembler
return self.assembler.compile()
def box(self, v, target):
if v.is_constant():
if v.is_int():
self.assembler.mov(target, integer_value(v.value))
elif v.is_double():
double = new_double(v.value)
self.assembler.mov(target, object_value(double))
else:
self.assembler.mov(target, object_value(v.value))
else:
if v.is_int():
reg = v.to_reg()
v.type = 'unknown' # fixme
self.assembler.shl(reg, 1)
self.assembler.mov(target, reg)
elif v.is_double():
assert False
elif v.is_unknown():
reg = v.to_reg()
if reg != target:
self.assembler.mov(target, reg)
else:
reg = v.to_reg()
v.type = 'unknown'
self.assembler.shl(reg, 1)
self.assembler.add(reg, 1)
if target != reg:
self.assembler.mov(target, reg)
def jump_not_int(self, reg, jump):
self.assembler.test(reg, 1)
self.assembler.jnz(jump)
def compile_node(self, node):
getattr(self, 'op_' + node.type.lower())(node)
def op_comma(self, nodes):
for node in nodes[:-1]:
self.compile_node(node)
self.frame.pop()
self.compile_node(nodes[-1])
def op_block(self, nodes):
for node in nodes:
self.compile_node(node)
def op_group(self, node):
self.compile_node(node[0])
def op_semicolon(self, node):
self.compile_node(node.expression)
self.frame.pop()
def op_number(self, node):
value = node.value
if isinstance(value, int):
#.........这里部分代码省略.........