blob: 7edf6616f6161605909375eb7d1ec1f94abaa152 [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001/***********************************************************
2Copyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
3Netherlands.
4
5 All Rights Reserved
6
7Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
9provided that the above copyright notice appear in all copies and that
10both that copyright notice and this permission notice appear in
11supporting documentation, and that the names of Stichting Mathematisch
12Centrum or CWI not be used in advertising or publicity pertaining to
13distribution of the software without specific, written prior permission.
14
15STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
16THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
18FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23******************************************************************/
24
Guido van Rossum10dc2e81990-11-18 17:27:39 +000025/* Instruction opcodes for compiled code */
26
Guido van Rossum3f5da241990-12-20 15:06:42 +000027#define STOP_CODE 0
Guido van Rossum10dc2e81990-11-18 17:27:39 +000028#define POP_TOP 1
29#define ROT_TWO 2
30#define ROT_THREE 3
Guido van Rossum3f5da241990-12-20 15:06:42 +000031#define DUP_TOP 4
Guido van Rossum10dc2e81990-11-18 17:27:39 +000032
33#define UNARY_POSITIVE 10
34#define UNARY_NEGATIVE 11
35#define UNARY_NOT 12
36#define UNARY_CONVERT 13
37#define UNARY_CALL 14
38
39#define BINARY_MULTIPLY 20
40#define BINARY_DIVIDE 21
41#define BINARY_MODULO 22
42#define BINARY_ADD 23
43#define BINARY_SUBTRACT 24
44#define BINARY_SUBSCR 25
45#define BINARY_CALL 26
46
47#define SLICE 30
48/* Also uses 31-33 */
49
50#define STORE_SLICE 40
51/* Also uses 41-43 */
52
53#define DELETE_SLICE 50
54/* Also uses 51-53 */
55
56#define STORE_SUBSCR 60
57#define DELETE_SUBSCR 61
58
59#define PRINT_EXPR 70
60#define PRINT_ITEM 71
61#define PRINT_NEWLINE 72
62
63#define BREAK_LOOP 80
64#define RAISE_EXCEPTION 81
Guido van Rossumf1270271990-11-18 17:38:15 +000065#define LOAD_LOCALS 82
Guido van Rossum10dc2e81990-11-18 17:27:39 +000066#define RETURN_VALUE 83
67#define REQUIRE_ARGS 84
68#define REFUSE_ARGS 85
69#define BUILD_FUNCTION 86
70#define POP_BLOCK 87
71#define END_FINALLY 88
Guido van Rossumf1270271990-11-18 17:38:15 +000072#define BUILD_CLASS 89
Guido van Rossum10dc2e81990-11-18 17:27:39 +000073
74#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */
75
76#define STORE_NAME 90 /* Index in name list */
77#define DELETE_NAME 91 /* "" */
78#define UNPACK_TUPLE 92 /* Number of tuple items */
79#define UNPACK_LIST 93 /* Number of list items */
80/* unused: 94 */
81#define STORE_ATTR 95 /* Index in name list */
82#define DELETE_ATTR 96 /* "" */
83
84#define LOAD_CONST 100 /* Index in const list */
85#define LOAD_NAME 101 /* Index in name list */
86#define BUILD_TUPLE 102 /* Number of tuple items */
87#define BUILD_LIST 103 /* Number of list items */
88#define BUILD_MAP 104 /* Always zero for now */
89#define LOAD_ATTR 105 /* Index in name list */
90#define COMPARE_OP 106 /* Comparison operator */
91#define IMPORT_NAME 107 /* Index in name list */
92#define IMPORT_FROM 108 /* Index in name list */
93
94#define JUMP_FORWARD 110 /* Number of bytes to skip */
95#define JUMP_IF_FALSE 111 /* "" */
96#define JUMP_IF_TRUE 112 /* "" */
97#define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */
98#define FOR_LOOP 114 /* Number of bytes to skip */
99
Guido van Rossum054ff1f1991-04-04 10:45:01 +0000100#define LOAD_LOCAL 115 /* Index in name list */
101#define LOAD_GLOBAL 116 /* Index in name list */
102
Guido van Rossum10dc2e81990-11-18 17:27:39 +0000103#define SETUP_LOOP 120 /* Target address (absolute) */
104#define SETUP_EXCEPT 121 /* "" */
105#define SETUP_FINALLY 122 /* "" */
106
Guido van Rossum3f5da241990-12-20 15:06:42 +0000107#define SET_LINENO 127 /* Current line number */
108
Guido van Rossum10dc2e81990-11-18 17:27:39 +0000109/* Comparison operator codes (argument to COMPARE_OP) */
110enum cmp_op {LT, LE, EQ, NE, GT, GE, IN, NOT_IN, IS, IS_NOT, EXC_MATCH, BAD};
Guido van Rossum3f5da241990-12-20 15:06:42 +0000111
112#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)