本文整理汇总了Python中Target.read_word方法的典型用法代码示例。如果您正苦于以下问题:Python Target.read_word方法的具体用法?Python Target.read_word怎么用?Python Target.read_word使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Target
的用法示例。
在下文中一共展示了Target.read_word方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _instr_unpack_args
# 需要导入模块: import Target [as 别名]
# 或者: from Target import read_word [as 别名]
def _instr_unpack_args(self, instr, cf):
num_fargs, has_vargs = Target.unpack_unpack_args(instr)
num_fargs = jit.promote(num_fargs)
has_vargs = jit.promote(has_vargs)
if not has_vargs:
nargs = jit.promote(cf.nargs)
else:
nargs = cf.nargs
if nargs > num_fargs and not has_vargs:
msg = "Too many parameters (%d passed, but a maximum of %d allowed)." % \
(nargs, num_fargs)
self.raise_helper("Parameters_Exception", [Builtins.Con_String(self, msg)])
if num_fargs > 0:
arg_offset = cf.bc_off + Target.INTSIZE + num_fargs * Target.INTSIZE
for i in range(num_fargs - 1, -1, -1):
arg_offset -= Target.INTSIZE
arg_info = Target.read_word(cf.pc.mod.bc, arg_offset)
if i >= nargs:
if not Target.unpack_unpack_args_is_mandatory(arg_info):
msg = "No value passed for parameter %d." % (i + 1)
self.raise_helper("Parameters_Exception", [Builtins.Con_String(self, msg)])
else:
if nargs > num_fargs:
o = cf.stack_pop_n(nargs - num_fargs)
else:
o = cf.stack_pop()
assert isinstance(o, Builtins.Con_Object)
cf.closure.vars[Target.unpack_unpack_args_arg_num(arg_info)] = o
if has_vargs:
arg_offset = cf.bc_off + Target.INTSIZE + num_fargs * Target.INTSIZE
arg_info = Target.read_word(cf.pc.mod.bc, arg_offset)
if nargs <= num_fargs:
l = []
else:
j = cf.stackpe
i = j - (nargs - num_fargs)
assert i >= 0 and j >= 0
l = cf.stack_get_slice(i, j)
cf.stackpe = i + 1
cf.closure.vars[Target.unpack_unpack_args_arg_num(arg_info)] = Builtins.Con_List(self, l)
cf.bc_off += Target.INTSIZE + (num_fargs + 1) * Target.INTSIZE
else:
cf.bc_off += Target.INTSIZE + num_fargs * Target.INTSIZE
示例2: _instr_is_assigned
# 需要导入模块: import Target [as 别名]
# 或者: from Target import read_word [as 别名]
def _instr_is_assigned(self, instr, cf):
closure_off, var_num = Target.unpack_var_lookup(instr)
closure = cf.closure
while closure_off > 0:
closure = closure.parent
closure_off -= 1
v = closure.vars[var_num]
if closure.vars[var_num] is not None:
pc = cf.pc
assert isinstance(pc, BC_PC)
mod_bc = pc.mod.bc
instr2 = Target.read_word(mod_bc, cf.bc_off + Target.INTSIZE)
cf.bc_off += Target.unpack_is_assigned(instr2)
else:
cf.bc_off += Target.INTSIZE + Target.INTSIZE
示例3: bc_loop
# 需要导入模块: import Target [as 别名]
# 或者: from Target import read_word [as 别名]
def bc_loop(self, cf):
pc = cf.pc
mod_bc = pc.mod.bc
prev_bc_off = -1
while 1:
bc_off = cf.bc_off
if prev_bc_off != -1 and prev_bc_off > bc_off:
jitdriver.can_enter_jit(bc_off=bc_off, mod_bc=mod_bc, cf=cf, prev_bc_off=prev_bc_off, pc=pc, self=self)
jitdriver.jit_merge_point(bc_off=bc_off, mod_bc=mod_bc, cf=cf, prev_bc_off=prev_bc_off, pc=pc, self=self)
assert cf is self.cur_cf
prev_bc_off = bc_off
instr = Target.read_word(mod_bc, bc_off)
it = Target.get_instr(instr)
try:
#x = cf.stackpe; assert x >= 0; print "%s %s %d [stackpe:%d ffp:%d gfp:%d xfp:%d]" % (Target.INSTR_NAMES[instr & 0xFF], str(cf.stack[:x]), bc_off, cf.stackpe, cf.ffp, cf.gfp, cf.xfp)
if it == Target.CON_INSTR_EXBI:
self._instr_exbi(instr, cf)
elif it == Target.CON_INSTR_VAR_LOOKUP:
self._instr_var_lookup(instr, cf)
elif it == Target.CON_INSTR_VAR_ASSIGN:
self._instr_var_assign(instr, cf)
elif it == Target.CON_INSTR_ADD_FAILURE_FRAME:
self._instr_add_failure_frame(instr, cf)
elif it == Target.CON_INSTR_ADD_FAIL_UP_FRAME:
self._instr_add_fail_up_frame(instr, cf)
elif it == Target.CON_INSTR_REMOVE_FAILURE_FRAME:
self._instr_remove_failure_frame(instr, cf)
elif it == Target.CON_INSTR_IS_ASSIGNED:
self._instr_is_assigned(instr, cf)
elif it == Target.CON_INSTR_IS:
self._instr_is(instr, cf)
elif it == Target.CON_INSTR_FAIL_NOW:
self._instr_fail_now(instr, cf)
elif it == Target.CON_INSTR_POP:
self._instr_pop(instr, cf)
elif it == Target.CON_INSTR_LIST:
self._instr_list(instr, cf)
elif it == Target.CON_INSTR_SLOT_LOOKUP:
self._instr_slot_lookup(instr, cf)
elif it == Target.CON_INSTR_APPLY:
self._instr_apply(instr, cf)
elif it == Target.CON_INSTR_FUNC_DEFN:
self._instr_func_defn(instr, cf)
elif it == Target.CON_INSTR_RETURN:
cf.returned = True
return cf.stack_pop()
elif it == Target.CON_INSTR_BRANCH:
self._instr_branch(instr, cf)
elif it == Target.CON_INSTR_YIELD:
cf.bc_off += Target.INTSIZE
return cf.stack_get(cf.stackpe - 1)
elif it == Target.CON_INSTR_IMPORT:
self._instr_import(instr, cf)
elif it == Target.CON_INSTR_DICT:
self._instr_dict(instr, cf)
elif it == Target.CON_INSTR_DUP:
self._instr_dup(instr, cf)
elif it == Target.CON_INSTR_PULL:
self._instr_pull(instr, cf)
elif it == Target.CON_INSTR_BUILTIN_LOOKUP:
self._instr_builtin_lookup(instr, cf)
elif it == Target.CON_INSTR_ASSIGN_SLOT:
self._instr_assign_slot(instr, cf)
elif it == Target.CON_INSTR_EYIELD:
self._instr_eyield(instr, cf)
elif it == Target.CON_INSTR_ADD_EXCEPTION_FRAME:
self._instr_add_exception_frame(instr, cf)
elif it == Target.CON_INSTR_REMOVE_EXCEPTION_FRAME:
self._instr_remove_exception_frame(instr, cf)
elif it == Target.CON_INSTR_RAISE:
self._instr_raise(instr, cf)
elif it == Target.CON_INSTR_UNPACK_ARGS:
self._instr_unpack_args(instr, cf)
elif it == Target.CON_INSTR_SET:
self._instr_set(instr, cf)
elif it == Target.CON_INSTR_CONST_GET:
self._instr_const_get(instr, cf)
elif it == Target.CON_INSTR_PRE_SLOT_LOOKUP_APPLY:
# In the C Converge VM, this instruction is used to avoid a very expensive path
# through the VM; it's currently unclear whether this VM will suffer from the
# same problem. Until we are more sure, we simply use the normal slot lookup
# function, which has the correct semantics, but may perhaps not be fully
# optimised.
self._instr_slot_lookup(instr, cf)
elif it == Target.CON_INSTR_UNPACK_ASSIGN:
self._instr_unpack_assign(instr, cf)
elif it == Target.CON_INSTR_BRANCH_IF_NOT_FAIL:
self._instr_branch_if_not_fail(instr, cf)
elif it == Target.CON_INSTR_BRANCH_IF_FAIL:
self._instr_branch_if_fail(instr, cf)
elif it == Target.CON_INSTR_EQ or it == Target.CON_INSTR_LE \
or it == Target.CON_INSTR_NEQ or it == Target.CON_INSTR_LE_EQ \
or it == Target.CON_INSTR_GR_EQ or it == Target.CON_INSTR_GT:
self._instr_cmp(instr, cf)
elif it == Target.CON_INSTR_ADD or it == Target.CON_INSTR_SUBTRACT:
self._instr_calc(instr, cf)
elif it == Target.CON_INSTR_MODULE_LOOKUP:
self._instr_module_lookup(instr, cf)
else:
#.........这里部分代码省略.........
示例4: get_printable_location
# 需要导入模块: import Target [as 别名]
# 或者: from Target import read_word [as 别名]
def get_printable_location(bc_off, mod_bc, pc, self):
assert isinstance(pc, BC_PC)
instr = Target.read_word(mod_bc, bc_off)
it = Target.get_instr(instr)
return "%s:%s at offset %s. bytecode: %s" % (pc.mod, pc.off, bc_off, Target.INSTR_NAMES[it])