wineps: Fix a couple of typos in the path painting function.
[wine/testsucceed.git] / dlls / jscript / engine.h
blob9b2e2b51077e2de1ee315b389fce7f09cdb788af
1 /*
2 * Copyright 2008 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 typedef struct _source_elements_t source_elements_t;
20 typedef struct _function_expression_t function_expression_t;
22 typedef struct _function_declaration_t {
23 function_expression_t *expr;
25 struct _function_declaration_t *next;
26 } function_declaration_t;
28 typedef struct _var_list_t {
29 const WCHAR *identifier;
31 struct _var_list_t *next;
32 } var_list_t;
34 typedef struct _func_stack {
35 function_declaration_t *func_head;
36 function_declaration_t *func_tail;
37 var_list_t *var_head;
38 var_list_t *var_tail;
40 struct _func_stack *next;
41 } func_stack_t;
43 typedef struct _parser_ctx_t {
44 LONG ref;
46 WCHAR *begin;
47 const WCHAR *end;
48 const WCHAR *ptr;
50 script_ctx_t *script;
51 source_elements_t *source;
52 BOOL nl;
53 BOOL is_html;
54 BOOL lexer_error;
55 HRESULT hres;
57 jsheap_t heap;
59 func_stack_t *func_stack;
61 struct _parser_ctx_t *next;
62 } parser_ctx_t;
64 HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,parser_ctx_t**) DECLSPEC_HIDDEN;
65 void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN;
67 int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN;
69 static inline void parser_addref(parser_ctx_t *ctx)
71 ctx->ref++;
74 static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size)
76 return jsheap_alloc(&ctx->heap, size);
79 static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size)
81 return jsheap_alloc(&ctx->script->tmp_heap, size);
84 typedef struct _scope_chain_t {
85 LONG ref;
86 jsdisp_t *obj;
87 struct _scope_chain_t *next;
88 } scope_chain_t;
90 HRESULT scope_push(scope_chain_t*,jsdisp_t*,scope_chain_t**) DECLSPEC_HIDDEN;
91 void scope_release(scope_chain_t*) DECLSPEC_HIDDEN;
93 static inline void scope_addref(scope_chain_t *scope)
95 scope->ref++;
98 struct _exec_ctx_t {
99 LONG ref;
101 parser_ctx_t *parser;
102 scope_chain_t *scope_chain;
103 jsdisp_t *var_disp;
104 IDispatch *this_obj;
105 BOOL is_global;
108 static inline void exec_addref(exec_ctx_t *ctx)
110 ctx->ref++;
113 void exec_release(exec_ctx_t*) DECLSPEC_HIDDEN;
114 HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,jsdisp_t*,scope_chain_t*,BOOL,exec_ctx_t**) DECLSPEC_HIDDEN;
115 HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,BOOL,jsexcept_t*,VARIANT*) DECLSPEC_HIDDEN;
117 typedef struct _statement_t statement_t;
118 typedef struct _expression_t expression_t;
119 typedef struct _parameter_t parameter_t;
121 HRESULT create_source_function(parser_ctx_t*,parameter_t*,source_elements_t*,scope_chain_t*,
122 const WCHAR*,DWORD,jsdisp_t**) DECLSPEC_HIDDEN;
124 typedef enum {
125 LT_INT,
126 LT_DOUBLE,
127 LT_STRING,
128 LT_BOOL,
129 LT_NULL,
130 LT_REGEXP
131 }literal_type_t;
133 typedef struct {
134 literal_type_t type;
135 union {
136 LONG lval;
137 double dval;
138 const WCHAR *wstr;
139 VARIANT_BOOL bval;
140 IDispatch *disp;
141 struct {
142 const WCHAR *str;
143 DWORD str_len;
144 DWORD flags;
145 } regexp;
146 } u;
147 } literal_t;
149 literal_t *parse_regexp(parser_ctx_t*) DECLSPEC_HIDDEN;
150 literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_BOOL) DECLSPEC_HIDDEN;
152 typedef struct _variable_declaration_t {
153 const WCHAR *identifier;
154 expression_t *expr;
156 struct _variable_declaration_t *next;
157 } variable_declaration_t;
159 typedef struct _return_type_t return_type_t;
161 typedef HRESULT (*statement_eval_t)(script_ctx_t*,statement_t*,return_type_t*,VARIANT*);
163 struct _statement_t {
164 statement_eval_t eval;
165 statement_t *next;
168 typedef struct {
169 statement_t stat;
170 statement_t *stat_list;
171 } block_statement_t;
173 typedef struct {
174 statement_t stat;
175 variable_declaration_t *variable_list;
176 } var_statement_t;
178 typedef struct {
179 statement_t stat;
180 expression_t *expr;
181 } expression_statement_t;
183 typedef struct {
184 statement_t stat;
185 expression_t *expr;
186 statement_t *if_stat;
187 statement_t *else_stat;
188 } if_statement_t;
190 typedef struct {
191 statement_t stat;
192 BOOL do_while;
193 expression_t *expr;
194 statement_t *statement;
195 } while_statement_t;
197 typedef struct {
198 statement_t stat;
199 variable_declaration_t *variable_list;
200 expression_t *begin_expr;
201 expression_t *expr;
202 expression_t *end_expr;
203 statement_t *statement;
204 } for_statement_t;
206 typedef struct {
207 statement_t stat;
208 variable_declaration_t *variable;
209 expression_t *expr;
210 expression_t *in_expr;
211 statement_t *statement;
212 } forin_statement_t;
214 typedef struct {
215 statement_t stat;
216 const WCHAR *identifier;
217 } branch_statement_t;
219 typedef struct {
220 statement_t stat;
221 expression_t *expr;
222 statement_t *statement;
223 } with_statement_t;
225 typedef struct {
226 statement_t stat;
227 const WCHAR *identifier;
228 statement_t *statement;
229 } labelled_statement_t;
231 typedef struct _case_clausule_t {
232 expression_t *expr;
233 statement_t *stat;
235 struct _case_clausule_t *next;
236 } case_clausule_t;
238 typedef struct {
239 statement_t stat;
240 expression_t *expr;
241 case_clausule_t *case_list;
242 } switch_statement_t;
244 typedef struct {
245 const WCHAR *identifier;
246 statement_t *statement;
247 } catch_block_t;
249 typedef struct {
250 statement_t stat;
251 statement_t *try_statement;
252 catch_block_t *catch_block;
253 statement_t *finally_statement;
254 } try_statement_t;
256 HRESULT block_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
257 HRESULT var_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
258 HRESULT empty_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
259 HRESULT expression_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
260 HRESULT if_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
261 HRESULT while_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
262 HRESULT for_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
263 HRESULT forin_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
264 HRESULT continue_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
265 HRESULT break_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
266 HRESULT return_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
267 HRESULT with_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
268 HRESULT labelled_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
269 HRESULT switch_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
270 HRESULT throw_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
271 HRESULT try_statement_eval(script_ctx_t*,statement_t*,return_type_t*,VARIANT*) DECLSPEC_HIDDEN;
273 typedef struct {
274 enum {
275 EXPRVAL_VARIANT,
276 EXPRVAL_IDREF,
277 EXPRVAL_NAMEREF,
278 EXPRVAL_INVALID
279 } type;
280 union {
281 VARIANT var;
282 struct {
283 IDispatch *disp;
284 DISPID id;
285 } idref;
286 struct {
287 IDispatch *disp;
288 BSTR name;
289 } nameref;
290 BSTR identifier;
291 } u;
292 } exprval_t;
294 typedef HRESULT (*expression_eval_t)(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*);
296 struct _expression_t {
297 expression_eval_t eval;
300 struct _parameter_t {
301 const WCHAR *identifier;
303 struct _parameter_t *next;
306 struct _source_elements_t {
307 statement_t *statement;
308 statement_t *statement_tail;
309 function_declaration_t *functions;
310 var_list_t *variables;
313 struct _function_expression_t {
314 expression_t expr;
315 const WCHAR *identifier;
316 parameter_t *parameter_list;
317 source_elements_t *source_elements;
318 const WCHAR *src_str;
319 DWORD src_len;
322 typedef struct {
323 expression_t expr;
324 expression_t *expression1;
325 expression_t *expression2;
326 } binary_expression_t;
328 typedef struct {
329 expression_t expr;
330 expression_t *expression;
331 } unary_expression_t;
333 typedef struct {
334 expression_t expr;
335 expression_t *expression;
336 expression_t *true_expression;
337 expression_t *false_expression;
338 } conditional_expression_t;
340 typedef struct {
341 expression_t expr;
342 expression_t *member_expr;
343 expression_t *expression;
344 } array_expression_t;
346 typedef struct {
347 expression_t expr;
348 expression_t *expression;
349 const WCHAR *identifier;
350 } member_expression_t;
352 typedef struct _argument_t {
353 expression_t *expr;
355 struct _argument_t *next;
356 } argument_t;
358 typedef struct {
359 expression_t expr;
360 expression_t *expression;
361 argument_t *argument_list;
362 } call_expression_t;
364 typedef struct {
365 expression_t expr;
366 const WCHAR *identifier;
367 } identifier_expression_t;
369 typedef struct {
370 expression_t expr;
371 literal_t *literal;
372 } literal_expression_t;
374 typedef struct _array_element_t {
375 int elision;
376 expression_t *expr;
378 struct _array_element_t *next;
379 } array_element_t;
381 typedef struct {
382 expression_t expr;
383 array_element_t *element_list;
384 int length;
385 } array_literal_expression_t;
387 typedef struct _prop_val_t {
388 literal_t *name;
389 expression_t *value;
391 struct _prop_val_t *next;
392 } prop_val_t;
394 typedef struct {
395 expression_t expr;
396 prop_val_t *property_list;
397 } property_value_expression_t;
399 typedef enum {
400 EXPR_COMMA,
401 EXPR_OR,
402 EXPR_AND,
403 EXPR_BOR,
404 EXPR_BXOR,
405 EXPR_BAND,
406 EXPR_INSTANCEOF,
407 EXPR_IN,
408 EXPR_ADD,
409 EXPR_SUB,
410 EXPR_MUL,
411 EXPR_DIV,
412 EXPR_MOD,
413 EXPR_DELETE,
414 EXPR_VOID,
415 EXPR_TYPEOF,
416 EXPR_MINUS,
417 EXPR_PLUS,
418 EXPR_POSTINC,
419 EXPR_POSTDEC,
420 EXPR_PREINC,
421 EXPR_PREDEC,
422 EXPR_EQ,
423 EXPR_EQEQ,
424 EXPR_NOTEQ,
425 EXPR_NOTEQEQ,
426 EXPR_LESS,
427 EXPR_LESSEQ,
428 EXPR_GREATER,
429 EXPR_GREATEREQ,
430 EXPR_BITNEG,
431 EXPR_LOGNEG,
432 EXPR_LSHIFT,
433 EXPR_RSHIFT,
434 EXPR_RRSHIFT,
435 EXPR_ASSIGN,
436 EXPR_ASSIGNLSHIFT,
437 EXPR_ASSIGNRSHIFT,
438 EXPR_ASSIGNRRSHIFT,
439 EXPR_ASSIGNADD,
440 EXPR_ASSIGNSUB,
441 EXPR_ASSIGNMUL,
442 EXPR_ASSIGNDIV,
443 EXPR_ASSIGNMOD,
444 EXPR_ASSIGNAND,
445 EXPR_ASSIGNOR,
446 EXPR_ASSIGNXOR
447 } expression_type_t;
449 HRESULT function_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
450 HRESULT conditional_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
451 HRESULT array_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
452 HRESULT member_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
453 HRESULT new_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
454 HRESULT call_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
455 HRESULT this_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
456 HRESULT identifier_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
457 HRESULT literal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
458 HRESULT array_literal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
459 HRESULT property_value_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
461 HRESULT comma_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
462 HRESULT logical_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
463 HRESULT logical_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
464 HRESULT binary_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
465 HRESULT binary_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
466 HRESULT binary_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
467 HRESULT instanceof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
468 HRESULT in_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
469 HRESULT add_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
470 HRESULT sub_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
471 HRESULT mul_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
472 HRESULT div_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
473 HRESULT mod_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
474 HRESULT delete_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
475 HRESULT void_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
476 HRESULT typeof_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
477 HRESULT minus_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
478 HRESULT plus_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
479 HRESULT post_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
480 HRESULT post_decrement_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
481 HRESULT pre_increment_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
482 HRESULT pre_decrement_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
483 HRESULT equal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
484 HRESULT equal2_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
485 HRESULT not_equal_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
486 HRESULT not_equal2_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
487 HRESULT less_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
488 HRESULT lesseq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
489 HRESULT greater_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
490 HRESULT greatereq_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
491 HRESULT binary_negation_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
492 HRESULT logical_negation_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
493 HRESULT left_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
494 HRESULT right_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
495 HRESULT right2_shift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
496 HRESULT assign_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
497 HRESULT assign_lshift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
498 HRESULT assign_rshift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
499 HRESULT assign_rrshift_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
500 HRESULT assign_add_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
501 HRESULT assign_sub_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
502 HRESULT assign_mul_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
503 HRESULT assign_div_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
504 HRESULT assign_mod_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
505 HRESULT assign_and_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
506 HRESULT assign_or_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;
507 HRESULT assign_xor_expression_eval(script_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*) DECLSPEC_HIDDEN;