Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenengine.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2008 Jacek Caban for CodeWeavers 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00017 */ 00018 00019 typedef struct _source_elements_t source_elements_t; 00020 typedef struct _function_expression_t function_expression_t; 00021 00022 typedef struct _function_declaration_t { 00023 function_expression_t *expr; 00024 00025 struct _function_declaration_t *next; 00026 } function_declaration_t; 00027 00028 typedef struct _var_list_t { 00029 const WCHAR *identifier; 00030 00031 struct _var_list_t *next; 00032 } var_list_t; 00033 00034 typedef struct _func_stack { 00035 function_declaration_t *func_head; 00036 function_declaration_t *func_tail; 00037 var_list_t *var_head; 00038 var_list_t *var_tail; 00039 00040 struct _func_stack *next; 00041 } func_stack_t; 00042 00043 typedef struct _parser_ctx_t { 00044 LONG ref; 00045 00046 WCHAR *begin; 00047 const WCHAR *end; 00048 const WCHAR *ptr; 00049 00050 script_ctx_t *script; 00051 source_elements_t *source; 00052 BOOL nl; 00053 BOOL is_html; 00054 BOOL lexer_error; 00055 HRESULT hres; 00056 00057 jsheap_t heap; 00058 00059 func_stack_t *func_stack; 00060 00061 struct _parser_ctx_t *next; 00062 } parser_ctx_t; 00063 00064 HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,parser_ctx_t**); 00065 void parser_release(parser_ctx_t*); 00066 00067 int parser_lex(void*,parser_ctx_t*); 00068 00069 static inline void parser_addref(parser_ctx_t *ctx) 00070 { 00071 ctx->ref++; 00072 } 00073 00074 static inline void *parser_alloc(parser_ctx_t *ctx, DWORD size) 00075 { 00076 return jsheap_alloc(&ctx->heap, size); 00077 } 00078 00079 static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size) 00080 { 00081 return jsheap_alloc(&ctx->script->tmp_heap, size); 00082 } 00083 00084 typedef struct _scope_chain_t { 00085 LONG ref; 00086 DispatchEx *obj; 00087 struct _scope_chain_t *next; 00088 } scope_chain_t; 00089 00090 HRESULT scope_push(scope_chain_t*,DispatchEx*,scope_chain_t**); 00091 void scope_release(scope_chain_t*); 00092 00093 static inline void scope_addref(scope_chain_t *scope) 00094 { 00095 scope->ref++; 00096 } 00097 00098 struct _exec_ctx_t { 00099 LONG ref; 00100 00101 parser_ctx_t *parser; 00102 scope_chain_t *scope_chain; 00103 DispatchEx *var_disp; 00104 IDispatch *this_obj; 00105 }; 00106 00107 static inline void exec_addref(exec_ctx_t *ctx) 00108 { 00109 ctx->ref++; 00110 } 00111 00112 typedef enum { 00113 EXECT_PROGRAM, 00114 EXECT_FUNCTION, 00115 EXECT_EVAL 00116 } exec_type_t; 00117 00118 void exec_release(exec_ctx_t*); 00119 HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,DispatchEx*,scope_chain_t*,exec_ctx_t**); 00120 HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,exec_type_t,jsexcept_t*,VARIANT*); 00121 00122 typedef struct _statement_t statement_t; 00123 typedef struct _expression_t expression_t; 00124 typedef struct _parameter_t parameter_t; 00125 00126 HRESULT create_source_function(parser_ctx_t*,parameter_t*,source_elements_t*,scope_chain_t*, 00127 const WCHAR*,DWORD,DispatchEx**); 00128 00129 typedef enum { 00130 LT_INT, 00131 LT_DOUBLE, 00132 LT_STRING, 00133 LT_BOOL, 00134 LT_NULL, 00135 LT_REGEXP 00136 }literal_type_t; 00137 00138 typedef struct { 00139 literal_type_t type; 00140 union { 00141 LONG lval; 00142 double dval; 00143 const WCHAR *wstr; 00144 VARIANT_BOOL bval; 00145 IDispatch *disp; 00146 struct { 00147 const WCHAR *str; 00148 DWORD str_len; 00149 DWORD flags; 00150 } regexp; 00151 } u; 00152 } literal_t; 00153 00154 literal_t *parse_regexp(parser_ctx_t*); 00155 00156 typedef struct _variable_declaration_t { 00157 const WCHAR *identifier; 00158 expression_t *expr; 00159 00160 struct _variable_declaration_t *next; 00161 } variable_declaration_t; 00162 00163 typedef struct { 00164 enum{ 00165 RT_NORMAL, 00166 RT_RETURN, 00167 RT_BREAK, 00168 RT_CONTINUE 00169 } type; 00170 jsexcept_t ei; 00171 } return_type_t; 00172 00173 typedef HRESULT (*statement_eval_t)(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00174 00175 struct _statement_t { 00176 statement_eval_t eval; 00177 statement_t *next; 00178 }; 00179 00180 typedef struct { 00181 statement_t stat; 00182 statement_t *stat_list; 00183 } block_statement_t; 00184 00185 typedef struct { 00186 statement_t stat; 00187 variable_declaration_t *variable_list; 00188 } var_statement_t; 00189 00190 typedef struct { 00191 statement_t stat; 00192 expression_t *expr; 00193 } expression_statement_t; 00194 00195 typedef struct { 00196 statement_t stat; 00197 expression_t *expr; 00198 statement_t *if_stat; 00199 statement_t *else_stat; 00200 } if_statement_t; 00201 00202 typedef struct { 00203 statement_t stat; 00204 BOOL do_while; 00205 expression_t *expr; 00206 statement_t *statement; 00207 } while_statement_t; 00208 00209 typedef struct { 00210 statement_t stat; 00211 variable_declaration_t *variable_list; 00212 expression_t *begin_expr; 00213 expression_t *expr; 00214 expression_t *end_expr; 00215 statement_t *statement; 00216 } for_statement_t; 00217 00218 typedef struct { 00219 statement_t stat; 00220 variable_declaration_t *variable; 00221 expression_t *expr; 00222 expression_t *in_expr; 00223 statement_t *statement; 00224 } forin_statement_t; 00225 00226 typedef struct { 00227 statement_t stat; 00228 const WCHAR *identifier; 00229 } branch_statement_t; 00230 00231 typedef struct { 00232 statement_t stat; 00233 expression_t *expr; 00234 statement_t *statement; 00235 } with_statement_t; 00236 00237 typedef struct { 00238 statement_t stat; 00239 const WCHAR *identifier; 00240 statement_t *statement; 00241 } labelled_statement_t; 00242 00243 typedef struct _case_clausule_t { 00244 expression_t *expr; 00245 statement_t *stat; 00246 00247 struct _case_clausule_t *next; 00248 } case_clausule_t; 00249 00250 typedef struct { 00251 statement_t stat; 00252 expression_t *expr; 00253 case_clausule_t *case_list; 00254 } switch_statement_t; 00255 00256 typedef struct { 00257 const WCHAR *identifier; 00258 statement_t *statement; 00259 } catch_block_t; 00260 00261 typedef struct { 00262 statement_t stat; 00263 statement_t *try_statement; 00264 catch_block_t *catch_block; 00265 statement_t *finally_statement; 00266 } try_statement_t; 00267 00268 HRESULT block_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00269 HRESULT var_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00270 HRESULT empty_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00271 HRESULT expression_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00272 HRESULT if_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00273 HRESULT while_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00274 HRESULT for_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00275 HRESULT forin_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00276 HRESULT continue_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00277 HRESULT break_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00278 HRESULT return_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00279 HRESULT with_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00280 HRESULT labelled_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00281 HRESULT switch_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00282 HRESULT throw_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00283 HRESULT try_statement_eval(exec_ctx_t*,statement_t*,return_type_t*,VARIANT*); 00284 00285 typedef struct { 00286 enum { 00287 EXPRVAL_VARIANT, 00288 EXPRVAL_IDREF, 00289 EXPRVAL_NAMEREF, 00290 EXPRVAL_INVALID 00291 } type; 00292 union { 00293 VARIANT var; 00294 struct { 00295 IDispatch *disp; 00296 DISPID id; 00297 } idref; 00298 struct { 00299 IDispatch *disp; 00300 BSTR name; 00301 } nameref; 00302 BSTR identifier; 00303 } u; 00304 } exprval_t; 00305 00306 typedef HRESULT (*expression_eval_t)(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00307 00308 struct _expression_t { 00309 expression_eval_t eval; 00310 }; 00311 00312 struct _parameter_t { 00313 const WCHAR *identifier; 00314 00315 struct _parameter_t *next; 00316 }; 00317 00318 struct _source_elements_t { 00319 statement_t *statement; 00320 statement_t *statement_tail; 00321 function_declaration_t *functions; 00322 var_list_t *variables; 00323 }; 00324 00325 struct _function_expression_t { 00326 expression_t expr; 00327 const WCHAR *identifier; 00328 parameter_t *parameter_list; 00329 source_elements_t *source_elements; 00330 const WCHAR *src_str; 00331 DWORD src_len; 00332 }; 00333 00334 typedef struct { 00335 expression_t expr; 00336 expression_t *expression1; 00337 expression_t *expression2; 00338 } binary_expression_t; 00339 00340 typedef struct { 00341 expression_t expr; 00342 expression_t *expression; 00343 } unary_expression_t; 00344 00345 typedef struct { 00346 expression_t expr; 00347 expression_t *expression; 00348 expression_t *true_expression; 00349 expression_t *false_expression; 00350 } conditional_expression_t; 00351 00352 typedef struct { 00353 expression_t expr; 00354 expression_t *member_expr; 00355 expression_t *expression; 00356 } array_expression_t; 00357 00358 typedef struct { 00359 expression_t expr; 00360 expression_t *expression; 00361 const WCHAR *identifier; 00362 } member_expression_t; 00363 00364 typedef struct _argument_t { 00365 expression_t *expr; 00366 00367 struct _argument_t *next; 00368 } argument_t; 00369 00370 typedef struct { 00371 expression_t expr; 00372 expression_t *expression; 00373 argument_t *argument_list; 00374 } call_expression_t; 00375 00376 typedef struct { 00377 expression_t expr; 00378 const WCHAR *identifier; 00379 } identifier_expression_t; 00380 00381 typedef struct { 00382 expression_t expr; 00383 literal_t *literal; 00384 } literal_expression_t; 00385 00386 typedef struct _array_element_t { 00387 int elision; 00388 expression_t *expr; 00389 00390 struct _array_element_t *next; 00391 } array_element_t; 00392 00393 typedef struct { 00394 expression_t expr; 00395 array_element_t *element_list; 00396 int length; 00397 } array_literal_expression_t; 00398 00399 typedef struct _prop_val_t { 00400 literal_t *name; 00401 expression_t *value; 00402 00403 struct _prop_val_t *next; 00404 } prop_val_t; 00405 00406 typedef struct { 00407 expression_t expr; 00408 prop_val_t *property_list; 00409 } property_value_expression_t; 00410 00411 typedef enum { 00412 EXPR_COMMA, 00413 EXPR_OR, 00414 EXPR_AND, 00415 EXPR_BOR, 00416 EXPR_BXOR, 00417 EXPR_BAND, 00418 EXPR_INSTANCEOF, 00419 EXPR_IN, 00420 EXPR_ADD, 00421 EXPR_SUB, 00422 EXPR_MUL, 00423 EXPR_DIV, 00424 EXPR_MOD, 00425 EXPR_DELETE, 00426 EXPR_VOID, 00427 EXPR_TYPEOF, 00428 EXPR_MINUS, 00429 EXPR_PLUS, 00430 EXPR_POSTINC, 00431 EXPR_POSTDEC, 00432 EXPR_PREINC, 00433 EXPR_PREDEC, 00434 EXPR_EQ, 00435 EXPR_EQEQ, 00436 EXPR_NOTEQ, 00437 EXPR_NOTEQEQ, 00438 EXPR_LESS, 00439 EXPR_LESSEQ, 00440 EXPR_GREATER, 00441 EXPR_GREATEREQ, 00442 EXPR_BITNEG, 00443 EXPR_LOGNEG, 00444 EXPR_LSHIFT, 00445 EXPR_RSHIFT, 00446 EXPR_RRSHIFT, 00447 EXPR_ASSIGN, 00448 EXPR_ASSIGNLSHIFT, 00449 EXPR_ASSIGNRSHIFT, 00450 EXPR_ASSIGNRRSHIFT, 00451 EXPR_ASSIGNADD, 00452 EXPR_ASSIGNSUB, 00453 EXPR_ASSIGNMUL, 00454 EXPR_ASSIGNDIV, 00455 EXPR_ASSIGNMOD, 00456 EXPR_ASSIGNAND, 00457 EXPR_ASSIGNOR, 00458 EXPR_ASSIGNXOR 00459 } expression_type_t; 00460 00461 HRESULT function_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00462 HRESULT conditional_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00463 HRESULT array_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00464 HRESULT member_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00465 HRESULT new_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00466 HRESULT call_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00467 HRESULT this_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00468 HRESULT identifier_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00469 HRESULT literal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00470 HRESULT array_literal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00471 HRESULT property_value_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00472 00473 HRESULT comma_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00474 HRESULT logical_or_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00475 HRESULT logical_and_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00476 HRESULT binary_or_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00477 HRESULT binary_xor_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00478 HRESULT binary_and_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00479 HRESULT instanceof_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00480 HRESULT in_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00481 HRESULT add_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00482 HRESULT sub_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00483 HRESULT mul_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00484 HRESULT div_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00485 HRESULT mod_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00486 HRESULT delete_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00487 HRESULT void_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00488 HRESULT typeof_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00489 HRESULT minus_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00490 HRESULT plus_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00491 HRESULT post_increment_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00492 HRESULT post_decrement_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00493 HRESULT pre_increment_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00494 HRESULT pre_decrement_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00495 HRESULT equal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00496 HRESULT equal2_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00497 HRESULT not_equal_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00498 HRESULT not_equal2_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00499 HRESULT less_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00500 HRESULT lesseq_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00501 HRESULT greater_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00502 HRESULT greatereq_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00503 HRESULT binary_negation_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00504 HRESULT logical_negation_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00505 HRESULT left_shift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00506 HRESULT right_shift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00507 HRESULT right2_shift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00508 HRESULT assign_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00509 HRESULT assign_lshift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00510 HRESULT assign_rshift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00511 HRESULT assign_rrshift_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00512 HRESULT assign_add_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00513 HRESULT assign_sub_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00514 HRESULT assign_mul_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00515 HRESULT assign_div_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00516 HRESULT assign_mod_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00517 HRESULT assign_and_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00518 HRESULT assign_or_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); 00519 HRESULT assign_xor_expression_eval(exec_ctx_t*,expression_t*,DWORD,jsexcept_t*,exprval_t*); Generated on Fri May 25 2012 04:22:13 for ReactOS by
1.7.6.1
|