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


Python dis.hasconst方法代码示例

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


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

示例1: get_instructions

# 需要导入模块: import dis [as 别名]
# 或者: from dis import hasconst [as 别名]
def get_instructions(co):
        code = co.co_code
        n = len(code)
        i = 0
        extended_arg = 0
        while i < n:
            offset = i
            c = code[i]
            op = ord(c)
            argval = None
            i = i + 1
            if op >= HAVE_ARGUMENT:
                oparg = ord(code[i]) + ord(code[i + 1]) * 256 + extended_arg
                extended_arg = 0
                i = i + 2
                if op == EXTENDED_ARG:
                    extended_arg = oparg * 65536

                if op in hasconst:
                    argval = co.co_consts[oparg]
            yield Instruction(offset, argval, opname[op]) 
开发者ID:alexmojaki,项目名称:executing,代码行数:23,代码来源:executing.py

示例2: _get_instructions

# 需要导入模块: import dis [as 别名]
# 或者: from dis import hasconst [as 别名]
def _get_instructions(co):
        code = co.co_code
        linestarts = dict(findlinestarts(co))
        n = len(code)
        i = 0
        extended_arg = 0
        while i < n:
            offset = i
            c = code[i]
            op = ord(c)
            lineno = linestarts.get(i)
            argval = None
            i = i + 1
            if op >= HAVE_ARGUMENT:
                oparg = ord(code[i]) + ord(code[i + 1]) * 256 + extended_arg
                extended_arg = 0
                i = i + 2
                if op == EXTENDED_ARG:
                    extended_arg = oparg * 65536

                if op in hasconst:
                    argval = co.co_consts[oparg]
            yield Instruction(offset, argval, opname[op], lineno) 
开发者ID:alexmojaki,项目名称:executing,代码行数:25,代码来源:executing.py

示例3: test_opmap

# 需要导入模块: import dis [as 别名]
# 或者: from dis import hasconst [as 别名]
def test_opmap(self):
        self.assertEqual(dis.opmap["STOP_CODE"], 0)
        self.assertIn(dis.opmap["LOAD_CONST"], dis.hasconst)
        self.assertIn(dis.opmap["STORE_NAME"], dis.hasname) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_dis.py

示例4: test_opmap

# 需要导入模块: import dis [as 别名]
# 或者: from dis import hasconst [as 别名]
def test_opmap(self):
        self.assertEqual(dis.opmap["NOP"], 9)
        self.assertIn(dis.opmap["LOAD_CONST"], dis.hasconst)
        self.assertIn(dis.opmap["STORE_NAME"], dis.hasname) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:test_dis.py

示例5: _get_base_class_names

# 需要导入模块: import dis [as 别名]
# 或者: from dis import hasconst [as 别名]
def _get_base_class_names(frame):
    """Get baseclass names from the code object"""
    co, lasti = frame.f_code, frame.f_lasti
    code = co.co_code
    i = 0
    extended_arg = 0
    extends = []
    while i <= lasti:
        c = code[i]
        op = ord(c)
        i += 1
        if op >= dis.HAVE_ARGUMENT:
            oparg = ord(code[i]) + ord(code[i + 1]) * 256 + extended_arg
            extended_arg = 0
            i += 2
            if op == dis.EXTENDED_ARG:
                extended_arg = oparg * int(65536)
            if op in dis.hasconst:
                if type(co.co_consts[oparg]) == str:
                    extends = []
            elif op in dis.hasname:
                if dis.opname[op] == 'LOAD_NAME':
                    extends.append(('name', co.co_names[oparg]))
                if dis.opname[op] == 'LOAD_ATTR':
                    extends.append(('attr', co.co_names[oparg]))
    items = []
    previous_item = []
    for t, s in extends:
        if t == 'name':
            if previous_item:
                items.append(previous_item)
            previous_item = [s]
        else:
            previous_item += [s]
    if previous_item:
        items.append(previous_item)
    return items 
开发者ID:rlworkgroup,项目名称:gym-sawyer,代码行数:39,代码来源:overrides.py

示例6: test_opmap

# 需要导入模块: import dis [as 别名]
# 或者: from dis import hasconst [as 别名]
def test_opmap(self):
        self.assertEqual(dis.opmap["STOP_CODE"], 0)
        self.assertEqual(dis.opmap["LOAD_CONST"] in dis.hasconst, True)
        self.assertEqual(dis.opmap["STORE_NAME"] in dis.hasname, True) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:6,代码来源:test_dis.py

示例7: _get_base_class_names

# 需要导入模块: import dis [as 别名]
# 或者: from dis import hasconst [as 别名]
def _get_base_class_names(frame):
    """Get baseclass names from the code object"""
    co, lasti = frame.f_code, frame.f_lasti
    code = co.co_code
    i = 0
    extended_arg = 0
    extends = []
    while i <= lasti:
        c = code[i]
        op = ord(c)
        i += 1
        if op >= dis.HAVE_ARGUMENT:
            oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg
            extended_arg = 0
            i += 2
            if op == dis.EXTENDED_ARG:
                extended_arg = oparg*int(65536)
            if op in dis.hasconst:
                if type(co.co_consts[oparg]) == str:
                    extends = []
            elif op in dis.hasname:
                if dis.opname[op] == 'LOAD_NAME':
                    extends.append(('name', co.co_names[oparg]))
                if dis.opname[op] == 'LOAD_ATTR':
                    extends.append(('attr', co.co_names[oparg]))
    items = []
    previous_item = []
    for t, s in extends:
        if t == 'name':
            if previous_item:
                items.append(previous_item)
            previous_item = [s]
        else:
            previous_item += [s]
    if previous_item:
        items.append(previous_item)
    return items 
开发者ID:ml3705454,项目名称:mapr2,代码行数:39,代码来源:overrides.py


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