00001 #ifndef KITE_VM__KITE_OPCODES_H
00002 #define KITE_VM__KITE_OPCODES_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 typedef struct kite_opcode_t
00034 {
00035 unsigned int opcode;
00036 unsigned int length;
00037 char *file;
00038 int line;
00039 struct kite_opcode_t *next;
00040 } kite_opcode_t;
00041
00042
00043
00044
00045 typedef struct kite_opcode_arithop
00046 {
00047 kite_opcode_t common;
00048 unsigned int operation;
00049 } kite_opcode_arithop;
00050
00051
00052
00053
00054 struct kite_object_t;
00055 typedef struct kite_opcode_push
00056 {
00057 kite_opcode_t common;
00058 struct kite_object_t *obj;
00059 } kite_opcode_push;
00060
00061
00062
00063
00064 typedef struct kite_opcode_list_cons
00065 {
00066 kite_opcode_t common;
00067 } kite_opcode_list_cons;
00068
00069
00070
00071
00072 typedef struct kite_opcode_list_cons_0
00073 {
00074 kite_opcode_t common;
00075 } kite_opcode_list_cons_0;
00076
00077
00078
00079
00080 typedef struct kite_opcode_list_cons_1
00081 {
00082 kite_opcode_t common;
00083 } kite_opcode_list_cons_1;
00084
00085
00086
00087
00088 typedef struct kite_opcode_deref_1
00089 {
00090 kite_opcode_t common;
00091 int create;
00092 } kite_opcode_deref_1;
00093
00094
00095
00096
00097 typedef struct kite_opcode_deref_2
00098 {
00099 kite_opcode_t common;
00100 } kite_opcode_deref_2;
00101
00102
00103
00104
00105 typedef struct kite_opcode_call
00106 {
00107 kite_opcode_t common;
00108 } kite_opcode_call;
00109
00110
00111
00112
00113 typedef struct kite_opcode_jump_true
00114 {
00115 kite_opcode_t common;
00116 kite_opcode_t *jumpto;
00117 } kite_opcode_jump_true;
00118
00119
00120
00121
00122 typedef struct kite_opcode_jump_false
00123 {
00124 kite_opcode_t common;
00125 kite_opcode_t *jumpto;
00126 } kite_opcode_jump_false;
00127
00128
00129
00130
00131 typedef struct kite_opcode_jump_unconditional
00132 {
00133 kite_opcode_t common;
00134 kite_opcode_t *jumpto;
00135 } kite_opcode_jump_unconditional;
00136
00137
00138
00139
00140 typedef struct kite_opcode_exception_hndl
00141 {
00142 kite_opcode_t common;
00143 kite_opcode_t *handler;
00144 } kite_opcode_exception_hndl;
00145
00146
00147
00148
00149 typedef struct kite_opcode_pop_exception_hndl
00150 {
00151 kite_opcode_t common;
00152 } kite_opcode_pop_exception_hndl;
00153
00154
00155
00156
00157 typedef struct kite_opcode_dupe_top
00158 {
00159 kite_opcode_t common;
00160 int dupe_ref;
00161 } kite_opcode_dupe_top;
00162
00163
00164
00165
00166 typedef struct kite_opcode_make
00167 {
00168 kite_opcode_t common;
00169 } kite_opcode_make;
00170
00171
00172
00173
00174 typedef struct kite_opcode_objis
00175 {
00176 kite_opcode_t common;
00177 int isof;
00178 } kite_opcode_objis;
00179
00180
00181
00182
00183 typedef struct kite_opcode_eval
00184 {
00185 kite_opcode_t common;
00186 } kite_opcode_eval;
00187
00188
00189
00190
00191 typedef struct kite_opcode_nop
00192 {
00193 kite_opcode_t common;
00194 } kite_opcode_nop;
00195
00196
00197
00198
00199 typedef struct kite_opcode_return
00200 {
00201 kite_opcode_t common;
00202 } kite_opcode_return;
00203
00204
00205
00206
00207 typedef struct kite_opcode_funcargs
00208 {
00209 kite_opcode_t common;
00210 struct kite_object_t *args;
00211 } kite_opcode_funcargs;
00212
00213
00214
00215
00216 typedef struct kite_opcode_defprop
00217 {
00218 kite_opcode_t common;
00219 } kite_opcode_defprop;
00220
00221
00222
00223
00224 typedef struct kite_opcode_this
00225 {
00226 kite_opcode_t common;
00227 } kite_opcode_this;
00228
00229
00230
00231
00232 enum kite_opcodes
00233 {
00234 JUMP_TRUE = 0,
00235 JUMP_FALSE,
00236 JUMP_UNCOND,
00237 CALL,
00238 DEREF_1,
00239 DEREF_2,
00240 DUPE_TOP,
00241 EXCEPTION_HNDL,
00242 POP_EXCEPTION_HNDL,
00243 LIST_CONS,
00244 LIST_CONS_0,
00245 LIST_CONS_1,
00246 PUSH,
00247 ARITH_OP,
00248 FUNCARGS,
00249 MAKE_OBJ,
00250 EVAL_OBJ,
00251 IS_ISOF,
00252 NOP,
00253 DEFPROP,
00254 PUSH_THIS,
00255 RETURN_NOW,
00256 NUM_OPCODES,
00257 TEMP_BREAK,
00258 TEMP_CONTINUE
00259 };
00260
00261
00262
00263
00264 enum kite_operators
00265 {
00266 OP_ADD = 0,
00267 OP_SUBTRACT,
00268 OP_MULTIPLY,
00269 OP_DIVIDE,
00270 OP_MODULUS,
00271 OP_UNARY_PLUS,
00272 OP_UNARY_MINUS,
00273 OP_ASSIGNMENT,
00274 OP_EQUALS,
00275 OP_NOT_EQUALS,
00276 OP_LESS_THAN,
00277 OP_GREATER_THAN,
00278 OP_LESS_OR_EQUALS,
00279 OP_GREATER_OR_EQUALS,
00280 OP_AND,
00281 OP_OR,
00282 OP_NOT,
00283 OP_XOR,
00284 OP_LEFT_SHIFT,
00285 OP_RIGHT_SHIFT,
00286 OP_MAP,
00287 OP_REDUCE,
00288 OP_ARRAY_DEREF,
00289 OP_METHOD_CALL,
00290 OP_PROPERTY,
00291 NUM_OPERATORS
00292 };
00293
00294
00295
00296
00297 #ifndef KITE_EXECUTE_C
00298 extern char *OPERATOR_STRINGS[];
00299 extern char *OPERATOR_METHODS[];
00300 #endif
00301 #define OP_TO_STRING(x) (OPERATOR_STRINGS[(x)])
00302 #define OP_TO_METHOD(x) (OPERATOR_METHODS[(x)])
00303
00304
00305
00306
00307 kite_opcode_t *kite_compile_arithop(unsigned int);
00308 kite_opcode_t *kite_compile_push(struct kite_object_t *);
00309 kite_opcode_t *kite_compile_list_cons();
00310 kite_opcode_t *kite_compile_list_cons_0();
00311 kite_opcode_t *kite_compile_list_cons_1();
00312 kite_opcode_t *kite_compile_deref_1(int create);
00313 kite_opcode_t *kite_compile_deref_2();
00314 kite_opcode_t *kite_compile_call();
00315 kite_opcode_t *kite_compile_jump_true(kite_opcode_t *);
00316 kite_opcode_t *kite_compile_jump_false(kite_opcode_t *);
00317 kite_opcode_t *kite_compile_jump_uncond(kite_opcode_t *);
00318 kite_opcode_t *kite_compile_exception_hndl(kite_opcode_t *);
00319 kite_opcode_t *kite_compile_pop_exception_hndl();
00320 kite_opcode_t *kite_compile_dupe_top(int dupe_ref);
00321 kite_opcode_t *kite_compile_funcargs(struct kite_object_t *);
00322 kite_opcode_t *kite_compile_make();
00323 kite_opcode_t *kite_compile_eval();
00324 kite_opcode_t *kite_compile_nop();
00325 kite_opcode_t *kite_compile_return();
00326 kite_opcode_t *kite_compile_objis(int isof);
00327 kite_opcode_t *kite_compile_defprop();
00328 kite_opcode_t *kite_compile_this();
00329
00330
00331
00332
00333 struct kite_thread_t;
00334 kite_opcode_t *kite_add_to_instruction_list(kite_opcode_t **, kite_opcode_t *);
00335 void kite_free_instruction_list(struct kite_thread_t *, kite_opcode_t *);
00336 kite_opcode_t *kite_copy_instruction_list(struct kite_thread_t *, kite_opcode_t *);
00337
00338 #endif
00339