summaryrefslogtreecommitdiffstats
path: root/generic/tclCompile.h
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCompile.h')
-rw-r--r--generic/tclCompile.h401
1 files changed, 177 insertions, 224 deletions
diff --git a/generic/tclCompile.h b/generic/tclCompile.h
index 3302f9b..06b398b 100644
--- a/generic/tclCompile.h
+++ b/generic/tclCompile.h
@@ -455,264 +455,223 @@ typedef struct ByteCode {
* tclExecute.c.
*/
-/* Opcodes 0 to 9 */
+/* Opcodes 0 to 7 */
#define INST_DONE 0
-#define INST_PUSH1 1
-#define INST_PUSH4 2
-#define INST_POP 3
-#define INST_DUP 4
-#define INST_CONCAT1 5
-#define INST_INVOKE_STK1 6
-#define INST_INVOKE_STK4 7
-#define INST_EVAL_STK 8
-#define INST_EXPR_STK 9
-
-/* Opcodes 10 to 23 */
-#define INST_LOAD_SCALAR1 10
-#define INST_LOAD_SCALAR4 11
-#define INST_LOAD_SCALAR_STK 12
-#define INST_LOAD_ARRAY1 13
-#define INST_LOAD_ARRAY4 14
-#define INST_LOAD_ARRAY_STK 15
-#define INST_LOAD_STK 16
-#define INST_STORE_SCALAR1 17
-#define INST_STORE_SCALAR4 18
-#define INST_STORE_SCALAR_STK 19
-#define INST_STORE_ARRAY1 20
-#define INST_STORE_ARRAY4 21
-#define INST_STORE_ARRAY_STK 22
-#define INST_STORE_STK 23
-
-/* Opcodes 24 to 33 */
-#define INST_INCR_SCALAR1 24
-#define INST_INCR_SCALAR_STK 25
-#define INST_INCR_ARRAY1 26
-#define INST_INCR_ARRAY_STK 27
-#define INST_INCR_STK 28
-#define INST_INCR_SCALAR1_IMM 29
-#define INST_INCR_SCALAR_STK_IMM 30
-#define INST_INCR_ARRAY1_IMM 31
-#define INST_INCR_ARRAY_STK_IMM 32
-#define INST_INCR_STK_IMM 33
-
-/* Opcodes 34 to 39 */
-#define INST_JUMP1 34
-#define INST_JUMP4 35
-#define INST_JUMP_TRUE1 36
-#define INST_JUMP_TRUE4 37
-#define INST_JUMP_FALSE1 38
-#define INST_JUMP_FALSE4 39
-
-/* Opcodes 40 to 64 */
-#define INST_LOR 40
-#define INST_LAND 41
-#define INST_BITOR 42
-#define INST_BITXOR 43
-#define INST_BITAND 44
-#define INST_EQ 45
-#define INST_NEQ 46
-#define INST_LT 47
-#define INST_GT 48
-#define INST_LE 49
-#define INST_GE 50
-#define INST_LSHIFT 51
-#define INST_RSHIFT 52
-#define INST_ADD 53
-#define INST_SUB 54
-#define INST_MULT 55
-#define INST_DIV 56
-#define INST_MOD 57
-#define INST_UPLUS 58
-#define INST_UMINUS 59
-#define INST_BITNOT 60
-#define INST_LNOT 61
-#define INST_CALL_BUILTIN_FUNC1 62
-#define INST_CALL_FUNC1 63
-#define INST_TRY_CVT_TO_NUMERIC 64
-
-/* Opcodes 65 to 66 */
-#define INST_BREAK 65
-#define INST_CONTINUE 66
-
-/* Opcodes 67 to 68 */
-#define INST_FOREACH_START4 67
-#define INST_FOREACH_STEP4 68
-
-/* Opcodes 69 to 72 */
-#define INST_BEGIN_CATCH4 69
-#define INST_END_CATCH 70
-#define INST_PUSH_RESULT 71
-#define INST_PUSH_RETURN_CODE 72
-
-/* Opcodes 73 to 78 */
-#define INST_STR_EQ 73
-#define INST_STR_NEQ 74
-#define INST_STR_CMP 75
-#define INST_STR_LEN 76
-#define INST_STR_INDEX 77
-#define INST_STR_MATCH 78
-
-/* Opcodes 78 to 81 */
-#define INST_LIST 79
-#define INST_LIST_INDEX 80
-#define INST_LIST_LENGTH 81
-
-/* Opcodes 82 to 87 */
-#define INST_APPEND_SCALAR1 82
-#define INST_APPEND_SCALAR4 83
-#define INST_APPEND_ARRAY1 84
-#define INST_APPEND_ARRAY4 85
-#define INST_APPEND_ARRAY_STK 86
-#define INST_APPEND_STK 87
-
-/* Opcodes 88 to 93 */
-#define INST_LAPPEND_SCALAR1 88
-#define INST_LAPPEND_SCALAR4 89
-#define INST_LAPPEND_ARRAY1 90
-#define INST_LAPPEND_ARRAY4 91
-#define INST_LAPPEND_ARRAY_STK 92
-#define INST_LAPPEND_STK 93
+#define INST_PUSH 1
+#define INST_POP 2
+#define INST_DUP 3
+#define INST_CONCAT 4
+#define INST_INVOKE_STK 5
+#define INST_EVAL_STK 6
+#define INST_EXPR_STK 7
+
+/* Opcodes 8 to 17: [set] */
+#define INST_LOAD_SCALAR 8
+#define INST_LOAD_SCALAR_STK 9
+#define INST_LOAD_ARRAY 10
+#define INST_LOAD_ARRAY_STK 11
+#define INST_LOAD_STK 12
+#define INST_STORE_SCALAR 13
+#define INST_STORE_SCALAR_STK 14
+#define INST_STORE_ARRAY 15
+#define INST_STORE_ARRAY_STK 16
+#define INST_STORE_STK 17
+
+/* Opcodes 18 to 27: [incr] */
+#define INST_INCR_SCALAR 18
+#define INST_INCR_SCALAR_STK 19
+#define INST_INCR_ARRAY 20
+#define INST_INCR_ARRAY_STK 21
+#define INST_INCR_STK 22
+#define INST_INCR_SCALAR_IMM 23
+#define INST_INCR_SCALAR_STK_IMM 24
+#define INST_INCR_ARRAY_IMM 25
+#define INST_INCR_ARRAY_STK_IMM 26
+#define INST_INCR_STK_IMM 27
+
+/* Opcodes 28 to 30 */
+#define INST_JUMP 28
+#define INST_JUMP_TRUE 29
+#define INST_JUMP_FALSE 30
+
+/* Opcodes 31 to 58: operators */
+#define INST_LOR 31
+#define INST_LAND 32
+#define INST_BITOR 33
+#define INST_BITXOR 34
+#define INST_BITAND 35
+#define INST_EQ 36
+#define INST_NEQ 37
+#define INST_LT 38
+#define INST_GT 39
+#define INST_LE 40
+#define INST_GE 41
+#define INST_LSHIFT 42
+#define INST_RSHIFT 43
+#define INST_ADD 44
+#define INST_SUB 45
+#define INST_MULT 46
+#define INST_DIV 47
+#define INST_MOD 48
+#define INST_UPLUS 49
+#define INST_UMINUS 50
+#define INST_BITNOT 51
+#define INST_LNOT 52
+#define INST_CALL_BUILTIN_FUNC 53
+#define INST_CALL_FUNC 54
+#define INST_TRY_CVT_TO_NUMERIC 55
+#define INST_EXPON 56
+#define INST_LIST_IN 57
+#define INST_LIST_NOT_IN 58
+
+/* Opcodes 59 to 60 */
+#define INST_FOREACH_START 59
+#define INST_FOREACH_STEP 60
+
+/* Opcodes 61 to 70 */
+#define INST_BREAK 61
+#define INST_CONTINUE 62
+#define INST_BEGIN_CATCH 63
+#define INST_END_CATCH 64
+#define INST_PUSH_RESULT 65
+#define INST_PUSH_RETURN_CODE 66
+#define INST_PUSH_RETURN_OPTIONS 67
+#define INST_RETURN_STK 68
+#define INST_RETURN_IMM 69
+#define INST_RETURN_CODE_BRANCH 70
+
+/* Opcodes 71 to 76 */
+#define INST_STR_EQ 71
+#define INST_STR_NEQ 72
+#define INST_STR_CMP 73
+#define INST_STR_LEN 74
+#define INST_STR_INDEX 75
+#define INST_STR_MATCH 76
+
+/* Opcodes 77 to 79 */
+#define INST_LIST 77
+#define INST_LIST_INDEX 78
+#define INST_LIST_LENGTH 79
+
+/* Opcodes 80 to 83: [append] */
+#define INST_APPEND_SCALAR 80
+#define INST_APPEND_ARRAY 81
+#define INST_APPEND_ARRAY_STK 82
+#define INST_APPEND_STK 83
+
+/* Opcodes 84 to 87: [lappend] */
+#define INST_LAPPEND_SCALAR 84
+#define INST_LAPPEND_ARRAY 85
+#define INST_LAPPEND_ARRAY_STK 86
+#define INST_LAPPEND_STK 87
/* TIP #22 - LINDEX operator with flat arg list */
+#define INST_LIST_INDEX_MULTI 88
-#define INST_LIST_INDEX_MULTI 94
-
-/*
- * TIP #33 - 'lset' command. Code gen also required a Forth-like
- * OVER operation.
- */
-
-#define INST_OVER 95
-#define INST_LSET_LIST 96
-#define INST_LSET_FLAT 97
-
-/* TIP#90 - 'return' command. */
-
-#define INST_RETURN_IMM 98
-
-/* TIP#123 - exponentiation operator. */
-
-#define INST_EXPON 99
+/* TIP #33 - 'lset' command. */
+#define INST_LSET_LIST 89
+#define INST_LSET_FLAT 90
/* TIP #157 - {*}... (word expansion) language syntax support. */
-
-#define INST_EXPAND_START 100
-#define INST_EXPAND_STKTOP 101
-#define INST_INVOKE_EXPANDED 102
+#define INST_EXPAND_START 91
+#define INST_EXPAND_STKTOP 92
+#define INST_INVOKE_EXPANDED 93
/*
* TIP #57 - 'lassign' command. Code generation requires immediate
* LINDEX and LRANGE operators.
*/
-#define INST_LIST_INDEX_IMM 103
-#define INST_LIST_RANGE_IMM 104
-
-#define INST_START_CMD 105
-
-#define INST_LIST_IN 106
-#define INST_LIST_NOT_IN 107
-
-#define INST_PUSH_RETURN_OPTIONS 108
-#define INST_RETURN_STK 109
-
-/*
- * Dictionary (TIP#111) related commands.
- */
-
-#define INST_DICT_GET 110
-#define INST_DICT_SET 111
-#define INST_DICT_UNSET 112
-#define INST_DICT_INCR_IMM 113
-#define INST_DICT_APPEND 114
-#define INST_DICT_LAPPEND 115
-#define INST_DICT_FIRST 116
-#define INST_DICT_NEXT 117
-#define INST_DICT_DONE 118
-#define INST_DICT_UPDATE_START 119
-#define INST_DICT_UPDATE_END 120
+#define INST_LIST_INDEX_IMM 94
+#define INST_LIST_RANGE_IMM 95
+
+#define INST_START_CMD 96
+
+/* Dictionary (TIP#111) related commands. */
+#define INST_DICT_GET 97
+#define INST_DICT_SET 98
+#define INST_DICT_UNSET 99
+#define INST_DICT_INCR_IMM 100
+#define INST_DICT_APPEND 101
+#define INST_DICT_LAPPEND 102
+#define INST_DICT_FIRST 103
+#define INST_DICT_NEXT 104
+#define INST_DICT_DONE 105
+#define INST_DICT_UPDATE_START 106
+#define INST_DICT_UPDATE_END 107
+#define INST_DICT_EXPAND 108
+#define INST_DICT_RECOMBINE_STK 109
+#define INST_DICT_RECOMBINE_IMM 110
+#define INST_DICT_EXISTS 111
+#define INST_DICT_VERIFY 112
/*
* Instruction to support jumps defined by tables (instead of the classic
* [switch] technique of chained comparisons).
*/
-#define INST_JUMP_TABLE 121
+#define INST_JUMP_TABLE 113
/*
* Instructions to support compilation of global, variable, upvar and
* [namespace upvar].
*/
-#define INST_UPVAR 122
-#define INST_NSUPVAR 123
-#define INST_VARIABLE 124
-
-/* Instruction to support compiling syntax error to bytecode */
+#define INST_UPVAR 114
+#define INST_NSUPVAR 115
+#define INST_VARIABLE 116
-#define INST_SYNTAX 125
-
-/* Instruction to reverse N items on top of stack */
-
-#define INST_REVERSE 126
+/* Utilities */
+#define INST_OVER 117
+#define INST_SYNTAX 118
+#define INST_REVERSE 119
+#define INST_NOP 120
/* regexp instruction */
-
-#define INST_REGEXP 127
+#define INST_REGEXP 121
/* For [info exists] compilation */
-#define INST_EXIST_SCALAR 128
-#define INST_EXIST_ARRAY 129
-#define INST_EXIST_ARRAY_STK 130
-#define INST_EXIST_STK 131
-
-/* For [subst] compilation */
-#define INST_NOP 132
-#define INST_RETURN_CODE_BRANCH 133
+#define INST_EXIST_SCALAR 122
+#define INST_EXIST_ARRAY 123
+#define INST_EXIST_ARRAY_STK 124
+#define INST_EXIST_STK 125
/* For [unset] compilation */
-#define INST_UNSET_SCALAR 134
-#define INST_UNSET_ARRAY 135
-#define INST_UNSET_ARRAY_STK 136
-#define INST_UNSET_STK 137
-
-/* For [dict with], [dict exists], [dict create] and [dict merge] */
-#define INST_DICT_EXPAND 138
-#define INST_DICT_RECOMBINE_STK 139
-#define INST_DICT_RECOMBINE_IMM 140
-#define INST_DICT_EXISTS 141
-#define INST_DICT_VERIFY 142
+#define INST_UNSET_SCALAR 126
+#define INST_UNSET_ARRAY 127
+#define INST_UNSET_ARRAY_STK 128
+#define INST_UNSET_STK 129
/* For [string map] and [regsub] compilation */
-#define INST_STR_MAP 143
-#define INST_STR_FIND 144
-#define INST_STR_FIND_LAST 145
-#define INST_STR_RANGE_IMM 146
-#define INST_STR_RANGE 147
+#define INST_STR_MAP 130
+#define INST_STR_FIND 131
+#define INST_STR_FIND_LAST 132
+#define INST_STR_RANGE_IMM 133
+#define INST_STR_RANGE 134
/* For operations to do with coroutines and other NRE-manipulators */
-#define INST_YIELD 148
-#define INST_COROUTINE_NAME 149
-#define INST_TAILCALL 150
+#define INST_YIELD 135
+#define INST_COROUTINE_NAME 136
+#define INST_TAILCALL 137
/* For compilation of basic information operations */
-#define INST_NS_CURRENT 151
-#define INST_INFO_LEVEL_NUM 152
-#define INST_INFO_LEVEL_ARGS 153
-#define INST_RESOLVE_COMMAND 154
-#define INST_TCLOO_SELF 155
-#define INST_TCLOO_CLASS 156
-#define INST_TCLOO_NS 157
-#define INST_TCLOO_IS_OBJECT 158
+#define INST_NS_CURRENT 138
+#define INST_INFO_LEVEL_NUM 139
+#define INST_INFO_LEVEL_ARGS 140
+#define INST_RESOLVE_COMMAND 141
+#define INST_TCLOO_SELF 142
+#define INST_TCLOO_CLASS 143
+#define INST_TCLOO_NS 144
+#define INST_TCLOO_IS_OBJECT 145
/* For compilation of [array] subcommands */
-#define INST_ARRAY_EXISTS_STK 159
-#define INST_ARRAY_EXISTS_IMM 160
-#define INST_ARRAY_MAKE_STK 161
-#define INST_ARRAY_MAKE_IMM 162
+#define INST_ARRAY_EXISTS_STK 146
+#define INST_ARRAY_EXISTS_IMM 147
+#define INST_ARRAY_MAKE_STK 148
+#define INST_ARRAY_MAKE_IMM 149
/* The last opcode */
-#define LAST_INST_OPCODE 162
+#define LAST_INST_OPCODE 149
/*
* Table describing the Tcl bytecode instructions: their name (for displaying
@@ -733,8 +692,6 @@ typedef enum InstOperandType {
OPERAND_UINT4, /* Four byte unsigned integer. */
OPERAND_IDX4, /* Four byte signed index (actually an
* integer, but displayed differently.) */
- OPERAND_LVT1, /* One byte unsigned index into the local
- * variable table. */
OPERAND_LVT4, /* Four byte unsigned index into the local
* variable table. */
OPERAND_AUX4 /* Four byte unsigned index into the aux data
@@ -1189,11 +1146,7 @@ MODULE_SCOPE Tcl_Obj *TclNewInstNameObj(unsigned char inst);
#define TclEmitPush(objIndex, envPtr) \
do { \
register int objIndexCopy = (objIndex); \
- if (objIndexCopy <= 255) { \
- TclEmitInstInt1(INST_PUSH1, objIndexCopy, (envPtr)); \
- } else { \
- TclEmitInstInt4(INST_PUSH4, objIndexCopy, (envPtr)); \
- } \
+ TclEmitInstInt4(INST_PUSH, objIndexCopy, (envPtr)); \
} while (0)
/*