2008-09-03 00:25:21 +02:00
|
|
|
/*
|
2011-12-30 11:20:43 +01:00
|
|
|
* Copyright 2008,2011 Jacek Caban for CodeWeavers
|
2008-09-03 00:25:21 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _source_elements_t source_elements_t;
|
2011-11-18 14:09:44 +01:00
|
|
|
typedef struct _expression_t expression_t;
|
2011-12-19 14:58:42 +01:00
|
|
|
typedef struct _statement_t statement_t;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
2012-03-12 19:24:22 +01:00
|
|
|
typedef struct {
|
2012-03-26 11:41:38 +02:00
|
|
|
const WCHAR *begin;
|
2012-03-12 19:24:22 +01:00
|
|
|
const WCHAR *end;
|
|
|
|
const WCHAR *ptr;
|
|
|
|
|
|
|
|
script_ctx_t *script;
|
|
|
|
source_elements_t *source;
|
|
|
|
BOOL nl;
|
2012-09-10 14:44:51 +02:00
|
|
|
BOOL implicit_nl_semicolon;
|
2012-03-12 19:24:22 +01:00
|
|
|
BOOL is_html;
|
|
|
|
BOOL lexer_error;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
jsheap_t heap;
|
|
|
|
} parser_ctx_t;
|
|
|
|
|
2011-11-24 14:23:39 +01:00
|
|
|
#define OP_LIST \
|
|
|
|
X(add, 1, 0,0) \
|
2011-12-08 12:02:53 +01:00
|
|
|
X(and, 1, 0,0) \
|
2011-12-07 11:01:13 +01:00
|
|
|
X(array, 1, 0,0) \
|
2011-12-05 11:11:29 +01:00
|
|
|
X(assign, 1, 0,0) \
|
2012-04-17 16:25:58 +02:00
|
|
|
X(assign_call,1, ARG_UINT, 0) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(bool, 1, ARG_INT, 0) \
|
|
|
|
X(bneg, 1, 0,0) \
|
2011-12-07 11:00:44 +01:00
|
|
|
X(call, 1, ARG_UINT, ARG_UINT) \
|
2011-12-07 11:00:20 +01:00
|
|
|
X(call_member,1, ARG_UINT, ARG_UINT) \
|
2011-12-08 12:02:40 +01:00
|
|
|
X(carray, 1, ARG_UINT, 0) \
|
2011-12-27 11:16:40 +01:00
|
|
|
X(case, 0, ARG_ADDR, 0) \
|
2011-12-20 11:47:23 +01:00
|
|
|
X(cnd_nz, 0, ARG_ADDR, 0) \
|
|
|
|
X(cnd_z, 0, ARG_ADDR, 0) \
|
2011-11-30 10:14:22 +01:00
|
|
|
X(delete, 1, 0,0) \
|
2011-12-15 15:42:27 +01:00
|
|
|
X(delete_ident,1,ARG_BSTR, 0) \
|
2011-11-29 11:09:04 +01:00
|
|
|
X(div, 1, 0,0) \
|
2011-12-28 12:06:28 +01:00
|
|
|
X(double, 1, ARG_DBL, 0) \
|
|
|
|
X(end_finally,1, 0,0) \
|
2011-11-25 12:07:30 +01:00
|
|
|
X(eq, 1, 0,0) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(eq2, 1, 0,0) \
|
2011-12-28 12:06:41 +01:00
|
|
|
X(forin, 0, ARG_ADDR, 0) \
|
2012-04-24 17:39:09 +02:00
|
|
|
X(func, 1, ARG_UINT, 0) \
|
2011-12-01 13:23:16 +01:00
|
|
|
X(gt, 1, 0,0) \
|
2011-12-05 11:11:29 +01:00
|
|
|
X(gteq, 1, 0,0) \
|
2011-11-28 12:08:54 +01:00
|
|
|
X(ident, 1, ARG_BSTR, 0) \
|
2011-12-07 11:00:20 +01:00
|
|
|
X(identid, 1, ARG_BSTR, ARG_INT) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(in, 1, 0,0) \
|
2011-12-12 14:43:54 +01:00
|
|
|
X(instanceof, 1, 0,0) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(int, 1, ARG_INT, 0) \
|
2011-11-28 12:04:51 +01:00
|
|
|
X(jmp, 0, ARG_ADDR, 0) \
|
2011-12-20 11:47:37 +01:00
|
|
|
X(jmp_z, 0, ARG_ADDR, 0) \
|
2011-12-09 11:04:57 +01:00
|
|
|
X(lshift, 1, 0,0) \
|
2011-12-01 13:22:52 +01:00
|
|
|
X(lt, 1, 0,0) \
|
2011-12-01 13:23:03 +01:00
|
|
|
X(lteq, 1, 0,0) \
|
2011-12-06 10:42:09 +01:00
|
|
|
X(member, 1, ARG_BSTR, 0) \
|
2011-12-07 11:00:20 +01:00
|
|
|
X(memberid, 1, ARG_UINT, 0) \
|
2011-11-25 12:06:30 +01:00
|
|
|
X(minus, 1, 0,0) \
|
2011-11-29 11:09:20 +01:00
|
|
|
X(mod, 1, 0,0) \
|
2011-11-29 11:08:54 +01:00
|
|
|
X(mul, 1, 0,0) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(neg, 1, 0,0) \
|
2011-11-25 12:07:30 +01:00
|
|
|
X(neq, 1, 0,0) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(neq2, 1, 0,0) \
|
2012-05-12 16:21:31 +02:00
|
|
|
X(new, 1, ARG_UINT, 0) \
|
2011-12-16 11:43:31 +01:00
|
|
|
X(new_obj, 1, 0,0) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(null, 1, 0,0) \
|
2011-12-16 11:43:31 +01:00
|
|
|
X(obj_prop, 1, ARG_BSTR, 0) \
|
2011-11-29 11:09:35 +01:00
|
|
|
X(or, 1, 0,0) \
|
2012-12-14 11:06:43 +01:00
|
|
|
X(pop, 1, ARG_UINT, 0) \
|
2011-12-28 12:06:28 +01:00
|
|
|
X(pop_except, 1, 0,0) \
|
2011-12-27 11:16:26 +01:00
|
|
|
X(pop_scope, 1, 0,0) \
|
2011-12-07 11:01:53 +01:00
|
|
|
X(postinc, 1, ARG_INT, 0) \
|
2011-12-08 12:02:08 +01:00
|
|
|
X(preinc, 1, ARG_INT, 0) \
|
2011-12-28 12:06:41 +01:00
|
|
|
X(push_except,1, ARG_ADDR, ARG_BSTR) \
|
2011-12-27 11:16:26 +01:00
|
|
|
X(push_scope, 1, 0,0) \
|
2012-05-12 16:21:44 +02:00
|
|
|
X(regexp, 1, ARG_STR, ARG_UINT) \
|
2011-12-08 12:03:22 +01:00
|
|
|
X(rshift, 1, 0,0) \
|
2011-12-09 11:04:24 +01:00
|
|
|
X(rshift2, 1, 0,0) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(str, 1, ARG_STR, 0) \
|
2011-11-24 14:24:14 +01:00
|
|
|
X(this, 1, 0,0) \
|
2011-12-28 12:06:17 +01:00
|
|
|
X(throw, 0, 0,0) \
|
2011-12-28 12:06:03 +01:00
|
|
|
X(throw_ref, 0, ARG_UINT, 0) \
|
2011-12-19 14:58:42 +01:00
|
|
|
X(throw_type, 0, ARG_UINT, ARG_STR) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(tonum, 1, 0,0) \
|
2011-12-13 11:57:11 +01:00
|
|
|
X(typeof, 1, 0,0) \
|
|
|
|
X(typeofid, 1, 0,0) \
|
|
|
|
X(typeofident,1, 0,0) \
|
2011-12-05 11:13:02 +01:00
|
|
|
X(refval, 1, 0,0) \
|
2011-11-24 14:24:45 +01:00
|
|
|
X(ret, 0, 0,0) \
|
2012-12-13 12:08:34 +01:00
|
|
|
X(setret, 1, 0,0) \
|
2011-11-25 12:06:05 +01:00
|
|
|
X(sub, 1, 0,0) \
|
2011-12-08 12:02:40 +01:00
|
|
|
X(undefined, 1, 0,0) \
|
2011-12-20 11:45:37 +01:00
|
|
|
X(var_set, 1, ARG_BSTR, 0) \
|
2011-11-29 11:09:49 +01:00
|
|
|
X(void, 1, 0,0) \
|
|
|
|
X(xor, 1, 0,0)
|
2011-11-18 14:09:44 +01:00
|
|
|
|
|
|
|
typedef enum {
|
2011-11-24 14:23:39 +01:00
|
|
|
#define X(x,a,b,c) OP_##x,
|
2011-11-18 14:09:44 +01:00
|
|
|
OP_LIST
|
|
|
|
#undef X
|
|
|
|
OP_LAST
|
|
|
|
} jsop_t;
|
|
|
|
|
|
|
|
typedef union {
|
2011-11-28 12:08:54 +01:00
|
|
|
BSTR bstr;
|
2011-11-23 12:13:46 +01:00
|
|
|
LONG lng;
|
2012-10-11 12:17:17 +02:00
|
|
|
jsstr_t *str;
|
2011-11-28 12:03:57 +01:00
|
|
|
unsigned uint;
|
2011-11-18 14:09:44 +01:00
|
|
|
} instr_arg_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ARG_NONE = 0,
|
2011-11-28 12:03:57 +01:00
|
|
|
ARG_ADDR,
|
2011-11-28 12:08:54 +01:00
|
|
|
ARG_BSTR,
|
2011-12-28 12:06:41 +01:00
|
|
|
ARG_DBL,
|
2011-12-16 11:42:57 +01:00
|
|
|
ARG_FUNC,
|
2011-11-28 12:03:57 +01:00
|
|
|
ARG_INT,
|
2011-12-28 12:06:41 +01:00
|
|
|
ARG_STR,
|
|
|
|
ARG_UINT
|
2011-11-18 14:09:44 +01:00
|
|
|
} instr_arg_type_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
jsop_t op;
|
2012-05-12 16:22:37 +02:00
|
|
|
union {
|
|
|
|
instr_arg_t arg[2];
|
|
|
|
double dbl;
|
|
|
|
} u;
|
2011-11-18 14:09:44 +01:00
|
|
|
} instr_t;
|
|
|
|
|
2012-04-24 17:39:09 +02:00
|
|
|
typedef struct _function_code_t {
|
2012-04-24 17:39:25 +02:00
|
|
|
BSTR name;
|
2012-04-24 17:39:09 +02:00
|
|
|
unsigned instr_off;
|
|
|
|
|
2012-04-24 17:39:40 +02:00
|
|
|
const WCHAR *source;
|
|
|
|
unsigned source_len;
|
|
|
|
|
2012-04-24 17:39:09 +02:00
|
|
|
unsigned func_cnt;
|
|
|
|
struct _function_code_t *funcs;
|
2012-04-25 10:47:56 +02:00
|
|
|
|
|
|
|
unsigned var_cnt;
|
|
|
|
BSTR *variables;
|
2012-04-25 11:25:57 +02:00
|
|
|
|
|
|
|
unsigned param_cnt;
|
|
|
|
BSTR *params;
|
2012-04-24 17:39:09 +02:00
|
|
|
} function_code_t;
|
|
|
|
|
2012-03-12 19:24:22 +01:00
|
|
|
typedef struct _bytecode_t {
|
|
|
|
LONG ref;
|
|
|
|
|
2011-11-18 14:09:44 +01:00
|
|
|
instr_t *instrs;
|
2011-11-23 12:14:15 +01:00
|
|
|
jsheap_t heap;
|
2011-11-28 12:08:54 +01:00
|
|
|
|
2012-04-24 17:39:09 +02:00
|
|
|
function_code_t global_code;
|
|
|
|
|
2012-03-26 11:41:38 +02:00
|
|
|
WCHAR *source;
|
|
|
|
|
2011-11-28 12:08:54 +01:00
|
|
|
BSTR *bstr_pool;
|
|
|
|
unsigned bstr_pool_size;
|
|
|
|
unsigned bstr_cnt;
|
2011-11-18 14:09:44 +01:00
|
|
|
|
2012-10-11 12:17:17 +02:00
|
|
|
jsstr_t **str_pool;
|
|
|
|
unsigned str_pool_size;
|
|
|
|
unsigned str_cnt;
|
|
|
|
|
2012-03-12 19:24:22 +01:00
|
|
|
struct _bytecode_t *next;
|
|
|
|
} bytecode_t;
|
2008-09-05 02:37:59 +02:00
|
|
|
|
2012-10-04 14:58:05 +02:00
|
|
|
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,BOOL,BOOL,bytecode_t**) DECLSPEC_HIDDEN;
|
2012-03-12 19:24:22 +01:00
|
|
|
void release_bytecode(bytecode_t*) DECLSPEC_HIDDEN;
|
2008-09-15 20:38:18 +02:00
|
|
|
|
2012-03-12 19:24:22 +01:00
|
|
|
static inline void bytecode_addref(bytecode_t *code)
|
|
|
|
{
|
|
|
|
code->ref++;
|
|
|
|
}
|
2008-09-03 00:25:21 +02:00
|
|
|
|
2012-03-12 19:22:36 +01:00
|
|
|
HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN;
|
2011-04-21 11:22:45 +02:00
|
|
|
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
2011-04-21 11:22:45 +02:00
|
|
|
int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
|
|
|
static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
|
|
|
|
{
|
2008-09-03 00:26:10 +02:00
|
|
|
return jsheap_alloc(&ctx->heap, size);
|
2008-09-03 00:25:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
|
|
|
|
{
|
2008-09-15 20:38:46 +02:00
|
|
|
return jsheap_alloc(&ctx->script->tmp_heap, size);
|
2008-09-03 00:25:21 +02:00
|
|
|
}
|
|
|
|
|
2008-09-09 01:24:22 +02:00
|
|
|
typedef struct _scope_chain_t {
|
|
|
|
LONG ref;
|
2012-09-13 14:34:25 +02:00
|
|
|
jsdisp_t *jsobj;
|
|
|
|
IDispatch *obj;
|
2008-09-09 01:24:22 +02:00
|
|
|
struct _scope_chain_t *next;
|
|
|
|
} scope_chain_t;
|
|
|
|
|
2012-09-13 14:34:25 +02:00
|
|
|
HRESULT scope_push(scope_chain_t*,jsdisp_t*,IDispatch*,scope_chain_t**) DECLSPEC_HIDDEN;
|
2011-04-21 11:22:45 +02:00
|
|
|
void scope_release(scope_chain_t*) DECLSPEC_HIDDEN;
|
2008-09-09 01:24:22 +02:00
|
|
|
|
|
|
|
static inline void scope_addref(scope_chain_t *scope)
|
|
|
|
{
|
|
|
|
scope->ref++;
|
|
|
|
}
|
|
|
|
|
2011-12-28 12:06:28 +01:00
|
|
|
typedef struct _except_frame_t except_frame_t;
|
2011-12-19 14:58:42 +01:00
|
|
|
|
2008-09-05 02:37:59 +02:00
|
|
|
struct _exec_ctx_t {
|
|
|
|
LONG ref;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
|
|
|
parser_ctx_t *parser;
|
2012-03-12 19:21:27 +01:00
|
|
|
bytecode_t *code;
|
2012-03-12 19:23:56 +01:00
|
|
|
script_ctx_t *script;
|
2008-09-09 01:24:22 +02:00
|
|
|
scope_chain_t *scope_chain;
|
2010-09-06 16:11:49 +02:00
|
|
|
jsdisp_t *var_disp;
|
2008-09-10 21:05:14 +02:00
|
|
|
IDispatch *this_obj;
|
2012-04-24 17:39:09 +02:00
|
|
|
function_code_t *func_code;
|
2010-10-14 15:21:13 +02:00
|
|
|
BOOL is_global;
|
2011-11-18 14:09:44 +01:00
|
|
|
|
2012-09-17 15:17:02 +02:00
|
|
|
jsval_t *stack;
|
2011-11-18 14:09:44 +01:00
|
|
|
unsigned stack_size;
|
|
|
|
unsigned top;
|
2011-12-28 12:06:28 +01:00
|
|
|
except_frame_t *except_frame;
|
2012-12-13 12:08:34 +01:00
|
|
|
jsval_t ret;
|
2011-11-18 14:09:44 +01:00
|
|
|
|
|
|
|
unsigned ip;
|
2008-09-05 02:37:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void exec_addref(exec_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
ctx->ref++;
|
|
|
|
}
|
|
|
|
|
2011-04-21 11:22:45 +02:00
|
|
|
void exec_release(exec_ctx_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,jsdisp_t*,scope_chain_t*,BOOL,exec_ctx_t**) DECLSPEC_HIDDEN;
|
2012-09-18 19:01:49 +02:00
|
|
|
HRESULT exec_source(exec_ctx_t*,bytecode_t*,function_code_t*,BOOL,jsval_t*) DECLSPEC_HIDDEN;
|
2012-04-25 11:25:57 +02:00
|
|
|
HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
2008-09-09 01:27:57 +02:00
|
|
|
|
2009-10-14 14:41:50 +02:00
|
|
|
typedef enum {
|
|
|
|
LT_DOUBLE,
|
|
|
|
LT_STRING,
|
|
|
|
LT_BOOL,
|
2009-10-14 14:43:01 +02:00
|
|
|
LT_NULL,
|
|
|
|
LT_REGEXP
|
2009-10-14 14:41:50 +02:00
|
|
|
}literal_type_t;
|
|
|
|
|
2008-09-03 00:25:21 +02:00
|
|
|
typedef struct {
|
2009-10-14 14:41:50 +02:00
|
|
|
literal_type_t type;
|
2008-09-03 00:25:21 +02:00
|
|
|
union {
|
|
|
|
double dval;
|
|
|
|
const WCHAR *wstr;
|
2012-09-17 15:20:37 +02:00
|
|
|
BOOL bval;
|
2009-10-14 14:43:01 +02:00
|
|
|
struct {
|
|
|
|
const WCHAR *str;
|
|
|
|
DWORD str_len;
|
|
|
|
DWORD flags;
|
|
|
|
} regexp;
|
2008-09-03 00:25:21 +02:00
|
|
|
} u;
|
|
|
|
} literal_t;
|
|
|
|
|
2011-04-21 11:22:45 +02:00
|
|
|
literal_t *parse_regexp(parser_ctx_t*) DECLSPEC_HIDDEN;
|
2012-09-17 15:20:37 +02:00
|
|
|
literal_t *new_boolean_literal(parser_ctx_t*,BOOL) DECLSPEC_HIDDEN;
|
2008-09-15 20:38:18 +02:00
|
|
|
|
2008-09-03 00:25:21 +02:00
|
|
|
typedef struct _variable_declaration_t {
|
|
|
|
const WCHAR *identifier;
|
|
|
|
expression_t *expr;
|
|
|
|
|
|
|
|
struct _variable_declaration_t *next;
|
2012-04-25 11:26:21 +02:00
|
|
|
struct _variable_declaration_t *global_next; /* for compiler */
|
2008-09-03 00:25:21 +02:00
|
|
|
} variable_declaration_t;
|
|
|
|
|
2011-12-19 14:58:19 +01:00
|
|
|
typedef enum {
|
|
|
|
STAT_BLOCK,
|
|
|
|
STAT_BREAK,
|
|
|
|
STAT_CONTINUE,
|
|
|
|
STAT_EMPTY,
|
|
|
|
STAT_EXPR,
|
|
|
|
STAT_FOR,
|
|
|
|
STAT_FORIN,
|
|
|
|
STAT_IF,
|
|
|
|
STAT_LABEL,
|
|
|
|
STAT_RETURN,
|
|
|
|
STAT_SWITCH,
|
|
|
|
STAT_THROW,
|
|
|
|
STAT_TRY,
|
|
|
|
STAT_VAR,
|
|
|
|
STAT_WHILE,
|
|
|
|
STAT_WITH
|
|
|
|
} statement_type_t;
|
|
|
|
|
2008-09-03 00:25:21 +02:00
|
|
|
struct _statement_t {
|
2011-12-19 14:58:19 +01:00
|
|
|
statement_type_t type;
|
2008-09-03 00:25:21 +02:00
|
|
|
statement_t *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
statement_t *stat_list;
|
|
|
|
} block_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
variable_declaration_t *variable_list;
|
|
|
|
} var_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
} expression_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *if_stat;
|
|
|
|
statement_t *else_stat;
|
|
|
|
} if_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
2008-09-17 23:35:38 +02:00
|
|
|
BOOL do_while;
|
2008-09-03 00:25:21 +02:00
|
|
|
expression_t *expr;
|
|
|
|
statement_t *statement;
|
|
|
|
} while_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
variable_declaration_t *variable_list;
|
|
|
|
expression_t *begin_expr;
|
|
|
|
expression_t *expr;
|
|
|
|
expression_t *end_expr;
|
|
|
|
statement_t *statement;
|
|
|
|
} for_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
variable_declaration_t *variable;
|
|
|
|
expression_t *expr;
|
|
|
|
expression_t *in_expr;
|
|
|
|
statement_t *statement;
|
|
|
|
} forin_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
} branch_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *statement;
|
|
|
|
} with_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
statement_t *statement;
|
|
|
|
} labelled_statement_t;
|
|
|
|
|
|
|
|
typedef struct _case_clausule_t {
|
|
|
|
expression_t *expr;
|
|
|
|
statement_t *stat;
|
|
|
|
|
|
|
|
struct _case_clausule_t *next;
|
|
|
|
} case_clausule_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
expression_t *expr;
|
|
|
|
case_clausule_t *case_list;
|
|
|
|
} switch_statement_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const WCHAR *identifier;
|
|
|
|
statement_t *statement;
|
|
|
|
} catch_block_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
statement_t stat;
|
|
|
|
statement_t *try_statement;
|
|
|
|
catch_block_t *catch_block;
|
|
|
|
statement_t *finally_statement;
|
|
|
|
} try_statement_t;
|
|
|
|
|
2008-09-09 01:21:55 +02:00
|
|
|
typedef struct {
|
|
|
|
enum {
|
2012-09-17 15:17:02 +02:00
|
|
|
EXPRVAL_JSVAL,
|
2008-09-09 01:21:55 +02:00
|
|
|
EXPRVAL_IDREF,
|
2009-08-27 01:21:38 +02:00
|
|
|
EXPRVAL_INVALID
|
2008-09-09 01:21:55 +02:00
|
|
|
} type;
|
|
|
|
union {
|
2012-09-17 15:17:02 +02:00
|
|
|
jsval_t val;
|
2008-09-09 01:21:55 +02:00
|
|
|
struct {
|
|
|
|
IDispatch *disp;
|
|
|
|
DISPID id;
|
|
|
|
} idref;
|
|
|
|
} u;
|
|
|
|
} exprval_t;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
2011-11-18 14:05:57 +01:00
|
|
|
typedef enum {
|
|
|
|
EXPR_COMMA,
|
|
|
|
EXPR_OR,
|
|
|
|
EXPR_AND,
|
|
|
|
EXPR_BOR,
|
|
|
|
EXPR_BXOR,
|
|
|
|
EXPR_BAND,
|
|
|
|
EXPR_INSTANCEOF,
|
|
|
|
EXPR_IN,
|
|
|
|
EXPR_ADD,
|
|
|
|
EXPR_SUB,
|
|
|
|
EXPR_MUL,
|
|
|
|
EXPR_DIV,
|
|
|
|
EXPR_MOD,
|
|
|
|
EXPR_DELETE,
|
|
|
|
EXPR_VOID,
|
|
|
|
EXPR_TYPEOF,
|
|
|
|
EXPR_MINUS,
|
|
|
|
EXPR_PLUS,
|
|
|
|
EXPR_POSTINC,
|
|
|
|
EXPR_POSTDEC,
|
|
|
|
EXPR_PREINC,
|
|
|
|
EXPR_PREDEC,
|
|
|
|
EXPR_EQ,
|
|
|
|
EXPR_EQEQ,
|
|
|
|
EXPR_NOTEQ,
|
|
|
|
EXPR_NOTEQEQ,
|
|
|
|
EXPR_LESS,
|
|
|
|
EXPR_LESSEQ,
|
|
|
|
EXPR_GREATER,
|
|
|
|
EXPR_GREATEREQ,
|
|
|
|
EXPR_BITNEG,
|
|
|
|
EXPR_LOGNEG,
|
|
|
|
EXPR_LSHIFT,
|
|
|
|
EXPR_RSHIFT,
|
|
|
|
EXPR_RRSHIFT,
|
|
|
|
EXPR_ASSIGN,
|
|
|
|
EXPR_ASSIGNLSHIFT,
|
|
|
|
EXPR_ASSIGNRSHIFT,
|
|
|
|
EXPR_ASSIGNRRSHIFT,
|
|
|
|
EXPR_ASSIGNADD,
|
|
|
|
EXPR_ASSIGNSUB,
|
|
|
|
EXPR_ASSIGNMUL,
|
|
|
|
EXPR_ASSIGNDIV,
|
|
|
|
EXPR_ASSIGNMOD,
|
|
|
|
EXPR_ASSIGNAND,
|
|
|
|
EXPR_ASSIGNOR,
|
|
|
|
EXPR_ASSIGNXOR,
|
|
|
|
EXPR_COND,
|
|
|
|
EXPR_ARRAY,
|
|
|
|
EXPR_MEMBER,
|
|
|
|
EXPR_NEW,
|
|
|
|
EXPR_CALL,
|
|
|
|
EXPR_THIS,
|
|
|
|
EXPR_FUNC,
|
|
|
|
EXPR_IDENT,
|
|
|
|
EXPR_ARRAYLIT,
|
|
|
|
EXPR_PROPVAL,
|
|
|
|
EXPR_LITERAL
|
|
|
|
} expression_type_t;
|
|
|
|
|
2008-09-03 00:25:21 +02:00
|
|
|
struct _expression_t {
|
2011-11-18 14:05:57 +01:00
|
|
|
expression_type_t type;
|
2008-09-03 00:25:21 +02:00
|
|
|
};
|
|
|
|
|
2012-04-25 11:25:57 +02:00
|
|
|
typedef struct _parameter_t {
|
2008-09-03 00:25:21 +02:00
|
|
|
const WCHAR *identifier;
|
|
|
|
struct _parameter_t *next;
|
2012-04-25 11:25:57 +02:00
|
|
|
} parameter_t;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
|
|
|
struct _source_elements_t {
|
|
|
|
statement_t *statement;
|
|
|
|
statement_t *statement_tail;
|
|
|
|
};
|
|
|
|
|
2012-04-26 16:17:31 +02:00
|
|
|
typedef struct _function_expression_t {
|
2008-09-03 00:25:21 +02:00
|
|
|
expression_t expr;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
parameter_t *parameter_list;
|
|
|
|
source_elements_t *source_elements;
|
2008-09-21 15:47:47 +02:00
|
|
|
const WCHAR *src_str;
|
|
|
|
DWORD src_len;
|
2012-04-26 16:17:31 +02:00
|
|
|
|
|
|
|
struct _function_expression_t *next; /* for compiler */
|
|
|
|
} function_expression_t;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *expression1;
|
|
|
|
expression_t *expression2;
|
|
|
|
} binary_expression_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *expression;
|
|
|
|
} unary_expression_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *expression;
|
|
|
|
expression_t *true_expression;
|
|
|
|
expression_t *false_expression;
|
|
|
|
} conditional_expression_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *expression;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
} member_expression_t;
|
|
|
|
|
|
|
|
typedef struct _argument_t {
|
|
|
|
expression_t *expr;
|
|
|
|
|
|
|
|
struct _argument_t *next;
|
|
|
|
} argument_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
expression_t *expression;
|
|
|
|
argument_t *argument_list;
|
|
|
|
} call_expression_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
} identifier_expression_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
literal_t *literal;
|
|
|
|
} literal_expression_t;
|
|
|
|
|
|
|
|
typedef struct _array_element_t {
|
|
|
|
int elision;
|
|
|
|
expression_t *expr;
|
|
|
|
|
|
|
|
struct _array_element_t *next;
|
|
|
|
} array_element_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
array_element_t *element_list;
|
|
|
|
int length;
|
|
|
|
} array_literal_expression_t;
|
|
|
|
|
|
|
|
typedef struct _prop_val_t {
|
|
|
|
literal_t *name;
|
|
|
|
expression_t *value;
|
|
|
|
|
|
|
|
struct _prop_val_t *next;
|
|
|
|
} prop_val_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
expression_t expr;
|
|
|
|
prop_val_t *property_list;
|
|
|
|
} property_value_expression_t;
|