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;
|
2008-10-20 22:12:42 +02:00
|
|
|
typedef struct _function_expression_t function_expression_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
|
|
|
|
2008-10-20 22:12:42 +02:00
|
|
|
typedef struct _function_declaration_t {
|
|
|
|
function_expression_t *expr;
|
|
|
|
|
|
|
|
struct _function_declaration_t *next;
|
|
|
|
} function_declaration_t;
|
|
|
|
|
2008-09-30 17:47:40 +02:00
|
|
|
typedef struct _var_list_t {
|
|
|
|
const WCHAR *identifier;
|
|
|
|
|
|
|
|
struct _var_list_t *next;
|
|
|
|
} var_list_t;
|
|
|
|
|
|
|
|
typedef struct _func_stack {
|
2008-10-20 22:12:42 +02:00
|
|
|
function_declaration_t *func_head;
|
|
|
|
function_declaration_t *func_tail;
|
2008-09-30 17:47:40 +02:00
|
|
|
var_list_t *var_head;
|
|
|
|
var_list_t *var_tail;
|
|
|
|
|
|
|
|
struct _func_stack *next;
|
|
|
|
} func_stack_t;
|
|
|
|
|
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;
|
|
|
|
BOOL is_html;
|
|
|
|
BOOL lexer_error;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
jsheap_t heap;
|
|
|
|
|
|
|
|
func_stack_t *func_stack;
|
|
|
|
} 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) \
|
2011-12-16 11:42:57 +01:00
|
|
|
X(func, 1, ARG_FUNC, 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) \
|
2011-11-28 12:05:07 +01:00
|
|
|
X(new, 1, ARG_INT, 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) \
|
2011-11-25 12:05:50 +01:00
|
|
|
X(pop, 1, 0,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) \
|
2011-11-24 14:23:39 +01:00
|
|
|
X(regexp, 1, ARG_STR, ARG_INT) \
|
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) \
|
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:14:31 +01:00
|
|
|
double *dbl;
|
2011-11-23 12:13:46 +01:00
|
|
|
LONG lng;
|
2011-11-23 12:14:15 +01:00
|
|
|
WCHAR *str;
|
2011-11-28 12:03:57 +01:00
|
|
|
unsigned uint;
|
2011-12-16 11:42:57 +01:00
|
|
|
function_expression_t *func; /* FIXME */
|
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;
|
|
|
|
instr_arg_t arg1;
|
2011-11-24 14:23:39 +01:00
|
|
|
instr_arg_t arg2;
|
2011-11-18 14:09:44 +01:00
|
|
|
} instr_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-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-03-12 19:24:22 +01:00
|
|
|
parser_ctx_t *parser;
|
2008-09-03 00:26:10 +02:00
|
|
|
|
2012-03-12 19:24:22 +01:00
|
|
|
struct _bytecode_t *next;
|
|
|
|
} bytecode_t;
|
2008-09-05 02:37:59 +02:00
|
|
|
|
2012-03-26 11:42:51 +02:00
|
|
|
HRESULT compile_script(script_ctx_t*,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;
|
2010-09-06 16:11:49 +02:00
|
|
|
jsdisp_t *obj;
|
2008-09-09 01:24:22 +02:00
|
|
|
struct _scope_chain_t *next;
|
|
|
|
} scope_chain_t;
|
|
|
|
|
2011-04-21 11:22:45 +02:00
|
|
|
HRESULT scope_push(scope_chain_t*,jsdisp_t*,scope_chain_t**) DECLSPEC_HIDDEN;
|
|
|
|
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;
|
2010-10-14 15:21:13 +02:00
|
|
|
BOOL is_global;
|
2011-11-18 14:09:44 +01:00
|
|
|
|
|
|
|
VARIANT *stack;
|
|
|
|
unsigned stack_size;
|
|
|
|
unsigned top;
|
2011-12-28 12:06:28 +01:00
|
|
|
except_frame_t *except_frame;
|
2011-11-18 14:09:44 +01:00
|
|
|
|
|
|
|
unsigned ip;
|
2011-12-19 14:59:34 +01:00
|
|
|
jsexcept_t *ei;
|
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-03-12 19:24:22 +01:00
|
|
|
HRESULT exec_source(exec_ctx_t*,bytecode_t*,source_elements_t*,BOOL,jsexcept_t*,VARIANT*) DECLSPEC_HIDDEN;
|
2008-09-03 00:25:21 +02:00
|
|
|
|
|
|
|
typedef struct _parameter_t parameter_t;
|
|
|
|
|
2012-03-12 19:24:22 +01:00
|
|
|
HRESULT create_source_function(script_ctx_t*,bytecode_t*,parameter_t*,source_elements_t*,scope_chain_t*,
|
2011-04-21 11:22:45 +02:00
|
|
|
const WCHAR*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
|
2008-09-09 01:27:57 +02:00
|
|
|
|
2009-10-14 14:41:50 +02:00
|
|
|
typedef enum {
|
|
|
|
LT_INT,
|
|
|
|
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 {
|
|
|
|
LONG lval;
|
|
|
|
double dval;
|
|
|
|
const WCHAR *wstr;
|
|
|
|
VARIANT_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;
|
|
|
|
literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_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;
|
|
|
|
} 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 {
|
|
|
|
EXPRVAL_VARIANT,
|
|
|
|
EXPRVAL_IDREF,
|
2009-08-27 01:21:38 +02:00
|
|
|
EXPRVAL_INVALID
|
2008-09-09 01:21:55 +02:00
|
|
|
} type;
|
|
|
|
union {
|
|
|
|
VARIANT var;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
struct _parameter_t {
|
|
|
|
const WCHAR *identifier;
|
|
|
|
|
|
|
|
struct _parameter_t *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _source_elements_t {
|
|
|
|
statement_t *statement;
|
|
|
|
statement_t *statement_tail;
|
|
|
|
function_declaration_t *functions;
|
2008-09-30 17:47:40 +02:00
|
|
|
var_list_t *variables;
|
2011-12-29 11:09:29 +01:00
|
|
|
unsigned instr_off;
|
2008-09-03 00:25:21 +02:00
|
|
|
};
|
|
|
|
|
2008-10-20 22:12:42 +02:00
|
|
|
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;
|
2008-10-20 22:12:42 +02:00
|
|
|
};
|
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;
|