2008-09-02 22:25:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* 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 20:12:42 +00:00
|
|
|
typedef struct _function_expression_t function_expression_t;
|
2011-11-18 13:09:44 +00:00
|
|
|
typedef struct _expression_t expression_t;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
2008-10-20 20:12:42 +00:00
|
|
|
typedef struct _function_declaration_t {
|
|
|
|
function_expression_t *expr;
|
|
|
|
|
|
|
|
struct _function_declaration_t *next;
|
|
|
|
} function_declaration_t;
|
|
|
|
|
2008-09-30 15:47:40 +00:00
|
|
|
typedef struct _var_list_t {
|
|
|
|
const WCHAR *identifier;
|
|
|
|
|
|
|
|
struct _var_list_t *next;
|
|
|
|
} var_list_t;
|
|
|
|
|
|
|
|
typedef struct _func_stack {
|
2008-10-20 20:12:42 +00:00
|
|
|
function_declaration_t *func_head;
|
|
|
|
function_declaration_t *func_tail;
|
2008-09-30 15:47:40 +00:00
|
|
|
var_list_t *var_head;
|
|
|
|
var_list_t *var_tail;
|
|
|
|
|
|
|
|
struct _func_stack *next;
|
|
|
|
} func_stack_t;
|
|
|
|
|
2011-11-24 13:23:39 +00:00
|
|
|
#define OP_LIST \
|
|
|
|
X(add, 1, 0,0) \
|
2011-12-05 10:11:29 +00:00
|
|
|
X(assign, 1, 0,0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(bool, 1, ARG_INT, 0) \
|
|
|
|
X(bneg, 1, 0,0) \
|
2011-12-07 10:00:20 +00:00
|
|
|
X(call_member,1, ARG_UINT, ARG_UINT) \
|
2011-11-30 09:14:22 +00:00
|
|
|
X(delete, 1, 0,0) \
|
2011-11-29 10:09:04 +00:00
|
|
|
X(div, 1, 0,0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(double, 1, ARG_SBL, 0) \
|
2011-11-25 11:07:30 +00:00
|
|
|
X(eq, 1, 0,0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(eq2, 1, 0,0) \
|
2011-12-01 12:23:16 +00:00
|
|
|
X(gt, 1, 0,0) \
|
2011-12-05 10:11:29 +00:00
|
|
|
X(gteq, 1, 0,0) \
|
2011-11-28 11:08:54 +00:00
|
|
|
X(ident, 1, ARG_BSTR, 0) \
|
2011-12-07 10:00:20 +00:00
|
|
|
X(identid, 1, ARG_BSTR, ARG_INT) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(in, 1, 0,0) \
|
|
|
|
X(int, 1, ARG_INT, 0) \
|
2011-11-28 11:04:51 +00:00
|
|
|
X(jmp, 0, ARG_ADDR, 0) \
|
2011-11-28 11:03:57 +00:00
|
|
|
X(jmp_nz, 0, ARG_ADDR, 0) \
|
2011-11-28 11:04:33 +00:00
|
|
|
X(jmp_z, 0, ARG_ADDR, 0) \
|
2011-12-01 12:22:52 +00:00
|
|
|
X(lt, 1, 0,0) \
|
2011-12-01 12:23:03 +00:00
|
|
|
X(lteq, 1, 0,0) \
|
2011-12-06 09:42:09 +00:00
|
|
|
X(member, 1, ARG_BSTR, 0) \
|
2011-12-07 10:00:20 +00:00
|
|
|
X(memberid, 1, ARG_UINT, 0) \
|
2011-11-25 11:06:30 +00:00
|
|
|
X(minus, 1, 0,0) \
|
2011-11-29 10:09:20 +00:00
|
|
|
X(mod, 1, 0,0) \
|
2011-11-29 10:08:54 +00:00
|
|
|
X(mul, 1, 0,0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(neg, 1, 0,0) \
|
2011-11-25 11:07:30 +00:00
|
|
|
X(neq, 1, 0,0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(neq2, 1, 0,0) \
|
2011-11-28 11:05:07 +00:00
|
|
|
X(new, 1, ARG_INT, 0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(null, 1, 0,0) \
|
2011-11-29 10:09:35 +00:00
|
|
|
X(or, 1, 0,0) \
|
2011-11-25 11:05:50 +00:00
|
|
|
X(pop, 1, 0,0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(regexp, 1, ARG_STR, ARG_INT) \
|
|
|
|
X(str, 1, ARG_STR, 0) \
|
2011-11-24 13:24:14 +00:00
|
|
|
X(this, 1, 0,0) \
|
2011-12-05 10:12:32 +00:00
|
|
|
X(throw, 0, ARG_UINT, 0) \
|
2011-11-24 13:23:39 +00:00
|
|
|
X(tonum, 1, 0,0) \
|
|
|
|
X(tree, 1, ARG_EXPR, 0) \
|
2011-12-05 10:13:02 +00:00
|
|
|
X(refval, 1, 0,0) \
|
2011-11-24 13:24:45 +00:00
|
|
|
X(ret, 0, 0,0) \
|
2011-11-25 11:06:05 +00:00
|
|
|
X(sub, 1, 0,0) \
|
2011-11-29 10:09:49 +00:00
|
|
|
X(void, 1, 0,0) \
|
|
|
|
X(xor, 1, 0,0)
|
2011-11-18 13:09:44 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2011-11-24 13:23:39 +00:00
|
|
|
#define X(x,a,b,c) OP_##x,
|
2011-11-18 13:09:44 +00:00
|
|
|
OP_LIST
|
|
|
|
#undef X
|
|
|
|
OP_LAST
|
|
|
|
} jsop_t;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
expression_t *expr;
|
2011-11-28 11:08:54 +00:00
|
|
|
BSTR bstr;
|
2011-11-23 11:14:31 +00:00
|
|
|
double *dbl;
|
2011-11-23 11:13:46 +00:00
|
|
|
LONG lng;
|
2011-11-23 11:14:15 +00:00
|
|
|
WCHAR *str;
|
2011-11-28 11:03:57 +00:00
|
|
|
unsigned uint;
|
2011-11-18 13:09:44 +00:00
|
|
|
} instr_arg_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ARG_NONE = 0,
|
2011-11-28 11:03:57 +00:00
|
|
|
ARG_ADDR,
|
2011-11-28 11:08:54 +00:00
|
|
|
ARG_BSTR,
|
2011-11-23 11:13:46 +00:00
|
|
|
ARG_EXPR,
|
2011-11-28 11:03:57 +00:00
|
|
|
ARG_INT,
|
|
|
|
ARG_STR
|
2011-11-18 13:09:44 +00:00
|
|
|
} instr_arg_type_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
jsop_t op;
|
|
|
|
instr_arg_t arg1;
|
2011-11-24 13:23:39 +00:00
|
|
|
instr_arg_t arg2;
|
2011-11-18 13:09:44 +00:00
|
|
|
} instr_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
instr_t *instrs;
|
2011-11-23 11:14:15 +00:00
|
|
|
jsheap_t heap;
|
2011-11-28 11:08:54 +00:00
|
|
|
|
|
|
|
BSTR *bstr_pool;
|
|
|
|
unsigned bstr_pool_size;
|
|
|
|
unsigned bstr_cnt;
|
2011-11-18 13:09:44 +00:00
|
|
|
} bytecode_t;
|
|
|
|
|
|
|
|
void release_bytecode(bytecode_t*);
|
|
|
|
|
|
|
|
typedef struct _compiler_ctx_t compiler_ctx_t;
|
|
|
|
|
|
|
|
void release_compiler(compiler_ctx_t*);
|
|
|
|
|
2008-09-02 22:25:21 +00:00
|
|
|
typedef struct _parser_ctx_t {
|
|
|
|
LONG ref;
|
|
|
|
|
2009-10-27 21:47:20 +00:00
|
|
|
WCHAR *begin;
|
2008-09-02 22:25:21 +00:00
|
|
|
const WCHAR *end;
|
2009-10-27 21:47:20 +00:00
|
|
|
const WCHAR *ptr;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
|
|
|
script_ctx_t *script;
|
|
|
|
source_elements_t *source;
|
|
|
|
BOOL nl;
|
2009-04-09 21:34:26 +00:00
|
|
|
BOOL is_html;
|
2009-08-05 21:27:09 +00:00
|
|
|
BOOL lexer_error;
|
2008-09-02 22:25:21 +00:00
|
|
|
HRESULT hres;
|
2008-09-02 22:26:10 +00:00
|
|
|
|
|
|
|
jsheap_t heap;
|
2008-09-05 00:37:59 +00:00
|
|
|
|
2008-09-30 15:47:40 +00:00
|
|
|
func_stack_t *func_stack;
|
2008-09-15 18:38:18 +00:00
|
|
|
|
2011-11-18 13:09:44 +00:00
|
|
|
bytecode_t *code;
|
|
|
|
compiler_ctx_t *compiler;
|
|
|
|
|
2008-09-05 00:37:59 +00:00
|
|
|
struct _parser_ctx_t *next;
|
2008-09-02 22:25:21 +00:00
|
|
|
} parser_ctx_t;
|
|
|
|
|
2011-04-21 09:22:45 +00:00
|
|
|
HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,parser_ctx_t**) DECLSPEC_HIDDEN;
|
|
|
|
void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
2011-04-21 09:22:45 +00:00
|
|
|
int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
|
|
|
static inline void parser_addref(parser_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
ctx->ref++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
|
|
|
|
{
|
2008-09-02 22:26:10 +00:00
|
|
|
return jsheap_alloc(&ctx->heap, size);
|
2008-09-02 22:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
|
|
|
|
{
|
2008-09-15 18:38:46 +00:00
|
|
|
return jsheap_alloc(&ctx->script->tmp_heap, size);
|
2008-09-02 22:25:21 +00:00
|
|
|
}
|
|
|
|
|
2008-09-08 23:24:22 +00:00
|
|
|
typedef struct _scope_chain_t {
|
|
|
|
LONG ref;
|
2010-09-06 14:11:49 +00:00
|
|
|
jsdisp_t *obj;
|
2008-09-08 23:24:22 +00:00
|
|
|
struct _scope_chain_t *next;
|
|
|
|
} scope_chain_t;
|
|
|
|
|
2011-04-21 09:22:45 +00:00
|
|
|
HRESULT scope_push(scope_chain_t*,jsdisp_t*,scope_chain_t**) DECLSPEC_HIDDEN;
|
|
|
|
void scope_release(scope_chain_t*) DECLSPEC_HIDDEN;
|
2008-09-08 23:24:22 +00:00
|
|
|
|
|
|
|
static inline void scope_addref(scope_chain_t *scope)
|
|
|
|
{
|
|
|
|
scope->ref++;
|
|
|
|
}
|
|
|
|
|
2008-09-05 00:37:59 +00:00
|
|
|
struct _exec_ctx_t {
|
|
|
|
LONG ref;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
|
|
|
parser_ctx_t *parser;
|
2008-09-08 23:24:22 +00:00
|
|
|
scope_chain_t *scope_chain;
|
2010-09-06 14:11:49 +00:00
|
|
|
jsdisp_t *var_disp;
|
2008-09-10 19:05:14 +00:00
|
|
|
IDispatch *this_obj;
|
2010-10-14 13:21:13 +00:00
|
|
|
BOOL is_global;
|
2011-11-18 13:09:44 +00:00
|
|
|
|
|
|
|
VARIANT *stack;
|
|
|
|
unsigned stack_size;
|
|
|
|
unsigned top;
|
|
|
|
|
|
|
|
unsigned ip;
|
|
|
|
jsexcept_t ei;
|
2008-09-05 00:37:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void exec_addref(exec_ctx_t *ctx)
|
|
|
|
{
|
|
|
|
ctx->ref++;
|
|
|
|
}
|
|
|
|
|
2011-04-21 09:22:45 +00: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;
|
|
|
|
HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,BOOL,jsexcept_t*,VARIANT*) DECLSPEC_HIDDEN;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
|
|
|
typedef struct _statement_t statement_t;
|
|
|
|
typedef struct _parameter_t parameter_t;
|
|
|
|
|
2008-09-21 13:47:47 +00:00
|
|
|
HRESULT create_source_function(parser_ctx_t*,parameter_t*,source_elements_t*,scope_chain_t*,
|
2011-04-21 09:22:45 +00:00
|
|
|
const WCHAR*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
|
2008-09-08 23:27:57 +00:00
|
|
|
|
2009-10-14 12:41:50 +00:00
|
|
|
typedef enum {
|
|
|
|
LT_INT,
|
|
|
|
LT_DOUBLE,
|
|
|
|
LT_STRING,
|
|
|
|
LT_BOOL,
|
2009-10-14 12:43:01 +00:00
|
|
|
LT_NULL,
|
|
|
|
LT_REGEXP
|
2009-10-14 12:41:50 +00:00
|
|
|
}literal_type_t;
|
|
|
|
|
2008-09-02 22:25:21 +00:00
|
|
|
typedef struct {
|
2009-10-14 12:41:50 +00:00
|
|
|
literal_type_t type;
|
2008-09-02 22:25:21 +00:00
|
|
|
union {
|
|
|
|
LONG lval;
|
|
|
|
double dval;
|
|
|
|
const WCHAR *wstr;
|
|
|
|
VARIANT_BOOL bval;
|
2009-10-14 12:43:01 +00:00
|
|
|
struct {
|
|
|
|
const WCHAR *str;
|
|
|
|
DWORD str_len;
|
|
|
|
DWORD flags;
|
|
|
|
} regexp;
|
2008-09-02 22:25:21 +00:00
|
|
|
} u;
|
|
|
|
} literal_t;
|
|
|
|
|
2011-04-21 09:22:45 +00: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 18:38:18 +00:00
|
|
|
|
2008-09-02 22:25:21 +00:00
|
|
|
typedef struct _variable_declaration_t {
|
|
|
|
const WCHAR *identifier;
|
|
|
|
expression_t *expr;
|
|
|
|
|
|
|
|
struct _variable_declaration_t *next;
|
|
|
|
} variable_declaration_t;
|
|
|
|
|
2011-10-25 09:56:36 +00:00
|
|
|
typedef struct _return_type_t return_type_t;
|
2008-09-05 00:37:59 +00:00
|
|
|
|
2010-10-23 14:41:55 +00:00
|
|
|
typedef HRESULT (*statement_eval_t)(script_ctx_t*,statement_t*,return_type_t*,VARIANT*);
|
2008-09-02 22:25:21 +00:00
|
|
|
|
|
|
|
struct _statement_t {
|
|
|
|
statement_eval_t eval;
|
|
|
|
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 21:35:38 +00:00
|
|
|
BOOL do_while;
|
2008-09-02 22:25:21 +00: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;
|
|
|
|
|
2011-04-21 09:22:45 +00:00
|
|
|
HRESULT block_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT var_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT empty_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT expression_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT if_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT while_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT for_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT forin_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT continue_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT break_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT return_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT with_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT labelled_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT switch_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT throw_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT try_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
2008-09-08 23:21:55 +00:00
|
|
|
typedef struct {
|
|
|
|
enum {
|
|
|
|
EXPRVAL_VARIANT,
|
|
|
|
EXPRVAL_IDREF,
|
2009-08-26 23:21:38 +00:00
|
|
|
EXPRVAL_INVALID
|
2008-09-08 23:21:55 +00:00
|
|
|
} type;
|
|
|
|
union {
|
|
|
|
VARIANT var;
|
|
|
|
struct {
|
|
|
|
IDispatch *disp;
|
|
|
|
DISPID id;
|
|
|
|
} idref;
|
2009-08-26 23:21:38 +00:00
|
|
|
BSTR identifier;
|
2008-09-08 23:21:55 +00:00
|
|
|
} u;
|
|
|
|
} exprval_t;
|
2008-09-02 22:25:21 +00:00
|
|
|
|
2011-11-18 13:05:57 +00: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;
|
|
|
|
|
2010-10-23 14:41:55 +00:00
|
|
|
typedef HRESULT (*expression_eval_t)(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
|
2008-09-02 22:25:21 +00:00
|
|
|
|
|
|
|
struct _expression_t {
|
2011-11-18 13:05:57 +00:00
|
|
|
expression_type_t type;
|
2008-09-02 22:25:21 +00:00
|
|
|
expression_eval_t eval;
|
2011-11-18 13:09:44 +00:00
|
|
|
unsigned instr_off;
|
2008-09-02 22:25:21 +00: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 15:47:40 +00:00
|
|
|
var_list_t *variables;
|
2008-09-02 22:25:21 +00:00
|
|
|
};
|
|
|
|
|
2008-10-20 20:12:42 +00:00
|
|
|
struct _function_expression_t {
|
2008-09-02 22:25:21 +00:00
|
|
|
expression_t expr;
|
|
|
|
const WCHAR *identifier;
|
|
|
|
parameter_t *parameter_list;
|
|
|
|
source_elements_t *source_elements;
|
2008-09-21 13:47:47 +00:00
|
|
|
const WCHAR *src_str;
|
|
|
|
DWORD src_len;
|
2008-10-20 20:12:42 +00:00
|
|
|
};
|
2008-09-02 22:25:21 +00: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 *member_expr;
|
|
|
|
expression_t *expression;
|
|
|
|
} array_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;
|
|
|
|
|
2011-04-21 09:22:45 +00:00
|
|
|
HRESULT function_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT array_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT member_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT call_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT array_literal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT property_value_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
|
|
|
|
HRESULT binary_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT instanceof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT delete_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT typeof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT post_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT post_decrement_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT pre_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT pre_decrement_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT left_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT right_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT right2_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT assign_lshift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT assign_rshift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT assign_rrshift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
HRESULT assign_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
2011-11-18 13:09:44 +00:00
|
|
|
|
|
|
|
HRESULT compiled_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
|
|
|
|
|
2011-12-07 10:00:20 +00:00
|
|
|
HRESULT compile_subscript(parser_ctx_t*,expression_t*,BOOL,unsigned*) DECLSPEC_HIDDEN;
|