diff options
| author | Bob Jamison <ishmalius@gmail.com> | 2007-03-05 10:34:59 +0000 |
|---|---|---|
| committer | ishmal <ishmal@users.sourceforge.net> | 2007-03-05 10:34:59 +0000 |
| commit | 33837efd4b94c4ebb80f95b3d9dbb6efd5499a98 (patch) | |
| tree | de482d7687b3bffa97cc78608ba75a8ad7e52b60 /src/dom/js/jsopcode.h | |
| parent | Adding optional dialog preview. Implments RFE [ 1435276 ] switch preview on/o... (diff) | |
| download | inkscape-33837efd4b94c4ebb80f95b3d9dbb6efd5499a98.tar.gz inkscape-33837efd4b94c4ebb80f95b3d9dbb6efd5499a98.zip | |
update JS
(bzr r2555)
Diffstat (limited to 'src/dom/js/jsopcode.h')
| -rw-r--r-- | src/dom/js/jsopcode.h | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/src/dom/js/jsopcode.h b/src/dom/js/jsopcode.h index 01a6d46ac..2a488f6eb 100644 --- a/src/dom/js/jsopcode.h +++ b/src/dom/js/jsopcode.h @@ -70,10 +70,14 @@ typedef enum JSOp { #define JOF_LOOKUPSWITCH 5 /* lookup switch */ #define JOF_QARG 6 /* quickened get/set function argument ops */ #define JOF_QVAR 7 /* quickened get/set local variable ops */ -#define JOF_DEFLOCALVAR 8 /* define local var with initial value */ +#define JOF_INDEXCONST 8 /* arg or var index + constant pool index */ #define JOF_JUMPX 9 /* signed 32-bit jump offset immediate */ #define JOF_TABLESWITCHX 10 /* extended (32-bit offset) table switch */ #define JOF_LOOKUPSWITCHX 11 /* extended (32-bit offset) lookup switch */ +#define JOF_UINT24 12 /* extended unsigned 24-bit literal (index) */ +#define JOF_LITOPX 13 /* JOF_UINT24 followed by op being extended, + where op if JOF_CONST has no unsigned 16- + bit immediate operand */ #define JOF_TYPEMASK 0x000f /* mask for above immediate types */ #define JOF_NAME 0x0010 /* name operation */ #define JOF_PROP 0x0020 /* obj.prop operation */ @@ -93,6 +97,7 @@ typedef enum JSOp { #define JOF_BACKPATCH 0x4000 /* backpatch placeholder during codegen */ #define JOF_LEFTASSOC 0x8000 /* left-associative operator */ #define JOF_DECLARING 0x10000 /* var, const, or function declaration op */ +#define JOF_XMLNAME 0x20000 /* XML name: *, a::b, @a, @a::b, etc. */ #define JOF_TYPE_IS_EXTENDED_JUMP(t) \ ((unsigned)((t) - JOF_JUMPX) <= (unsigned)(JOF_LOOKUPSWITCHX - JOF_JUMPX)) @@ -107,7 +112,7 @@ typedef enum JSOp { #define JUMP_OFFSET_LO(off) ((jsbytecode)(off)) #define GET_JUMP_OFFSET(pc) ((int16)(((pc)[1] << 8) | (pc)[2])) #define SET_JUMP_OFFSET(pc,off) ((pc)[1] = JUMP_OFFSET_HI(off), \ - (pc)[2] = JUMP_OFFSET_LO(off)) + (pc)[2] = JUMP_OFFSET_LO(off)) #define JUMP_OFFSET_MIN ((int16)0x8000) #define JUMP_OFFSET_MAX ((int16)0x7fff) @@ -124,7 +129,7 @@ typedef enum JSOp { */ #define GET_SPANDEP_INDEX(pc) ((uint16)(((pc)[1] << 8) | (pc)[2])) #define SET_SPANDEP_INDEX(pc,i) ((pc)[1] = JUMP_OFFSET_HI(i), \ - (pc)[2] = JUMP_OFFSET_LO(i)) + (pc)[2] = JUMP_OFFSET_LO(i)) #define SPANDEP_INDEX_MAX ((uint16)0xfffe) #define SPANDEP_INDEX_HUGE ((uint16)0xffff) @@ -143,16 +148,36 @@ typedef enum JSOp { #define JUMPX_OFFSET_MIN ((int32)0x80000000) #define JUMPX_OFFSET_MAX ((int32)0x7fffffff) -/* A literal is indexed by a per-script atom map. */ +/* + * A literal is indexed by a per-script atom map. Most scripts have relatively + * few literals, so the standard JOF_CONST format specifies a fixed 16 bits of + * immediate operand index. A script with more than 64K literals must push all + * high-indexed literals on the stack using JSOP_LITERAL, then use JOF_ELEM ops + * instead of JOF_PROP, etc. + */ #define ATOM_INDEX_LEN 2 -#define ATOM_INDEX_HI(index) ((jsbytecode)((index) >> 8)) -#define ATOM_INDEX_LO(index) ((jsbytecode)(index)) +#define ATOM_INDEX_HI(i) ((jsbytecode)((i) >> 8)) +#define ATOM_INDEX_LO(i) ((jsbytecode)(i)) #define GET_ATOM_INDEX(pc) ((jsatomid)(((pc)[1] << 8) | (pc)[2])) -#define SET_ATOM_INDEX(pc,index)((pc)[1] = ATOM_INDEX_HI(index), \ - (pc)[2] = ATOM_INDEX_LO(index)) +#define SET_ATOM_INDEX(pc,i) ((pc)[1] = ATOM_INDEX_HI(i), \ + (pc)[2] = ATOM_INDEX_LO(i)) #define GET_ATOM(cx,script,pc) js_GetAtom((cx), &(script)->atomMap, \ - GET_ATOM_INDEX(pc)) -#define ATOM_INDEX_LIMIT_LOG2 16 + GET_ATOM_INDEX(pc)) + +/* A full atom index for JSOP_LITERAL uses 24 bits of immediate operand. */ +#define LITERAL_INDEX_LEN 3 +#define LITERAL_INDEX_HI(i) ((jsbytecode)((i) >> 16)) +#define LITERAL_INDEX_MID(i) ((jsbytecode)((i) >> 8)) +#define LITERAL_INDEX_LO(i) ((jsbytecode)(i)) +#define GET_LITERAL_INDEX(pc) ((jsatomid)(((pc)[1] << 16) | \ + ((pc)[2] << 8) | \ + (pc)[3])) +#define SET_LITERAL_INDEX(pc,i) ((pc)[1] = LITERAL_INDEX_HI(i), \ + (pc)[2] = LITERAL_INDEX_MID(i), \ + (pc)[3] = LITERAL_INDEX_LO(i)) + +/* Atom index limit is determined by SN_3BYTE_OFFSET_FLAG, see jsemit.h. */ +#define ATOM_INDEX_LIMIT_LOG2 23 #define ATOM_INDEX_LIMIT ((uint32)1 << ATOM_INDEX_LIMIT_LOG2) /* Actual argument count operand format helpers. */ @@ -192,6 +217,7 @@ extern const char js_null_str[]; extern const char js_this_str[]; extern const char js_false_str[]; extern const char js_true_str[]; +extern const char js_default_str[]; extern const JSCodeSpec js_CodeSpec[]; extern uintN js_NumCodeSpecs; extern const jschar js_EscapeMap[]; @@ -230,12 +256,12 @@ js_puts(JSPrinter *jp, const char *s); */ #include <stdio.h> -extern JS_FRIEND_API(void) +extern JS_FRIEND_API(JSBool) js_Disassemble(JSContext *cx, JSScript *script, JSBool lines, FILE *fp); extern JS_FRIEND_API(uintN) js_Disassemble1(JSContext *cx, JSScript *script, jsbytecode *pc, uintN loc, - JSBool lines, FILE *fp); + JSBool lines, FILE *fp); #endif /* DEBUG */ /* @@ -265,7 +291,7 @@ js_DecompileFunction(JSPrinter *jp, JSFunction *fun); */ extern JSString * js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v, - JSString *fallback); + JSString *fallback); #define JSDVG_IGNORE_STACK 0 #define JSDVG_SEARCH_STACK 1 |
