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
20 #include "wine/port.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
31 #define EXPR_NOVAL 0x0001
32 #define EXPR_NEWREF 0x0002
33 #define EXPR_STRREF 0x0004
35 static inline HRESULT stat_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
37 return stat->eval(ctx, stat, rt, ret);
40 static inline HRESULT expr_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
42 return _expr->eval(ctx, _expr, flags, ei, ret);
45 static void exprval_release(exprval_t *val)
49 if(V_VT(&val->u.var) != VT_EMPTY)
50 VariantClear(&val->u.var);
54 IDispatch_Release(val->u.idref.disp);
57 if(val->u.nameref.disp)
58 IDispatch_Release(val->u.nameref.disp);
59 SysFreeString(val->u.nameref.name);
63 /* ECMA-262 3rd Edition 8.7.1 */
64 static HRESULT exprval_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
70 return VariantCopy(ret, &val->u.var);
72 if(!val->u.idref.disp) {
73 FIXME("throw ReferenceError\n");
77 return disp_propget(val->u.idref.disp, val->u.idref.id, ctx->lcid, ret, ei, NULL/*FIXME*/);
79 ERR("type %d\n", val->type);
84 static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
86 if(val->type == EXPRVAL_VARIANT) {
88 V_VT(&val->u.var) = VT_EMPTY;
92 return exprval_value(ctx, val, ei, ret);
95 static HRESULT exprval_to_boolean(script_ctx_t *ctx, exprval_t *exprval, jsexcept_t *ei, VARIANT_BOOL *b)
97 if(exprval->type != EXPRVAL_VARIANT) {
101 hres = exprval_to_value(ctx, exprval, ei, &val);
105 hres = to_boolean(&val, b);
110 return to_boolean(&exprval->u.var, b);
113 static void exprval_init(exprval_t *val)
115 val->type = EXPRVAL_VARIANT;
116 V_VT(&val->u.var) = VT_EMPTY;
119 static void exprval_set_idref(exprval_t *val, IDispatch *disp, DISPID id)
121 val->type = EXPRVAL_IDREF;
122 val->u.idref.disp = disp;
123 val->u.idref.id = id;
126 IDispatch_AddRef(disp);
129 HRESULT scope_push(scope_chain_t *scope, DispatchEx *obj, scope_chain_t **ret)
131 scope_chain_t *new_scope;
133 new_scope = heap_alloc(sizeof(scope_chain_t));
135 return E_OUTOFMEMORY;
139 IDispatchEx_AddRef(_IDispatchEx_(obj));
140 new_scope->obj = obj;
144 new_scope->next = scope;
146 new_scope->next = NULL;
153 static void scope_pop(scope_chain_t **scope)
162 void scope_release(scope_chain_t *scope)
168 scope_release(scope->next);
170 IDispatchEx_Release(_IDispatchEx_(scope->obj));
174 HRESULT create_exec_ctx(IDispatch *this_obj, DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t **ret)
178 ctx = heap_alloc_zero(sizeof(exec_ctx_t));
180 return E_OUTOFMEMORY;
182 IDispatch_AddRef(this_obj);
183 ctx->this_obj = this_obj;
185 IDispatchEx_AddRef(_IDispatchEx_(var_disp));
186 ctx->var_disp = var_disp;
190 ctx->scope_chain = scope;
197 void exec_release(exec_ctx_t *ctx)
203 scope_release(ctx->scope_chain);
205 IDispatchEx_Release(_IDispatchEx_(ctx->var_disp));
207 IDispatch_Release(ctx->this_obj);
211 static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id)
216 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
218 TRACE("unsing IDispatch\n");
221 return IDispatch_GetIDsOfNames(disp, &IID_NULL, &name, 1, 0, id);
225 hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id);
226 IDispatchEx_Release(dispex);
230 /* ECMA-262 3rd Edition 8.7.2 */
231 static HRESULT put_value(script_ctx_t *ctx, exprval_t *ref, VARIANT *v, jsexcept_t *ei)
233 if(ref->type != EXPRVAL_IDREF) {
234 FIXME("throw ReferemceError\n");
238 return disp_propput(ref->u.idref.disp, ref->u.idref.id, ctx->lcid, v, ei, NULL/*FIXME*/);
241 static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
243 IObjectIdentity *identity;
244 IUnknown *unk1, *unk2;
252 hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
256 hres = IDispatch_QueryInterface(disp2, &IID_IUnknown, (void**)&unk2);
258 IUnknown_Release(unk1);
265 hres = IUnknown_QueryInterface(unk1, &IID_IObjectIdentity, (void**)&identity);
266 if(SUCCEEDED(hres)) {
267 hres = IObjectIdentity_IsEqualObject(identity, unk2);
268 IObjectIdentity_Release(identity);
275 IUnknown_Release(unk1);
276 IUnknown_Release(unk2);
280 /* ECMA-262 3rd Edition 11.9.6 */
281 HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret)
285 if(V_VT(lval) != V_VT(rval)) {
286 if(is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))) {
287 *ret = num_val(lval) == num_val(rval);
301 *ret = V_I4(lval) == V_I4(rval);
304 *ret = V_R8(lval) == V_R8(rval);
307 *ret = !strcmpW(V_BSTR(lval), V_BSTR(rval));
310 return disp_cmp(V_DISPATCH(lval), V_DISPATCH(rval), ret);
312 *ret = !V_BOOL(lval) == !V_BOOL(rval);
315 FIXME("unimplemented vt %d\n", V_VT(lval));
322 static HRESULT literal_to_var(literal_t *literal, VARIANT *v)
324 V_VT(v) = literal->vt;
331 V_I4(v) = literal->u.lval;
334 V_R8(v) = literal->u.dval;
337 V_BSTR(v) = SysAllocString(literal->u.wstr);
340 V_BOOL(v) = literal->u.bval;
343 IDispatch_AddRef(literal->u.disp);
344 V_DISPATCH(v) = literal->u.disp;
347 ERR("wrong type %d\n", V_VT(v));
354 HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
356 script_ctx_t *script = parser->script;
357 function_declaration_t *func;
358 parser_ctx_t *prev_parser;
362 exec_ctx_t *prev_ctx;
366 for(func = source->functions; func; func = func->next) {
367 DispatchEx *func_obj;
370 hres = create_source_function(parser, func->expr->parameter_list, func->expr->source_elements,
371 ctx->scope_chain, func->expr->src_str, func->expr->src_len, &func_obj);
375 V_VT(&var) = VT_DISPATCH;
376 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(func_obj);
377 hres = jsdisp_propput_name(ctx->var_disp, func->expr->identifier, script->lcid, &var, ei, NULL);
378 jsdisp_release(func_obj);
383 for(var = source->variables; var; var = var->next) {
386 hres = jsdisp_get_id(ctx->var_disp, var->identifier, fdexNameEnsure, &id);
391 prev_ctx = script->exec_ctx;
392 script->exec_ctx = ctx;
394 prev_parser = ctx->parser;
395 ctx->parser = parser;
397 V_VT(&val) = VT_EMPTY;
398 memset(&rt, 0, sizeof(rt));
401 for(stat = source->statement; stat; stat = stat->next) {
402 hres = stat_eval(ctx, stat, &rt, &tmp);
408 if(rt.type != RT_NORMAL)
412 script->exec_ctx = prev_ctx;
413 ctx->parser = prev_parser;
415 if(rt.type != RT_NORMAL && rt.type != RT_RETURN) {
416 FIXME("wrong rt %d\n", rt.type);
433 /* ECMA-262 3rd Edition 10.1.4 */
434 static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, exprval_t *ret)
436 scope_chain_t *scope;
441 TRACE("%s\n", debugstr_w(identifier));
443 for(scope = ctx->scope_chain; scope; scope = scope->next) {
444 hres = jsdisp_get_id(scope->obj, identifier, 0, &id);
450 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(scope->obj), id);
454 hres = jsdisp_get_id(ctx->parser->script->global, identifier, 0, &id);
455 if(SUCCEEDED(hres)) {
456 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->global), id);
460 for(item = ctx->parser->script->named_items; item; item = item->next) {
461 hres = disp_get_id(item->disp, identifier, 0, &id);
467 exprval_set_idref(ret, (IDispatch*)item->disp, id);
471 hres = jsdisp_get_id(ctx->parser->script->script_disp, identifier, 0, &id);
472 if(SUCCEEDED(hres)) {
473 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->script_disp), id);
477 if(flags & EXPR_NEWREF) {
478 hres = jsdisp_get_id(ctx->var_disp, identifier, fdexNameEnsure, &id);
482 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->var_disp), id);
486 WARN("Could not find identifier %s\n", debugstr_w(identifier));
490 /* ECMA-262 3rd Edition 12.1 */
491 HRESULT block_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
493 block_statement_t *stat = (block_statement_t*)_stat;
500 V_VT(&val) = VT_EMPTY;
501 for(iter = stat->stat_list; iter; iter = iter->next) {
502 hres = stat_eval(ctx, iter, rt, &tmp);
508 if(rt->type != RT_NORMAL)
521 /* ECMA-262 3rd Edition 12.2 */
522 static HRESULT variable_list_eval(exec_ctx_t *ctx, variable_declaration_t *var_list, jsexcept_t *ei)
524 variable_declaration_t *iter;
527 for(iter = var_list; iter; iter = iter->next) {
534 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
538 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
539 exprval_release(&exprval);
543 hres = jsdisp_propput_name(ctx->var_disp, iter->identifier, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
552 /* ECMA-262 3rd Edition 12.2 */
553 HRESULT var_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
555 var_statement_t *stat = (var_statement_t*)_stat;
560 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
564 V_VT(ret) = VT_EMPTY;
568 /* ECMA-262 3rd Edition 12.3 */
569 HRESULT empty_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
573 V_VT(ret) = VT_EMPTY;
577 /* ECMA-262 3rd Edition 12.4 */
578 HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
580 expression_statement_t *stat = (expression_statement_t*)_stat;
587 hres = expr_eval(ctx, stat->expr, EXPR_NOVAL, &rt->ei, &exprval);
591 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
592 exprval_release(&exprval);
597 TRACE("= %s\n", debugstr_variant(ret));
601 /* ECMA-262 3rd Edition 12.5 */
602 HRESULT if_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
604 if_statement_t *stat = (if_statement_t*)_stat;
611 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
615 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
616 exprval_release(&exprval);
621 hres = stat_eval(ctx, stat->if_stat, rt, ret);
622 else if(stat->else_stat)
623 hres = stat_eval(ctx, stat->else_stat, rt, ret);
625 V_VT(ret) = VT_EMPTY;
630 /* ECMA-262 3rd Edition 12.6.2 */
631 HRESULT while_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
633 while_statement_t *stat = (while_statement_t*)_stat;
642 V_VT(&val) = VT_EMPTY;
643 test_expr = !stat->do_while;
647 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
651 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
652 exprval_release(&exprval);
653 if(FAILED(hres) || !b)
659 hres = stat_eval(ctx, stat->statement, rt, &tmp);
666 if(rt->type == RT_CONTINUE)
667 rt->type = RT_NORMAL;
668 if(rt->type != RT_NORMAL)
677 if(rt->type == RT_BREAK)
678 rt->type = RT_NORMAL;
684 /* ECMA-262 3rd Edition 12.6.3 */
685 HRESULT for_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
687 for_statement_t *stat = (for_statement_t*)_stat;
688 VARIANT val, tmp, retv;
695 if(stat->variable_list) {
696 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
699 }else if(stat->begin_expr) {
700 hres = expr_eval(ctx, stat->begin_expr, EXPR_NEWREF, &rt->ei, &exprval);
704 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
705 exprval_release(&exprval);
712 V_VT(&retv) = VT_EMPTY;
716 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
720 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
721 exprval_release(&exprval);
722 if(FAILED(hres) || !b)
726 hres = stat_eval(ctx, stat->statement, rt, &tmp);
733 if(rt->type == RT_CONTINUE)
734 rt->type = RT_NORMAL;
735 else if(rt->type != RT_NORMAL)
739 hres = expr_eval(ctx, stat->end_expr, 0, &rt->ei, &exprval);
743 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
744 exprval_release(&exprval);
757 if(rt->type == RT_BREAK)
758 rt->type = RT_NORMAL;
764 /* ECMA-262 3rd Edition 12.6.4 */
765 HRESULT forin_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
767 forin_statement_t *stat = (forin_statement_t*)_stat;
768 VARIANT val, name, retv, tmp;
769 DISPID id = DISPID_STARTENUM;
770 BSTR str, identifier = NULL;
778 hres = variable_list_eval(ctx, stat->variable, &rt->ei);
783 hres = expr_eval(ctx, stat->in_expr, EXPR_NEWREF, &rt->ei, &exprval);
787 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
788 exprval_release(&exprval);
792 if(V_VT(&val) != VT_DISPATCH) {
793 TRACE("in vt %d\n", V_VT(&val));
795 V_VT(ret) = VT_EMPTY;
799 hres = IDispatch_QueryInterface(V_DISPATCH(&val), &IID_IDispatchEx, (void**)&in_obj);
800 IDispatch_Release(V_DISPATCH(&val));
802 FIXME("Object doesn't support IDispatchEx\n");
806 V_VT(&retv) = VT_EMPTY;
809 identifier = SysAllocString(stat->variable->identifier);
812 hres = IDispatchEx_GetNextDispID(in_obj, fdexEnumDefault, id, &id);
813 if(FAILED(hres) || hres == S_FALSE)
816 hres = IDispatchEx_GetMemberName(in_obj, id, &str);
820 TRACE("iter %s\n", debugstr_w(str));
823 hres = identifier_eval(ctx, identifier, 0, &exprval);
825 hres = expr_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval);
826 if(SUCCEEDED(hres)) {
827 V_VT(&name) = VT_BSTR;
829 hres = put_value(ctx->parser->script, &exprval, &name, &rt->ei);
830 exprval_release(&exprval);
836 hres = stat_eval(ctx, stat->statement, rt, &tmp);
843 if(rt->type == RT_CONTINUE)
844 rt->type = RT_NORMAL;
845 else if(rt->type != RT_NORMAL)
849 SysFreeString(identifier);
850 IDispatchEx_Release(in_obj);
856 if(rt->type == RT_BREAK)
857 rt->type = RT_NORMAL;
863 /* ECMA-262 3rd Edition 12.7 */
864 HRESULT continue_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
866 branch_statement_t *stat = (branch_statement_t*)_stat;
870 if(stat->identifier) {
871 FIXME("indentifier not implemented\n");
875 rt->type = RT_CONTINUE;
876 V_VT(ret) = VT_EMPTY;
880 /* ECMA-262 3rd Edition 12.8 */
881 HRESULT break_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
883 branch_statement_t *stat = (branch_statement_t*)_stat;
887 if(stat->identifier) {
888 FIXME("indentifier not implemented\n");
893 V_VT(ret) = VT_EMPTY;
897 /* ECMA-262 3rd Edition 12.9 */
898 HRESULT return_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
900 expression_statement_t *stat = (expression_statement_t*)_stat;
908 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
912 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, ret);
913 exprval_release(&exprval);
917 V_VT(ret) = VT_EMPTY;
920 TRACE("= %s\n", debugstr_variant(ret));
921 rt->type = RT_RETURN;
925 /* ECMA-262 3rd Edition 12.10 */
926 HRESULT with_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
928 with_statement_t *stat = (with_statement_t*)_stat;
937 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
941 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
942 exprval_release(&exprval);
946 hres = to_object(ctx, &val, &disp);
951 obj = iface_to_jsdisp((IUnknown*)disp);
952 IDispatch_Release(disp);
954 FIXME("disp id not jsdisp\n");
958 hres = scope_push(ctx->scope_chain, obj, &ctx->scope_chain);
963 hres = stat_eval(ctx, stat->statement, rt, ret);
965 scope_pop(&ctx->scope_chain);
969 /* ECMA-262 3rd Edition 12.12 */
970 HRESULT labelled_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
976 /* ECMA-262 3rd Edition 12.13 */
977 HRESULT switch_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
979 switch_statement_t *stat = (switch_statement_t*)_stat;
980 case_clausule_t *iter, *default_clausule = NULL;
981 statement_t *stat_iter;
989 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
993 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
994 exprval_release(&exprval);
998 for(iter = stat->case_list; iter; iter = iter->next) {
1000 default_clausule = iter;
1004 hres = expr_eval(ctx, iter->expr, 0, &rt->ei, &exprval);
1008 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &cval);
1009 exprval_release(&exprval);
1013 hres = equal2_values(&val, &cval, &b);
1014 VariantClear(&cval);
1015 if(FAILED(hres) || b)
1024 iter = default_clausule;
1026 V_VT(&val) = VT_EMPTY;
1030 for(stat_iter = iter->stat; stat_iter; stat_iter = stat_iter->next) {
1031 hres = stat_eval(ctx, stat_iter, rt, &tmp);
1038 if(rt->type != RT_NORMAL)
1048 if(rt->type == RT_BREAK)
1049 rt->type = RT_NORMAL;
1055 /* ECMA-262 3rd Edition 12.13 */
1056 HRESULT throw_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1058 expression_statement_t *stat = (expression_statement_t*)_stat;
1065 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
1069 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
1070 exprval_release(&exprval);
1075 return DISP_E_EXCEPTION;
1078 /* ECMA-262 3rd Edition 12.14 */
1079 static HRESULT catch_eval(exec_ctx_t *ctx, catch_block_t *block, return_type_t *rt, VARIANT *ret)
1081 DispatchEx *var_disp;
1086 memset(&rt->ei, 0, sizeof(jsexcept_t));
1088 hres = create_dispex(ctx->parser->script, NULL, NULL, &var_disp);
1089 if(SUCCEEDED(hres)) {
1090 hres = jsdisp_propput_name(var_disp, block->identifier, ctx->parser->script->lcid,
1091 &ex, &rt->ei, NULL/*FIXME*/);
1092 if(SUCCEEDED(hres)) {
1093 hres = scope_push(ctx->scope_chain, var_disp, &ctx->scope_chain);
1094 if(SUCCEEDED(hres)) {
1095 hres = stat_eval(ctx, block->statement, rt, &val);
1096 scope_pop(&ctx->scope_chain);
1100 jsdisp_release(var_disp);
1111 /* ECMA-262 3rd Edition 12.14 */
1112 HRESULT try_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1114 try_statement_t *stat = (try_statement_t*)_stat;
1120 hres = stat_eval(ctx, stat->try_statement, rt, &val);
1122 TRACE("EXCEPTION\n");
1123 if(!stat->catch_block)
1126 hres = catch_eval(ctx, stat->catch_block, rt, &val);
1131 if(stat->finally_statement) {
1133 hres = stat_eval(ctx, stat->finally_statement, rt, &val);
1142 static HRESULT return_bool(exprval_t *ret, DWORD b)
1144 ret->type = EXPRVAL_VARIANT;
1145 V_VT(&ret->u.var) = VT_BOOL;
1146 V_BOOL(&ret->u.var) = b ? VARIANT_TRUE : VARIANT_FALSE;
1151 static HRESULT get_binary_expr_values(exec_ctx_t *ctx, binary_expression_t *expr, jsexcept_t *ei, VARIANT *lval, VARIANT *rval)
1156 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1160 hres = exprval_to_value(ctx->parser->script, &exprval, ei, lval);
1161 exprval_release(&exprval);
1165 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1166 if(SUCCEEDED(hres)) {
1167 hres = exprval_to_value(ctx->parser->script, &exprval, ei, rval);
1168 exprval_release(&exprval);
1179 typedef HRESULT (*oper_t)(exec_ctx_t*,VARIANT*,VARIANT*,jsexcept_t*,VARIANT*);
1181 static HRESULT binary_expr_eval(exec_ctx_t *ctx, binary_expression_t *expr, oper_t oper, jsexcept_t *ei,
1184 VARIANT lval, rval, retv;
1187 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1191 hres = oper(ctx, &lval, &rval, ei, &retv);
1192 VariantClear(&lval);
1193 VariantClear(&rval);
1197 ret->type = EXPRVAL_VARIANT;
1202 /* ECMA-262 3rd Edition 11.13.2 */
1203 static HRESULT assign_oper_eval(exec_ctx_t *ctx, expression_t *lexpr, expression_t *rexpr, oper_t oper,
1204 jsexcept_t *ei, exprval_t *ret)
1206 VARIANT retv, lval, rval;
1207 exprval_t exprval, exprvalr;
1210 hres = expr_eval(ctx, lexpr, EXPR_NEWREF, ei, &exprval);
1214 hres = exprval_value(ctx->parser->script, &exprval, ei, &lval);
1215 if(SUCCEEDED(hres)) {
1216 hres = expr_eval(ctx, rexpr, 0, ei, &exprvalr);
1217 if(SUCCEEDED(hres)) {
1218 hres = exprval_value(ctx->parser->script, &exprvalr, ei, &rval);
1219 exprval_release(&exprvalr);
1221 if(SUCCEEDED(hres)) {
1222 hres = oper(ctx, &lval, &rval, ei, &retv);
1223 VariantClear(&rval);
1225 VariantClear(&lval);
1228 if(SUCCEEDED(hres)) {
1229 hres = put_value(ctx->parser->script, &exprval, &retv, ei);
1231 VariantClear(&retv);
1233 exprval_release(&exprval);
1238 ret->type = EXPRVAL_VARIANT;
1243 /* ECMA-262 3rd Edition 13 */
1244 HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1246 function_expression_t *expr = (function_expression_t*)_expr;
1252 if(expr->identifier) {
1253 hres = jsdisp_propget_name(ctx->var_disp, expr->identifier, ctx->parser->script->lcid, &var, ei, NULL/*FIXME*/);
1259 hres = create_source_function(ctx->parser, expr->parameter_list, expr->source_elements, ctx->scope_chain,
1260 expr->src_str, expr->src_len, &dispex);
1264 V_VT(&var) = VT_DISPATCH;
1265 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(dispex);
1268 ret->type = EXPRVAL_VARIANT;
1273 /* ECMA-262 3rd Edition 11.12 */
1274 HRESULT conditional_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1276 conditional_expression_t *expr = (conditional_expression_t*)_expr;
1283 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1287 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
1288 exprval_release(&exprval);
1292 return expr_eval(ctx, b ? expr->true_expression : expr->false_expression, flags, ei, ret);
1295 /* ECMA-262 3rd Edition 11.2.1 */
1296 HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1298 array_expression_t *expr = (array_expression_t*)_expr;
1300 VARIANT member, val;
1303 IDispatch *obj = NULL;
1308 hres = expr_eval(ctx, expr->member_expr, EXPR_NEWREF, ei, &exprval);
1312 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1313 exprval_release(&exprval);
1317 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
1318 if(SUCCEEDED(hres)) {
1319 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1320 exprval_release(&exprval);
1324 hres = to_object(ctx, &member, &obj);
1325 VariantClear(&member);
1326 if(SUCCEEDED(hres)) {
1327 hres = to_string(ctx->parser->script, &val, ei, &str);
1328 if(SUCCEEDED(hres)) {
1329 if(flags & EXPR_STRREF) {
1330 ret->type = EXPRVAL_NAMEREF;
1331 ret->u.nameref.disp = obj;
1332 ret->u.nameref.name = str;
1336 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1339 if(SUCCEEDED(hres)) {
1340 exprval_set_idref(ret, obj, id);
1341 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1346 IDispatch_Release(obj);
1352 /* ECMA-262 3rd Edition 11.2.1 */
1353 HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1355 member_expression_t *expr = (member_expression_t*)_expr;
1356 IDispatch *obj = NULL;
1365 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1369 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1370 exprval_release(&exprval);
1374 hres = to_object(ctx, &member, &obj);
1375 VariantClear(&member);
1379 str = SysAllocString(expr->identifier);
1380 if(flags & EXPR_STRREF) {
1381 ret->type = EXPRVAL_NAMEREF;
1382 ret->u.nameref.disp = obj;
1383 ret->u.nameref.name = str;
1387 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1389 if(SUCCEEDED(hres)) {
1390 exprval_set_idref(ret, obj, id);
1391 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1396 IDispatch_Release(obj);
1400 static void free_dp(DISPPARAMS *dp)
1404 for(i=0; i < dp->cArgs; i++)
1405 VariantClear(dp->rgvarg+i);
1406 heap_free(dp->rgvarg);
1409 static HRESULT args_to_param(exec_ctx_t *ctx, argument_t *args, jsexcept_t *ei, DISPPARAMS *dp)
1415 HRESULT hres = S_OK;
1417 memset(dp, 0, sizeof(*dp));
1421 for(iter = args; iter; iter = iter->next)
1424 vargs = heap_alloc_zero(cnt * sizeof(*vargs));
1426 return E_OUTOFMEMORY;
1428 for(i = cnt, iter = args; iter; iter = iter->next) {
1429 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
1433 hres = exprval_to_value(ctx->parser->script, &exprval, ei, vargs + (--i));
1434 exprval_release(&exprval);
1449 /* ECMA-262 3rd Edition 11.2.2 */
1450 HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1452 call_expression_t *expr = (call_expression_t*)_expr;
1454 VARIANT constr, var;
1460 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1464 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1466 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &constr);
1467 exprval_release(&exprval);
1471 if(V_VT(&constr) != VT_DISPATCH) {
1472 FIXME("throw TypeError\n");
1473 VariantClear(&constr);
1477 hres = disp_call(V_DISPATCH(&constr), DISPID_VALUE, ctx->parser->script->lcid,
1478 DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/);
1479 IDispatch_Release(V_DISPATCH(&constr));
1483 ret->type = EXPRVAL_VARIANT;
1488 /* ECMA-262 3rd Edition 11.2.3 */
1489 HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1491 call_expression_t *expr = (call_expression_t*)_expr;
1499 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1503 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1504 if(SUCCEEDED(hres)) {
1505 switch(exprval.type) {
1507 hres = disp_call(exprval.u.idref.disp, exprval.u.idref.id, ctx->parser->script->lcid, DISPATCH_METHOD,
1508 &dp, flags & EXPR_NOVAL ? NULL : &var, ei, NULL/*FIXME*/);
1509 if(flags & EXPR_NOVAL)
1510 V_VT(&var) = VT_EMPTY;
1513 FIXME("unimplemented type %d\n", V_VT(&func));
1520 exprval_release(&exprval);
1524 TRACE("= %s\n", debugstr_variant(&var));
1525 ret->type = EXPRVAL_VARIANT;
1530 /* ECMA-262 3rd Edition 11.1.1 */
1531 HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1535 ret->type = EXPRVAL_VARIANT;
1536 V_VT(&ret->u.var) = VT_DISPATCH;
1537 V_DISPATCH(&ret->u.var) = ctx->this_obj;
1538 IDispatch_AddRef(ctx->this_obj);
1542 /* ECMA-262 3rd Edition 10.1.4 */
1543 HRESULT identifier_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1545 identifier_expression_t *expr = (identifier_expression_t*)_expr;
1551 identifier = SysAllocString(expr->identifier);
1553 return E_OUTOFMEMORY;
1555 hres = identifier_eval(ctx, identifier, flags, ret);
1557 SysFreeString(identifier);
1561 /* ECMA-262 3rd Edition 7.8 */
1562 HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1564 literal_expression_t *expr = (literal_expression_t*)_expr;
1570 hres = literal_to_var(expr->literal, &var);
1574 ret->type = EXPRVAL_VARIANT;
1579 /* ECMA-262 3rd Edition 11.1.4 */
1580 HRESULT array_literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1582 array_literal_expression_t *expr = (array_literal_expression_t*)_expr;
1583 DWORD length = 0, i = 0;
1584 array_element_t *elem;
1592 for(elem = expr->element_list; elem; elem = elem->next)
1593 length += elem->elision+1;
1594 length += expr->length;
1596 hres = create_array(ctx->parser->script, length, &array);
1600 for(elem = expr->element_list; elem; elem = elem->next) {
1603 hres = expr_eval(ctx, elem->expr, 0, ei, &exprval);
1607 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1608 exprval_release(&exprval);
1612 hres = jsdisp_propput_idx(array, i, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1621 jsdisp_release(array);
1625 ret->type = EXPRVAL_VARIANT;
1626 V_VT(&ret->u.var) = VT_DISPATCH;
1627 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(array);
1631 /* ECMA-262 3rd Edition 11.1.5 */
1632 HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1634 property_value_expression_t *expr = (property_value_expression_t*)_expr;
1644 hres = create_object(ctx->parser->script, NULL, &obj);
1648 for(iter = expr->property_list; iter; iter = iter->next) {
1649 hres = literal_to_var(iter->name, &tmp);
1653 hres = to_string(ctx->parser->script, &tmp, ei, &name);
1658 hres = expr_eval(ctx, iter->value, 0, ei, &exprval);
1659 if(SUCCEEDED(hres)) {
1660 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1661 exprval_release(&exprval);
1662 if(SUCCEEDED(hres)) {
1663 hres = jsdisp_propput_name(obj, name, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1668 SysFreeString(name);
1674 jsdisp_release(obj);
1678 ret->type = EXPRVAL_VARIANT;
1679 V_VT(&ret->u.var) = VT_DISPATCH;
1680 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(obj);
1684 /* ECMA-262 3rd Edition 11.14 */
1685 HRESULT comma_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1687 binary_expression_t *expr = (binary_expression_t*)_expr;
1693 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1697 VariantClear(&lval);
1699 ret->type = EXPRVAL_VARIANT;
1704 /* ECMA-262 3rd Edition 11.11 */
1705 HRESULT logical_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1707 binary_expression_t *expr = (binary_expression_t*)_expr;
1715 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1719 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1720 exprval_release(&exprval);
1724 hres = to_boolean(&val, &b);
1725 if(SUCCEEDED(hres) && b) {
1726 ret->type = EXPRVAL_VARIANT;
1735 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1739 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1740 exprval_release(&exprval);
1744 ret->type = EXPRVAL_VARIANT;
1749 /* ECMA-262 3rd Edition 11.11 */
1750 HRESULT logical_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1752 binary_expression_t *expr = (binary_expression_t*)_expr;
1760 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1764 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1765 exprval_release(&exprval);
1769 hres = to_boolean(&val, &b);
1770 if(SUCCEEDED(hres) && !b) {
1771 ret->type = EXPRVAL_VARIANT;
1780 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1784 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1785 exprval_release(&exprval);
1789 ret->type = EXPRVAL_VARIANT;
1794 /* ECMA-262 3rd Edition 11.10 */
1795 static HRESULT bitor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1800 hres = to_int32(ctx->parser->script, lval, ei, &li);
1804 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1813 /* ECMA-262 3rd Edition 11.10 */
1814 HRESULT binary_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1816 binary_expression_t *expr = (binary_expression_t*)_expr;
1820 return binary_expr_eval(ctx, expr, bitor_eval, ei, ret);
1823 /* ECMA-262 3rd Edition 11.10 */
1824 static HRESULT xor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1829 hres = to_int32(ctx->parser->script, lval, ei, &li);
1833 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1842 /* ECMA-262 3rd Edition 11.10 */
1843 HRESULT binary_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1845 binary_expression_t *expr = (binary_expression_t*)_expr;
1849 return binary_expr_eval(ctx, expr, xor_eval, ei, ret);
1852 /* ECMA-262 3rd Edition 11.10 */
1853 static HRESULT bitand_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1858 hres = to_int32(ctx->parser->script, lval, ei, &li);
1862 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1871 /* ECMA-262 3rd Edition 11.10 */
1872 HRESULT binary_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1874 binary_expression_t *expr = (binary_expression_t*)_expr;
1878 return binary_expr_eval(ctx, expr, bitand_eval, ei, ret);
1881 /* ECMA-262 3rd Edition 11.8.6 */
1882 HRESULT instanceof_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1888 /* ECMA-262 3rd Edition 11.8.7 */
1889 HRESULT in_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1895 /* ECMA-262 3rd Edition 11.6.1 */
1896 static HRESULT add_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1901 hres = to_primitive(ctx->parser->script, lval, ei, &l);
1905 hres = to_primitive(ctx->parser->script, rval, ei, &r);
1911 if(V_VT(&l) == VT_BSTR || V_VT(&r) == VT_BSTR) {
1912 BSTR lstr = NULL, rstr = NULL;
1914 if(V_VT(&l) == VT_BSTR)
1917 hres = to_string(ctx->parser->script, &l, ei, &lstr);
1919 if(SUCCEEDED(hres)) {
1920 if(V_VT(&r) == VT_BSTR)
1923 hres = to_string(ctx->parser->script, &r, ei, &rstr);
1926 if(SUCCEEDED(hres)) {
1929 len1 = SysStringLen(lstr);
1930 len2 = SysStringLen(rstr);
1932 V_VT(retv) = VT_BSTR;
1933 V_BSTR(retv) = SysAllocStringLen(NULL, len1+len2);
1934 memcpy(V_BSTR(retv), lstr, len1*sizeof(WCHAR));
1935 memcpy(V_BSTR(retv)+len1, rstr, (len2+1)*sizeof(WCHAR));
1938 if(V_VT(&l) != VT_BSTR)
1939 SysFreeString(lstr);
1940 if(V_VT(&r) != VT_BSTR)
1941 SysFreeString(rstr);
1945 hres = to_number(ctx->parser->script, &l, ei, &nl);
1946 if(SUCCEEDED(hres)) {
1947 hres = to_number(ctx->parser->script, &r, ei, &nr);
1949 num_set_val(retv, num_val(&nl) + num_val(&nr));
1958 /* ECMA-262 3rd Edition 11.6.1 */
1959 HRESULT add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1961 binary_expression_t *expr = (binary_expression_t*)_expr;
1965 return binary_expr_eval(ctx, expr, add_eval, ei, ret);
1968 /* ECMA-262 3rd Edition 11.6.2 */
1969 static HRESULT sub_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1974 hres = to_number(ctx->parser->script, lval, ei, &lnum);
1978 hres = to_number(ctx->parser->script, rval, ei, &rnum);
1982 num_set_val(retv, num_val(&lnum) - num_val(&rnum));
1986 /* ECMA-262 3rd Edition 11.6.2 */
1987 HRESULT sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1989 binary_expression_t *expr = (binary_expression_t*)_expr;
1993 return binary_expr_eval(ctx, expr, sub_eval, ei, ret);
1996 /* ECMA-262 3rd Edition 11.5.1 */
1997 static HRESULT mul_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2002 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2006 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2010 num_set_val(retv, num_val(&lnum) * num_val(&rnum));
2014 /* ECMA-262 3rd Edition 11.5.1 */
2015 HRESULT mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2017 binary_expression_t *expr = (binary_expression_t*)_expr;
2021 return binary_expr_eval(ctx, expr, mul_eval, ei, ret);
2024 /* ECMA-262 3rd Edition 11.5.2 */
2025 static HRESULT div_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2030 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2034 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2038 num_set_val(retv, num_val(&lnum) / num_val(&rnum));
2042 /* ECMA-262 3rd Edition 11.5.2 */
2043 HRESULT div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2045 binary_expression_t *expr = (binary_expression_t*)_expr;
2049 return binary_expr_eval(ctx, expr, div_eval, ei, ret);
2052 /* ECMA-262 3rd Edition 11.5.3 */
2053 static HRESULT mod_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2058 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2062 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2066 num_set_val(retv, fmod(num_val(&lnum), num_val(&rnum)));
2070 /* ECMA-262 3rd Edition 11.5.3 */
2071 HRESULT mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2073 binary_expression_t *expr = (binary_expression_t*)_expr;
2077 return binary_expr_eval(ctx, expr, mod_eval, ei, ret);
2080 /* ECMA-262 3rd Edition 11.4.2 */
2081 HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2083 unary_expression_t *expr = (unary_expression_t*)_expr;
2084 VARIANT_BOOL b = VARIANT_FALSE;
2090 hres = expr_eval(ctx, expr->expression, EXPR_STRREF, ei, &exprval);
2094 switch(exprval.type) {
2095 case EXPRVAL_IDREF: {
2096 IDispatchEx *dispex;
2098 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2099 if(SUCCEEDED(hres)) {
2100 hres = IDispatchEx_DeleteMemberByDispID(dispex, exprval.u.idref.id);
2102 IDispatchEx_Release(dispex);
2106 case EXPRVAL_NAMEREF: {
2107 IDispatchEx *dispex;
2109 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2110 if(SUCCEEDED(hres)) {
2111 hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, fdexNameCaseSensitive);
2113 IDispatchEx_Release(dispex);
2118 FIXME("unsupported type %d\n", exprval.type);
2122 exprval_release(&exprval);
2126 return return_bool(ret, b);
2129 /* ECMA-262 3rd Edition 11.4.2 */
2130 HRESULT void_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2132 unary_expression_t *expr = (unary_expression_t*)_expr;
2139 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2143 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &tmp);
2144 exprval_release(&exprval);
2150 ret->type = EXPRVAL_VARIANT;
2151 V_VT(&ret->u.var) = VT_EMPTY;
2155 /* ECMA-262 3rd Edition 11.4.3 */
2156 HRESULT typeof_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2158 unary_expression_t *expr = (unary_expression_t*)_expr;
2164 static const WCHAR booleanW[] = {'b','o','o','l','e','a','n',0};
2165 static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
2166 static const WCHAR numberW[] = {'n','u','m','b','e','r',0};
2167 static const WCHAR objectW[] = {'o','b','j','e','c','t',0};
2168 static const WCHAR stringW[] = {'s','t','r','i','n','g',0};
2169 static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
2173 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2177 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2178 exprval_release(&exprval);
2182 switch(V_VT(&val)) {
2202 dispex = iface_to_jsdisp((IUnknown*)V_DISPATCH(&val));
2204 str = dispex->builtin_info->class == JSCLASS_FUNCTION ? functionW : objectW;
2205 IDispatchEx_Release(_IDispatchEx_(dispex));
2212 FIXME("unhandled vt %d\n", V_VT(&val));
2219 ret->type = EXPRVAL_VARIANT;
2220 V_VT(&ret->u.var) = VT_BSTR;
2221 V_BSTR(&ret->u.var) = SysAllocString(str);
2225 /* ECMA-262 3rd Edition 11.4.7 */
2226 HRESULT minus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2228 unary_expression_t *expr = (unary_expression_t*)_expr;
2235 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2239 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2240 exprval_release(&exprval);
2244 hres = to_number(ctx->parser->script, &val, ei, &num);
2249 ret->type = EXPRVAL_VARIANT;
2250 num_set_val(&ret->u.var, -num_val(&num));
2254 /* ECMA-262 3rd Edition 11.4.6 */
2255 HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2257 unary_expression_t *expr = (unary_expression_t*)_expr;
2264 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2268 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2269 exprval_release(&exprval);
2273 hres = to_number(ctx->parser->script, &val, ei, &num);
2277 ret->type = EXPRVAL_VARIANT;
2282 /* ECMA-262 3rd Edition 11.3.1 */
2283 HRESULT post_increment_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2285 unary_expression_t *expr = (unary_expression_t*)_expr;
2292 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2296 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2297 if(SUCCEEDED(hres)) {
2298 hres = to_number(ctx->parser->script, &val, ei, &num);
2302 if(SUCCEEDED(hres)) {
2304 num_set_val(&inc, num_val(&num)+1.0);
2305 hres = put_value(ctx->parser->script, &exprval, &inc, ei);
2308 exprval_release(&exprval);
2312 ret->type = EXPRVAL_VARIANT;
2317 /* ECMA-262 3rd Edition 11.3.2 */
2318 HRESULT post_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2320 unary_expression_t *expr = (unary_expression_t*)_expr;
2327 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2331 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2332 if(SUCCEEDED(hres)) {
2333 hres = to_number(ctx->parser->script, &val, ei, &num);
2337 if(SUCCEEDED(hres)) {
2339 num_set_val(&dec, num_val(&num)-1.0);
2340 hres = put_value(ctx->parser->script, &exprval, &dec, ei);
2343 exprval_release(&exprval);
2347 ret->type = EXPRVAL_VARIANT;
2352 /* ECMA-262 3rd Edition 11.4.4 */
2353 HRESULT pre_increment_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2355 unary_expression_t *expr = (unary_expression_t*)_expr;
2362 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2366 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2367 if(SUCCEEDED(hres)) {
2368 hres = to_number(ctx->parser->script, &val, ei, &num);
2372 if(SUCCEEDED(hres)) {
2373 num_set_val(&val, num_val(&num)+1.0);
2374 hres = put_value(ctx->parser->script, &exprval, &val, ei);
2377 exprval_release(&exprval);
2381 ret->type = EXPRVAL_VARIANT;
2386 /* ECMA-262 3rd Edition 11.4.5 */
2387 HRESULT pre_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2389 unary_expression_t *expr = (unary_expression_t*)_expr;
2396 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2400 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2401 if(SUCCEEDED(hres)) {
2402 hres = to_number(ctx->parser->script, &val, ei, &num);
2406 if(SUCCEEDED(hres)) {
2407 num_set_val(&val, num_val(&num)-1.0);
2408 hres = put_value(ctx->parser->script, &exprval, &val, ei);
2411 exprval_release(&exprval);
2415 ret->type = EXPRVAL_VARIANT;
2420 /* ECMA-262 3rd Edition 11.9.3 */
2421 static HRESULT equal_values(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, BOOL *ret)
2423 if(V_VT(lval) == V_VT(rval) || (is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))))
2424 return equal2_values(lval, rval, ret);
2426 /* FIXME: NULL disps should be handled in more general way */
2427 if(V_VT(lval) == VT_DISPATCH && !V_DISPATCH(lval)) {
2430 return equal_values(ctx, &v, rval, ei, ret);
2433 if(V_VT(rval) == VT_DISPATCH && !V_DISPATCH(rval)) {
2436 return equal_values(ctx, lval, &v, ei, ret);
2439 if((V_VT(lval) == VT_NULL && V_VT(rval) == VT_EMPTY) ||
2440 (V_VT(lval) == VT_EMPTY && V_VT(rval) == VT_NULL)) {
2445 if(V_VT(lval) == VT_BSTR && is_num_vt(V_VT(rval))) {
2449 hres = to_number(ctx->parser->script, lval, ei, &v);
2453 return equal_values(ctx, &v, rval, ei, ret);
2456 if(V_VT(rval) == VT_BSTR && is_num_vt(V_VT(lval))) {
2460 hres = to_number(ctx->parser->script, rval, ei, &v);
2464 return equal_values(ctx, lval, &v, ei, ret);
2467 if(V_VT(rval) == VT_BOOL) {
2471 V_I4(&v) = V_BOOL(rval) ? 1 : 0;
2472 return equal_values(ctx, lval, &v, ei, ret);
2475 if(V_VT(lval) == VT_BOOL) {
2479 V_I4(&v) = V_BOOL(lval) ? 1 : 0;
2480 return equal_values(ctx, &v, rval, ei, ret);
2484 if(V_VT(rval) == VT_DISPATCH && (V_VT(lval) == VT_BSTR || is_num_vt(V_VT(lval)))) {
2488 hres = to_primitive(ctx->parser->script, rval, ei, &v);
2492 hres = equal_values(ctx, lval, &v, ei, ret);
2499 if(V_VT(lval) == VT_DISPATCH && (V_VT(rval) == VT_BSTR || is_num_vt(V_VT(rval)))) {
2503 hres = to_primitive(ctx->parser->script, lval, ei, &v);
2507 hres = equal_values(ctx, &v, rval, ei, ret);
2518 /* ECMA-262 3rd Edition 11.9.1 */
2519 HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2521 binary_expression_t *expr = (binary_expression_t*)_expr;
2528 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2532 hres = equal_values(ctx, &rval, &lval, ei, &b);
2536 return return_bool(ret, b);
2539 /* ECMA-262 3rd Edition 11.9.4 */
2540 HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2542 binary_expression_t *expr = (binary_expression_t*)_expr;
2549 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2553 hres = equal2_values(&rval, &lval, &b);
2557 return return_bool(ret, b);
2560 /* ECMA-262 3rd Edition 11.9.2 */
2561 HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2563 binary_expression_t *expr = (binary_expression_t*)_expr;
2570 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2574 hres = equal_values(ctx, &lval, &rval, ei, &b);
2578 return return_bool(ret, !b);
2581 /* ECMA-262 3rd Edition 11.9.5 */
2582 HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2584 binary_expression_t *expr = (binary_expression_t*)_expr;
2591 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2595 hres = equal2_values(&lval, &rval, &b);
2599 return return_bool(ret, !b);
2602 /* ECMA-262 3rd Edition 11.8.5 */
2603 static HRESULT less_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, BOOL greater, jsexcept_t *ei, BOOL *ret)
2605 VARIANT l, r, ln, rn;
2608 hres = to_primitive(ctx->parser->script, lval, ei, &l);
2612 hres = to_primitive(ctx->parser->script, rval, ei, &r);
2618 if(V_VT(&l) == VT_BSTR && V_VT(&r) == VT_BSTR) {
2619 *ret = (strcmpW(V_BSTR(&l), V_BSTR(&r)) < 0) ^ greater;
2620 SysFreeString(V_BSTR(&l));
2621 SysFreeString(V_BSTR(&r));
2625 hres = to_number(ctx->parser->script, &l, ei, &ln);
2628 hres = to_number(ctx->parser->script, &r, ei, &rn);
2633 if(V_VT(&ln) == VT_I4 && V_VT(&rn) == VT_I4) {
2634 *ret = (V_I4(&ln) < V_I4(&rn)) ^ greater;
2636 DOUBLE ld = num_val(&ln);
2637 DOUBLE rd = num_val(&rn);
2639 *ret = !isnan(ld) && !isnan(rd) && ((ld < rd) ^ greater);
2645 /* ECMA-262 3rd Edition 11.8.1 */
2646 HRESULT less_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2648 binary_expression_t *expr = (binary_expression_t*)_expr;
2655 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2659 hres = less_eval(ctx, &lval, &rval, FALSE, ei, &b);
2660 VariantClear(&lval);
2661 VariantClear(&rval);
2665 return return_bool(ret, b);
2668 /* ECMA-262 3rd Edition 11.8.3 */
2669 HRESULT lesseq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2671 binary_expression_t *expr = (binary_expression_t*)_expr;
2678 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2682 hres = less_eval(ctx, &rval, &lval, TRUE, ei, &b);
2683 VariantClear(&lval);
2684 VariantClear(&rval);
2688 return return_bool(ret, b);
2691 /* ECMA-262 3rd Edition 11.8.2 */
2692 HRESULT greater_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2694 binary_expression_t *expr = (binary_expression_t*)_expr;
2701 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2705 hres = less_eval(ctx, &rval, &lval, FALSE, ei, &b);
2706 VariantClear(&lval);
2707 VariantClear(&rval);
2711 return return_bool(ret, b);
2714 /* ECMA-262 3rd Edition 11.8.4 */
2715 HRESULT greatereq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2717 binary_expression_t *expr = (binary_expression_t*)_expr;
2724 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2728 hres = less_eval(ctx, &lval, &rval, TRUE, ei, &b);
2729 VariantClear(&lval);
2730 VariantClear(&rval);
2734 return return_bool(ret, b);
2737 /* ECMA-262 3rd Edition 11.4.8 */
2738 HRESULT binary_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2740 unary_expression_t *expr = (unary_expression_t*)_expr;
2748 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2752 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2753 exprval_release(&exprval);
2757 hres = to_int32(ctx->parser->script, &val, ei, &i);
2761 ret->type = EXPRVAL_VARIANT;
2762 V_VT(&ret->u.var) = VT_I4;
2763 V_I4(&ret->u.var) = ~i;
2767 /* ECMA-262 3rd Edition 11.4.9 */
2768 HRESULT logical_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2770 unary_expression_t *expr = (unary_expression_t*)_expr;
2777 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2781 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
2782 exprval_release(&exprval);
2786 return return_bool(ret, !b);
2789 /* ECMA-262 3rd Edition 11.7.1 */
2790 static HRESULT lshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2796 hres = to_int32(ctx->parser->script, lval, ei, &li);
2800 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2805 V_I4(retv) = li << (ri&0x1f);
2809 /* ECMA-262 3rd Edition 11.7.1 */
2810 HRESULT left_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2812 binary_expression_t *expr = (binary_expression_t*)_expr;
2816 return binary_expr_eval(ctx, expr, lshift_eval, ei, ret);
2819 /* ECMA-262 3rd Edition 11.7.2 */
2820 static HRESULT rshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2826 hres = to_int32(ctx->parser->script, lval, ei, &li);
2830 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2835 V_I4(retv) = li >> (ri&0x1f);
2839 /* ECMA-262 3rd Edition 11.7.2 */
2840 HRESULT right_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2842 binary_expression_t *expr = (binary_expression_t*)_expr;
2846 return binary_expr_eval(ctx, expr, rshift_eval, ei, ret);
2849 /* ECMA-262 3rd Edition 11.7.3 */
2850 static HRESULT rshift2_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2855 hres = to_uint32(ctx->parser->script, lval, ei, &li);
2859 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2864 V_I4(retv) = li >> (ri&0x1f);
2868 /* ECMA-262 3rd Edition 11.7.3 */
2869 HRESULT right2_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2871 binary_expression_t *expr = (binary_expression_t*)_expr;
2875 return binary_expr_eval(ctx, expr, rshift2_eval, ei, ret);
2878 /* ECMA-262 3rd Edition 11.13.1 */
2879 HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2881 binary_expression_t *expr = (binary_expression_t*)_expr;
2882 exprval_t exprval, exprvalr;
2888 hres = expr_eval(ctx, expr->expression1, EXPR_NEWREF, ei, &exprval);
2892 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprvalr);
2893 if(SUCCEEDED(hres)) {
2894 hres = exprval_to_value(ctx->parser->script, &exprvalr, ei, &rval);
2895 exprval_release(&exprvalr);
2899 hres = put_value(ctx->parser->script, &exprval, &rval, ei);
2901 exprval_release(&exprval);
2905 ret->type = EXPRVAL_VARIANT;
2910 /* ECMA-262 3rd Edition 11.13.2 */
2911 HRESULT assign_lshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2913 binary_expression_t *expr = (binary_expression_t*)_expr;
2917 return assign_oper_eval(ctx, expr->expression1, expr->expression2, lshift_eval, ei, ret);
2920 /* ECMA-262 3rd Edition 11.13.2 */
2921 HRESULT assign_rshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2923 binary_expression_t *expr = (binary_expression_t*)_expr;
2927 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift_eval, ei, ret);
2930 /* ECMA-262 3rd Edition 11.13.2 */
2931 HRESULT assign_rrshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2933 binary_expression_t *expr = (binary_expression_t*)_expr;
2937 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift2_eval, ei, ret);
2940 /* ECMA-262 3rd Edition 11.13.2 */
2941 HRESULT assign_add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2943 binary_expression_t *expr = (binary_expression_t*)_expr;
2947 return assign_oper_eval(ctx, expr->expression1, expr->expression2, add_eval, ei, ret);
2950 /* ECMA-262 3rd Edition 11.13.2 */
2951 HRESULT assign_sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2953 binary_expression_t *expr = (binary_expression_t*)_expr;
2957 return assign_oper_eval(ctx, expr->expression1, expr->expression2, sub_eval, ei, ret);
2960 /* ECMA-262 3rd Edition 11.13.2 */
2961 HRESULT assign_mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2963 binary_expression_t *expr = (binary_expression_t*)_expr;
2967 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mul_eval, ei, ret);
2970 /* ECMA-262 3rd Edition 11.13.2 */
2971 HRESULT assign_div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2973 binary_expression_t *expr = (binary_expression_t*)_expr;
2977 return assign_oper_eval(ctx, expr->expression1, expr->expression2, div_eval, ei, ret);
2980 /* ECMA-262 3rd Edition 11.13.2 */
2981 HRESULT assign_mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2983 binary_expression_t *expr = (binary_expression_t*)_expr;
2987 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mod_eval, ei, ret);
2990 /* ECMA-262 3rd Edition 11.13.2 */
2991 HRESULT assign_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2993 binary_expression_t *expr = (binary_expression_t*)_expr;
2997 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitand_eval, ei, ret);
3000 /* ECMA-262 3rd Edition 11.13.2 */
3001 HRESULT assign_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3003 binary_expression_t *expr = (binary_expression_t*)_expr;
3007 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitor_eval, ei, ret);
3010 /* ECMA-262 3rd Edition 11.13.2 */
3011 HRESULT assign_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3013 binary_expression_t *expr = (binary_expression_t*)_expr;
3017 return assign_oper_eval(ctx, expr->expression1, expr->expression2, xor_eval, ei, ret);