当前位置: 首页>>代码示例>>Python>>正文


Python Target.get_instr方法代码示例

本文整理汇总了Python中Target.get_instr方法的典型用法代码示例。如果您正苦于以下问题:Python Target.get_instr方法的具体用法?Python Target.get_instr怎么用?Python Target.get_instr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Target的用法示例。


在下文中一共展示了Target.get_instr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _instr_cmp

# 需要导入模块: import Target [as 别名]
# 或者: from Target import get_instr [as 别名]
 def _instr_cmp(self, instr, cf):
     rhs = cf.stack_pop()
     lhs = cf.stack_pop()
     
     it = Target.get_instr(instr)
     if it == Target.CON_INSTR_EQ:
         r = lhs.eq(self, rhs)
     elif it == Target.CON_INSTR_LE:
         r = lhs.le(self, rhs)
     elif it == Target.CON_INSTR_NEQ:
         r = lhs.neq(self, rhs)
     elif it == Target.CON_INSTR_LE_EQ:
         r = lhs.le_eq(self, rhs)
     elif it == Target.CON_INSTR_GR_EQ:
         r = lhs.gr_eq(self, rhs)
     elif it == Target.CON_INSTR_GT:
         r = lhs.gt(self, rhs)
     else:
         raise Exception("XXX")
     
     if r:
         cf.stack_push(rhs)
         cf.bc_off += Target.INTSIZE
     else:
         self._fail_now(cf)
开发者ID:ltratt,项目名称:converge,代码行数:27,代码来源:VM.py

示例2: _instr_calc

# 需要导入模块: import Target [as 别名]
# 或者: from Target import get_instr [as 别名]
    def _instr_calc(self, instr, cf):
        rhs = cf.stack_pop()
        lhs = cf.stack_pop()
        
        it = Target.get_instr(instr)
        if it == Target.CON_INSTR_ADD:
            r = lhs.add(self, rhs)
        else:
            assert it == Target.CON_INSTR_SUBTRACT
            r = lhs.subtract(self, rhs)

        cf.stack_push(r)
        cf.bc_off += Target.INTSIZE
开发者ID:ltratt,项目名称:converge,代码行数:15,代码来源:VM.py

示例3: bc_loop

# 需要导入模块: import Target [as 别名]
# 或者: from Target import get_instr [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:
#.........这里部分代码省略.........
开发者ID:ltratt,项目名称:converge,代码行数:103,代码来源:VM.py

示例4: get_printable_location

# 需要导入模块: import Target [as 别名]
# 或者: from Target import get_instr [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])
开发者ID:ltratt,项目名称:converge,代码行数:7,代码来源:VM.py


注:本文中的Target.get_instr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。