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;
184 IDispatch_AddRef(this_obj);
185 ctx->this_obj = this_obj;
187 IDispatchEx_AddRef(_IDispatchEx_(var_disp));
188 ctx->var_disp = var_disp;
192 ctx->scope_chain = scope;
199 void exec_release(exec_ctx_t *ctx)
205 scope_release(ctx->scope_chain);
207 IDispatchEx_Release(_IDispatchEx_(ctx->var_disp));
209 IDispatch_Release(ctx->this_obj);
213 static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id)
218 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
220 TRACE("unsing IDispatch\n");
223 return IDispatch_GetIDsOfNames(disp, &IID_NULL, &name, 1, 0, id);
227 hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id);
228 IDispatchEx_Release(dispex);
232 /* ECMA-262 3rd Edition 8.7.2 */
233 static HRESULT put_value(script_ctx_t *ctx, exprval_t *ref, VARIANT *v, jsexcept_t *ei)
235 if(ref->type != EXPRVAL_IDREF) {
236 FIXME("throw ReferemceError\n");
240 return disp_propput(ref->u.idref.disp, ref->u.idref.id, ctx->lcid, v, ei, NULL/*FIXME*/);
243 static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
245 IObjectIdentity *identity;
246 IUnknown *unk1, *unk2;
254 hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
258 hres = IDispatch_QueryInterface(disp2, &IID_IUnknown, (void**)&unk2);
260 IUnknown_Release(unk1);
267 hres = IUnknown_QueryInterface(unk1, &IID_IObjectIdentity, (void**)&identity);
268 if(SUCCEEDED(hres)) {
269 hres = IObjectIdentity_IsEqualObject(identity, unk2);
270 IObjectIdentity_Release(identity);
277 IUnknown_Release(unk1);
278 IUnknown_Release(unk2);
282 /* ECMA-262 3rd Edition 11.9.6 */
283 static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret)
287 if(V_VT(lval) != V_VT(rval)) {
288 if(is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))) {
289 *ret = num_val(lval) == num_val(rval);
303 *ret = V_I4(lval) == V_I4(rval);
306 *ret = V_R8(lval) == V_R8(rval);
309 *ret = !strcmpW(V_BSTR(lval), V_BSTR(rval));
312 return disp_cmp(V_DISPATCH(lval), V_DISPATCH(rval), ret);
314 *ret = !V_BOOL(lval) == !V_BOOL(rval);
317 FIXME("unimplemented vt %d\n", V_VT(lval));
324 static HRESULT literal_to_var(literal_t *literal, VARIANT *v)
326 V_VT(v) = literal->vt;
333 V_I4(v) = literal->u.lval;
336 V_R8(v) = literal->u.dval;
339 V_BSTR(v) = SysAllocString(literal->u.wstr);
342 V_BOOL(v) = literal->u.bval;
345 IDispatch_AddRef(literal->u.disp);
346 V_DISPATCH(v) = literal->u.disp;
349 ERR("wrong type %d\n", V_VT(v));
356 HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
358 script_ctx_t *script = parser->script;
359 function_declaration_t *func;
360 parser_ctx_t *prev_parser;
364 exec_ctx_t *prev_ctx;
368 for(func = source->functions; func; func = func->next) {
369 DispatchEx *func_obj;
372 hres = create_source_function(parser, func->expr->parameter_list, func->expr->source_elements,
373 ctx->scope_chain, func->expr->src_str, func->expr->src_len, &func_obj);
377 V_VT(&var) = VT_DISPATCH;
378 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(func_obj);
379 hres = jsdisp_propput_name(ctx->var_disp, func->expr->identifier, script->lcid, &var, ei, NULL);
380 jsdisp_release(func_obj);
385 for(var = source->variables; var; var = var->next) {
388 hres = jsdisp_get_id(ctx->var_disp, var->identifier, fdexNameEnsure, &id);
393 prev_ctx = script->exec_ctx;
394 script->exec_ctx = ctx;
396 prev_parser = ctx->parser;
397 ctx->parser = parser;
399 V_VT(&val) = VT_EMPTY;
400 memset(&rt, 0, sizeof(rt));
403 for(stat = source->statement; stat; stat = stat->next) {
404 hres = stat_eval(ctx, stat, &rt, &tmp);
410 if(rt.type != RT_NORMAL)
414 script->exec_ctx = prev_ctx;
415 ctx->parser = prev_parser;
417 if(rt.type != RT_NORMAL && rt.type != RT_RETURN) {
418 FIXME("wrong rt %d\n", rt.type);
435 /* ECMA-262 3rd Edition 10.1.4 */
436 static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, exprval_t *ret)
438 scope_chain_t *scope;
443 TRACE("%s\n", debugstr_w(identifier));
445 for(scope = ctx->scope_chain; scope; scope = scope->next) {
446 hres = jsdisp_get_id(scope->obj, identifier, 0, &id);
452 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(scope->obj), id);
456 hres = jsdisp_get_id(ctx->parser->script->global, identifier, 0, &id);
457 if(SUCCEEDED(hres)) {
458 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->global), id);
462 for(item = ctx->parser->script->named_items; item; item = item->next) {
463 if((item->flags & SCRIPTITEM_ISVISIBLE) && !strcmpW(item->name, identifier)) {
467 if(!ctx->parser->script->site)
470 hres = IActiveScriptSite_GetItemInfo(ctx->parser->script->site, identifier,
471 SCRIPTINFO_IUNKNOWN, &unk, NULL);
473 WARN("GetItemInfo failed: %08x\n", hres);
477 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
478 IUnknown_Release(unk);
480 WARN("object does not implement IDispatch\n");
485 ret->type = EXPRVAL_VARIANT;
486 V_VT(&ret->u.var) = VT_DISPATCH;
487 V_DISPATCH(&ret->u.var) = item->disp;
488 IDispatch_AddRef(item->disp);
493 for(item = ctx->parser->script->named_items; item; item = item->next) {
494 if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
495 hres = disp_get_id(item->disp, identifier, 0, &id);
502 exprval_set_idref(ret, item->disp, id);
506 hres = jsdisp_get_id(ctx->parser->script->script_disp, identifier, 0, &id);
507 if(SUCCEEDED(hres)) {
508 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->script_disp), id);
512 if(flags & EXPR_NEWREF) {
513 hres = jsdisp_get_id(ctx->var_disp, identifier, fdexNameEnsure, &id);
517 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->var_disp), id);
521 WARN("Could not find identifier %s\n", debugstr_w(identifier));
525 /* ECMA-262 3rd Edition 12.1 */
526 HRESULT block_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
528 block_statement_t *stat = (block_statement_t*)_stat;
535 V_VT(&val) = VT_EMPTY;
536 for(iter = stat->stat_list; iter; iter = iter->next) {
537 hres = stat_eval(ctx, iter, rt, &tmp);
543 if(rt->type != RT_NORMAL)
556 /* ECMA-262 3rd Edition 12.2 */
557 static HRESULT variable_list_eval(exec_ctx_t *ctx, variable_declaration_t *var_list, jsexcept_t *ei)
559 variable_declaration_t *iter;
562 for(iter = var_list; iter; iter = iter->next) {
569 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
573 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
574 exprval_release(&exprval);
578 hres = jsdisp_propput_name(ctx->var_disp, iter->identifier, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
587 /* ECMA-262 3rd Edition 12.2 */
588 HRESULT var_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
590 var_statement_t *stat = (var_statement_t*)_stat;
595 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
599 V_VT(ret) = VT_EMPTY;
603 /* ECMA-262 3rd Edition 12.3 */
604 HRESULT empty_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
608 V_VT(ret) = VT_EMPTY;
612 /* ECMA-262 3rd Edition 12.4 */
613 HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
615 expression_statement_t *stat = (expression_statement_t*)_stat;
622 hres = expr_eval(ctx, stat->expr, EXPR_NOVAL, &rt->ei, &exprval);
626 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
627 exprval_release(&exprval);
632 TRACE("= %s\n", debugstr_variant(ret));
636 /* ECMA-262 3rd Edition 12.5 */
637 HRESULT if_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
639 if_statement_t *stat = (if_statement_t*)_stat;
646 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
650 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
651 exprval_release(&exprval);
656 hres = stat_eval(ctx, stat->if_stat, rt, ret);
657 else if(stat->else_stat)
658 hres = stat_eval(ctx, stat->else_stat, rt, ret);
660 V_VT(ret) = VT_EMPTY;
665 /* ECMA-262 3rd Edition 12.6.2 */
666 HRESULT while_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
668 while_statement_t *stat = (while_statement_t*)_stat;
677 V_VT(&val) = VT_EMPTY;
678 test_expr = !stat->do_while;
682 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
686 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
687 exprval_release(&exprval);
688 if(FAILED(hres) || !b)
694 hres = stat_eval(ctx, stat->statement, rt, &tmp);
701 if(rt->type == RT_CONTINUE)
702 rt->type = RT_NORMAL;
703 if(rt->type != RT_NORMAL)
712 if(rt->type == RT_BREAK)
713 rt->type = RT_NORMAL;
719 /* ECMA-262 3rd Edition 12.6.3 */
720 HRESULT for_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
722 for_statement_t *stat = (for_statement_t*)_stat;
723 VARIANT val, tmp, retv;
730 if(stat->variable_list) {
731 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
734 }else if(stat->begin_expr) {
735 hres = expr_eval(ctx, stat->begin_expr, EXPR_NEWREF, &rt->ei, &exprval);
739 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
740 exprval_release(&exprval);
747 V_VT(&retv) = VT_EMPTY;
751 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
755 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
756 exprval_release(&exprval);
757 if(FAILED(hres) || !b)
761 hres = stat_eval(ctx, stat->statement, rt, &tmp);
768 if(rt->type == RT_CONTINUE)
769 rt->type = RT_NORMAL;
770 else if(rt->type != RT_NORMAL)
774 hres = expr_eval(ctx, stat->end_expr, 0, &rt->ei, &exprval);
778 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
779 exprval_release(&exprval);
792 if(rt->type == RT_BREAK)
793 rt->type = RT_NORMAL;
799 /* ECMA-262 3rd Edition 12.6.4 */
800 HRESULT forin_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
802 forin_statement_t *stat = (forin_statement_t*)_stat;
803 VARIANT val, name, retv, tmp;
804 DISPID id = DISPID_STARTENUM;
805 BSTR str, identifier = NULL;
813 hres = variable_list_eval(ctx, stat->variable, &rt->ei);
818 hres = expr_eval(ctx, stat->in_expr, EXPR_NEWREF, &rt->ei, &exprval);
822 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
823 exprval_release(&exprval);
827 if(V_VT(&val) != VT_DISPATCH) {
828 TRACE("in vt %d\n", V_VT(&val));
830 V_VT(ret) = VT_EMPTY;
834 hres = IDispatch_QueryInterface(V_DISPATCH(&val), &IID_IDispatchEx, (void**)&in_obj);
835 IDispatch_Release(V_DISPATCH(&val));
837 FIXME("Object doesn't support IDispatchEx\n");
841 V_VT(&retv) = VT_EMPTY;
844 identifier = SysAllocString(stat->variable->identifier);
847 hres = IDispatchEx_GetNextDispID(in_obj, fdexEnumDefault, id, &id);
848 if(FAILED(hres) || hres == S_FALSE)
851 hres = IDispatchEx_GetMemberName(in_obj, id, &str);
855 TRACE("iter %s\n", debugstr_w(str));
858 hres = identifier_eval(ctx, identifier, 0, &exprval);
860 hres = expr_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval);
861 if(SUCCEEDED(hres)) {
862 V_VT(&name) = VT_BSTR;
864 hres = put_value(ctx->parser->script, &exprval, &name, &rt->ei);
865 exprval_release(&exprval);
871 hres = stat_eval(ctx, stat->statement, rt, &tmp);
878 if(rt->type == RT_CONTINUE)
879 rt->type = RT_NORMAL;
880 else if(rt->type != RT_NORMAL)
884 SysFreeString(identifier);
885 IDispatchEx_Release(in_obj);
891 if(rt->type == RT_BREAK)
892 rt->type = RT_NORMAL;
898 /* ECMA-262 3rd Edition 12.7 */
899 HRESULT continue_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
901 branch_statement_t *stat = (branch_statement_t*)_stat;
905 if(stat->identifier) {
906 FIXME("indentifier not implemented\n");
910 rt->type = RT_CONTINUE;
911 V_VT(ret) = VT_EMPTY;
915 /* ECMA-262 3rd Edition 12.8 */
916 HRESULT break_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
918 branch_statement_t *stat = (branch_statement_t*)_stat;
922 if(stat->identifier) {
923 FIXME("indentifier not implemented\n");
928 V_VT(ret) = VT_EMPTY;
932 /* ECMA-262 3rd Edition 12.9 */
933 HRESULT return_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
935 expression_statement_t *stat = (expression_statement_t*)_stat;
943 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
947 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, ret);
948 exprval_release(&exprval);
952 V_VT(ret) = VT_EMPTY;
955 TRACE("= %s\n", debugstr_variant(ret));
956 rt->type = RT_RETURN;
960 /* ECMA-262 3rd Edition 12.10 */
961 HRESULT with_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
963 with_statement_t *stat = (with_statement_t*)_stat;
972 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
976 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
977 exprval_release(&exprval);
981 hres = to_object(ctx, &val, &disp);
986 obj = iface_to_jsdisp((IUnknown*)disp);
987 IDispatch_Release(disp);
989 FIXME("disp id not jsdisp\n");
993 hres = scope_push(ctx->scope_chain, obj, &ctx->scope_chain);
998 hres = stat_eval(ctx, stat->statement, rt, ret);
1000 scope_pop(&ctx->scope_chain);
1004 /* ECMA-262 3rd Edition 12.12 */
1005 HRESULT labelled_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
1011 /* ECMA-262 3rd Edition 12.13 */
1012 HRESULT switch_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1014 switch_statement_t *stat = (switch_statement_t*)_stat;
1015 case_clausule_t *iter, *default_clausule = NULL;
1016 statement_t *stat_iter;
1024 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
1028 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
1029 exprval_release(&exprval);
1033 for(iter = stat->case_list; iter; iter = iter->next) {
1035 default_clausule = iter;
1039 hres = expr_eval(ctx, iter->expr, 0, &rt->ei, &exprval);
1043 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &cval);
1044 exprval_release(&exprval);
1048 hres = equal2_values(&val, &cval, &b);
1049 VariantClear(&cval);
1050 if(FAILED(hres) || b)
1059 iter = default_clausule;
1061 V_VT(&val) = VT_EMPTY;
1065 for(stat_iter = iter->stat; stat_iter; stat_iter = stat_iter->next) {
1066 hres = stat_eval(ctx, stat_iter, rt, &tmp);
1073 if(rt->type != RT_NORMAL)
1083 if(rt->type == RT_BREAK)
1084 rt->type = RT_NORMAL;
1090 /* ECMA-262 3rd Edition 12.13 */
1091 HRESULT throw_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1093 expression_statement_t *stat = (expression_statement_t*)_stat;
1100 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
1104 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
1105 exprval_release(&exprval);
1110 return DISP_E_EXCEPTION;
1113 /* ECMA-262 3rd Edition 12.14 */
1114 static HRESULT catch_eval(exec_ctx_t *ctx, catch_block_t *block, return_type_t *rt, VARIANT *ret)
1116 DispatchEx *var_disp;
1121 memset(&rt->ei, 0, sizeof(jsexcept_t));
1123 hres = create_dispex(ctx->parser->script, NULL, NULL, &var_disp);
1124 if(SUCCEEDED(hres)) {
1125 hres = jsdisp_propput_name(var_disp, block->identifier, ctx->parser->script->lcid,
1126 &ex, &rt->ei, NULL/*FIXME*/);
1127 if(SUCCEEDED(hres)) {
1128 hres = scope_push(ctx->scope_chain, var_disp, &ctx->scope_chain);
1129 if(SUCCEEDED(hres)) {
1130 hres = stat_eval(ctx, block->statement, rt, &val);
1131 scope_pop(&ctx->scope_chain);
1135 jsdisp_release(var_disp);
1146 /* ECMA-262 3rd Edition 12.14 */
1147 HRESULT try_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1149 try_statement_t *stat = (try_statement_t*)_stat;
1155 hres = stat_eval(ctx, stat->try_statement, rt, &val);
1157 TRACE("EXCEPTION\n");
1158 if(!stat->catch_block)
1161 hres = catch_eval(ctx, stat->catch_block, rt, &val);
1166 if(stat->finally_statement) {
1168 hres = stat_eval(ctx, stat->finally_statement, rt, &val);
1177 static HRESULT return_bool(exprval_t *ret, DWORD b)
1179 ret->type = EXPRVAL_VARIANT;
1180 V_VT(&ret->u.var) = VT_BOOL;
1181 V_BOOL(&ret->u.var) = b ? VARIANT_TRUE : VARIANT_FALSE;
1186 static HRESULT get_binary_expr_values(exec_ctx_t *ctx, binary_expression_t *expr, jsexcept_t *ei, VARIANT *lval, VARIANT *rval)
1191 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1195 hres = exprval_to_value(ctx->parser->script, &exprval, ei, lval);
1196 exprval_release(&exprval);
1200 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1201 if(SUCCEEDED(hres)) {
1202 hres = exprval_to_value(ctx->parser->script, &exprval, ei, rval);
1203 exprval_release(&exprval);
1214 typedef HRESULT (*oper_t)(exec_ctx_t*,VARIANT*,VARIANT*,jsexcept_t*,VARIANT*);
1216 static HRESULT binary_expr_eval(exec_ctx_t *ctx, binary_expression_t *expr, oper_t oper, jsexcept_t *ei,
1219 VARIANT lval, rval, retv;
1222 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1226 hres = oper(ctx, &lval, &rval, ei, &retv);
1227 VariantClear(&lval);
1228 VariantClear(&rval);
1232 ret->type = EXPRVAL_VARIANT;
1237 /* ECMA-262 3rd Edition 11.13.2 */
1238 static HRESULT assign_oper_eval(exec_ctx_t *ctx, expression_t *lexpr, expression_t *rexpr, oper_t oper,
1239 jsexcept_t *ei, exprval_t *ret)
1241 VARIANT retv, lval, rval;
1242 exprval_t exprval, exprvalr;
1245 hres = expr_eval(ctx, lexpr, EXPR_NEWREF, ei, &exprval);
1249 hres = exprval_value(ctx->parser->script, &exprval, ei, &lval);
1250 if(SUCCEEDED(hres)) {
1251 hres = expr_eval(ctx, rexpr, 0, ei, &exprvalr);
1252 if(SUCCEEDED(hres)) {
1253 hres = exprval_value(ctx->parser->script, &exprvalr, ei, &rval);
1254 exprval_release(&exprvalr);
1256 if(SUCCEEDED(hres)) {
1257 hres = oper(ctx, &lval, &rval, ei, &retv);
1258 VariantClear(&rval);
1260 VariantClear(&lval);
1263 if(SUCCEEDED(hres)) {
1264 hres = put_value(ctx->parser->script, &exprval, &retv, ei);
1266 VariantClear(&retv);
1268 exprval_release(&exprval);
1273 ret->type = EXPRVAL_VARIANT;
1278 /* ECMA-262 3rd Edition 13 */
1279 HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1281 function_expression_t *expr = (function_expression_t*)_expr;
1287 if(expr->identifier) {
1288 hres = jsdisp_propget_name(ctx->var_disp, expr->identifier, ctx->parser->script->lcid, &var, ei, NULL/*FIXME*/);
1294 hres = create_source_function(ctx->parser, expr->parameter_list, expr->source_elements, ctx->scope_chain,
1295 expr->src_str, expr->src_len, &dispex);
1299 V_VT(&var) = VT_DISPATCH;
1300 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(dispex);
1303 ret->type = EXPRVAL_VARIANT;
1308 /* ECMA-262 3rd Edition 11.12 */
1309 HRESULT conditional_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1311 conditional_expression_t *expr = (conditional_expression_t*)_expr;
1318 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1322 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
1323 exprval_release(&exprval);
1327 return expr_eval(ctx, b ? expr->true_expression : expr->false_expression, flags, ei, ret);
1330 /* ECMA-262 3rd Edition 11.2.1 */
1331 HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1333 array_expression_t *expr = (array_expression_t*)_expr;
1335 VARIANT member, val;
1338 IDispatch *obj = NULL;
1343 hres = expr_eval(ctx, expr->member_expr, EXPR_NEWREF, ei, &exprval);
1347 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1348 exprval_release(&exprval);
1352 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
1353 if(SUCCEEDED(hres)) {
1354 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1355 exprval_release(&exprval);
1359 hres = to_object(ctx, &member, &obj);
1360 VariantClear(&member);
1361 if(SUCCEEDED(hres)) {
1362 hres = to_string(ctx->parser->script, &val, ei, &str);
1363 if(SUCCEEDED(hres)) {
1364 if(flags & EXPR_STRREF) {
1365 ret->type = EXPRVAL_NAMEREF;
1366 ret->u.nameref.disp = obj;
1367 ret->u.nameref.name = str;
1371 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1374 if(SUCCEEDED(hres)) {
1375 exprval_set_idref(ret, obj, id);
1376 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1381 IDispatch_Release(obj);
1387 /* ECMA-262 3rd Edition 11.2.1 */
1388 HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1390 member_expression_t *expr = (member_expression_t*)_expr;
1391 IDispatch *obj = NULL;
1400 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1404 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1405 exprval_release(&exprval);
1409 hres = to_object(ctx, &member, &obj);
1410 VariantClear(&member);
1414 str = SysAllocString(expr->identifier);
1415 if(flags & EXPR_STRREF) {
1416 ret->type = EXPRVAL_NAMEREF;
1417 ret->u.nameref.disp = obj;
1418 ret->u.nameref.name = str;
1422 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1424 if(SUCCEEDED(hres)) {
1425 exprval_set_idref(ret, obj, id);
1426 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1431 IDispatch_Release(obj);
1435 static void free_dp(DISPPARAMS *dp)
1439 for(i=0; i < dp->cArgs; i++)
1440 VariantClear(dp->rgvarg+i);
1441 heap_free(dp->rgvarg);
1444 static HRESULT args_to_param(exec_ctx_t *ctx, argument_t *args, jsexcept_t *ei, DISPPARAMS *dp)
1450 HRESULT hres = S_OK;
1452 memset(dp, 0, sizeof(*dp));
1456 for(iter = args; iter; iter = iter->next)
1459 vargs = heap_alloc_zero(cnt * sizeof(*vargs));
1461 return E_OUTOFMEMORY;
1463 for(i = cnt, iter = args; iter; iter = iter->next) {
1464 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
1468 hres = exprval_to_value(ctx->parser->script, &exprval, ei, vargs + (--i));
1469 exprval_release(&exprval);
1484 /* ECMA-262 3rd Edition 11.2.2 */
1485 HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1487 call_expression_t *expr = (call_expression_t*)_expr;
1489 VARIANT constr, var;
1495 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1499 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1501 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &constr);
1502 exprval_release(&exprval);
1506 if(V_VT(&constr) != VT_DISPATCH) {
1507 FIXME("throw TypeError\n");
1508 VariantClear(&constr);
1512 hres = disp_call(V_DISPATCH(&constr), DISPID_VALUE, ctx->parser->script->lcid,
1513 DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/);
1514 IDispatch_Release(V_DISPATCH(&constr));
1518 ret->type = EXPRVAL_VARIANT;
1523 /* ECMA-262 3rd Edition 11.2.3 */
1524 HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1526 call_expression_t *expr = (call_expression_t*)_expr;
1534 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1538 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1539 if(SUCCEEDED(hres)) {
1540 switch(exprval.type) {
1541 case EXPRVAL_VARIANT:
1542 if(V_VT(&exprval.u.var) != VT_DISPATCH)
1543 return throw_type_error(ctx->var_disp->ctx, ei, IDS_NO_PROPERTY, NULL);
1545 hres = disp_call(V_DISPATCH(&exprval.u.var), DISPID_VALUE, ctx->parser->script->lcid,
1546 DISPATCH_METHOD, &dp, flags & EXPR_NOVAL ? NULL : &var, ei, NULL/*FIXME*/);
1549 hres = disp_call(exprval.u.idref.disp, exprval.u.idref.id, ctx->parser->script->lcid,
1550 DISPATCH_METHOD, &dp, flags & EXPR_NOVAL ? NULL : &var, ei, NULL/*FIXME*/);
1553 FIXME("unimplemented type %d\n", exprval.type);
1560 exprval_release(&exprval);
1564 ret->type = EXPRVAL_VARIANT;
1565 if(flags & EXPR_NOVAL) {
1566 V_VT(&ret->u.var) = VT_EMPTY;
1568 TRACE("= %s\n", debugstr_variant(&var));
1574 /* ECMA-262 3rd Edition 11.1.1 */
1575 HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1579 ret->type = EXPRVAL_VARIANT;
1580 V_VT(&ret->u.var) = VT_DISPATCH;
1581 V_DISPATCH(&ret->u.var) = ctx->this_obj;
1582 IDispatch_AddRef(ctx->this_obj);
1586 /* ECMA-262 3rd Edition 10.1.4 */
1587 HRESULT identifier_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1589 identifier_expression_t *expr = (identifier_expression_t*)_expr;
1595 identifier = SysAllocString(expr->identifier);
1597 return E_OUTOFMEMORY;
1599 hres = identifier_eval(ctx, identifier, flags, ret);
1601 SysFreeString(identifier);
1605 /* ECMA-262 3rd Edition 7.8 */
1606 HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1608 literal_expression_t *expr = (literal_expression_t*)_expr;
1614 hres = literal_to_var(expr->literal, &var);
1618 ret->type = EXPRVAL_VARIANT;
1623 /* ECMA-262 3rd Edition 11.1.4 */
1624 HRESULT array_literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1626 array_literal_expression_t *expr = (array_literal_expression_t*)_expr;
1627 DWORD length = 0, i = 0;
1628 array_element_t *elem;
1636 for(elem = expr->element_list; elem; elem = elem->next)
1637 length += elem->elision+1;
1638 length += expr->length;
1640 hres = create_array(ctx->parser->script, length, &array);
1644 for(elem = expr->element_list; elem; elem = elem->next) {
1647 hres = expr_eval(ctx, elem->expr, 0, ei, &exprval);
1651 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1652 exprval_release(&exprval);
1656 hres = jsdisp_propput_idx(array, i, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1665 jsdisp_release(array);
1669 ret->type = EXPRVAL_VARIANT;
1670 V_VT(&ret->u.var) = VT_DISPATCH;
1671 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(array);
1675 /* ECMA-262 3rd Edition 11.1.5 */
1676 HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1678 property_value_expression_t *expr = (property_value_expression_t*)_expr;
1688 hres = create_object(ctx->parser->script, NULL, &obj);
1692 for(iter = expr->property_list; iter; iter = iter->next) {
1693 hres = literal_to_var(iter->name, &tmp);
1697 hres = to_string(ctx->parser->script, &tmp, ei, &name);
1702 hres = expr_eval(ctx, iter->value, 0, ei, &exprval);
1703 if(SUCCEEDED(hres)) {
1704 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1705 exprval_release(&exprval);
1706 if(SUCCEEDED(hres)) {
1707 hres = jsdisp_propput_name(obj, name, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1712 SysFreeString(name);
1718 jsdisp_release(obj);
1722 ret->type = EXPRVAL_VARIANT;
1723 V_VT(&ret->u.var) = VT_DISPATCH;
1724 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(obj);
1728 /* ECMA-262 3rd Edition 11.14 */
1729 HRESULT comma_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1731 binary_expression_t *expr = (binary_expression_t*)_expr;
1737 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1741 VariantClear(&lval);
1743 ret->type = EXPRVAL_VARIANT;
1748 /* ECMA-262 3rd Edition 11.11 */
1749 HRESULT logical_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1751 binary_expression_t *expr = (binary_expression_t*)_expr;
1759 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1763 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1764 exprval_release(&exprval);
1768 hres = to_boolean(&val, &b);
1769 if(SUCCEEDED(hres) && b) {
1770 ret->type = EXPRVAL_VARIANT;
1779 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1783 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1784 exprval_release(&exprval);
1788 ret->type = EXPRVAL_VARIANT;
1793 /* ECMA-262 3rd Edition 11.11 */
1794 HRESULT logical_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1796 binary_expression_t *expr = (binary_expression_t*)_expr;
1804 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1808 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1809 exprval_release(&exprval);
1813 hres = to_boolean(&val, &b);
1814 if(SUCCEEDED(hres) && !b) {
1815 ret->type = EXPRVAL_VARIANT;
1824 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1828 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1829 exprval_release(&exprval);
1833 ret->type = EXPRVAL_VARIANT;
1838 /* ECMA-262 3rd Edition 11.10 */
1839 static HRESULT bitor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1844 hres = to_int32(ctx->parser->script, lval, ei, &li);
1848 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1857 /* ECMA-262 3rd Edition 11.10 */
1858 HRESULT binary_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1860 binary_expression_t *expr = (binary_expression_t*)_expr;
1864 return binary_expr_eval(ctx, expr, bitor_eval, ei, ret);
1867 /* ECMA-262 3rd Edition 11.10 */
1868 static HRESULT xor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1873 hres = to_int32(ctx->parser->script, lval, ei, &li);
1877 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1886 /* ECMA-262 3rd Edition 11.10 */
1887 HRESULT binary_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1889 binary_expression_t *expr = (binary_expression_t*)_expr;
1893 return binary_expr_eval(ctx, expr, xor_eval, ei, ret);
1896 /* ECMA-262 3rd Edition 11.10 */
1897 static HRESULT bitand_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1902 hres = to_int32(ctx->parser->script, lval, ei, &li);
1906 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1915 /* ECMA-262 3rd Edition 11.10 */
1916 HRESULT binary_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1918 binary_expression_t *expr = (binary_expression_t*)_expr;
1922 return binary_expr_eval(ctx, expr, bitand_eval, ei, ret);
1925 /* ECMA-262 3rd Edition 11.8.6 */
1926 HRESULT instanceof_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1932 /* ECMA-262 3rd Edition 11.8.7 */
1933 HRESULT in_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1939 /* ECMA-262 3rd Edition 11.6.1 */
1940 static HRESULT add_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1945 hres = to_primitive(ctx->parser->script, lval, ei, &l, NO_HINT);
1949 hres = to_primitive(ctx->parser->script, rval, ei, &r, NO_HINT);
1955 if(V_VT(&l) == VT_BSTR || V_VT(&r) == VT_BSTR) {
1956 BSTR lstr = NULL, rstr = NULL;
1958 if(V_VT(&l) == VT_BSTR)
1961 hres = to_string(ctx->parser->script, &l, ei, &lstr);
1963 if(SUCCEEDED(hres)) {
1964 if(V_VT(&r) == VT_BSTR)
1967 hres = to_string(ctx->parser->script, &r, ei, &rstr);
1970 if(SUCCEEDED(hres)) {
1973 len1 = SysStringLen(lstr);
1974 len2 = SysStringLen(rstr);
1976 V_VT(retv) = VT_BSTR;
1977 V_BSTR(retv) = SysAllocStringLen(NULL, len1+len2);
1978 memcpy(V_BSTR(retv), lstr, len1*sizeof(WCHAR));
1979 memcpy(V_BSTR(retv)+len1, rstr, (len2+1)*sizeof(WCHAR));
1982 if(V_VT(&l) != VT_BSTR)
1983 SysFreeString(lstr);
1984 if(V_VT(&r) != VT_BSTR)
1985 SysFreeString(rstr);
1989 hres = to_number(ctx->parser->script, &l, ei, &nl);
1990 if(SUCCEEDED(hres)) {
1991 hres = to_number(ctx->parser->script, &r, ei, &nr);
1993 num_set_val(retv, num_val(&nl) + num_val(&nr));
2002 /* ECMA-262 3rd Edition 11.6.1 */
2003 HRESULT add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2005 binary_expression_t *expr = (binary_expression_t*)_expr;
2009 return binary_expr_eval(ctx, expr, add_eval, ei, ret);
2012 /* ECMA-262 3rd Edition 11.6.2 */
2013 static HRESULT sub_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2018 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2022 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2026 num_set_val(retv, num_val(&lnum) - num_val(&rnum));
2030 /* ECMA-262 3rd Edition 11.6.2 */
2031 HRESULT sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2033 binary_expression_t *expr = (binary_expression_t*)_expr;
2037 return binary_expr_eval(ctx, expr, sub_eval, ei, ret);
2040 /* ECMA-262 3rd Edition 11.5.1 */
2041 static HRESULT mul_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2046 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2050 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2054 num_set_val(retv, num_val(&lnum) * num_val(&rnum));
2058 /* ECMA-262 3rd Edition 11.5.1 */
2059 HRESULT mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2061 binary_expression_t *expr = (binary_expression_t*)_expr;
2065 return binary_expr_eval(ctx, expr, mul_eval, ei, ret);
2068 /* ECMA-262 3rd Edition 11.5.2 */
2069 static HRESULT div_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2074 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2078 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2082 num_set_val(retv, num_val(&lnum) / num_val(&rnum));
2086 /* ECMA-262 3rd Edition 11.5.2 */
2087 HRESULT div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2089 binary_expression_t *expr = (binary_expression_t*)_expr;
2093 return binary_expr_eval(ctx, expr, div_eval, ei, ret);
2096 /* ECMA-262 3rd Edition 11.5.3 */
2097 static HRESULT mod_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2102 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2106 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2110 num_set_val(retv, fmod(num_val(&lnum), num_val(&rnum)));
2114 /* ECMA-262 3rd Edition 11.5.3 */
2115 HRESULT mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2117 binary_expression_t *expr = (binary_expression_t*)_expr;
2121 return binary_expr_eval(ctx, expr, mod_eval, ei, ret);
2124 /* ECMA-262 3rd Edition 11.4.2 */
2125 HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2127 unary_expression_t *expr = (unary_expression_t*)_expr;
2128 VARIANT_BOOL b = VARIANT_FALSE;
2134 hres = expr_eval(ctx, expr->expression, EXPR_STRREF, ei, &exprval);
2138 switch(exprval.type) {
2139 case EXPRVAL_IDREF: {
2140 IDispatchEx *dispex;
2142 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2143 if(SUCCEEDED(hres)) {
2144 hres = IDispatchEx_DeleteMemberByDispID(dispex, exprval.u.idref.id);
2146 IDispatchEx_Release(dispex);
2150 case EXPRVAL_NAMEREF: {
2151 IDispatchEx *dispex;
2153 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2154 if(SUCCEEDED(hres)) {
2155 hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, fdexNameCaseSensitive);
2157 IDispatchEx_Release(dispex);
2162 FIXME("unsupported type %d\n", exprval.type);
2166 exprval_release(&exprval);
2170 return return_bool(ret, b);
2173 /* ECMA-262 3rd Edition 11.4.2 */
2174 HRESULT void_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2176 unary_expression_t *expr = (unary_expression_t*)_expr;
2183 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2187 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &tmp);
2188 exprval_release(&exprval);
2194 ret->type = EXPRVAL_VARIANT;
2195 V_VT(&ret->u.var) = VT_EMPTY;
2199 /* ECMA-262 3rd Edition 11.4.3 */
2200 HRESULT typeof_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2202 unary_expression_t *expr = (unary_expression_t*)_expr;
2208 static const WCHAR booleanW[] = {'b','o','o','l','e','a','n',0};
2209 static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
2210 static const WCHAR numberW[] = {'n','u','m','b','e','r',0};
2211 static const WCHAR objectW[] = {'o','b','j','e','c','t',0};
2212 static const WCHAR stringW[] = {'s','t','r','i','n','g',0};
2213 static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
2217 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2221 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2222 exprval_release(&exprval);
2226 switch(V_VT(&val)) {
2246 dispex = iface_to_jsdisp((IUnknown*)V_DISPATCH(&val));
2248 str = dispex->builtin_info->class == JSCLASS_FUNCTION ? functionW : objectW;
2249 IDispatchEx_Release(_IDispatchEx_(dispex));
2256 FIXME("unhandled vt %d\n", V_VT(&val));
2263 ret->type = EXPRVAL_VARIANT;
2264 V_VT(&ret->u.var) = VT_BSTR;
2265 V_BSTR(&ret->u.var) = SysAllocString(str);
2269 /* ECMA-262 3rd Edition 11.4.7 */
2270 HRESULT minus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2272 unary_expression_t *expr = (unary_expression_t*)_expr;
2279 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2283 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2284 exprval_release(&exprval);
2288 hres = to_number(ctx->parser->script, &val, ei, &num);
2293 ret->type = EXPRVAL_VARIANT;
2294 num_set_val(&ret->u.var, -num_val(&num));
2298 /* ECMA-262 3rd Edition 11.4.6 */
2299 HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2301 unary_expression_t *expr = (unary_expression_t*)_expr;
2308 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2312 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2313 exprval_release(&exprval);
2317 hres = to_number(ctx->parser->script, &val, ei, &num);
2321 ret->type = EXPRVAL_VARIANT;
2326 /* ECMA-262 3rd Edition 11.3.1 */
2327 HRESULT post_increment_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2329 unary_expression_t *expr = (unary_expression_t*)_expr;
2336 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2340 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2341 if(SUCCEEDED(hres)) {
2342 hres = to_number(ctx->parser->script, &val, ei, &num);
2346 if(SUCCEEDED(hres)) {
2348 num_set_val(&inc, num_val(&num)+1.0);
2349 hres = put_value(ctx->parser->script, &exprval, &inc, ei);
2352 exprval_release(&exprval);
2356 ret->type = EXPRVAL_VARIANT;
2361 /* ECMA-262 3rd Edition 11.3.2 */
2362 HRESULT post_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2364 unary_expression_t *expr = (unary_expression_t*)_expr;
2371 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2375 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2376 if(SUCCEEDED(hres)) {
2377 hres = to_number(ctx->parser->script, &val, ei, &num);
2381 if(SUCCEEDED(hres)) {
2383 num_set_val(&dec, num_val(&num)-1.0);
2384 hres = put_value(ctx->parser->script, &exprval, &dec, ei);
2387 exprval_release(&exprval);
2391 ret->type = EXPRVAL_VARIANT;
2396 /* ECMA-262 3rd Edition 11.4.4 */
2397 HRESULT pre_increment_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2399 unary_expression_t *expr = (unary_expression_t*)_expr;
2406 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2410 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2411 if(SUCCEEDED(hres)) {
2412 hres = to_number(ctx->parser->script, &val, ei, &num);
2416 if(SUCCEEDED(hres)) {
2417 num_set_val(&val, num_val(&num)+1.0);
2418 hres = put_value(ctx->parser->script, &exprval, &val, ei);
2421 exprval_release(&exprval);
2425 ret->type = EXPRVAL_VARIANT;
2430 /* ECMA-262 3rd Edition 11.4.5 */
2431 HRESULT pre_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2433 unary_expression_t *expr = (unary_expression_t*)_expr;
2440 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2444 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2445 if(SUCCEEDED(hres)) {
2446 hres = to_number(ctx->parser->script, &val, ei, &num);
2450 if(SUCCEEDED(hres)) {
2451 num_set_val(&val, num_val(&num)-1.0);
2452 hres = put_value(ctx->parser->script, &exprval, &val, ei);
2455 exprval_release(&exprval);
2459 ret->type = EXPRVAL_VARIANT;
2464 /* ECMA-262 3rd Edition 11.9.3 */
2465 static HRESULT equal_values(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, BOOL *ret)
2467 if(V_VT(lval) == V_VT(rval) || (is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))))
2468 return equal2_values(lval, rval, ret);
2470 /* FIXME: NULL disps should be handled in more general way */
2471 if(V_VT(lval) == VT_DISPATCH && !V_DISPATCH(lval)) {
2474 return equal_values(ctx, &v, rval, ei, ret);
2477 if(V_VT(rval) == VT_DISPATCH && !V_DISPATCH(rval)) {
2480 return equal_values(ctx, lval, &v, ei, ret);
2483 if((V_VT(lval) == VT_NULL && V_VT(rval) == VT_EMPTY) ||
2484 (V_VT(lval) == VT_EMPTY && V_VT(rval) == VT_NULL)) {
2489 if(V_VT(lval) == VT_BSTR && is_num_vt(V_VT(rval))) {
2493 hres = to_number(ctx->parser->script, lval, ei, &v);
2497 return equal_values(ctx, &v, rval, ei, ret);
2500 if(V_VT(rval) == VT_BSTR && is_num_vt(V_VT(lval))) {
2504 hres = to_number(ctx->parser->script, rval, ei, &v);
2508 return equal_values(ctx, lval, &v, ei, ret);
2511 if(V_VT(rval) == VT_BOOL) {
2515 V_I4(&v) = V_BOOL(rval) ? 1 : 0;
2516 return equal_values(ctx, lval, &v, ei, ret);
2519 if(V_VT(lval) == VT_BOOL) {
2523 V_I4(&v) = V_BOOL(lval) ? 1 : 0;
2524 return equal_values(ctx, &v, rval, ei, ret);
2528 if(V_VT(rval) == VT_DISPATCH && (V_VT(lval) == VT_BSTR || is_num_vt(V_VT(lval)))) {
2532 hres = to_primitive(ctx->parser->script, rval, ei, &v, NO_HINT);
2536 hres = equal_values(ctx, lval, &v, ei, ret);
2543 if(V_VT(lval) == VT_DISPATCH && (V_VT(rval) == VT_BSTR || is_num_vt(V_VT(rval)))) {
2547 hres = to_primitive(ctx->parser->script, lval, ei, &v, NO_HINT);
2551 hres = equal_values(ctx, &v, rval, ei, ret);
2562 /* ECMA-262 3rd Edition 11.9.1 */
2563 HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2565 binary_expression_t *expr = (binary_expression_t*)_expr;
2572 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2576 hres = equal_values(ctx, &rval, &lval, ei, &b);
2580 return return_bool(ret, b);
2583 /* ECMA-262 3rd Edition 11.9.4 */
2584 HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2586 binary_expression_t *expr = (binary_expression_t*)_expr;
2593 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2597 hres = equal2_values(&rval, &lval, &b);
2601 return return_bool(ret, b);
2604 /* ECMA-262 3rd Edition 11.9.2 */
2605 HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2607 binary_expression_t *expr = (binary_expression_t*)_expr;
2614 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2618 hres = equal_values(ctx, &lval, &rval, ei, &b);
2622 return return_bool(ret, !b);
2625 /* ECMA-262 3rd Edition 11.9.5 */
2626 HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2628 binary_expression_t *expr = (binary_expression_t*)_expr;
2635 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2639 hres = equal2_values(&lval, &rval, &b);
2643 return return_bool(ret, !b);
2646 /* ECMA-262 3rd Edition 11.8.5 */
2647 static HRESULT less_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, BOOL greater, jsexcept_t *ei, BOOL *ret)
2649 VARIANT l, r, ln, rn;
2652 hres = to_primitive(ctx->parser->script, lval, ei, &l, NO_HINT);
2656 hres = to_primitive(ctx->parser->script, rval, ei, &r, NO_HINT);
2662 if(V_VT(&l) == VT_BSTR && V_VT(&r) == VT_BSTR) {
2663 *ret = (strcmpW(V_BSTR(&l), V_BSTR(&r)) < 0) ^ greater;
2664 SysFreeString(V_BSTR(&l));
2665 SysFreeString(V_BSTR(&r));
2669 hres = to_number(ctx->parser->script, &l, ei, &ln);
2672 hres = to_number(ctx->parser->script, &r, ei, &rn);
2677 if(V_VT(&ln) == VT_I4 && V_VT(&rn) == VT_I4) {
2678 *ret = (V_I4(&ln) < V_I4(&rn)) ^ greater;
2680 DOUBLE ld = num_val(&ln);
2681 DOUBLE rd = num_val(&rn);
2683 *ret = !isnan(ld) && !isnan(rd) && ((ld < rd) ^ greater);
2689 /* ECMA-262 3rd Edition 11.8.1 */
2690 HRESULT less_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2692 binary_expression_t *expr = (binary_expression_t*)_expr;
2699 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2703 hres = less_eval(ctx, &lval, &rval, FALSE, ei, &b);
2704 VariantClear(&lval);
2705 VariantClear(&rval);
2709 return return_bool(ret, b);
2712 /* ECMA-262 3rd Edition 11.8.3 */
2713 HRESULT lesseq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2715 binary_expression_t *expr = (binary_expression_t*)_expr;
2722 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2726 hres = less_eval(ctx, &rval, &lval, TRUE, ei, &b);
2727 VariantClear(&lval);
2728 VariantClear(&rval);
2732 return return_bool(ret, b);
2735 /* ECMA-262 3rd Edition 11.8.2 */
2736 HRESULT greater_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2738 binary_expression_t *expr = (binary_expression_t*)_expr;
2745 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2749 hres = less_eval(ctx, &rval, &lval, FALSE, ei, &b);
2750 VariantClear(&lval);
2751 VariantClear(&rval);
2755 return return_bool(ret, b);
2758 /* ECMA-262 3rd Edition 11.8.4 */
2759 HRESULT greatereq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2761 binary_expression_t *expr = (binary_expression_t*)_expr;
2768 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2772 hres = less_eval(ctx, &lval, &rval, TRUE, ei, &b);
2773 VariantClear(&lval);
2774 VariantClear(&rval);
2778 return return_bool(ret, b);
2781 /* ECMA-262 3rd Edition 11.4.8 */
2782 HRESULT binary_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2784 unary_expression_t *expr = (unary_expression_t*)_expr;
2792 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2796 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2797 exprval_release(&exprval);
2801 hres = to_int32(ctx->parser->script, &val, ei, &i);
2805 ret->type = EXPRVAL_VARIANT;
2806 V_VT(&ret->u.var) = VT_I4;
2807 V_I4(&ret->u.var) = ~i;
2811 /* ECMA-262 3rd Edition 11.4.9 */
2812 HRESULT logical_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2814 unary_expression_t *expr = (unary_expression_t*)_expr;
2821 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2825 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
2826 exprval_release(&exprval);
2830 return return_bool(ret, !b);
2833 /* ECMA-262 3rd Edition 11.7.1 */
2834 static HRESULT lshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2840 hres = to_int32(ctx->parser->script, lval, ei, &li);
2844 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2849 V_I4(retv) = li << (ri&0x1f);
2853 /* ECMA-262 3rd Edition 11.7.1 */
2854 HRESULT left_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2856 binary_expression_t *expr = (binary_expression_t*)_expr;
2860 return binary_expr_eval(ctx, expr, lshift_eval, ei, ret);
2863 /* ECMA-262 3rd Edition 11.7.2 */
2864 static HRESULT rshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2870 hres = to_int32(ctx->parser->script, lval, ei, &li);
2874 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2879 V_I4(retv) = li >> (ri&0x1f);
2883 /* ECMA-262 3rd Edition 11.7.2 */
2884 HRESULT right_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2886 binary_expression_t *expr = (binary_expression_t*)_expr;
2890 return binary_expr_eval(ctx, expr, rshift_eval, ei, ret);
2893 /* ECMA-262 3rd Edition 11.7.3 */
2894 static HRESULT rshift2_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2899 hres = to_uint32(ctx->parser->script, lval, ei, &li);
2903 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2908 V_I4(retv) = li >> (ri&0x1f);
2912 /* ECMA-262 3rd Edition 11.7.3 */
2913 HRESULT right2_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2915 binary_expression_t *expr = (binary_expression_t*)_expr;
2919 return binary_expr_eval(ctx, expr, rshift2_eval, ei, ret);
2922 /* ECMA-262 3rd Edition 11.13.1 */
2923 HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2925 binary_expression_t *expr = (binary_expression_t*)_expr;
2926 exprval_t exprval, exprvalr;
2932 hres = expr_eval(ctx, expr->expression1, EXPR_NEWREF, ei, &exprval);
2936 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprvalr);
2937 if(SUCCEEDED(hres)) {
2938 hres = exprval_to_value(ctx->parser->script, &exprvalr, ei, &rval);
2939 exprval_release(&exprvalr);
2943 hres = put_value(ctx->parser->script, &exprval, &rval, ei);
2945 exprval_release(&exprval);
2949 ret->type = EXPRVAL_VARIANT;
2954 /* ECMA-262 3rd Edition 11.13.2 */
2955 HRESULT assign_lshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2957 binary_expression_t *expr = (binary_expression_t*)_expr;
2961 return assign_oper_eval(ctx, expr->expression1, expr->expression2, lshift_eval, ei, ret);
2964 /* ECMA-262 3rd Edition 11.13.2 */
2965 HRESULT assign_rshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2967 binary_expression_t *expr = (binary_expression_t*)_expr;
2971 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift_eval, ei, ret);
2974 /* ECMA-262 3rd Edition 11.13.2 */
2975 HRESULT assign_rrshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2977 binary_expression_t *expr = (binary_expression_t*)_expr;
2981 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift2_eval, ei, ret);
2984 /* ECMA-262 3rd Edition 11.13.2 */
2985 HRESULT assign_add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2987 binary_expression_t *expr = (binary_expression_t*)_expr;
2991 return assign_oper_eval(ctx, expr->expression1, expr->expression2, add_eval, ei, ret);
2994 /* ECMA-262 3rd Edition 11.13.2 */
2995 HRESULT assign_sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2997 binary_expression_t *expr = (binary_expression_t*)_expr;
3001 return assign_oper_eval(ctx, expr->expression1, expr->expression2, sub_eval, ei, ret);
3004 /* ECMA-262 3rd Edition 11.13.2 */
3005 HRESULT assign_mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3007 binary_expression_t *expr = (binary_expression_t*)_expr;
3011 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mul_eval, ei, ret);
3014 /* ECMA-262 3rd Edition 11.13.2 */
3015 HRESULT assign_div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3017 binary_expression_t *expr = (binary_expression_t*)_expr;
3021 return assign_oper_eval(ctx, expr->expression1, expr->expression2, div_eval, ei, ret);
3024 /* ECMA-262 3rd Edition 11.13.2 */
3025 HRESULT assign_mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3027 binary_expression_t *expr = (binary_expression_t*)_expr;
3031 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mod_eval, ei, ret);
3034 /* ECMA-262 3rd Edition 11.13.2 */
3035 HRESULT assign_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3037 binary_expression_t *expr = (binary_expression_t*)_expr;
3041 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitand_eval, ei, ret);
3044 /* ECMA-262 3rd Edition 11.13.2 */
3045 HRESULT assign_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3047 binary_expression_t *expr = (binary_expression_t*)_expr;
3051 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitor_eval, ei, ret);
3054 /* ECMA-262 3rd Edition 11.13.2 */
3055 HRESULT assign_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3057 binary_expression_t *expr = (binary_expression_t*)_expr;
3061 return assign_oper_eval(ctx, expr->expression1, expr->expression2, xor_eval, ei, ret);