| 1 | #ifndef js_compile_h |
| 2 | #define js_compile_h |
| 3 | |
| 4 | enum js_OpCode |
| 5 | { |
| 6 | OP_POP, /* A -- */ |
| 7 | OP_DUP, /* A -- A A */ |
| 8 | OP_DUP2, /* A B -- A B A B */ |
| 9 | OP_ROT2, /* A B -- B A */ |
| 10 | OP_ROT3, /* A B C -- C A B */ |
| 11 | OP_ROT4, /* A B C D -- D A B C */ |
| 12 | |
| 13 | OP_INTEGER, /* -K- (number-32768) */ |
| 14 | OP_NUMBER, /* -N- <number> */ |
| 15 | OP_STRING, /* -S- <string> */ |
| 16 | OP_CLOSURE, /* -F- <closure> */ |
| 17 | |
| 18 | OP_NEWARRAY, |
| 19 | OP_NEWOBJECT, |
| 20 | OP_NEWREGEXP, /* -S,opts- <regexp> */ |
| 21 | |
| 22 | OP_UNDEF, |
| 23 | OP_NULL, |
| 24 | OP_TRUE, |
| 25 | OP_FALSE, |
| 26 | |
| 27 | OP_THIS, |
| 28 | OP_CURRENT, /* currently executing function object */ |
| 29 | |
| 30 | OP_GETLOCAL, /* -K- <value> */ |
| 31 | OP_SETLOCAL, /* <value> -K- <value> */ |
| 32 | OP_DELLOCAL, /* -K- false */ |
| 33 | |
| 34 | OP_HASVAR, /* -S- ( <value> | undefined ) */ |
| 35 | OP_GETVAR, /* -S- <value> */ |
| 36 | OP_SETVAR, /* <value> -S- <value> */ |
| 37 | OP_DELVAR, /* -S- <success> */ |
| 38 | |
| 39 | OP_IN, /* <name> <obj> -- <exists?> */ |
| 40 | |
| 41 | OP_INITPROP, /* <obj> <key> <val> -- <obj> */ |
| 42 | OP_INITGETTER, /* <obj> <key> <closure> -- <obj> */ |
| 43 | OP_INITSETTER, /* <obj> <key> <closure> -- <obj> */ |
| 44 | |
| 45 | OP_GETPROP, /* <obj> <name> -- <value> */ |
| 46 | OP_GETPROP_S, /* <obj> -S- <value> */ |
| 47 | OP_SETPROP, /* <obj> <name> <value> -- <value> */ |
| 48 | OP_SETPROP_S, /* <obj> <value> -S- <value> */ |
| 49 | OP_DELPROP, /* <obj> <name> -- <success> */ |
| 50 | OP_DELPROP_S, /* <obj> -S- <success> */ |
| 51 | |
| 52 | OP_ITERATOR, /* <obj> -- <iobj> */ |
| 53 | OP_NEXTITER, /* <iobj> -- ( <iobj> <name> true | false ) */ |
| 54 | |
| 55 | OP_EVAL, /* <args...> -(numargs)- <returnvalue> */ |
| 56 | OP_CALL, /* <closure> <this> <args...> -(numargs)- <returnvalue> */ |
| 57 | OP_NEW, /* <closure> <args...> -(numargs)- <returnvalue> */ |
| 58 | |
| 59 | OP_TYPEOF, |
| 60 | OP_POS, |
| 61 | OP_NEG, |
| 62 | OP_BITNOT, |
| 63 | OP_LOGNOT, |
| 64 | OP_INC, /* <x> -- ToNumber(x)+1 */ |
| 65 | OP_DEC, /* <x> -- ToNumber(x)-1 */ |
| 66 | OP_POSTINC, /* <x> -- ToNumber(x)+1 ToNumber(x) */ |
| 67 | OP_POSTDEC, /* <x> -- ToNumber(x)-1 ToNumber(x) */ |
| 68 | |
| 69 | OP_MUL, |
| 70 | OP_DIV, |
| 71 | OP_MOD, |
| 72 | OP_ADD, |
| 73 | OP_SUB, |
| 74 | OP_SHL, |
| 75 | OP_SHR, |
| 76 | OP_USHR, |
| 77 | OP_LT, |
| 78 | OP_GT, |
| 79 | OP_LE, |
| 80 | OP_GE, |
| 81 | OP_EQ, |
| 82 | OP_NE, |
| 83 | OP_STRICTEQ, |
| 84 | OP_STRICTNE, |
| 85 | OP_JCASE, |
| 86 | OP_BITAND, |
| 87 | OP_BITXOR, |
| 88 | OP_BITOR, |
| 89 | |
| 90 | OP_INSTANCEOF, |
| 91 | |
| 92 | OP_THROW, |
| 93 | |
| 94 | OP_TRY, /* -ADDR- /jump/ or -ADDR- <exception> */ |
| 95 | OP_ENDTRY, |
| 96 | |
| 97 | OP_CATCH, /* push scope chain with exception variable */ |
| 98 | OP_ENDCATCH, |
| 99 | |
| 100 | OP_WITH, |
| 101 | OP_ENDWITH, |
| 102 | |
| 103 | OP_DEBUGGER, |
| 104 | OP_JUMP, |
| 105 | OP_JTRUE, |
| 106 | OP_JFALSE, |
| 107 | OP_RETURN, |
| 108 | }; |
| 109 | |
| 110 | struct js_Function |
| 111 | { |
| 112 | const char *name; |
| 113 | int script; |
| 114 | int lightweight; |
| 115 | int strict; |
| 116 | int arguments; |
| 117 | int numparams; |
| 118 | |
| 119 | js_Instruction *code; |
| 120 | int codecap, codelen; |
| 121 | |
| 122 | js_Function **funtab; |
| 123 | int funcap, funlen; |
| 124 | |
| 125 | double *numtab; |
| 126 | int numcap, numlen; |
| 127 | |
| 128 | const char **strtab; |
| 129 | int strcap, strlen; |
| 130 | |
| 131 | const char **vartab; |
| 132 | int varcap, varlen; |
| 133 | |
| 134 | const char *filename; |
| 135 | int line, lastline; |
| 136 | |
| 137 | js_Function *gcnext; |
| 138 | int gcmark; |
| 139 | }; |
| 140 | |
| 141 | js_Function *jsC_compilefunction(js_State *J, js_Ast *prog); |
| 142 | js_Function *jsC_compilescript(js_State *J, js_Ast *prog, int default_strict); |
| 143 | const char *jsC_opcodestring(enum js_OpCode opcode); |
| 144 | void jsC_dumpfunction(js_State *J, js_Function *fun); |
| 145 | |
| 146 | #endif |
| 147 | |