blob: 5f5826fd4c04a37bbfefc7411ecbde8febd50084 [file] [log] [blame]
Guido van Rossumf70e43a1991-02-19 12:39:46 +00001/***********************************************************
Guido van Rossum9bfef441993-03-29 10:43:31 +00002Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
3Amsterdam, The Netherlands.
Guido van Rossumf70e43a1991-02-19 12:39:46 +00004
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
Guido van Rossum7928cd71991-10-24 14:59:31 +000038#define UNARY_INVERT 15
Guido van Rossum10dc2e81990-11-18 17:27:39 +000039
40#define BINARY_MULTIPLY 20
41#define BINARY_DIVIDE 21
42#define BINARY_MODULO 22
43#define BINARY_ADD 23
44#define BINARY_SUBTRACT 24
45#define BINARY_SUBSCR 25
46#define BINARY_CALL 26
47
48#define SLICE 30
49/* Also uses 31-33 */
50
51#define STORE_SLICE 40
52/* Also uses 41-43 */
53
54#define DELETE_SLICE 50
55/* Also uses 51-53 */
56
57#define STORE_SUBSCR 60
58#define DELETE_SUBSCR 61
59
Guido van Rossum7928cd71991-10-24 14:59:31 +000060#define BINARY_LSHIFT 62
61#define BINARY_RSHIFT 63
62#define BINARY_AND 64
63#define BINARY_XOR 65
64#define BINARY_OR 66
65
66
Guido van Rossum10dc2e81990-11-18 17:27:39 +000067#define PRINT_EXPR 70
68#define PRINT_ITEM 71
69#define PRINT_NEWLINE 72
70
71#define BREAK_LOOP 80
72#define RAISE_EXCEPTION 81
Guido van Rossumf1270271990-11-18 17:38:15 +000073#define LOAD_LOCALS 82
Guido van Rossum10dc2e81990-11-18 17:27:39 +000074#define RETURN_VALUE 83
Guido van Rossum8b17d6b1993-03-30 13:18:41 +000075
Guido van Rossum10dc2e81990-11-18 17:27:39 +000076#define BUILD_FUNCTION 86
77#define POP_BLOCK 87
78#define END_FINALLY 88
Guido van Rossumf1270271990-11-18 17:38:15 +000079#define BUILD_CLASS 89
Guido van Rossum10dc2e81990-11-18 17:27:39 +000080
81#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */
82
83#define STORE_NAME 90 /* Index in name list */
84#define DELETE_NAME 91 /* "" */
85#define UNPACK_TUPLE 92 /* Number of tuple items */
86#define UNPACK_LIST 93 /* Number of list items */
Guido van Rossum750bf141991-12-16 13:07:35 +000087#define UNPACK_ARG 94 /* Number of arguments */
Guido van Rossum10dc2e81990-11-18 17:27:39 +000088#define STORE_ATTR 95 /* Index in name list */
89#define DELETE_ATTR 96 /* "" */
Guido van Rossum97ff5301991-12-10 13:59:17 +000090#define STORE_GLOBAL 97 /* "" */
91#define DELETE_GLOBAL 98 /* "" */
Guido van Rossum22f863f1992-01-14 18:38:56 +000092#define UNPACK_VARARG 99 /* Minimal number of arguments */
Guido van Rossum10dc2e81990-11-18 17:27:39 +000093
94#define LOAD_CONST 100 /* Index in const list */
95#define LOAD_NAME 101 /* Index in name list */
96#define BUILD_TUPLE 102 /* Number of tuple items */
97#define BUILD_LIST 103 /* Number of list items */
98#define BUILD_MAP 104 /* Always zero for now */
99#define LOAD_ATTR 105 /* Index in name list */
100#define COMPARE_OP 106 /* Comparison operator */
101#define IMPORT_NAME 107 /* Index in name list */
102#define IMPORT_FROM 108 /* Index in name list */
Guido van Rossum25831651993-05-19 14:50:45 +0000103#define ACCESS_MODE 109 /* Name (mode is int on top of stack) */
Guido van Rossum10dc2e81990-11-18 17:27:39 +0000104
105#define JUMP_FORWARD 110 /* Number of bytes to skip */
106#define JUMP_IF_FALSE 111 /* "" */
107#define JUMP_IF_TRUE 112 /* "" */
108#define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */
109#define FOR_LOOP 114 /* Number of bytes to skip */
110
Guido van Rossum054ff1f1991-04-04 10:45:01 +0000111#define LOAD_LOCAL 115 /* Index in name list */
112#define LOAD_GLOBAL 116 /* Index in name list */
113
Guido van Rossum10dc2e81990-11-18 17:27:39 +0000114#define SETUP_LOOP 120 /* Target address (absolute) */
115#define SETUP_EXCEPT 121 /* "" */
116#define SETUP_FINALLY 122 /* "" */
117
Guido van Rossum8b17d6b1993-03-30 13:18:41 +0000118#define RESERVE_FAST 123 /* Number of local variables */
119#define LOAD_FAST 124 /* Local variable number */
120#define STORE_FAST 125 /* Local variable number */
121#define DELETE_FAST 126 /* Local variable number */
122
Guido van Rossum3f5da241990-12-20 15:06:42 +0000123#define SET_LINENO 127 /* Current line number */
124
Guido van Rossum10dc2e81990-11-18 17:27:39 +0000125/* Comparison operator codes (argument to COMPARE_OP) */
126enum 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 +0000127
128#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT)