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
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
28 #define EXPR_NOVAL 0x0001
29 #define EXPR_NEWREF 0x0002
30 #define EXPR_STRREF 0x0004
32 static inline HRESULT stat_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
34 return stat->eval(ctx, stat, rt, ret);
37 static inline HRESULT expr_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
39 return _expr->eval(ctx, _expr, flags, ei, ret);
42 static void exprval_release(exprval_t *val)
46 if(V_VT(&val->u.var) != VT_EMPTY)
47 VariantClear(&val->u.var);
51 IDispatch_Release(val->u.idref.disp);
54 if(val->u.nameref.disp)
55 IDispatch_Release(val->u.nameref.disp);
56 SysFreeString(val->u.nameref.name);
60 /* ECMA-262 3rd Edition 8.7.1 */
61 static HRESULT exprval_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
67 return VariantCopy(ret, &val->u.var);
69 if(!val->u.idref.disp) {
70 FIXME("throw ReferenceError\n");
74 return disp_propget(val->u.idref.disp, val->u.idref.id, ctx->lcid, ret, ei, NULL/*FIXME*/);
76 ERR("type %d\n", val->type);
81 static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
83 if(val->type == EXPRVAL_VARIANT) {
85 V_VT(&val->u.var) = VT_EMPTY;
89 return exprval_value(ctx, val, ei, ret);
92 static HRESULT exprval_to_boolean(script_ctx_t *ctx, exprval_t *exprval, jsexcept_t *ei, VARIANT_BOOL *b)
94 if(exprval->type != EXPRVAL_VARIANT) {
98 hres = exprval_to_value(ctx, exprval, ei, &val);
102 hres = to_boolean(&val, b);
107 return to_boolean(&exprval->u.var, b);
110 static void exprval_init(exprval_t *val)
112 val->type = EXPRVAL_VARIANT;
113 V_VT(&val->u.var) = VT_EMPTY;
116 static void exprval_set_idref(exprval_t *val, IDispatch *disp, DISPID id)
118 val->type = EXPRVAL_IDREF;
119 val->u.idref.disp = disp;
120 val->u.idref.id = id;
123 IDispatch_AddRef(disp);
126 HRESULT scope_push(scope_chain_t *scope, DispatchEx *obj, scope_chain_t **ret)
128 scope_chain_t *new_scope;
130 new_scope = heap_alloc(sizeof(scope_chain_t));
132 return E_OUTOFMEMORY;
136 IDispatchEx_AddRef(_IDispatchEx_(obj));
137 new_scope->obj = obj;
141 new_scope->next = scope;
143 new_scope->next = NULL;
150 static void scope_pop(scope_chain_t **scope)
159 void scope_release(scope_chain_t *scope)
165 scope_release(scope->next);
167 IDispatchEx_Release(_IDispatchEx_(scope->obj));
171 HRESULT create_exec_ctx(IDispatch *this_obj, DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t **ret)
175 ctx = heap_alloc_zero(sizeof(exec_ctx_t));
177 return E_OUTOFMEMORY;
179 IDispatch_AddRef(this_obj);
180 ctx->this_obj = this_obj;
182 IDispatchEx_AddRef(_IDispatchEx_(var_disp));
183 ctx->var_disp = var_disp;
187 ctx->scope_chain = scope;
194 void exec_release(exec_ctx_t *ctx)
200 scope_release(ctx->scope_chain);
202 IDispatchEx_Release(_IDispatchEx_(ctx->var_disp));
204 IDispatch_Release(ctx->this_obj);
208 static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id)
213 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
215 TRACE("unsing IDispatch\n");
218 return IDispatch_GetIDsOfNames(disp, &IID_NULL, &name, 1, 0, id);
222 hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id);
223 IDispatchEx_Release(dispex);
227 /* ECMA-262 3rd Edition 8.7.2 */
228 static HRESULT put_value(script_ctx_t *ctx, exprval_t *ref, VARIANT *v, jsexcept_t *ei)
230 if(ref->type != EXPRVAL_IDREF) {
231 FIXME("throw ReferemceError\n");
235 return disp_propput(ref->u.idref.disp, ref->u.idref.id, ctx->lcid, v, ei, NULL/*FIXME*/);
238 static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
240 IObjectIdentity *identity;
241 IUnknown *unk1, *unk2;
249 hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
253 hres = IDispatch_QueryInterface(disp2, &IID_IUnknown, (void**)&unk2);
255 IUnknown_Release(unk1);
262 hres = IUnknown_QueryInterface(unk1, &IID_IObjectIdentity, (void**)&identity);
263 if(SUCCEEDED(hres)) {
264 hres = IObjectIdentity_IsEqualObject(identity, unk2);
265 IObjectIdentity_Release(identity);
272 IUnknown_Release(unk1);
273 IUnknown_Release(unk2);
277 /* ECMA-262 3rd Edition 11.9.6 */
278 HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret)
282 if(V_VT(lval) != V_VT(rval)) {
283 if(is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))) {
284 *ret = num_val(lval) == num_val(rval);
298 *ret = V_I4(lval) == V_I4(rval);
301 *ret = V_R8(lval) == V_R8(rval);
304 *ret = !strcmpW(V_BSTR(lval), V_BSTR(rval));
307 return disp_cmp(V_DISPATCH(lval), V_DISPATCH(rval), ret);
309 *ret = !V_BOOL(lval) == !V_BOOL(rval);
312 FIXME("unimplemented vt %d\n", V_VT(lval));
319 static HRESULT literal_to_var(literal_t *literal, VARIANT *v)
321 V_VT(v) = literal->vt;
328 V_I4(v) = literal->u.lval;
331 V_R8(v) = literal->u.dval;
334 V_BSTR(v) = SysAllocString(literal->u.wstr);
337 V_BOOL(v) = literal->u.bval;
340 IDispatch_AddRef(literal->u.disp);
341 V_DISPATCH(v) = literal->u.disp;
344 ERR("wrong type %d\n", V_VT(v));
351 HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
353 script_ctx_t *script = parser->script;
354 function_declaration_t *func;
355 parser_ctx_t *prev_parser;
359 exec_ctx_t *prev_ctx;
363 for(func = source->functions; func; func = func->next) {
364 DispatchEx *func_obj;
367 hres = create_source_function(parser, func->parameter_list, func->source_elements,
368 ctx->scope_chain, func->src_str, func->src_len, &func_obj);
372 V_VT(&var) = VT_DISPATCH;
373 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(func_obj);
374 hres = jsdisp_propput_name(ctx->var_disp, func->identifier, script->lcid, &var, ei, NULL);
375 jsdisp_release(func_obj);
380 for(var = source->variables; var; var = var->next) {
383 hres = jsdisp_get_id(ctx->var_disp, var->identifier, fdexNameEnsure, &id);
388 prev_ctx = script->exec_ctx;
389 script->exec_ctx = ctx;
391 prev_parser = ctx->parser;
392 ctx->parser = parser;
394 V_VT(&val) = VT_EMPTY;
395 memset(&rt, 0, sizeof(rt));
398 for(stat = source->statement; stat; stat = stat->next) {
399 hres = stat_eval(ctx, stat, &rt, &tmp);
405 if(rt.type != RT_NORMAL)
409 script->exec_ctx = prev_ctx;
410 ctx->parser = prev_parser;
412 if(rt.type != RT_NORMAL && rt.type != RT_RETURN) {
413 FIXME("wrong rt %d\n", rt.type);
430 /* ECMA-262 3rd Edition 10.1.4 */
431 static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, exprval_t *ret)
433 scope_chain_t *scope;
438 TRACE("%s\n", debugstr_w(identifier));
440 for(scope = ctx->scope_chain; scope; scope = scope->next) {
441 hres = jsdisp_get_id(scope->obj, identifier, 0, &id);
447 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(scope->obj), id);
451 hres = jsdisp_get_id(ctx->parser->script->global, identifier, 0, &id);
452 if(SUCCEEDED(hres)) {
453 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->global), id);
457 for(item = ctx->parser->script->named_items; item; item = item->next) {
458 hres = disp_get_id(item->disp, identifier, 0, &id);
464 exprval_set_idref(ret, (IDispatch*)item->disp, id);
468 hres = jsdisp_get_id(ctx->parser->script->script_disp, identifier, 0, &id);
469 if(SUCCEEDED(hres)) {
470 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->script_disp), id);
474 if(flags & EXPR_NEWREF) {
475 hres = jsdisp_get_id(ctx->var_disp, identifier, fdexNameEnsure, &id);
479 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->var_disp), id);
483 WARN("Could not find identifier %s\n", debugstr_w(identifier));
487 /* ECMA-262 3rd Edition 12.1 */
488 HRESULT block_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
490 block_statement_t *stat = (block_statement_t*)_stat;
497 V_VT(&val) = VT_EMPTY;
498 for(iter = stat->stat_list; iter; iter = iter->next) {
499 hres = stat_eval(ctx, iter, rt, &tmp);
505 if(rt->type != RT_NORMAL)
518 /* ECMA-262 3rd Edition 12.2 */
519 static HRESULT variable_list_eval(exec_ctx_t *ctx, variable_declaration_t *var_list, jsexcept_t *ei)
521 variable_declaration_t *iter;
524 for(iter = var_list; iter; iter = iter->next) {
531 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
535 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
536 exprval_release(&exprval);
540 hres = jsdisp_propput_name(ctx->var_disp, iter->identifier, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
549 /* ECMA-262 3rd Edition 12.2 */
550 HRESULT var_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
552 var_statement_t *stat = (var_statement_t*)_stat;
557 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
561 V_VT(ret) = VT_EMPTY;
565 /* ECMA-262 3rd Edition 12.3 */
566 HRESULT empty_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
570 V_VT(ret) = VT_EMPTY;
574 /* ECMA-262 3rd Edition 12.4 */
575 HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
577 expression_statement_t *stat = (expression_statement_t*)_stat;
584 hres = expr_eval(ctx, stat->expr, EXPR_NOVAL, &rt->ei, &exprval);
588 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
589 exprval_release(&exprval);
594 TRACE("= %s\n", debugstr_variant(ret));
598 /* ECMA-262 3rd Edition 12.5 */
599 HRESULT if_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
601 if_statement_t *stat = (if_statement_t*)_stat;
608 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
612 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
613 exprval_release(&exprval);
618 hres = stat_eval(ctx, stat->if_stat, rt, ret);
619 else if(stat->else_stat)
620 hres = stat_eval(ctx, stat->else_stat, rt, ret);
622 V_VT(ret) = VT_EMPTY;
627 /* ECMA-262 3rd Edition 12.6.2 */
628 HRESULT while_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
630 while_statement_t *stat = (while_statement_t*)_stat;
639 V_VT(&val) = VT_EMPTY;
640 test_expr = !stat->do_while;
644 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
648 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
649 exprval_release(&exprval);
650 if(FAILED(hres) || !b)
656 hres = stat_eval(ctx, stat->statement, rt, &tmp);
663 if(rt->type == RT_CONTINUE)
664 rt->type = RT_NORMAL;
665 if(rt->type != RT_NORMAL)
674 if(rt->type == RT_BREAK)
675 rt->type = RT_NORMAL;
681 /* ECMA-262 3rd Edition 12.6.3 */
682 HRESULT for_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
684 for_statement_t *stat = (for_statement_t*)_stat;
685 VARIANT val, tmp, retv;
692 if(stat->variable_list) {
693 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
696 }else if(stat->begin_expr) {
697 hres = expr_eval(ctx, stat->begin_expr, EXPR_NEWREF, &rt->ei, &exprval);
701 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
702 exprval_release(&exprval);
709 V_VT(&retv) = VT_EMPTY;
713 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
717 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
718 exprval_release(&exprval);
719 if(FAILED(hres) || !b)
723 hres = stat_eval(ctx, stat->statement, rt, &tmp);
730 if(rt->type == RT_CONTINUE)
731 rt->type = RT_NORMAL;
732 else if(rt->type != RT_NORMAL)
736 hres = expr_eval(ctx, stat->end_expr, 0, &rt->ei, &exprval);
740 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
741 exprval_release(&exprval);
754 if(rt->type == RT_BREAK)
755 rt->type = RT_NORMAL;
761 /* ECMA-262 3rd Edition 12.6.4 */
762 HRESULT forin_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
764 forin_statement_t *stat = (forin_statement_t*)_stat;
765 VARIANT val, name, retv, tmp;
766 DISPID id = DISPID_STARTENUM;
767 BSTR str, identifier = NULL;
775 hres = variable_list_eval(ctx, stat->variable, &rt->ei);
780 hres = expr_eval(ctx, stat->in_expr, EXPR_NEWREF, &rt->ei, &exprval);
784 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
785 exprval_release(&exprval);
789 if(V_VT(&val) != VT_DISPATCH) {
790 TRACE("in vt %d\n", V_VT(&val));
792 V_VT(ret) = VT_EMPTY;
796 hres = IDispatch_QueryInterface(V_DISPATCH(&val), &IID_IDispatchEx, (void**)&in_obj);
797 IDispatch_Release(V_DISPATCH(&val));
799 FIXME("Object doesn't support IDispatchEx\n");
803 V_VT(&retv) = VT_EMPTY;
806 identifier = SysAllocString(stat->variable->identifier);
809 hres = IDispatchEx_GetNextDispID(in_obj, fdexEnumDefault, id, &id);
810 if(FAILED(hres) || hres == S_FALSE)
813 hres = IDispatchEx_GetMemberName(in_obj, id, &str);
817 TRACE("iter %s\n", debugstr_w(str));
820 hres = identifier_eval(ctx, identifier, 0, &exprval);
822 hres = expr_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval);
823 if(SUCCEEDED(hres)) {
824 V_VT(&name) = VT_BSTR;
826 hres = put_value(ctx->parser->script, &exprval, &name, &rt->ei);
827 exprval_release(&exprval);
833 hres = stat_eval(ctx, stat->statement, rt, &tmp);
840 if(rt->type == RT_CONTINUE)
841 rt->type = RT_NORMAL;
842 else if(rt->type != RT_NORMAL)
846 SysFreeString(identifier);
847 IDispatchEx_Release(in_obj);
853 if(rt->type == RT_BREAK)
854 rt->type = RT_NORMAL;
860 /* ECMA-262 3rd Edition 12.7 */
861 HRESULT continue_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
863 branch_statement_t *stat = (branch_statement_t*)_stat;
867 if(stat->identifier) {
868 FIXME("indentifier not implemented\n");
872 rt->type = RT_CONTINUE;
873 V_VT(ret) = VT_EMPTY;
877 /* ECMA-262 3rd Edition 12.8 */
878 HRESULT break_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
880 branch_statement_t *stat = (branch_statement_t*)_stat;
884 if(stat->identifier) {
885 FIXME("indentifier not implemented\n");
890 V_VT(ret) = VT_EMPTY;
894 /* ECMA-262 3rd Edition 12.9 */
895 HRESULT return_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
897 expression_statement_t *stat = (expression_statement_t*)_stat;
905 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
909 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, ret);
910 exprval_release(&exprval);
914 V_VT(ret) = VT_EMPTY;
917 TRACE("= %s\n", debugstr_variant(ret));
918 rt->type = RT_RETURN;
922 /* ECMA-262 3rd Edition 12.10 */
923 HRESULT with_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
925 with_statement_t *stat = (with_statement_t*)_stat;
934 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
938 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
939 exprval_release(&exprval);
943 hres = to_object(ctx, &val, &disp);
948 obj = iface_to_jsdisp((IUnknown*)disp);
949 IDispatch_Release(disp);
951 FIXME("disp id not jsdisp\n");
955 hres = scope_push(ctx->scope_chain, obj, &ctx->scope_chain);
960 hres = stat_eval(ctx, stat->statement, rt, ret);
962 scope_pop(&ctx->scope_chain);
966 /* ECMA-262 3rd Edition 12.12 */
967 HRESULT labelled_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
973 /* ECMA-262 3rd Edition 12.13 */
974 HRESULT switch_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
976 switch_statement_t *stat = (switch_statement_t*)_stat;
977 case_clausule_t *iter, *default_clausule = NULL;
978 statement_t *stat_iter;
986 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
990 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
991 exprval_release(&exprval);
995 for(iter = stat->case_list; iter; iter = iter->next) {
997 default_clausule = iter;
1001 hres = expr_eval(ctx, iter->expr, 0, &rt->ei, &exprval);
1005 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &cval);
1006 exprval_release(&exprval);
1010 hres = equal2_values(&val, &cval, &b);
1011 VariantClear(&cval);
1012 if(FAILED(hres) || b)
1021 iter = default_clausule;
1023 V_VT(&val) = VT_EMPTY;
1027 for(stat_iter = iter->stat; stat_iter; stat_iter = stat_iter->next) {
1028 hres = stat_eval(ctx, stat_iter, rt, &tmp);
1035 if(rt->type != RT_NORMAL)
1045 if(rt->type == RT_BREAK)
1046 rt->type = RT_NORMAL;
1052 /* ECMA-262 3rd Edition 12.13 */
1053 HRESULT throw_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1055 expression_statement_t *stat = (expression_statement_t*)_stat;
1062 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
1066 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
1067 exprval_release(&exprval);
1072 return DISP_E_EXCEPTION;
1075 /* ECMA-262 3rd Edition 12.14 */
1076 static HRESULT catch_eval(exec_ctx_t *ctx, catch_block_t *block, return_type_t *rt, VARIANT *ret)
1078 DispatchEx *var_disp;
1083 memset(&rt->ei, 0, sizeof(jsexcept_t));
1085 hres = create_dispex(ctx->parser->script, NULL, NULL, &var_disp);
1086 if(SUCCEEDED(hres)) {
1087 hres = jsdisp_propput_name(var_disp, block->identifier, ctx->parser->script->lcid,
1088 &ex, &rt->ei, NULL/*FIXME*/);
1089 if(SUCCEEDED(hres)) {
1090 hres = scope_push(ctx->scope_chain, var_disp, &ctx->scope_chain);
1091 if(SUCCEEDED(hres)) {
1092 hres = stat_eval(ctx, block->statement, rt, &val);
1093 scope_pop(&ctx->scope_chain);
1097 jsdisp_release(var_disp);
1108 /* ECMA-262 3rd Edition 12.14 */
1109 HRESULT try_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1111 try_statement_t *stat = (try_statement_t*)_stat;
1117 hres = stat_eval(ctx, stat->try_statement, rt, &val);
1119 TRACE("EXCEPTION\n");
1120 if(!stat->catch_block)
1123 hres = catch_eval(ctx, stat->catch_block, rt, &val);
1128 if(stat->finally_statement) {
1130 hres = stat_eval(ctx, stat->finally_statement, rt, &val);
1139 static HRESULT return_bool(exprval_t *ret, DWORD b)
1141 ret->type = EXPRVAL_VARIANT;
1142 V_VT(&ret->u.var) = VT_BOOL;
1143 V_BOOL(&ret->u.var) = b ? VARIANT_TRUE : VARIANT_FALSE;
1148 static HRESULT get_binary_expr_values(exec_ctx_t *ctx, binary_expression_t *expr, jsexcept_t *ei, VARIANT *lval, VARIANT *rval)
1153 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1157 hres = exprval_to_value(ctx->parser->script, &exprval, ei, lval);
1158 exprval_release(&exprval);
1162 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1163 if(SUCCEEDED(hres)) {
1164 hres = exprval_to_value(ctx->parser->script, &exprval, ei, rval);
1165 exprval_release(&exprval);
1176 typedef HRESULT (*oper_t)(exec_ctx_t*,VARIANT*,VARIANT*,jsexcept_t*,VARIANT*);
1178 static HRESULT binary_expr_eval(exec_ctx_t *ctx, binary_expression_t *expr, oper_t oper, jsexcept_t *ei,
1181 VARIANT lval, rval, retv;
1184 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1188 hres = oper(ctx, &lval, &rval, ei, &retv);
1189 VariantClear(&lval);
1190 VariantClear(&rval);
1194 ret->type = EXPRVAL_VARIANT;
1199 /* ECMA-262 3rd Edition 11.13.2 */
1200 static HRESULT assign_oper_eval(exec_ctx_t *ctx, expression_t *lexpr, expression_t *rexpr, oper_t oper,
1201 jsexcept_t *ei, exprval_t *ret)
1203 VARIANT retv, lval, rval;
1204 exprval_t exprval, exprvalr;
1207 hres = expr_eval(ctx, lexpr, EXPR_NEWREF, ei, &exprval);
1211 hres = exprval_value(ctx->parser->script, &exprval, ei, &lval);
1212 if(SUCCEEDED(hres)) {
1213 hres = expr_eval(ctx, rexpr, 0, ei, &exprvalr);
1214 if(SUCCEEDED(hres)) {
1215 hres = exprval_value(ctx->parser->script, &exprvalr, ei, &rval);
1216 exprval_release(&exprvalr);
1218 if(SUCCEEDED(hres)) {
1219 hres = oper(ctx, &lval, &rval, ei, &retv);
1220 VariantClear(&rval);
1222 VariantClear(&lval);
1225 if(SUCCEEDED(hres)) {
1226 hres = put_value(ctx->parser->script, &exprval, &retv, ei);
1228 VariantClear(&retv);
1230 exprval_release(&exprval);
1235 ret->type = EXPRVAL_VARIANT;
1240 /* ECMA-262 3rd Edition 13 */
1241 HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1243 function_expression_t *expr = (function_expression_t*)_expr;
1250 hres = create_source_function(ctx->parser, expr->parameter_list, expr->source_elements, ctx->scope_chain,
1251 expr->src_str, expr->src_len, &dispex);
1255 V_VT(&var) = VT_DISPATCH;
1256 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(dispex);
1258 if(expr->identifier) {
1259 hres = jsdisp_propput_name(ctx->var_disp, expr->identifier, ctx->parser->script->lcid, &var, ei, NULL/*FIXME*/);
1261 jsdisp_release(dispex);
1266 ret->type = EXPRVAL_VARIANT;
1271 /* ECMA-262 3rd Edition 11.12 */
1272 HRESULT conditional_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1274 conditional_expression_t *expr = (conditional_expression_t*)_expr;
1281 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1285 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
1286 exprval_release(&exprval);
1290 return expr_eval(ctx, b ? expr->true_expression : expr->false_expression, flags, ei, ret);
1293 /* ECMA-262 3rd Edition 11.2.1 */
1294 HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1296 array_expression_t *expr = (array_expression_t*)_expr;
1298 VARIANT member, val;
1301 IDispatch *obj = NULL;
1306 hres = expr_eval(ctx, expr->member_expr, EXPR_NEWREF, ei, &exprval);
1310 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1311 exprval_release(&exprval);
1315 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
1316 if(SUCCEEDED(hres)) {
1317 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1318 exprval_release(&exprval);
1322 hres = to_object(ctx, &member, &obj);
1323 VariantClear(&member);
1324 if(SUCCEEDED(hres)) {
1325 hres = to_string(ctx->parser->script, &val, ei, &str);
1326 if(SUCCEEDED(hres)) {
1327 if(flags & EXPR_STRREF) {
1328 ret->type = EXPRVAL_NAMEREF;
1329 ret->u.nameref.disp = obj;
1330 ret->u.nameref.name = str;
1334 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1337 if(SUCCEEDED(hres)) {
1338 exprval_set_idref(ret, obj, id);
1339 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1344 IDispatch_Release(obj);
1350 /* ECMA-262 3rd Edition 11.2.1 */
1351 HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1353 member_expression_t *expr = (member_expression_t*)_expr;
1354 IDispatch *obj = NULL;
1363 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1367 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1368 exprval_release(&exprval);
1372 hres = to_object(ctx, &member, &obj);
1373 VariantClear(&member);
1377 str = SysAllocString(expr->identifier);
1378 if(flags & EXPR_STRREF) {
1379 ret->type = EXPRVAL_NAMEREF;
1380 ret->u.nameref.disp = obj;
1381 ret->u.nameref.name = str;
1385 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1387 if(SUCCEEDED(hres)) {
1388 exprval_set_idref(ret, obj, id);
1389 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1394 IDispatch_Release(obj);
1398 static void free_dp(DISPPARAMS *dp)
1402 for(i=0; i < dp->cArgs; i++)
1403 VariantClear(dp->rgvarg+i);
1404 heap_free(dp->rgvarg);
1407 static HRESULT args_to_param(exec_ctx_t *ctx, argument_t *args, jsexcept_t *ei, DISPPARAMS *dp)
1413 HRESULT hres = S_OK;
1415 memset(dp, 0, sizeof(*dp));
1419 for(iter = args; iter; iter = iter->next)
1422 vargs = heap_alloc_zero(cnt * sizeof(*vargs));
1424 return E_OUTOFMEMORY;
1426 for(i = cnt, iter = args; iter; iter = iter->next) {
1427 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
1431 hres = exprval_to_value(ctx->parser->script, &exprval, ei, vargs + (--i));
1432 exprval_release(&exprval);
1447 /* ECMA-262 3rd Edition 11.2.2 */
1448 HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1450 call_expression_t *expr = (call_expression_t*)_expr;
1452 VARIANT constr, var;
1458 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1462 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1464 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &constr);
1465 exprval_release(&exprval);
1469 if(V_VT(&constr) != VT_DISPATCH) {
1470 FIXME("throw TypeError\n");
1471 VariantClear(&constr);
1475 hres = disp_call(V_DISPATCH(&constr), DISPID_VALUE, ctx->parser->script->lcid,
1476 DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/);
1477 IDispatch_Release(V_DISPATCH(&constr));
1481 ret->type = EXPRVAL_VARIANT;
1486 /* ECMA-262 3rd Edition 11.2.3 */
1487 HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1489 call_expression_t *expr = (call_expression_t*)_expr;
1497 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1501 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1502 if(SUCCEEDED(hres)) {
1503 switch(exprval.type) {
1505 hres = disp_call(exprval.u.idref.disp, exprval.u.idref.id, ctx->parser->script->lcid, DISPATCH_METHOD,
1506 &dp, flags & EXPR_NOVAL ? NULL : &var, ei, NULL/*FIXME*/);
1507 if(flags & EXPR_NOVAL)
1508 V_VT(&var) = VT_EMPTY;
1511 FIXME("unimplemented type %d\n", V_VT(&func));
1518 exprval_release(&exprval);
1522 TRACE("= %s\n", debugstr_variant(&var));
1523 ret->type = EXPRVAL_VARIANT;
1528 /* ECMA-262 3rd Edition 11.1.1 */
1529 HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1533 ret->type = EXPRVAL_VARIANT;
1534 V_VT(&ret->u.var) = VT_DISPATCH;
1535 V_DISPATCH(&ret->u.var) = ctx->this_obj;
1536 IDispatch_AddRef(ctx->this_obj);
1540 /* ECMA-262 3rd Edition 10.1.4 */
1541 HRESULT identifier_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1543 identifier_expression_t *expr = (identifier_expression_t*)_expr;
1549 identifier = SysAllocString(expr->identifier);
1551 return E_OUTOFMEMORY;
1553 hres = identifier_eval(ctx, identifier, flags, ret);
1555 SysFreeString(identifier);
1559 /* ECMA-262 3rd Edition 7.8 */
1560 HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1562 literal_expression_t *expr = (literal_expression_t*)_expr;
1568 hres = literal_to_var(expr->literal, &var);
1572 ret->type = EXPRVAL_VARIANT;
1577 /* ECMA-262 3rd Edition 11.1.4 */
1578 HRESULT array_literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1580 array_literal_expression_t *expr = (array_literal_expression_t*)_expr;
1581 DWORD length = 0, i = 0;
1582 array_element_t *elem;
1590 for(elem = expr->element_list; elem; elem = elem->next)
1591 length += elem->elision+1;
1592 length += expr->length;
1594 hres = create_array(ctx->parser->script, length, &array);
1598 for(elem = expr->element_list; elem; elem = elem->next) {
1601 hres = expr_eval(ctx, elem->expr, 0, ei, &exprval);
1605 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1606 exprval_release(&exprval);
1610 hres = jsdisp_propput_idx(array, i, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1619 jsdisp_release(array);
1623 ret->type = EXPRVAL_VARIANT;
1624 V_VT(&ret->u.var) = VT_DISPATCH;
1625 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(array);
1629 /* ECMA-262 3rd Edition 11.1.5 */
1630 HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1632 property_value_expression_t *expr = (property_value_expression_t*)_expr;
1642 hres = create_object(ctx->parser->script, NULL, &obj);
1646 for(iter = expr->property_list; iter; iter = iter->next) {
1647 hres = literal_to_var(iter->name, &tmp);
1651 hres = to_string(ctx->parser->script, &tmp, ei, &name);
1656 hres = expr_eval(ctx, iter->value, 0, ei, &exprval);
1657 if(SUCCEEDED(hres)) {
1658 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1659 exprval_release(&exprval);
1660 if(SUCCEEDED(hres)) {
1661 hres = jsdisp_propput_name(obj, name, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1666 SysFreeString(name);
1672 jsdisp_release(obj);
1676 ret->type = EXPRVAL_VARIANT;
1677 V_VT(&ret->u.var) = VT_DISPATCH;
1678 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(obj);
1682 /* ECMA-262 3rd Edition 11.14 */
1683 HRESULT comma_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1685 binary_expression_t *expr = (binary_expression_t*)_expr;
1691 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1695 VariantClear(&lval);
1697 ret->type = EXPRVAL_VARIANT;
1702 /* ECMA-262 3rd Edition 11.11 */
1703 HRESULT logical_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1705 binary_expression_t *expr = (binary_expression_t*)_expr;
1713 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1717 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1718 exprval_release(&exprval);
1722 hres = to_boolean(&val, &b);
1723 if(SUCCEEDED(hres) && b) {
1724 ret->type = EXPRVAL_VARIANT;
1733 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1737 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1738 exprval_release(&exprval);
1742 ret->type = EXPRVAL_VARIANT;
1747 /* ECMA-262 3rd Edition 11.11 */
1748 HRESULT logical_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1750 binary_expression_t *expr = (binary_expression_t*)_expr;
1758 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1762 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1763 exprval_release(&exprval);
1767 hres = to_boolean(&val, &b);
1768 if(SUCCEEDED(hres) && !b) {
1769 ret->type = EXPRVAL_VARIANT;
1778 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1782 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1783 exprval_release(&exprval);
1787 ret->type = EXPRVAL_VARIANT;
1792 /* ECMA-262 3rd Edition 11.10 */
1793 static HRESULT bitor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1798 hres = to_int32(ctx->parser->script, lval, ei, &li);
1802 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1811 /* ECMA-262 3rd Edition 11.10 */
1812 HRESULT binary_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1814 binary_expression_t *expr = (binary_expression_t*)_expr;
1818 return binary_expr_eval(ctx, expr, bitor_eval, ei, ret);
1821 /* ECMA-262 3rd Edition 11.10 */
1822 static HRESULT xor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1827 hres = to_int32(ctx->parser->script, lval, ei, &li);
1831 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1840 /* ECMA-262 3rd Edition 11.10 */
1841 HRESULT binary_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1843 binary_expression_t *expr = (binary_expression_t*)_expr;
1847 return binary_expr_eval(ctx, expr, xor_eval, ei, ret);
1850 /* ECMA-262 3rd Edition 11.10 */
1851 static HRESULT bitand_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1856 hres = to_int32(ctx->parser->script, lval, ei, &li);
1860 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1869 /* ECMA-262 3rd Edition 11.10 */
1870 HRESULT binary_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1872 binary_expression_t *expr = (binary_expression_t*)_expr;
1876 return binary_expr_eval(ctx, expr, bitand_eval, ei, ret);
1879 /* ECMA-262 3rd Edition 11.8.6 */
1880 HRESULT instanceof_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1886 /* ECMA-262 3rd Edition 11.8.7 */
1887 HRESULT in_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1893 /* ECMA-262 3rd Edition 11.6.1 */
1894 static HRESULT add_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1899 hres = to_primitive(ctx->parser->script, lval, ei, &l);
1903 hres = to_primitive(ctx->parser->script, rval, ei, &r);
1909 if(V_VT(&l) == VT_BSTR || V_VT(&r) == VT_BSTR) {
1910 BSTR lstr = NULL, rstr = NULL;
1912 if(V_VT(&l) == VT_BSTR)
1915 hres = to_string(ctx->parser->script, &l, ei, &lstr);
1917 if(SUCCEEDED(hres)) {
1918 if(V_VT(&r) == VT_BSTR)
1921 hres = to_string(ctx->parser->script, &r, ei, &rstr);
1924 if(SUCCEEDED(hres)) {
1927 len1 = SysStringLen(lstr);
1928 len2 = SysStringLen(rstr);
1930 V_VT(retv) = VT_BSTR;
1931 V_BSTR(retv) = SysAllocStringLen(NULL, len1+len2);
1932 memcpy(V_BSTR(retv), lstr, len1*sizeof(WCHAR));
1933 memcpy(V_BSTR(retv)+len1, rstr, (len2+1)*sizeof(WCHAR));
1936 if(V_VT(&l) != VT_BSTR)
1937 SysFreeString(lstr);
1938 if(V_VT(&r) != VT_BSTR)
1939 SysFreeString(rstr);
1943 hres = to_number(ctx->parser->script, &l, ei, &nl);
1944 if(SUCCEEDED(hres)) {
1945 hres = to_number(ctx->parser->script, &r, ei, &nr);
1947 num_set_val(retv, num_val(&nl) + num_val(&nr));
1956 /* ECMA-262 3rd Edition 11.6.1 */
1957 HRESULT add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1959 binary_expression_t *expr = (binary_expression_t*)_expr;
1963 return binary_expr_eval(ctx, expr, add_eval, ei, ret);
1966 /* ECMA-262 3rd Edition 11.6.2 */
1967 static HRESULT sub_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1972 hres = to_number(ctx->parser->script, lval, ei, &lnum);
1976 hres = to_number(ctx->parser->script, rval, ei, &rnum);
1980 num_set_val(retv, num_val(&lnum) - num_val(&rnum));
1984 /* ECMA-262 3rd Edition 11.6.2 */
1985 HRESULT sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1987 binary_expression_t *expr = (binary_expression_t*)_expr;
1991 return binary_expr_eval(ctx, expr, sub_eval, ei, ret);
1994 /* ECMA-262 3rd Edition 11.5.1 */
1995 static HRESULT mul_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2000 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2004 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2008 num_set_val(retv, num_val(&lnum) * num_val(&rnum));
2012 /* ECMA-262 3rd Edition 11.5.1 */
2013 HRESULT mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2015 binary_expression_t *expr = (binary_expression_t*)_expr;
2019 return binary_expr_eval(ctx, expr, mul_eval, ei, ret);
2022 /* ECMA-262 3rd Edition 11.5.2 */
2023 static HRESULT div_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2028 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2032 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2036 num_set_val(retv, num_val(&lnum) / num_val(&rnum));
2040 /* ECMA-262 3rd Edition 11.5.2 */
2041 HRESULT div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2043 binary_expression_t *expr = (binary_expression_t*)_expr;
2047 return binary_expr_eval(ctx, expr, div_eval, ei, ret);
2050 /* ECMA-262 3rd Edition 11.5.3 */
2051 static HRESULT mod_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2056 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2060 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2064 num_set_val(retv, fmod(num_val(&lnum), num_val(&rnum)));
2068 /* ECMA-262 3rd Edition 11.5.3 */
2069 HRESULT mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2071 binary_expression_t *expr = (binary_expression_t*)_expr;
2075 return binary_expr_eval(ctx, expr, mod_eval, ei, ret);
2078 /* ECMA-262 3rd Edition 11.4.2 */
2079 HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2081 unary_expression_t *expr = (unary_expression_t*)_expr;
2082 VARIANT_BOOL b = VARIANT_FALSE;
2088 hres = expr_eval(ctx, expr->expression, EXPR_STRREF, ei, &exprval);
2092 switch(exprval.type) {
2093 case EXPRVAL_IDREF: {
2094 IDispatchEx *dispex;
2096 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2097 if(SUCCEEDED(hres)) {
2098 hres = IDispatchEx_DeleteMemberByDispID(dispex, exprval.u.idref.id);
2100 IDispatchEx_Release(dispex);
2104 case EXPRVAL_NAMEREF: {
2105 IDispatchEx *dispex;
2107 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2108 if(SUCCEEDED(hres)) {
2109 hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, fdexNameCaseSensitive);
2111 IDispatchEx_Release(dispex);
2116 FIXME("unsupported type %d\n", exprval.type);
2120 exprval_release(&exprval);
2124 return return_bool(ret, b);
2127 /* ECMA-262 3rd Edition 11.4.2 */
2128 HRESULT void_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2130 unary_expression_t *expr = (unary_expression_t*)_expr;
2137 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2141 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &tmp);
2142 exprval_release(&exprval);
2148 ret->type = EXPRVAL_VARIANT;
2149 V_VT(&ret->u.var) = VT_EMPTY;
2153 /* ECMA-262 3rd Edition 11.4.3 */
2154 HRESULT typeof_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2156 unary_expression_t *expr = (unary_expression_t*)_expr;
2162 static const WCHAR booleanW[] = {'b','o','o','l','e','a','n',0};
2163 static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
2164 static const WCHAR numberW[] = {'n','u','m','b','e','r',0};
2165 static const WCHAR objectW[] = {'o','b','j','e','c','t',0};
2166 static const WCHAR stringW[] = {'s','t','r','i','n','g',0};
2167 static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
2171 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2175 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2176 exprval_release(&exprval);
2180 switch(V_VT(&val)) {
2200 dispex = iface_to_jsdisp((IUnknown*)V_DISPATCH(&val));
2202 str = dispex->builtin_info->class == JSCLASS_FUNCTION ? functionW : objectW;
2203 IDispatchEx_Release(_IDispatchEx_(dispex));
2210 FIXME("unhandled vt %d\n", V_VT(&val));
2218 ret->type = EXPRVAL_VARIANT;
2219 V_VT(&ret->u.var) = VT_BSTR;
2220 V_BSTR(&ret->u.var) = SysAllocString(str);
2224 /* ECMA-262 3rd Edition 11.4.7 */
2225 HRESULT minus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2227 unary_expression_t *expr = (unary_expression_t*)_expr;
2234 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2238 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2239 exprval_release(&exprval);
2243 hres = to_number(ctx->parser->script, &val, ei, &num);
2248 ret->type = EXPRVAL_VARIANT;
2249 num_set_val(&ret->u.var, -num_val(&num));
2253 /* ECMA-262 3rd Edition 11.4.6 */
2254 HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2256 unary_expression_t *expr = (unary_expression_t*)_expr;
2263 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2267 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2268 exprval_release(&exprval);
2272 hres = to_number(ctx->parser->script, &val, ei, &num);
2276 ret->type = EXPRVAL_VARIANT;
2281 /* ECMA-262 3rd Edition 11.3.1 */
2282 HRESULT post_increment_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2284 unary_expression_t *expr = (unary_expression_t*)_expr;
2291 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2295 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2296 if(SUCCEEDED(hres)) {
2297 hres = to_number(ctx->parser->script, &val, ei, &num);
2301 if(SUCCEEDED(hres)) {
2303 num_set_val(&inc, num_val(&num)+1.0);
2304 hres = put_value(ctx->parser->script, &exprval, &inc, ei);
2307 exprval_release(&exprval);
2311 ret->type = EXPRVAL_VARIANT;
2316 /* ECMA-262 3rd Edition 11.3.2 */
2317 HRESULT post_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2319 unary_expression_t *expr = (unary_expression_t*)_expr;
2326 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2330 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2331 if(SUCCEEDED(hres)) {
2332 hres = to_number(ctx->parser->script, &val, ei, &num);
2336 if(SUCCEEDED(hres)) {
2338 num_set_val(&dec, num_val(&num)-1.0);
2339 hres = put_value(ctx->parser->script, &exprval, &dec, ei);
2342 exprval_release(&exprval);
2346 ret->type = EXPRVAL_VARIANT;
2351 /* ECMA-262 3rd Edition 11.4.4 */
2352 HRESULT pre_increment_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2354 unary_expression_t *expr = (unary_expression_t*)_expr;
2361 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2365 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2366 if(SUCCEEDED(hres)) {
2367 hres = to_number(ctx->parser->script, &val, ei, &num);
2371 if(SUCCEEDED(hres)) {
2372 num_set_val(&val, num_val(&num)+1.0);
2373 hres = put_value(ctx->parser->script, &exprval, &val, ei);
2376 exprval_release(&exprval);
2380 ret->type = EXPRVAL_VARIANT;
2385 /* ECMA-262 3rd Edition 11.4.5 */
2386 HRESULT pre_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2388 unary_expression_t *expr = (unary_expression_t*)_expr;
2395 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2399 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2400 if(SUCCEEDED(hres)) {
2401 hres = to_number(ctx->parser->script, &val, ei, &num);
2405 if(SUCCEEDED(hres)) {
2406 num_set_val(&val, num_val(&num)-1.0);
2407 hres = put_value(ctx->parser->script, &exprval, &val, ei);
2410 exprval_release(&exprval);
2414 ret->type = EXPRVAL_VARIANT;
2419 /* ECMA-262 3rd Edition 11.9.3 */
2420 static HRESULT equal_values(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, BOOL *ret)
2422 if(V_VT(lval) == V_VT(rval) || (is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))))
2423 return equal2_values(lval, rval, ret);
2425 /* FIXME: NULL disps should be handled in more general way */
2426 if(V_VT(lval) == VT_DISPATCH && !V_DISPATCH(lval)) {
2429 return equal_values(ctx, &v, rval, ei, ret);
2432 if(V_VT(rval) == VT_DISPATCH && !V_DISPATCH(rval)) {
2435 return equal_values(ctx, lval, &v, ei, ret);
2438 if((V_VT(lval) == VT_NULL && V_VT(rval) == VT_EMPTY) ||
2439 (V_VT(lval) == VT_EMPTY && V_VT(rval) == VT_NULL)) {
2444 if(V_VT(lval) == VT_BSTR && is_num_vt(V_VT(rval))) {
2448 hres = to_number(ctx->parser->script, lval, ei, &v);
2452 return equal_values(ctx, &v, rval, ei, ret);
2455 if(V_VT(rval) == VT_BSTR && is_num_vt(V_VT(lval))) {
2459 hres = to_number(ctx->parser->script, rval, ei, &v);
2463 return equal_values(ctx, lval, &v, ei, ret);
2466 if(V_VT(rval) == VT_BOOL) {
2470 V_I4(&v) = V_BOOL(rval) ? 1 : 0;
2471 return equal_values(ctx, lval, &v, ei, ret);
2474 if(V_VT(lval) == VT_BOOL) {
2478 V_I4(&v) = V_BOOL(lval) ? 1 : 0;
2479 return equal_values(ctx, &v, rval, ei, ret);
2483 if(V_VT(rval) == VT_DISPATCH && (V_VT(lval) == VT_BSTR || is_num_vt(V_VT(lval)))) {
2487 hres = to_primitive(ctx->parser->script, rval, ei, &v);
2491 hres = equal_values(ctx, lval, &v, ei, ret);
2498 if(V_VT(lval) == VT_DISPATCH && (V_VT(rval) == VT_BSTR || is_num_vt(V_VT(rval)))) {
2502 hres = to_primitive(ctx->parser->script, lval, ei, &v);
2506 hres = equal_values(ctx, &v, rval, ei, ret);
2517 /* ECMA-262 3rd Edition 11.9.1 */
2518 HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2520 binary_expression_t *expr = (binary_expression_t*)_expr;
2527 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2531 hres = equal_values(ctx, &rval, &lval, ei, &b);
2535 return return_bool(ret, b);
2538 /* ECMA-262 3rd Edition 11.9.4 */
2539 HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2541 binary_expression_t *expr = (binary_expression_t*)_expr;
2548 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2552 hres = equal2_values(&rval, &lval, &b);
2556 return return_bool(ret, b);
2559 /* ECMA-262 3rd Edition 11.9.2 */
2560 HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2562 binary_expression_t *expr = (binary_expression_t*)_expr;
2569 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2573 hres = equal_values(ctx, &lval, &rval, ei, &b);
2577 return return_bool(ret, !b);
2580 /* ECMA-262 3rd Edition 11.9.5 */
2581 HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2583 binary_expression_t *expr = (binary_expression_t*)_expr;
2590 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2594 hres = equal2_values(&lval, &rval, &b);
2598 return return_bool(ret, !b);
2601 /* ECMA-262 3rd Edition 11.8.5 */
2602 static HRESULT less_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, BOOL *ret)
2604 VARIANT l, r, ln, rn;
2607 hres = to_primitive(ctx->parser->script, lval, ei, &l);
2611 hres = to_primitive(ctx->parser->script, rval, ei, &r);
2617 if(V_VT(&l) == VT_BSTR && V_VT(&r) == VT_BSTR) {
2618 *ret = strcmpW(V_BSTR(&l), V_BSTR(&r)) < 0;
2619 SysFreeString(V_BSTR(&l));
2620 SysFreeString(V_BSTR(&r));
2624 hres = to_number(ctx->parser->script, &l, ei, &ln);
2627 hres = to_number(ctx->parser->script, &r, ei, &rn);
2632 if(V_VT(&ln) == VT_I4 && V_VT(&rn) == VT_I4)
2633 *ret = V_I4(&ln) < V_I4(&rn);
2635 *ret = num_val(&ln) < num_val(&rn);
2640 /* ECMA-262 3rd Edition 11.8.1 */
2641 HRESULT less_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2643 binary_expression_t *expr = (binary_expression_t*)_expr;
2650 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2654 hres = less_eval(ctx, &lval, &rval, ei, &b);
2655 VariantClear(&lval);
2656 VariantClear(&rval);
2660 return return_bool(ret, b);
2663 /* ECMA-262 3rd Edition 11.8.3 */
2664 HRESULT lesseq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2666 binary_expression_t *expr = (binary_expression_t*)_expr;
2673 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2677 hres = less_eval(ctx, &rval, &lval, ei, &b);
2678 VariantClear(&lval);
2679 VariantClear(&rval);
2683 return return_bool(ret, !b);
2686 /* ECMA-262 3rd Edition 11.8.2 */
2687 HRESULT greater_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2689 binary_expression_t *expr = (binary_expression_t*)_expr;
2696 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2700 hres = less_eval(ctx, &rval, &lval, ei, &b);
2701 VariantClear(&lval);
2702 VariantClear(&rval);
2706 return return_bool(ret, b);
2709 /* ECMA-262 3rd Edition 11.8.4 */
2710 HRESULT greatereq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2712 binary_expression_t *expr = (binary_expression_t*)_expr;
2719 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2723 hres = less_eval(ctx, &lval, &rval, ei, &b);
2724 VariantClear(&lval);
2725 VariantClear(&rval);
2729 return return_bool(ret, !b);
2732 /* ECMA-262 3rd Edition 11.4.8 */
2733 HRESULT binary_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2735 unary_expression_t *expr = (unary_expression_t*)_expr;
2743 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2747 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2748 exprval_release(&exprval);
2752 hres = to_int32(ctx->parser->script, &val, ei, &i);
2756 ret->type = EXPRVAL_VARIANT;
2757 V_VT(&ret->u.var) = VT_I4;
2758 V_I4(&ret->u.var) = ~i;
2762 /* ECMA-262 3rd Edition 11.4.9 */
2763 HRESULT logical_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2765 unary_expression_t *expr = (unary_expression_t*)_expr;
2772 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2776 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
2777 exprval_release(&exprval);
2781 return return_bool(ret, !b);
2784 /* ECMA-262 3rd Edition 11.7.1 */
2785 static HRESULT lshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2791 hres = to_int32(ctx->parser->script, lval, ei, &li);
2795 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2800 V_I4(retv) = li << (ri&0x1f);
2804 /* ECMA-262 3rd Edition 11.7.1 */
2805 HRESULT left_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2807 binary_expression_t *expr = (binary_expression_t*)_expr;
2811 return binary_expr_eval(ctx, expr, lshift_eval, ei, ret);
2814 /* ECMA-262 3rd Edition 11.7.2 */
2815 static HRESULT rshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2821 hres = to_int32(ctx->parser->script, lval, ei, &li);
2825 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2830 V_I4(retv) = li >> (ri&0x1f);
2834 /* ECMA-262 3rd Edition 11.7.2 */
2835 HRESULT right_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2837 binary_expression_t *expr = (binary_expression_t*)_expr;
2841 return binary_expr_eval(ctx, expr, rshift_eval, ei, ret);
2844 /* ECMA-262 3rd Edition 11.7.3 */
2845 static HRESULT rshift2_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2850 hres = to_uint32(ctx->parser->script, lval, ei, &li);
2854 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2859 V_I4(retv) = li >> (ri&0x1f);
2863 /* ECMA-262 3rd Edition 11.7.3 */
2864 HRESULT right2_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2866 binary_expression_t *expr = (binary_expression_t*)_expr;
2870 return binary_expr_eval(ctx, expr, rshift2_eval, ei, ret);
2873 /* ECMA-262 3rd Edition 11.13.1 */
2874 HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2876 binary_expression_t *expr = (binary_expression_t*)_expr;
2877 exprval_t exprval, exprvalr;
2883 hres = expr_eval(ctx, expr->expression1, EXPR_NEWREF, ei, &exprval);
2887 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprvalr);
2888 if(SUCCEEDED(hres)) {
2889 hres = exprval_to_value(ctx->parser->script, &exprvalr, ei, &rval);
2890 exprval_release(&exprvalr);
2894 hres = put_value(ctx->parser->script, &exprval, &rval, ei);
2896 exprval_release(&exprval);
2900 ret->type = EXPRVAL_VARIANT;
2905 /* ECMA-262 3rd Edition 11.13.2 */
2906 HRESULT assign_lshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2908 binary_expression_t *expr = (binary_expression_t*)_expr;
2912 return assign_oper_eval(ctx, expr->expression1, expr->expression2, lshift_eval, ei, ret);
2915 /* ECMA-262 3rd Edition 11.13.2 */
2916 HRESULT assign_rshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2918 binary_expression_t *expr = (binary_expression_t*)_expr;
2922 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift_eval, ei, ret);
2925 /* ECMA-262 3rd Edition 11.13.2 */
2926 HRESULT assign_rrshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2928 binary_expression_t *expr = (binary_expression_t*)_expr;
2932 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift2_eval, ei, ret);
2935 /* ECMA-262 3rd Edition 11.13.2 */
2936 HRESULT assign_add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2938 binary_expression_t *expr = (binary_expression_t*)_expr;
2942 return assign_oper_eval(ctx, expr->expression1, expr->expression2, add_eval, ei, ret);
2945 /* ECMA-262 3rd Edition 11.13.2 */
2946 HRESULT assign_sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2948 binary_expression_t *expr = (binary_expression_t*)_expr;
2952 return assign_oper_eval(ctx, expr->expression1, expr->expression2, sub_eval, ei, ret);
2955 /* ECMA-262 3rd Edition 11.13.2 */
2956 HRESULT assign_mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2958 binary_expression_t *expr = (binary_expression_t*)_expr;
2962 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mul_eval, ei, ret);
2965 /* ECMA-262 3rd Edition 11.13.2 */
2966 HRESULT assign_div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2968 binary_expression_t *expr = (binary_expression_t*)_expr;
2972 return assign_oper_eval(ctx, expr->expression1, expr->expression2, div_eval, ei, ret);
2975 /* ECMA-262 3rd Edition 11.13.2 */
2976 HRESULT assign_mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2978 binary_expression_t *expr = (binary_expression_t*)_expr;
2982 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mod_eval, ei, ret);
2985 /* ECMA-262 3rd Edition 11.13.2 */
2986 HRESULT assign_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2988 binary_expression_t *expr = (binary_expression_t*)_expr;
2992 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitand_eval, ei, ret);
2995 /* ECMA-262 3rd Edition 11.13.2 */
2996 HRESULT assign_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2998 binary_expression_t *expr = (binary_expression_t*)_expr;
3002 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitor_eval, ei, ret);
3005 /* ECMA-262 3rd Edition 11.13.2 */
3006 HRESULT assign_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3008 binary_expression_t *expr = (binary_expression_t*)_expr;
3012 return assign_oper_eval(ctx, expr->expression1, expr->expression2, xor_eval, ei, ret);