]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.10/Lib/opcode.py
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 4/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Lib / opcode.py
diff --git a/AppPkg/Applications/Python/Python-2.7.10/Lib/opcode.py b/AppPkg/Applications/Python/Python-2.7.10/Lib/opcode.py
new file mode 100644 (file)
index 0000000..14e8d5c
--- /dev/null
@@ -0,0 +1,192 @@
+\r
+"""\r
+opcode module - potentially shared between dis and other modules which\r
+operate on bytecodes (e.g. peephole optimizers).\r
+"""\r
+\r
+__all__ = ["cmp_op", "hasconst", "hasname", "hasjrel", "hasjabs",\r
+           "haslocal", "hascompare", "hasfree", "opname", "opmap",\r
+           "HAVE_ARGUMENT", "EXTENDED_ARG"]\r
+\r
+cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is',\r
+        'is not', 'exception match', 'BAD')\r
+\r
+hasconst = []\r
+hasname = []\r
+hasjrel = []\r
+hasjabs = []\r
+haslocal = []\r
+hascompare = []\r
+hasfree = []\r
+\r
+opmap = {}\r
+opname = [''] * 256\r
+for op in range(256): opname[op] = '<%r>' % (op,)\r
+del op\r
+\r
+def def_op(name, op):\r
+    opname[op] = name\r
+    opmap[name] = op\r
+\r
+def name_op(name, op):\r
+    def_op(name, op)\r
+    hasname.append(op)\r
+\r
+def jrel_op(name, op):\r
+    def_op(name, op)\r
+    hasjrel.append(op)\r
+\r
+def jabs_op(name, op):\r
+    def_op(name, op)\r
+    hasjabs.append(op)\r
+\r
+# Instruction opcodes for compiled code\r
+# Blank lines correspond to available opcodes\r
+\r
+def_op('STOP_CODE', 0)\r
+def_op('POP_TOP', 1)\r
+def_op('ROT_TWO', 2)\r
+def_op('ROT_THREE', 3)\r
+def_op('DUP_TOP', 4)\r
+def_op('ROT_FOUR', 5)\r
+\r
+def_op('NOP', 9)\r
+def_op('UNARY_POSITIVE', 10)\r
+def_op('UNARY_NEGATIVE', 11)\r
+def_op('UNARY_NOT', 12)\r
+def_op('UNARY_CONVERT', 13)\r
+\r
+def_op('UNARY_INVERT', 15)\r
+\r
+def_op('BINARY_POWER', 19)\r
+def_op('BINARY_MULTIPLY', 20)\r
+def_op('BINARY_DIVIDE', 21)\r
+def_op('BINARY_MODULO', 22)\r
+def_op('BINARY_ADD', 23)\r
+def_op('BINARY_SUBTRACT', 24)\r
+def_op('BINARY_SUBSCR', 25)\r
+def_op('BINARY_FLOOR_DIVIDE', 26)\r
+def_op('BINARY_TRUE_DIVIDE', 27)\r
+def_op('INPLACE_FLOOR_DIVIDE', 28)\r
+def_op('INPLACE_TRUE_DIVIDE', 29)\r
+def_op('SLICE+0', 30)\r
+def_op('SLICE+1', 31)\r
+def_op('SLICE+2', 32)\r
+def_op('SLICE+3', 33)\r
+\r
+def_op('STORE_SLICE+0', 40)\r
+def_op('STORE_SLICE+1', 41)\r
+def_op('STORE_SLICE+2', 42)\r
+def_op('STORE_SLICE+3', 43)\r
+\r
+def_op('DELETE_SLICE+0', 50)\r
+def_op('DELETE_SLICE+1', 51)\r
+def_op('DELETE_SLICE+2', 52)\r
+def_op('DELETE_SLICE+3', 53)\r
+\r
+def_op('STORE_MAP', 54)\r
+def_op('INPLACE_ADD', 55)\r
+def_op('INPLACE_SUBTRACT', 56)\r
+def_op('INPLACE_MULTIPLY', 57)\r
+def_op('INPLACE_DIVIDE', 58)\r
+def_op('INPLACE_MODULO', 59)\r
+def_op('STORE_SUBSCR', 60)\r
+def_op('DELETE_SUBSCR', 61)\r
+def_op('BINARY_LSHIFT', 62)\r
+def_op('BINARY_RSHIFT', 63)\r
+def_op('BINARY_AND', 64)\r
+def_op('BINARY_XOR', 65)\r
+def_op('BINARY_OR', 66)\r
+def_op('INPLACE_POWER', 67)\r
+def_op('GET_ITER', 68)\r
+\r
+def_op('PRINT_EXPR', 70)\r
+def_op('PRINT_ITEM', 71)\r
+def_op('PRINT_NEWLINE', 72)\r
+def_op('PRINT_ITEM_TO', 73)\r
+def_op('PRINT_NEWLINE_TO', 74)\r
+def_op('INPLACE_LSHIFT', 75)\r
+def_op('INPLACE_RSHIFT', 76)\r
+def_op('INPLACE_AND', 77)\r
+def_op('INPLACE_XOR', 78)\r
+def_op('INPLACE_OR', 79)\r
+def_op('BREAK_LOOP', 80)\r
+def_op('WITH_CLEANUP', 81)\r
+def_op('LOAD_LOCALS', 82)\r
+def_op('RETURN_VALUE', 83)\r
+def_op('IMPORT_STAR', 84)\r
+def_op('EXEC_STMT', 85)\r
+def_op('YIELD_VALUE', 86)\r
+def_op('POP_BLOCK', 87)\r
+def_op('END_FINALLY', 88)\r
+def_op('BUILD_CLASS', 89)\r
+\r
+HAVE_ARGUMENT = 90              # Opcodes from here have an argument:\r
+\r
+name_op('STORE_NAME', 90)       # Index in name list\r
+name_op('DELETE_NAME', 91)      # ""\r
+def_op('UNPACK_SEQUENCE', 92)   # Number of tuple items\r
+jrel_op('FOR_ITER', 93)\r
+def_op('LIST_APPEND', 94)\r
+name_op('STORE_ATTR', 95)       # Index in name list\r
+name_op('DELETE_ATTR', 96)      # ""\r
+name_op('STORE_GLOBAL', 97)     # ""\r
+name_op('DELETE_GLOBAL', 98)    # ""\r
+def_op('DUP_TOPX', 99)          # number of items to duplicate\r
+def_op('LOAD_CONST', 100)       # Index in const list\r
+hasconst.append(100)\r
+name_op('LOAD_NAME', 101)       # Index in name list\r
+def_op('BUILD_TUPLE', 102)      # Number of tuple items\r
+def_op('BUILD_LIST', 103)       # Number of list items\r
+def_op('BUILD_SET', 104)        # Number of set items\r
+def_op('BUILD_MAP', 105)        # Number of dict entries (upto 255)\r
+name_op('LOAD_ATTR', 106)       # Index in name list\r
+def_op('COMPARE_OP', 107)       # Comparison operator\r
+hascompare.append(107)\r
+name_op('IMPORT_NAME', 108)     # Index in name list\r
+name_op('IMPORT_FROM', 109)     # Index in name list\r
+jrel_op('JUMP_FORWARD', 110)    # Number of bytes to skip\r
+jabs_op('JUMP_IF_FALSE_OR_POP', 111) # Target byte offset from beginning of code\r
+jabs_op('JUMP_IF_TRUE_OR_POP', 112)  # ""\r
+jabs_op('JUMP_ABSOLUTE', 113)        # ""\r
+jabs_op('POP_JUMP_IF_FALSE', 114)    # ""\r
+jabs_op('POP_JUMP_IF_TRUE', 115)     # ""\r
+\r
+name_op('LOAD_GLOBAL', 116)     # Index in name list\r
+\r
+jabs_op('CONTINUE_LOOP', 119)   # Target address\r
+jrel_op('SETUP_LOOP', 120)      # Distance to target address\r
+jrel_op('SETUP_EXCEPT', 121)    # ""\r
+jrel_op('SETUP_FINALLY', 122)   # ""\r
+\r
+def_op('LOAD_FAST', 124)        # Local variable number\r
+haslocal.append(124)\r
+def_op('STORE_FAST', 125)       # Local variable number\r
+haslocal.append(125)\r
+def_op('DELETE_FAST', 126)      # Local variable number\r
+haslocal.append(126)\r
+\r
+def_op('RAISE_VARARGS', 130)    # Number of raise arguments (1, 2, or 3)\r
+def_op('CALL_FUNCTION', 131)    # #args + (#kwargs << 8)\r
+def_op('MAKE_FUNCTION', 132)    # Number of args with default values\r
+def_op('BUILD_SLICE', 133)      # Number of items\r
+def_op('MAKE_CLOSURE', 134)\r
+def_op('LOAD_CLOSURE', 135)\r
+hasfree.append(135)\r
+def_op('LOAD_DEREF', 136)\r
+hasfree.append(136)\r
+def_op('STORE_DEREF', 137)\r
+hasfree.append(137)\r
+\r
+def_op('CALL_FUNCTION_VAR', 140)     # #args + (#kwargs << 8)\r
+def_op('CALL_FUNCTION_KW', 141)      # #args + (#kwargs << 8)\r
+def_op('CALL_FUNCTION_VAR_KW', 142)  # #args + (#kwargs << 8)\r
+\r
+jrel_op('SETUP_WITH', 143)\r
+\r
+def_op('EXTENDED_ARG', 145)\r
+EXTENDED_ARG = 145\r
+def_op('SET_ADD', 146)\r
+def_op('MAP_ADD', 147)\r
+\r
+del def_op, name_op, jrel_op, jabs_op\r