home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / OPCODE.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-01  |  4.1 KB  |  146 lines

  1. #ifndef Py_OPCODE_H
  2. #define Py_OPCODE_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7.  
  8. /* Instruction opcodes for compiled code */
  9.  
  10. #define STOP_CODE    0
  11. #define POP_TOP        1
  12. #define ROT_TWO        2
  13. #define ROT_THREE    3
  14. #define DUP_TOP        4
  15. #define ROT_FOUR    5
  16.  
  17. #define UNARY_POSITIVE    10
  18. #define UNARY_NEGATIVE    11
  19. #define UNARY_NOT    12
  20. #define UNARY_CONVERT    13
  21.  
  22. #define UNARY_INVERT    15
  23.  
  24. #define BINARY_POWER    19
  25.  
  26. #define BINARY_MULTIPLY    20
  27. #define BINARY_DIVIDE    21
  28. #define BINARY_MODULO    22
  29. #define BINARY_ADD    23
  30. #define BINARY_SUBTRACT    24
  31. #define BINARY_SUBSCR    25
  32.  
  33. #define SLICE        30
  34. /* Also uses 31-33 */
  35.  
  36. #define STORE_SLICE    40
  37. /* Also uses 41-43 */
  38.  
  39. #define DELETE_SLICE    50
  40. /* Also uses 51-53 */
  41.  
  42. #define INPLACE_ADD    55
  43. #define INPLACE_SUBTRACT    56
  44. #define INPLACE_MULTIPLY    57
  45. #define INPLACE_DIVIDE    58
  46. #define INPLACE_MODULO    59
  47. #define STORE_SUBSCR    60
  48. #define DELETE_SUBSCR    61
  49.  
  50. #define BINARY_LSHIFT    62
  51. #define BINARY_RSHIFT    63
  52. #define BINARY_AND    64
  53. #define BINARY_XOR    65
  54. #define BINARY_OR    66
  55. #define INPLACE_POWER    67
  56.  
  57. #define PRINT_EXPR    70
  58. #define PRINT_ITEM    71
  59. #define PRINT_NEWLINE    72
  60. #define PRINT_ITEM_TO   73
  61. #define PRINT_NEWLINE_TO 74
  62. #define INPLACE_LSHIFT    75
  63. #define INPLACE_RSHIFT    76
  64. #define INPLACE_AND    77
  65. #define INPLACE_XOR    78
  66. #define INPLACE_OR    79
  67. #define BREAK_LOOP    80
  68.  
  69. #define LOAD_LOCALS    82
  70. #define RETURN_VALUE    83
  71. #define IMPORT_STAR    84
  72. #define EXEC_STMT    85
  73.  
  74. #define POP_BLOCK    87
  75. #define END_FINALLY    88
  76. #define BUILD_CLASS    89
  77.  
  78. #define HAVE_ARGUMENT    90    /* Opcodes from here have an argument: */
  79.  
  80. #define STORE_NAME    90    /* Index in name list */
  81. #define DELETE_NAME    91    /* "" */
  82. #define UNPACK_SEQUENCE    92    /* Number of sequence items */
  83.  
  84. #define STORE_ATTR    95    /* Index in name list */
  85. #define DELETE_ATTR    96    /* "" */
  86. #define STORE_GLOBAL    97    /* "" */
  87. #define DELETE_GLOBAL    98    /* "" */
  88. #define DUP_TOPX    99    /* number of items to duplicate */
  89. #define LOAD_CONST    100    /* Index in const list */
  90. #define LOAD_NAME    101    /* Index in name list */
  91. #define BUILD_TUPLE    102    /* Number of tuple items */
  92. #define BUILD_LIST    103    /* Number of list items */
  93. #define BUILD_MAP    104    /* Always zero for now */
  94. #define LOAD_ATTR    105    /* Index in name list */
  95. #define COMPARE_OP    106    /* Comparison operator */
  96. #define IMPORT_NAME    107    /* Index in name list */
  97. #define IMPORT_FROM    108    /* Index in name list */
  98.  
  99. #define JUMP_FORWARD    110    /* Number of bytes to skip */
  100. #define JUMP_IF_FALSE    111    /* "" */
  101. #define JUMP_IF_TRUE    112    /* "" */
  102. #define JUMP_ABSOLUTE    113    /* Target byte offset from beginning of code */
  103. #define FOR_LOOP    114    /* Number of bytes to skip */
  104.  
  105. #define LOAD_GLOBAL    116    /* Index in name list */
  106.  
  107. #define SETUP_LOOP    120    /* Target address (absolute) */
  108. #define SETUP_EXCEPT    121    /* "" */
  109. #define SETUP_FINALLY    122    /* "" */
  110.  
  111. #define LOAD_FAST    124    /* Local variable number */
  112. #define STORE_FAST    125    /* Local variable number */
  113. #define DELETE_FAST    126    /* Local variable number */
  114.  
  115. #define SET_LINENO    127    /* Current line number */
  116.  
  117. /* It used to be the case that opcodes should fit in 7 bits.  This is
  118.    no longer the case -- 8 bits is fine (the instruction stream is now
  119.    a sequence of unsigned characters).  We gladly use the new space
  120.    for new opcodes. */
  121.  
  122. #define RAISE_VARARGS    130    /* Number of raise arguments (1, 2 or 3) */
  123. /* CALL_FUNCTION_XXX opcodes defined below depend on this definition */
  124. #define CALL_FUNCTION    131    /* #args + (#kwargs<<8) */
  125. #define MAKE_FUNCTION    132    /* #defaults */
  126. #define BUILD_SLICE     133    /* Number of items */
  127.  
  128. /* The next 3 opcodes must be contiguous and satisfy
  129.    (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1  */
  130. #define CALL_FUNCTION_VAR          140    /* #args + (#kwargs<<8) */
  131. #define CALL_FUNCTION_KW           141    /* #args + (#kwargs<<8) */
  132. #define CALL_FUNCTION_VAR_KW       142    /* #args + (#kwargs<<8) */
  133.  
  134. /* Support for opargs more than 16 bits long */
  135. #define EXTENDED_ARG  143
  136.  
  137. /* Comparison operator codes (argument to COMPARE_OP) */
  138. enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};
  139.  
  140. #define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)
  141.  
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif /* !Py_OPCODE_H */
  146.