d3d10core/tests: Add more tests for creating depth stencil views.
[wine.git] / dlls / jscript / engine.h
blob409430368db7589955b6aacac2cbd7b4f45ae379
1 /*
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
19 #define OP_LIST \
20 X(add, 1, 0,0) \
21 X(and, 1, 0,0) \
22 X(array, 1, 0,0) \
23 X(assign, 1, 0,0) \
24 X(assign_call,1, ARG_UINT, 0) \
25 X(bool, 1, ARG_INT, 0) \
26 X(bneg, 1, 0,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) \
33 X(delete, 1, 0,0) \
34 X(delete_ident,1,ARG_BSTR, 0) \
35 X(div, 1, 0,0) \
36 X(double, 1, ARG_DBL, 0) \
37 X(end_finally,1, 0,0) \
38 X(eq, 1, 0,0) \
39 X(eq2, 1, 0,0) \
40 X(forin, 0, ARG_ADDR, 0) \
41 X(func, 1, ARG_UINT, 0) \
42 X(gt, 1, 0,0) \
43 X(gteq, 1, 0,0) \
44 X(ident, 1, ARG_BSTR, 0) \
45 X(identid, 1, ARG_BSTR, ARG_INT) \
46 X(in, 1, 0,0) \
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) \
51 X(lshift, 1, 0,0) \
52 X(lt, 1, 0,0) \
53 X(lteq, 1, 0,0) \
54 X(member, 1, ARG_BSTR, 0) \
55 X(memberid, 1, ARG_UINT, 0) \
56 X(minus, 1, 0,0) \
57 X(mod, 1, 0,0) \
58 X(mul, 1, 0,0) \
59 X(neg, 1, 0,0) \
60 X(neq, 1, 0,0) \
61 X(neq2, 1, 0,0) \
62 X(new, 1, ARG_UINT, 0) \
63 X(new_obj, 1, 0,0) \
64 X(null, 1, 0,0) \
65 X(obj_prop, 1, ARG_BSTR, 0) \
66 X(or, 1, 0,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_ret, 1, 0,0) \
74 X(push_scope, 1, 0,0) \
75 X(regexp, 1, ARG_STR, ARG_UINT) \
76 X(rshift, 1, 0,0) \
77 X(rshift2, 1, 0,0) \
78 X(str, 1, ARG_STR, 0) \
79 X(this, 1, 0,0) \
80 X(throw, 0, 0,0) \
81 X(throw_ref, 0, ARG_UINT, 0) \
82 X(throw_type, 0, ARG_UINT, ARG_STR) \
83 X(tonum, 1, 0,0) \
84 X(typeof, 1, 0,0) \
85 X(typeofid, 1, 0,0) \
86 X(typeofident,1, 0,0) \
87 X(refval, 1, 0,0) \
88 X(ret, 0, 0,0) \
89 X(setret, 1, 0,0) \
90 X(sub, 1, 0,0) \
91 X(undefined, 1, 0,0) \
92 X(var_set, 1, ARG_BSTR, 0) \
93 X(void, 1, 0,0) \
94 X(xor, 1, 0,0)
96 typedef enum {
97 #define X(x,a,b,c) OP_##x,
98 OP_LIST
99 #undef X
100 OP_LAST
101 } jsop_t;
103 typedef union {
104 BSTR bstr;
105 LONG lng;
106 jsstr_t *str;
107 unsigned uint;
108 } instr_arg_t;
110 typedef enum {
111 ARG_NONE = 0,
112 ARG_ADDR,
113 ARG_BSTR,
114 ARG_DBL,
115 ARG_FUNC,
116 ARG_INT,
117 ARG_STR,
118 ARG_UINT
119 } instr_arg_type_t;
121 typedef struct {
122 jsop_t op;
123 union {
124 instr_arg_t arg[2];
125 double dbl;
126 } u;
127 } instr_t;
129 typedef struct _function_code_t {
130 BSTR name;
131 BSTR event_target;
132 unsigned instr_off;
134 const WCHAR *source;
135 unsigned source_len;
137 unsigned func_cnt;
138 struct _function_code_t *funcs;
140 unsigned var_cnt;
141 BSTR *variables;
143 unsigned param_cnt;
144 BSTR *params;
145 } function_code_t;
147 typedef struct _bytecode_t {
148 LONG ref;
150 instr_t *instrs;
151 heap_pool_t heap;
153 function_code_t global_code;
155 WCHAR *source;
157 BSTR *bstr_pool;
158 unsigned bstr_pool_size;
159 unsigned bstr_cnt;
161 jsstr_t **str_pool;
162 unsigned str_pool_size;
163 unsigned str_cnt;
165 struct _bytecode_t *next;
166 } bytecode_t;
168 HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,const WCHAR*,BOOL,BOOL,bytecode_t**) DECLSPEC_HIDDEN;
169 void release_bytecode(bytecode_t*) DECLSPEC_HIDDEN;
171 static inline bytecode_t *bytecode_addref(bytecode_t *code)
173 code->ref++;
174 return code;
177 typedef struct _scope_chain_t {
178 LONG ref;
179 jsdisp_t *jsobj;
180 IDispatch *obj;
181 struct _scope_chain_t *next;
182 } scope_chain_t;
184 HRESULT scope_push(scope_chain_t*,jsdisp_t*,IDispatch*,scope_chain_t**) DECLSPEC_HIDDEN;
185 void scope_release(scope_chain_t*) DECLSPEC_HIDDEN;
187 static inline scope_chain_t *scope_addref(scope_chain_t *scope)
189 scope->ref++;
190 return scope;
193 typedef struct _except_frame_t except_frame_t;
194 struct _parser_ctx_t;
196 typedef struct _call_frame_t {
197 unsigned ip;
198 except_frame_t *except_frame;
199 unsigned stack_base;
200 scope_chain_t *scope;
201 scope_chain_t *base_scope;
203 jsval_t ret;
205 IDispatch *this_obj;
206 jsdisp_t *function_instance;
207 jsdisp_t *variable_obj;
208 jsdisp_t *arguments_obj;
209 DWORD flags;
211 bytecode_t *bytecode;
212 function_code_t *function;
214 struct _call_frame_t *prev_frame;
215 } call_frame_t;
217 #define EXEC_GLOBAL 0x0001
218 #define EXEC_CONSTRUCTOR 0x0002
219 #define EXEC_RETURN_TO_INTERP 0x0004
221 HRESULT exec_source(script_ctx_t*,DWORD,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,
222 jsdisp_t*,jsdisp_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
224 HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN;