00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __INTERP_H__
00017 #define __INTERP_H__
00018
00019
00028 #include "thread.h"
00029
00030
00031 #define INTERP_LOOP_FOREVER 0
00032 #define INTERP_RETURN_ON_NO_THREADS 1
00033
00034
00036 #define FP (gVmGlobal.pthread->pframe)
00037
00038 #define MP (gVmGlobal.pmod)
00039
00040 #define IP (FP->fo_ip)
00041
00042 #undef SP
00043 #define SP (FP->fo_sp)
00044
00045 #define MS (FP->fo_memspace)
00046
00048 #define TOS (*(SP - 1))
00049
00050 #define TOS1 (*(SP - 2))
00051
00052 #define TOS2 (*(SP - 3))
00053
00054 #define TOS3 (*(SP - 4))
00055
00056 #define STACK(n) (*(SP - ((n) + 1)))
00057
00058 #define PM_POP() (*(--SP))
00059
00060 #define PM_PUSH(pobj) (*(SP++) = (pobj))
00061
00062 #define GET_ARG() mem_getWord(MS, &IP)
00063
00065 #define NATIVE_SET_TOS(pobj) (gVmGlobal.nativeframe.nf_stack = \
00066 (pobj))
00067
00068 #define NATIVE_GET_LOCAL(n) (gVmGlobal.nativeframe.nf_locals[n])
00069
00070 #define NATIVE_GET_PFRAME() (*ppframe)
00071
00072 #define NATIVE_GET_NUM_ARGS() (gVmGlobal.nativeframe.nf_numlocals)
00073
00074
00081 typedef enum PmCompare_e
00082 {
00083 COMP_LT = 0,
00084 COMP_LE,
00085 COMP_EQ,
00086 COMP_NE,
00087 COMP_GT,
00088 COMP_GE,
00089 COMP_IN,
00090 COMP_NOT_IN,
00091 COMP_IS,
00092 COMP_IS_NOT,
00093 COMP_EXN_MATCH
00094 } PmCompare_t, *pPmCompare_t;
00095
00099 typedef enum PmBcode_e
00100 {
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 STOP_CODE = 0,
00112 POP_TOP,
00113 ROT_TWO,
00114 ROT_THREE,
00115 DUP_TOP,
00116 ROT_FOUR,
00117 UNUSED_06,
00118 UNUSED_07,
00119 UNUSED_08,
00120 NOP,
00121 UNARY_POSITIVE,
00122 UNARY_NEGATIVE,
00123 UNARY_NOT,
00124 UNARY_CONVERT,
00125 UNUSED_0E,
00126 UNARY_INVERT,
00127 UNUSED_10,
00128 UNUSED_11,
00129 LIST_APPEND,
00130 BINARY_POWER,
00131 BINARY_MULTIPLY,
00132 BINARY_DIVIDE,
00133 BINARY_MODULO,
00134 BINARY_ADD,
00135 BINARY_SUBTRACT,
00136 BINARY_SUBSCR,
00137 BINARY_FLOOR_DIVIDE,
00138 BINARY_TRUE_DIVIDE,
00139 INPLACE_FLOOR_DIVIDE,
00140 INPLACE_TRUE_DIVIDE,
00141 SLICE_0,
00142 SLICE_1,
00143 SLICE_2,
00144 SLICE_3,
00145 UNUSED_22,
00146 UNUSED_23,
00147 UNUSED_24,
00148 UNUSED_25,
00149 UNUSED_26,
00150 UNUSED_27,
00151 STORE_SLICE_0,
00152 STORE_SLICE_1,
00153 STORE_SLICE_2,
00154 STORE_SLICE_3,
00155 UNUSED_2C,
00156 UNUSED_2D,
00157 UNUSED_2E,
00158 UNUSED_2F,
00159 UNUSED_30,
00160 UNUSED_31,
00161 DELETE_SLICE_0,
00162 DELETE_SLICE_1,
00163 DELETE_SLICE_2,
00164 DELETE_SLICE_3,
00165 STORE_MAP,
00166 INPLACE_ADD,
00167 INPLACE_SUBTRACT,
00168 INPLACE_MULTIPLY,
00169 INPLACE_DIVIDE,
00170 INPLACE_MODULO,
00171 STORE_SUBSCR,
00172 DELETE_SUBSCR,
00173 BINARY_LSHIFT,
00174 BINARY_RSHIFT,
00175 BINARY_AND,
00176 BINARY_XOR,
00177 BINARY_OR,
00178 INPLACE_POWER,
00179 GET_ITER,
00180 UNUSED_45,
00181 PRINT_EXPR,
00182 PRINT_ITEM,
00183 PRINT_NEWLINE,
00184 PRINT_ITEM_TO,
00185 PRINT_NEWLINE_TO,
00186 INPLACE_LSHIFT,
00187 INPLACE_RSHIFT,
00188 INPLACE_AND,
00189 INPLACE_XOR,
00190 INPLACE_OR,
00191 BREAK_LOOP,
00192 WITH_CLEANUP,
00193 LOAD_LOCALS,
00194 RETURN_VALUE,
00195 IMPORT_STAR,
00196 EXEC_STMT,
00197 YIELD_VALUE,
00198 POP_BLOCK,
00199 END_FINALLY,
00200 BUILD_CLASS,
00201
00202
00203 HAVE_ARGUMENT = 90,
00204 STORE_NAME = 90,
00205 DELETE_NAME,
00206 UNPACK_SEQUENCE,
00207 FOR_ITER,
00208 UNUSED_5E,
00209 STORE_ATTR,
00210 DELETE_ATTR,
00211 STORE_GLOBAL,
00212 DELETE_GLOBAL,
00213 DUP_TOPX,
00214 LOAD_CONST,
00215 LOAD_NAME,
00216 BUILD_TUPLE,
00217 BUILD_LIST,
00218 BUILD_MAP,
00219 LOAD_ATTR,
00220 COMPARE_OP,
00221 IMPORT_NAME,
00222 IMPORT_FROM,
00223 UNUSED_6D,
00224 JUMP_FORWARD,
00225 JUMP_IF_FALSE,
00226 JUMP_IF_TRUE,
00227 JUMP_ABSOLUTE,
00228 UNUSED_72,
00229 UNUSED_73,
00230 LOAD_GLOBAL,
00231 UNUSED_75,
00232 UNUSED_76,
00233 CONTINUE_LOOP,
00234 SETUP_LOOP,
00235 SETUP_EXCEPT,
00236 SETUP_FINALLY,
00237 UNUSED_7B,
00238 LOAD_FAST,
00239 STORE_FAST,
00240 DELETE_FAST,
00241 UNUSED_79,
00242 UNUSED_80,
00243 UNUSED_81,
00244 RAISE_VARARGS,
00245 CALL_FUNCTION,
00246 MAKE_FUNCTION,
00247 BUILD_SLICE,
00248 MAKE_CLOSURE,
00249 LOAD_CLOSURE,
00250 LOAD_DEREF,
00251 STORE_DEREF,
00252 UNUSED_8A,
00253 UNUSED_8B,
00254 CALL_FUNCTION_VAR,
00255 CALL_FUNCTION_KW,
00256 CALL_FUNCTION_VAR_KW,
00257 EXTENDED_ARG,
00258
00259 UNUSED_90, UNUSED_91, UNUSED_92, UNUSED_93,
00260 UNUSED_94, UNUSED_95, UNUSED_96, UNUSED_97,
00261 UNUSED_98, UNUSED_99, UNUSED_9A, UNUSED_9B,
00262 UNUSED_9C, UNUSED_9D, UNUSED_9E, UNUSED_9F,
00263 UNUSED_A0, UNUSED_A1, UNUSED_A2, UNUSED_A3,
00264 UNUSED_A4, UNUSED_A5, UNUSED_A6, UNUSED_A7,
00265 UNUSED_A8, UNUSED_A9, UNUSED_AA, UNUSED_AB,
00266 UNUSED_AC, UNUSED_AD, UNUSED_AE, UNUSED_AF,
00267 UNUSED_B0, UNUSED_B1, UNUSED_B2, UNUSED_B3,
00268 UNUSED_B4, UNUSED_B5, UNUSED_B6, UNUSED_B7,
00269 UNUSED_B8, UNUSED_B9, UNUSED_BA, UNUSED_BB,
00270 UNUSED_BC, UNUSED_BD, UNUSED_BE, UNUSED_BF,
00271 UNUSED_C0, UNUSED_C1, UNUSED_C2, UNUSED_C3,
00272 UNUSED_C4, UNUSED_C5, UNUSED_C6, UNUSED_C7,
00273 UNUSED_C8, UNUSED_C9, UNUSED_CA, UNUSED_CB,
00274 UNUSED_CC, UNUSED_CD, UNUSED_CE, UNUSED_CF,
00275 UNUSED_D0, UNUSED_D1, UNUSED_D2, UNUSED_D3,
00276 UNUSED_D4, UNUSED_D5, UNUSED_D6, UNUSED_D7,
00277 UNUSED_D8, UNUSED_D9, UNUSED_DA, UNUSED_DB,
00278 UNUSED_DC, UNUSED_DD, UNUSED_DE, UNUSED_DF,
00279 UNUSED_E0, UNUSED_E1, UNUSED_E2, UNUSED_E3,
00280 UNUSED_E4, UNUSED_E5, UNUSED_E6, UNUSED_E7,
00281 UNUSED_E8, UNUSED_E9, UNUSED_EA, UNUSED_EB,
00282 UNUSED_EC, UNUSED_ED, UNUSED_EE, UNUSED_EF,
00283 UNUSED_F0, UNUSED_F1, UNUSED_F2, UNUSED_F3,
00284 UNUSED_F4, UNUSED_F5, UNUSED_F6, UNUSED_F7,
00285 UNUSED_F8, UNUSED_F9, UNUSED_FA, UNUSED_FB,
00286 UNUSED_FC, UNUSED_FD, UNUSED_FE, UNUSED_FF
00287 } PmBcode_t, *pPmBcode_t;
00288
00289
00298 PmReturn_t interpret(const uint8_t returnOnNoThreads);
00299
00306 PmReturn_t interp_reschedule(void);
00307
00318 PmReturn_t interp_addThread(pPmFunc_t pfunc);
00319
00326 void interp_setRescheduleFlag(uint8_t boolean);
00327
00328 #endif