2 * Copyright 2008,2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 X(assign_call,1, ARG_UINT, 0) \
25 X(bool, 1, ARG_INT, 0) \
27 X(call, 1, ARG_UINT, ARG_UINT) \
28 X(call_member,1, ARG_UINT, ARG_UINT) \
29 X(carray, 1, ARG_UINT, 0) \
30 X(case, 0, ARG_ADDR, 0) \
31 X(cnd_nz, 0, ARG_ADDR, 0) \
32 X(cnd_z, 0, ARG_ADDR, 0) \
34 X(delete_ident,1,ARG_BSTR, 0) \
36 X(double, 1, ARG_DBL, 0) \
37 X(end_finally,1, 0,0) \
40 X(forin, 0, ARG_ADDR, 0) \
41 X(func, 1, ARG_UINT, 0) \
44 X(ident, 1, ARG_BSTR, 0) \
45 X(identid, 1, ARG_BSTR, ARG_INT) \
47 X(instanceof, 1, 0,0) \
48 X(int, 1, ARG_INT, 0) \
49 X(jmp, 0, ARG_ADDR, 0) \
50 X(jmp_z, 0, ARG_ADDR, 0) \
54 X(member, 1, ARG_BSTR, 0) \
55 X(memberid, 1, ARG_UINT, 0) \
62 X(new, 1, ARG_UINT, 0) \
65 X(obj_prop, 1, ARG_BSTR, 0) \
67 X(pop, 1, ARG_UINT, 0) \
68 X(pop_except, 1, 0,0) \
69 X(pop_scope, 1, 0,0) \
70 X(postinc, 1, ARG_INT, 0) \
71 X(preinc, 1, ARG_INT, 0) \
72 X(push_except,1, ARG_ADDR, ARG_BSTR) \
73 X(push_scope, 1, 0,0) \
74 X(regexp, 1, ARG_STR, ARG_UINT) \
77 X(str, 1, ARG_STR, 0) \
80 X(throw_ref, 0, ARG_UINT, 0) \
81 X(throw_type, 0, ARG_UINT, ARG_STR) \
85 X(typeofident,1, 0,0) \
90 X(undefined, 1, 0,0) \
91 X(var_set, 1, ARG_BSTR, 0) \
96 #define X(x,a,b,c) OP_##x,
128 typedef struct _function_code_t
{
137 struct _function_code_t
*funcs
;
146 typedef struct _bytecode_t
{
152 function_code_t global_code
;
157 unsigned bstr_pool_size
;
161 unsigned str_pool_size
;
164 struct _bytecode_t
*next
;
167 HRESULT
compile_script(script_ctx_t
*,const WCHAR
*,const WCHAR
*,const WCHAR
*,BOOL
,BOOL
,bytecode_t
**) DECLSPEC_HIDDEN
;
168 void release_bytecode(bytecode_t
*) DECLSPEC_HIDDEN
;
170 static inline void bytecode_addref(bytecode_t
*code
)
175 typedef struct _scope_chain_t
{
179 struct _scope_chain_t
*next
;
182 HRESULT
scope_push(scope_chain_t
*,jsdisp_t
*,IDispatch
*,scope_chain_t
**) DECLSPEC_HIDDEN
;
183 void scope_release(scope_chain_t
*) DECLSPEC_HIDDEN
;
185 static inline void scope_addref(scope_chain_t
*scope
)
190 typedef struct _except_frame_t except_frame_t
;
191 struct _parser_ctx_t
;
196 struct _parser_ctx_t
*parser
;
198 script_ctx_t
*script
;
199 scope_chain_t
*scope_chain
;
202 function_code_t
*func_code
;
208 except_frame_t
*except_frame
;
214 static inline void exec_addref(exec_ctx_t
*ctx
)
219 void exec_release(exec_ctx_t
*) DECLSPEC_HIDDEN
;
220 HRESULT
create_exec_ctx(script_ctx_t
*,IDispatch
*,jsdisp_t
*,scope_chain_t
*,BOOL
,exec_ctx_t
**) DECLSPEC_HIDDEN
;
221 HRESULT
exec_source(exec_ctx_t
*,bytecode_t
*,function_code_t
*,BOOL
,jsval_t
*) DECLSPEC_HIDDEN
;
222 HRESULT
create_source_function(script_ctx_t
*,bytecode_t
*,function_code_t
*,scope_chain_t
*,jsdisp_t
**) DECLSPEC_HIDDEN
;