2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/port.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(jscript);
31 #define EXPR_NOVAL 0x0001
32 #define EXPR_NEWREF 0x0002
33 #define EXPR_STRREF 0x0004
35 static inline HRESULT stat_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
37 return stat->eval(ctx, stat, rt, ret);
40 static inline HRESULT expr_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
42 return _expr->eval(ctx, _expr, flags, ei, ret);
45 static void exprval_release(exprval_t *val)
49 if(V_VT(&val->u.var) != VT_EMPTY)
50 VariantClear(&val->u.var);
54 IDispatch_Release(val->u.idref.disp);
57 if(val->u.nameref.disp)
58 IDispatch_Release(val->u.nameref.disp);
59 SysFreeString(val->u.nameref.name);
63 /* ECMA-262 3rd Edition 8.7.1 */
64 static HRESULT exprval_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
70 return VariantCopy(ret, &val->u.var);
72 if(!val->u.idref.disp) {
73 FIXME("throw ReferenceError\n");
77 return disp_propget(val->u.idref.disp, val->u.idref.id, ctx->lcid, ret, ei, NULL/*FIXME*/);
79 ERR("type %d\n", val->type);
84 static HRESULT exprval_to_value(script_ctx_t *ctx, exprval_t *val, jsexcept_t *ei, VARIANT *ret)
86 if(val->type == EXPRVAL_VARIANT) {
88 V_VT(&val->u.var) = VT_EMPTY;
92 return exprval_value(ctx, val, ei, ret);
95 static HRESULT exprval_to_boolean(script_ctx_t *ctx, exprval_t *exprval, jsexcept_t *ei, VARIANT_BOOL *b)
97 if(exprval->type != EXPRVAL_VARIANT) {
101 hres = exprval_to_value(ctx, exprval, ei, &val);
105 hres = to_boolean(&val, b);
110 return to_boolean(&exprval->u.var, b);
113 static void exprval_init(exprval_t *val)
115 val->type = EXPRVAL_VARIANT;
116 V_VT(&val->u.var) = VT_EMPTY;
119 static void exprval_set_idref(exprval_t *val, IDispatch *disp, DISPID id)
121 val->type = EXPRVAL_IDREF;
122 val->u.idref.disp = disp;
123 val->u.idref.id = id;
126 IDispatch_AddRef(disp);
129 HRESULT scope_push(scope_chain_t *scope, DispatchEx *obj, scope_chain_t **ret)
131 scope_chain_t *new_scope;
133 new_scope = heap_alloc(sizeof(scope_chain_t));
135 return E_OUTOFMEMORY;
139 IDispatchEx_AddRef(_IDispatchEx_(obj));
140 new_scope->obj = obj;
144 new_scope->next = scope;
146 new_scope->next = NULL;
153 static void scope_pop(scope_chain_t **scope)
162 void scope_release(scope_chain_t *scope)
168 scope_release(scope->next);
170 IDispatchEx_Release(_IDispatchEx_(scope->obj));
174 HRESULT create_exec_ctx(IDispatch *this_obj, DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t **ret)
178 ctx = heap_alloc_zero(sizeof(exec_ctx_t));
180 return E_OUTOFMEMORY;
182 IDispatch_AddRef(this_obj);
183 ctx->this_obj = this_obj;
185 IDispatchEx_AddRef(_IDispatchEx_(var_disp));
186 ctx->var_disp = var_disp;
190 ctx->scope_chain = scope;
197 void exec_release(exec_ctx_t *ctx)
203 scope_release(ctx->scope_chain);
205 IDispatchEx_Release(_IDispatchEx_(ctx->var_disp));
207 IDispatch_Release(ctx->this_obj);
211 static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id)
216 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
218 TRACE("unsing IDispatch\n");
221 return IDispatch_GetIDsOfNames(disp, &IID_NULL, &name, 1, 0, id);
225 hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id);
226 IDispatchEx_Release(dispex);
230 /* ECMA-262 3rd Edition 8.7.2 */
231 static HRESULT put_value(script_ctx_t *ctx, exprval_t *ref, VARIANT *v, jsexcept_t *ei)
233 if(ref->type != EXPRVAL_IDREF) {
234 FIXME("throw ReferemceError\n");
238 return disp_propput(ref->u.idref.disp, ref->u.idref.id, ctx->lcid, v, ei, NULL/*FIXME*/);
241 static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
243 IObjectIdentity *identity;
244 IUnknown *unk1, *unk2;
252 hres = IDispatch_QueryInterface(disp1, &IID_IUnknown, (void**)&unk1);
256 hres = IDispatch_QueryInterface(disp2, &IID_IUnknown, (void**)&unk2);
258 IUnknown_Release(unk1);
265 hres = IUnknown_QueryInterface(unk1, &IID_IObjectIdentity, (void**)&identity);
266 if(SUCCEEDED(hres)) {
267 hres = IObjectIdentity_IsEqualObject(identity, unk2);
268 IObjectIdentity_Release(identity);
275 IUnknown_Release(unk1);
276 IUnknown_Release(unk2);
280 /* ECMA-262 3rd Edition 11.9.6 */
281 static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret)
285 if(V_VT(lval) != V_VT(rval)) {
286 if(is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))) {
287 *ret = num_val(lval) == num_val(rval);
301 *ret = V_I4(lval) == V_I4(rval);
304 *ret = V_R8(lval) == V_R8(rval);
307 *ret = !strcmpW(V_BSTR(lval), V_BSTR(rval));
310 return disp_cmp(V_DISPATCH(lval), V_DISPATCH(rval), ret);
312 *ret = !V_BOOL(lval) == !V_BOOL(rval);
315 FIXME("unimplemented vt %d\n", V_VT(lval));
322 static HRESULT literal_to_var(literal_t *literal, VARIANT *v)
324 V_VT(v) = literal->vt;
331 V_I4(v) = literal->u.lval;
334 V_R8(v) = literal->u.dval;
337 V_BSTR(v) = SysAllocString(literal->u.wstr);
340 V_BOOL(v) = literal->u.bval;
343 IDispatch_AddRef(literal->u.disp);
344 V_DISPATCH(v) = literal->u.disp;
347 ERR("wrong type %d\n", V_VT(v));
354 HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv)
356 script_ctx_t *script = parser->script;
357 function_declaration_t *func;
358 parser_ctx_t *prev_parser;
362 exec_ctx_t *prev_ctx;
366 for(func = source->functions; func; func = func->next) {
367 DispatchEx *func_obj;
370 hres = create_source_function(parser, func->expr->parameter_list, func->expr->source_elements,
371 ctx->scope_chain, func->expr->src_str, func->expr->src_len, &func_obj);
375 V_VT(&var) = VT_DISPATCH;
376 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(func_obj);
377 hres = jsdisp_propput_name(ctx->var_disp, func->expr->identifier, script->lcid, &var, ei, NULL);
378 jsdisp_release(func_obj);
383 for(var = source->variables; var; var = var->next) {
386 hres = jsdisp_get_id(ctx->var_disp, var->identifier, fdexNameEnsure, &id);
391 prev_ctx = script->exec_ctx;
392 script->exec_ctx = ctx;
394 prev_parser = ctx->parser;
395 ctx->parser = parser;
397 V_VT(&val) = VT_EMPTY;
398 memset(&rt, 0, sizeof(rt));
401 for(stat = source->statement; stat; stat = stat->next) {
402 hres = stat_eval(ctx, stat, &rt, &tmp);
408 if(rt.type != RT_NORMAL)
412 script->exec_ctx = prev_ctx;
413 ctx->parser = prev_parser;
415 if(rt.type != RT_NORMAL && rt.type != RT_RETURN) {
416 FIXME("wrong rt %d\n", rt.type);
433 /* ECMA-262 3rd Edition 10.1.4 */
434 static HRESULT identifier_eval(exec_ctx_t *ctx, BSTR identifier, DWORD flags, exprval_t *ret)
436 scope_chain_t *scope;
441 TRACE("%s\n", debugstr_w(identifier));
443 for(scope = ctx->scope_chain; scope; scope = scope->next) {
444 hres = jsdisp_get_id(scope->obj, identifier, 0, &id);
450 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(scope->obj), id);
454 hres = jsdisp_get_id(ctx->parser->script->global, identifier, 0, &id);
455 if(SUCCEEDED(hres)) {
456 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->global), id);
460 for(item = ctx->parser->script->named_items; item; item = item->next) {
461 if((item->flags & SCRIPTITEM_ISVISIBLE) && !strcmpW(item->name, identifier)) {
465 if(!ctx->parser->script->site)
468 hres = IActiveScriptSite_GetItemInfo(ctx->parser->script->site, identifier,
469 SCRIPTINFO_IUNKNOWN, &unk, NULL);
471 WARN("GetItemInfo failed: %08x\n", hres);
475 hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&item->disp);
476 IUnknown_Release(unk);
478 WARN("object does not implement IDispatch\n");
483 ret->type = EXPRVAL_VARIANT;
484 V_VT(&ret->u.var) = VT_DISPATCH;
485 V_DISPATCH(&ret->u.var) = item->disp;
486 IDispatch_AddRef(item->disp);
491 for(item = ctx->parser->script->named_items; item; item = item->next) {
492 if(item->flags & SCRIPTITEM_GLOBALMEMBERS) {
493 hres = disp_get_id(item->disp, identifier, 0, &id);
500 exprval_set_idref(ret, item->disp, id);
504 hres = jsdisp_get_id(ctx->parser->script->script_disp, identifier, 0, &id);
505 if(SUCCEEDED(hres)) {
506 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->parser->script->script_disp), id);
510 if(flags & EXPR_NEWREF) {
511 hres = jsdisp_get_id(ctx->var_disp, identifier, fdexNameEnsure, &id);
515 exprval_set_idref(ret, (IDispatch*)_IDispatchEx_(ctx->var_disp), id);
519 WARN("Could not find identifier %s\n", debugstr_w(identifier));
523 /* ECMA-262 3rd Edition 12.1 */
524 HRESULT block_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
526 block_statement_t *stat = (block_statement_t*)_stat;
533 V_VT(&val) = VT_EMPTY;
534 for(iter = stat->stat_list; iter; iter = iter->next) {
535 hres = stat_eval(ctx, iter, rt, &tmp);
541 if(rt->type != RT_NORMAL)
554 /* ECMA-262 3rd Edition 12.2 */
555 static HRESULT variable_list_eval(exec_ctx_t *ctx, variable_declaration_t *var_list, jsexcept_t *ei)
557 variable_declaration_t *iter;
560 for(iter = var_list; iter; iter = iter->next) {
567 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
571 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
572 exprval_release(&exprval);
576 hres = jsdisp_propput_name(ctx->var_disp, iter->identifier, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
585 /* ECMA-262 3rd Edition 12.2 */
586 HRESULT var_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
588 var_statement_t *stat = (var_statement_t*)_stat;
593 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
597 V_VT(ret) = VT_EMPTY;
601 /* ECMA-262 3rd Edition 12.3 */
602 HRESULT empty_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
606 V_VT(ret) = VT_EMPTY;
610 /* ECMA-262 3rd Edition 12.4 */
611 HRESULT expression_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
613 expression_statement_t *stat = (expression_statement_t*)_stat;
620 hres = expr_eval(ctx, stat->expr, EXPR_NOVAL, &rt->ei, &exprval);
624 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
625 exprval_release(&exprval);
630 TRACE("= %s\n", debugstr_variant(ret));
634 /* ECMA-262 3rd Edition 12.5 */
635 HRESULT if_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
637 if_statement_t *stat = (if_statement_t*)_stat;
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);
654 hres = stat_eval(ctx, stat->if_stat, rt, ret);
655 else if(stat->else_stat)
656 hres = stat_eval(ctx, stat->else_stat, rt, ret);
658 V_VT(ret) = VT_EMPTY;
663 /* ECMA-262 3rd Edition 12.6.2 */
664 HRESULT while_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
666 while_statement_t *stat = (while_statement_t*)_stat;
675 V_VT(&val) = VT_EMPTY;
676 test_expr = !stat->do_while;
680 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
684 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
685 exprval_release(&exprval);
686 if(FAILED(hres) || !b)
692 hres = stat_eval(ctx, stat->statement, rt, &tmp);
699 if(rt->type == RT_CONTINUE)
700 rt->type = RT_NORMAL;
701 if(rt->type != RT_NORMAL)
710 if(rt->type == RT_BREAK)
711 rt->type = RT_NORMAL;
717 /* ECMA-262 3rd Edition 12.6.3 */
718 HRESULT for_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
720 for_statement_t *stat = (for_statement_t*)_stat;
721 VARIANT val, tmp, retv;
728 if(stat->variable_list) {
729 hres = variable_list_eval(ctx, stat->variable_list, &rt->ei);
732 }else if(stat->begin_expr) {
733 hres = expr_eval(ctx, stat->begin_expr, EXPR_NEWREF, &rt->ei, &exprval);
737 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
738 exprval_release(&exprval);
745 V_VT(&retv) = VT_EMPTY;
749 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
753 hres = exprval_to_boolean(ctx->parser->script, &exprval, &rt->ei, &b);
754 exprval_release(&exprval);
755 if(FAILED(hres) || !b)
759 hres = stat_eval(ctx, stat->statement, rt, &tmp);
766 if(rt->type == RT_CONTINUE)
767 rt->type = RT_NORMAL;
768 else if(rt->type != RT_NORMAL)
772 hres = expr_eval(ctx, stat->end_expr, 0, &rt->ei, &exprval);
776 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
777 exprval_release(&exprval);
790 if(rt->type == RT_BREAK)
791 rt->type = RT_NORMAL;
797 /* ECMA-262 3rd Edition 12.6.4 */
798 HRESULT forin_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
800 forin_statement_t *stat = (forin_statement_t*)_stat;
801 VARIANT val, name, retv, tmp;
802 DISPID id = DISPID_STARTENUM;
803 BSTR str, identifier = NULL;
811 hres = variable_list_eval(ctx, stat->variable, &rt->ei);
816 hres = expr_eval(ctx, stat->in_expr, EXPR_NEWREF, &rt->ei, &exprval);
820 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
821 exprval_release(&exprval);
825 if(V_VT(&val) != VT_DISPATCH) {
826 TRACE("in vt %d\n", V_VT(&val));
828 V_VT(ret) = VT_EMPTY;
832 hres = IDispatch_QueryInterface(V_DISPATCH(&val), &IID_IDispatchEx, (void**)&in_obj);
833 IDispatch_Release(V_DISPATCH(&val));
835 FIXME("Object doesn't support IDispatchEx\n");
839 V_VT(&retv) = VT_EMPTY;
842 identifier = SysAllocString(stat->variable->identifier);
845 hres = IDispatchEx_GetNextDispID(in_obj, fdexEnumDefault, id, &id);
846 if(FAILED(hres) || hres == S_FALSE)
849 hres = IDispatchEx_GetMemberName(in_obj, id, &str);
853 TRACE("iter %s\n", debugstr_w(str));
856 hres = identifier_eval(ctx, identifier, 0, &exprval);
858 hres = expr_eval(ctx, stat->expr, EXPR_NEWREF, &rt->ei, &exprval);
859 if(SUCCEEDED(hres)) {
860 V_VT(&name) = VT_BSTR;
862 hres = put_value(ctx->parser->script, &exprval, &name, &rt->ei);
863 exprval_release(&exprval);
869 hres = stat_eval(ctx, stat->statement, rt, &tmp);
876 if(rt->type == RT_CONTINUE)
877 rt->type = RT_NORMAL;
878 else if(rt->type != RT_NORMAL)
882 SysFreeString(identifier);
883 IDispatchEx_Release(in_obj);
889 if(rt->type == RT_BREAK)
890 rt->type = RT_NORMAL;
896 /* ECMA-262 3rd Edition 12.7 */
897 HRESULT continue_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
899 branch_statement_t *stat = (branch_statement_t*)_stat;
903 if(stat->identifier) {
904 FIXME("indentifier not implemented\n");
908 rt->type = RT_CONTINUE;
909 V_VT(ret) = VT_EMPTY;
913 /* ECMA-262 3rd Edition 12.8 */
914 HRESULT break_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
916 branch_statement_t *stat = (branch_statement_t*)_stat;
920 if(stat->identifier) {
921 FIXME("indentifier not implemented\n");
926 V_VT(ret) = VT_EMPTY;
930 /* ECMA-262 3rd Edition 12.9 */
931 HRESULT return_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
933 expression_statement_t *stat = (expression_statement_t*)_stat;
941 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
945 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, ret);
946 exprval_release(&exprval);
950 V_VT(ret) = VT_EMPTY;
953 TRACE("= %s\n", debugstr_variant(ret));
954 rt->type = RT_RETURN;
958 /* ECMA-262 3rd Edition 12.10 */
959 HRESULT with_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
961 with_statement_t *stat = (with_statement_t*)_stat;
970 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
974 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
975 exprval_release(&exprval);
979 hres = to_object(ctx, &val, &disp);
984 obj = iface_to_jsdisp((IUnknown*)disp);
985 IDispatch_Release(disp);
987 FIXME("disp id not jsdisp\n");
991 hres = scope_push(ctx->scope_chain, obj, &ctx->scope_chain);
996 hres = stat_eval(ctx, stat->statement, rt, ret);
998 scope_pop(&ctx->scope_chain);
1002 /* ECMA-262 3rd Edition 12.12 */
1003 HRESULT labelled_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t *rt, VARIANT *ret)
1009 /* ECMA-262 3rd Edition 12.13 */
1010 HRESULT switch_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1012 switch_statement_t *stat = (switch_statement_t*)_stat;
1013 case_clausule_t *iter, *default_clausule = NULL;
1014 statement_t *stat_iter;
1022 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
1026 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
1027 exprval_release(&exprval);
1031 for(iter = stat->case_list; iter; iter = iter->next) {
1033 default_clausule = iter;
1037 hres = expr_eval(ctx, iter->expr, 0, &rt->ei, &exprval);
1041 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &cval);
1042 exprval_release(&exprval);
1046 hres = equal2_values(&val, &cval, &b);
1047 VariantClear(&cval);
1048 if(FAILED(hres) || b)
1057 iter = default_clausule;
1059 V_VT(&val) = VT_EMPTY;
1063 for(stat_iter = iter->stat; stat_iter; stat_iter = stat_iter->next) {
1064 hres = stat_eval(ctx, stat_iter, rt, &tmp);
1071 if(rt->type != RT_NORMAL)
1081 if(rt->type == RT_BREAK)
1082 rt->type = RT_NORMAL;
1088 /* ECMA-262 3rd Edition 12.13 */
1089 HRESULT throw_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1091 expression_statement_t *stat = (expression_statement_t*)_stat;
1098 hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
1102 hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
1103 exprval_release(&exprval);
1108 return DISP_E_EXCEPTION;
1111 /* ECMA-262 3rd Edition 12.14 */
1112 static HRESULT catch_eval(exec_ctx_t *ctx, catch_block_t *block, return_type_t *rt, VARIANT *ret)
1114 DispatchEx *var_disp;
1119 memset(&rt->ei, 0, sizeof(jsexcept_t));
1121 hres = create_dispex(ctx->parser->script, NULL, NULL, &var_disp);
1122 if(SUCCEEDED(hres)) {
1123 hres = jsdisp_propput_name(var_disp, block->identifier, ctx->parser->script->lcid,
1124 &ex, &rt->ei, NULL/*FIXME*/);
1125 if(SUCCEEDED(hres)) {
1126 hres = scope_push(ctx->scope_chain, var_disp, &ctx->scope_chain);
1127 if(SUCCEEDED(hres)) {
1128 hres = stat_eval(ctx, block->statement, rt, &val);
1129 scope_pop(&ctx->scope_chain);
1133 jsdisp_release(var_disp);
1144 /* ECMA-262 3rd Edition 12.14 */
1145 HRESULT try_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
1147 try_statement_t *stat = (try_statement_t*)_stat;
1153 hres = stat_eval(ctx, stat->try_statement, rt, &val);
1155 TRACE("EXCEPTION\n");
1156 if(!stat->catch_block)
1159 hres = catch_eval(ctx, stat->catch_block, rt, &val);
1164 if(stat->finally_statement) {
1166 hres = stat_eval(ctx, stat->finally_statement, rt, &val);
1175 static HRESULT return_bool(exprval_t *ret, DWORD b)
1177 ret->type = EXPRVAL_VARIANT;
1178 V_VT(&ret->u.var) = VT_BOOL;
1179 V_BOOL(&ret->u.var) = b ? VARIANT_TRUE : VARIANT_FALSE;
1184 static HRESULT get_binary_expr_values(exec_ctx_t *ctx, binary_expression_t *expr, jsexcept_t *ei, VARIANT *lval, VARIANT *rval)
1189 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1193 hres = exprval_to_value(ctx->parser->script, &exprval, ei, lval);
1194 exprval_release(&exprval);
1198 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1199 if(SUCCEEDED(hres)) {
1200 hres = exprval_to_value(ctx->parser->script, &exprval, ei, rval);
1201 exprval_release(&exprval);
1212 typedef HRESULT (*oper_t)(exec_ctx_t*,VARIANT*,VARIANT*,jsexcept_t*,VARIANT*);
1214 static HRESULT binary_expr_eval(exec_ctx_t *ctx, binary_expression_t *expr, oper_t oper, jsexcept_t *ei,
1217 VARIANT lval, rval, retv;
1220 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1224 hres = oper(ctx, &lval, &rval, ei, &retv);
1225 VariantClear(&lval);
1226 VariantClear(&rval);
1230 ret->type = EXPRVAL_VARIANT;
1235 /* ECMA-262 3rd Edition 11.13.2 */
1236 static HRESULT assign_oper_eval(exec_ctx_t *ctx, expression_t *lexpr, expression_t *rexpr, oper_t oper,
1237 jsexcept_t *ei, exprval_t *ret)
1239 VARIANT retv, lval, rval;
1240 exprval_t exprval, exprvalr;
1243 hres = expr_eval(ctx, lexpr, EXPR_NEWREF, ei, &exprval);
1247 hres = exprval_value(ctx->parser->script, &exprval, ei, &lval);
1248 if(SUCCEEDED(hres)) {
1249 hres = expr_eval(ctx, rexpr, 0, ei, &exprvalr);
1250 if(SUCCEEDED(hres)) {
1251 hres = exprval_value(ctx->parser->script, &exprvalr, ei, &rval);
1252 exprval_release(&exprvalr);
1254 if(SUCCEEDED(hres)) {
1255 hres = oper(ctx, &lval, &rval, ei, &retv);
1256 VariantClear(&rval);
1258 VariantClear(&lval);
1261 if(SUCCEEDED(hres)) {
1262 hres = put_value(ctx->parser->script, &exprval, &retv, ei);
1264 VariantClear(&retv);
1266 exprval_release(&exprval);
1271 ret->type = EXPRVAL_VARIANT;
1276 /* ECMA-262 3rd Edition 13 */
1277 HRESULT function_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1279 function_expression_t *expr = (function_expression_t*)_expr;
1285 if(expr->identifier) {
1286 hres = jsdisp_propget_name(ctx->var_disp, expr->identifier, ctx->parser->script->lcid, &var, ei, NULL/*FIXME*/);
1292 hres = create_source_function(ctx->parser, expr->parameter_list, expr->source_elements, ctx->scope_chain,
1293 expr->src_str, expr->src_len, &dispex);
1297 V_VT(&var) = VT_DISPATCH;
1298 V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(dispex);
1301 ret->type = EXPRVAL_VARIANT;
1306 /* ECMA-262 3rd Edition 11.12 */
1307 HRESULT conditional_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1309 conditional_expression_t *expr = (conditional_expression_t*)_expr;
1316 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1320 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
1321 exprval_release(&exprval);
1325 return expr_eval(ctx, b ? expr->true_expression : expr->false_expression, flags, ei, ret);
1328 /* ECMA-262 3rd Edition 11.2.1 */
1329 HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1331 array_expression_t *expr = (array_expression_t*)_expr;
1333 VARIANT member, val;
1336 IDispatch *obj = NULL;
1341 hres = expr_eval(ctx, expr->member_expr, EXPR_NEWREF, ei, &exprval);
1345 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1346 exprval_release(&exprval);
1350 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
1351 if(SUCCEEDED(hres)) {
1352 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1353 exprval_release(&exprval);
1357 hres = to_object(ctx, &member, &obj);
1358 VariantClear(&member);
1359 if(SUCCEEDED(hres)) {
1360 hres = to_string(ctx->parser->script, &val, ei, &str);
1361 if(SUCCEEDED(hres)) {
1362 if(flags & EXPR_STRREF) {
1363 ret->type = EXPRVAL_NAMEREF;
1364 ret->u.nameref.disp = obj;
1365 ret->u.nameref.name = str;
1369 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1372 if(SUCCEEDED(hres)) {
1373 exprval_set_idref(ret, obj, id);
1374 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1379 IDispatch_Release(obj);
1385 /* ECMA-262 3rd Edition 11.2.1 */
1386 HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1388 member_expression_t *expr = (member_expression_t*)_expr;
1389 IDispatch *obj = NULL;
1398 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1402 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &member);
1403 exprval_release(&exprval);
1407 hres = to_object(ctx, &member, &obj);
1408 VariantClear(&member);
1412 str = SysAllocString(expr->identifier);
1413 if(flags & EXPR_STRREF) {
1414 ret->type = EXPRVAL_NAMEREF;
1415 ret->u.nameref.disp = obj;
1416 ret->u.nameref.name = str;
1420 hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id);
1422 if(SUCCEEDED(hres)) {
1423 exprval_set_idref(ret, obj, id);
1424 }else if(!(flags & EXPR_NEWREF) && hres == DISP_E_UNKNOWNNAME) {
1429 IDispatch_Release(obj);
1433 static void free_dp(DISPPARAMS *dp)
1437 for(i=0; i < dp->cArgs; i++)
1438 VariantClear(dp->rgvarg+i);
1439 heap_free(dp->rgvarg);
1442 static HRESULT args_to_param(exec_ctx_t *ctx, argument_t *args, jsexcept_t *ei, DISPPARAMS *dp)
1448 HRESULT hres = S_OK;
1450 memset(dp, 0, sizeof(*dp));
1454 for(iter = args; iter; iter = iter->next)
1457 vargs = heap_alloc_zero(cnt * sizeof(*vargs));
1459 return E_OUTOFMEMORY;
1461 for(i = cnt, iter = args; iter; iter = iter->next) {
1462 hres = expr_eval(ctx, iter->expr, 0, ei, &exprval);
1466 hres = exprval_to_value(ctx->parser->script, &exprval, ei, vargs + (--i));
1467 exprval_release(&exprval);
1482 /* ECMA-262 3rd Edition 11.2.2 */
1483 HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1485 call_expression_t *expr = (call_expression_t*)_expr;
1487 VARIANT constr, var;
1493 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1497 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1499 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &constr);
1500 exprval_release(&exprval);
1504 if(V_VT(&constr) != VT_DISPATCH) {
1505 FIXME("throw TypeError\n");
1506 VariantClear(&constr);
1510 hres = disp_call(V_DISPATCH(&constr), DISPID_VALUE, ctx->parser->script->lcid,
1511 DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/);
1512 IDispatch_Release(V_DISPATCH(&constr));
1516 ret->type = EXPRVAL_VARIANT;
1521 /* ECMA-262 3rd Edition 11.2.3 */
1522 HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1524 call_expression_t *expr = (call_expression_t*)_expr;
1532 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
1536 hres = args_to_param(ctx, expr->argument_list, ei, &dp);
1537 if(SUCCEEDED(hres)) {
1538 switch(exprval.type) {
1540 hres = disp_call(exprval.u.idref.disp, exprval.u.idref.id, ctx->parser->script->lcid, DISPATCH_METHOD,
1541 &dp, flags & EXPR_NOVAL ? NULL : &var, ei, NULL/*FIXME*/);
1542 if(flags & EXPR_NOVAL)
1543 V_VT(&var) = VT_EMPTY;
1546 FIXME("unimplemented type %d\n", exprval.type);
1553 exprval_release(&exprval);
1557 TRACE("= %s\n", debugstr_variant(&var));
1558 ret->type = EXPRVAL_VARIANT;
1563 /* ECMA-262 3rd Edition 11.1.1 */
1564 HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1568 ret->type = EXPRVAL_VARIANT;
1569 V_VT(&ret->u.var) = VT_DISPATCH;
1570 V_DISPATCH(&ret->u.var) = ctx->this_obj;
1571 IDispatch_AddRef(ctx->this_obj);
1575 /* ECMA-262 3rd Edition 10.1.4 */
1576 HRESULT identifier_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1578 identifier_expression_t *expr = (identifier_expression_t*)_expr;
1584 identifier = SysAllocString(expr->identifier);
1586 return E_OUTOFMEMORY;
1588 hres = identifier_eval(ctx, identifier, flags, ret);
1590 SysFreeString(identifier);
1594 /* ECMA-262 3rd Edition 7.8 */
1595 HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1597 literal_expression_t *expr = (literal_expression_t*)_expr;
1603 hres = literal_to_var(expr->literal, &var);
1607 ret->type = EXPRVAL_VARIANT;
1612 /* ECMA-262 3rd Edition 11.1.4 */
1613 HRESULT array_literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1615 array_literal_expression_t *expr = (array_literal_expression_t*)_expr;
1616 DWORD length = 0, i = 0;
1617 array_element_t *elem;
1625 for(elem = expr->element_list; elem; elem = elem->next)
1626 length += elem->elision+1;
1627 length += expr->length;
1629 hres = create_array(ctx->parser->script, length, &array);
1633 for(elem = expr->element_list; elem; elem = elem->next) {
1636 hres = expr_eval(ctx, elem->expr, 0, ei, &exprval);
1640 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1641 exprval_release(&exprval);
1645 hres = jsdisp_propput_idx(array, i, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1654 jsdisp_release(array);
1658 ret->type = EXPRVAL_VARIANT;
1659 V_VT(&ret->u.var) = VT_DISPATCH;
1660 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(array);
1664 /* ECMA-262 3rd Edition 11.1.5 */
1665 HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1667 property_value_expression_t *expr = (property_value_expression_t*)_expr;
1677 hres = create_object(ctx->parser->script, NULL, &obj);
1681 for(iter = expr->property_list; iter; iter = iter->next) {
1682 hres = literal_to_var(iter->name, &tmp);
1686 hres = to_string(ctx->parser->script, &tmp, ei, &name);
1691 hres = expr_eval(ctx, iter->value, 0, ei, &exprval);
1692 if(SUCCEEDED(hres)) {
1693 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1694 exprval_release(&exprval);
1695 if(SUCCEEDED(hres)) {
1696 hres = jsdisp_propput_name(obj, name, ctx->parser->script->lcid, &val, ei, NULL/*FIXME*/);
1701 SysFreeString(name);
1707 jsdisp_release(obj);
1711 ret->type = EXPRVAL_VARIANT;
1712 V_VT(&ret->u.var) = VT_DISPATCH;
1713 V_DISPATCH(&ret->u.var) = (IDispatch*)_IDispatchEx_(obj);
1717 /* ECMA-262 3rd Edition 11.14 */
1718 HRESULT comma_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1720 binary_expression_t *expr = (binary_expression_t*)_expr;
1726 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
1730 VariantClear(&lval);
1732 ret->type = EXPRVAL_VARIANT;
1737 /* ECMA-262 3rd Edition 11.11 */
1738 HRESULT logical_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1740 binary_expression_t *expr = (binary_expression_t*)_expr;
1748 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1752 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1753 exprval_release(&exprval);
1757 hres = to_boolean(&val, &b);
1758 if(SUCCEEDED(hres) && b) {
1759 ret->type = EXPRVAL_VARIANT;
1768 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1772 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1773 exprval_release(&exprval);
1777 ret->type = EXPRVAL_VARIANT;
1782 /* ECMA-262 3rd Edition 11.11 */
1783 HRESULT logical_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1785 binary_expression_t *expr = (binary_expression_t*)_expr;
1793 hres = expr_eval(ctx, expr->expression1, 0, ei, &exprval);
1797 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1798 exprval_release(&exprval);
1802 hres = to_boolean(&val, &b);
1803 if(SUCCEEDED(hres) && !b) {
1804 ret->type = EXPRVAL_VARIANT;
1813 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprval);
1817 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
1818 exprval_release(&exprval);
1822 ret->type = EXPRVAL_VARIANT;
1827 /* ECMA-262 3rd Edition 11.10 */
1828 static HRESULT bitor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1833 hres = to_int32(ctx->parser->script, lval, ei, &li);
1837 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1846 /* ECMA-262 3rd Edition 11.10 */
1847 HRESULT binary_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1849 binary_expression_t *expr = (binary_expression_t*)_expr;
1853 return binary_expr_eval(ctx, expr, bitor_eval, ei, ret);
1856 /* ECMA-262 3rd Edition 11.10 */
1857 static HRESULT xor_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1862 hres = to_int32(ctx->parser->script, lval, ei, &li);
1866 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1875 /* ECMA-262 3rd Edition 11.10 */
1876 HRESULT binary_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1878 binary_expression_t *expr = (binary_expression_t*)_expr;
1882 return binary_expr_eval(ctx, expr, xor_eval, ei, ret);
1885 /* ECMA-262 3rd Edition 11.10 */
1886 static HRESULT bitand_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1891 hres = to_int32(ctx->parser->script, lval, ei, &li);
1895 hres = to_int32(ctx->parser->script, rval, ei, &ri);
1904 /* ECMA-262 3rd Edition 11.10 */
1905 HRESULT binary_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1907 binary_expression_t *expr = (binary_expression_t*)_expr;
1911 return binary_expr_eval(ctx, expr, bitand_eval, ei, ret);
1914 /* ECMA-262 3rd Edition 11.8.6 */
1915 HRESULT instanceof_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1921 /* ECMA-262 3rd Edition 11.8.7 */
1922 HRESULT in_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1928 /* ECMA-262 3rd Edition 11.6.1 */
1929 static HRESULT add_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
1934 hres = to_primitive(ctx->parser->script, lval, ei, &l);
1938 hres = to_primitive(ctx->parser->script, rval, ei, &r);
1944 if(V_VT(&l) == VT_BSTR || V_VT(&r) == VT_BSTR) {
1945 BSTR lstr = NULL, rstr = NULL;
1947 if(V_VT(&l) == VT_BSTR)
1950 hres = to_string(ctx->parser->script, &l, ei, &lstr);
1952 if(SUCCEEDED(hres)) {
1953 if(V_VT(&r) == VT_BSTR)
1956 hres = to_string(ctx->parser->script, &r, ei, &rstr);
1959 if(SUCCEEDED(hres)) {
1962 len1 = SysStringLen(lstr);
1963 len2 = SysStringLen(rstr);
1965 V_VT(retv) = VT_BSTR;
1966 V_BSTR(retv) = SysAllocStringLen(NULL, len1+len2);
1967 memcpy(V_BSTR(retv), lstr, len1*sizeof(WCHAR));
1968 memcpy(V_BSTR(retv)+len1, rstr, (len2+1)*sizeof(WCHAR));
1971 if(V_VT(&l) != VT_BSTR)
1972 SysFreeString(lstr);
1973 if(V_VT(&r) != VT_BSTR)
1974 SysFreeString(rstr);
1978 hres = to_number(ctx->parser->script, &l, ei, &nl);
1979 if(SUCCEEDED(hres)) {
1980 hres = to_number(ctx->parser->script, &r, ei, &nr);
1982 num_set_val(retv, num_val(&nl) + num_val(&nr));
1991 /* ECMA-262 3rd Edition 11.6.1 */
1992 HRESULT add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
1994 binary_expression_t *expr = (binary_expression_t*)_expr;
1998 return binary_expr_eval(ctx, expr, add_eval, ei, ret);
2001 /* ECMA-262 3rd Edition 11.6.2 */
2002 static HRESULT sub_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2007 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2011 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2015 num_set_val(retv, num_val(&lnum) - num_val(&rnum));
2019 /* ECMA-262 3rd Edition 11.6.2 */
2020 HRESULT sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2022 binary_expression_t *expr = (binary_expression_t*)_expr;
2026 return binary_expr_eval(ctx, expr, sub_eval, ei, ret);
2029 /* ECMA-262 3rd Edition 11.5.1 */
2030 static HRESULT mul_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2035 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2039 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2043 num_set_val(retv, num_val(&lnum) * num_val(&rnum));
2047 /* ECMA-262 3rd Edition 11.5.1 */
2048 HRESULT mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2050 binary_expression_t *expr = (binary_expression_t*)_expr;
2054 return binary_expr_eval(ctx, expr, mul_eval, ei, ret);
2057 /* ECMA-262 3rd Edition 11.5.2 */
2058 static HRESULT div_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2063 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2067 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2071 num_set_val(retv, num_val(&lnum) / num_val(&rnum));
2075 /* ECMA-262 3rd Edition 11.5.2 */
2076 HRESULT div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2078 binary_expression_t *expr = (binary_expression_t*)_expr;
2082 return binary_expr_eval(ctx, expr, div_eval, ei, ret);
2085 /* ECMA-262 3rd Edition 11.5.3 */
2086 static HRESULT mod_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2091 hres = to_number(ctx->parser->script, lval, ei, &lnum);
2095 hres = to_number(ctx->parser->script, rval, ei, &rnum);
2099 num_set_val(retv, fmod(num_val(&lnum), num_val(&rnum)));
2103 /* ECMA-262 3rd Edition 11.5.3 */
2104 HRESULT mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2106 binary_expression_t *expr = (binary_expression_t*)_expr;
2110 return binary_expr_eval(ctx, expr, mod_eval, ei, ret);
2113 /* ECMA-262 3rd Edition 11.4.2 */
2114 HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2116 unary_expression_t *expr = (unary_expression_t*)_expr;
2117 VARIANT_BOOL b = VARIANT_FALSE;
2123 hres = expr_eval(ctx, expr->expression, EXPR_STRREF, ei, &exprval);
2127 switch(exprval.type) {
2128 case EXPRVAL_IDREF: {
2129 IDispatchEx *dispex;
2131 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2132 if(SUCCEEDED(hres)) {
2133 hres = IDispatchEx_DeleteMemberByDispID(dispex, exprval.u.idref.id);
2135 IDispatchEx_Release(dispex);
2139 case EXPRVAL_NAMEREF: {
2140 IDispatchEx *dispex;
2142 hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex);
2143 if(SUCCEEDED(hres)) {
2144 hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, fdexNameCaseSensitive);
2146 IDispatchEx_Release(dispex);
2151 FIXME("unsupported type %d\n", exprval.type);
2155 exprval_release(&exprval);
2159 return return_bool(ret, b);
2162 /* ECMA-262 3rd Edition 11.4.2 */
2163 HRESULT void_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2165 unary_expression_t *expr = (unary_expression_t*)_expr;
2172 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2176 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &tmp);
2177 exprval_release(&exprval);
2183 ret->type = EXPRVAL_VARIANT;
2184 V_VT(&ret->u.var) = VT_EMPTY;
2188 /* ECMA-262 3rd Edition 11.4.3 */
2189 HRESULT typeof_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2191 unary_expression_t *expr = (unary_expression_t*)_expr;
2197 static const WCHAR booleanW[] = {'b','o','o','l','e','a','n',0};
2198 static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
2199 static const WCHAR numberW[] = {'n','u','m','b','e','r',0};
2200 static const WCHAR objectW[] = {'o','b','j','e','c','t',0};
2201 static const WCHAR stringW[] = {'s','t','r','i','n','g',0};
2202 static const WCHAR undefinedW[] = {'u','n','d','e','f','i','n','e','d',0};
2206 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2210 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2211 exprval_release(&exprval);
2215 switch(V_VT(&val)) {
2235 dispex = iface_to_jsdisp((IUnknown*)V_DISPATCH(&val));
2237 str = dispex->builtin_info->class == JSCLASS_FUNCTION ? functionW : objectW;
2238 IDispatchEx_Release(_IDispatchEx_(dispex));
2245 FIXME("unhandled vt %d\n", V_VT(&val));
2252 ret->type = EXPRVAL_VARIANT;
2253 V_VT(&ret->u.var) = VT_BSTR;
2254 V_BSTR(&ret->u.var) = SysAllocString(str);
2258 /* ECMA-262 3rd Edition 11.4.7 */
2259 HRESULT minus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2261 unary_expression_t *expr = (unary_expression_t*)_expr;
2268 hres = expr_eval(ctx, expr->expression, 0, ei, &exprval);
2272 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2273 exprval_release(&exprval);
2277 hres = to_number(ctx->parser->script, &val, ei, &num);
2282 ret->type = EXPRVAL_VARIANT;
2283 num_set_val(&ret->u.var, -num_val(&num));
2287 /* ECMA-262 3rd Edition 11.4.6 */
2288 HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2290 unary_expression_t *expr = (unary_expression_t*)_expr;
2297 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2301 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2302 exprval_release(&exprval);
2306 hres = to_number(ctx->parser->script, &val, ei, &num);
2310 ret->type = EXPRVAL_VARIANT;
2315 /* ECMA-262 3rd Edition 11.3.1 */
2316 HRESULT post_increment_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2318 unary_expression_t *expr = (unary_expression_t*)_expr;
2325 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2329 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2330 if(SUCCEEDED(hres)) {
2331 hres = to_number(ctx->parser->script, &val, ei, &num);
2335 if(SUCCEEDED(hres)) {
2337 num_set_val(&inc, num_val(&num)+1.0);
2338 hres = put_value(ctx->parser->script, &exprval, &inc, ei);
2341 exprval_release(&exprval);
2345 ret->type = EXPRVAL_VARIANT;
2350 /* ECMA-262 3rd Edition 11.3.2 */
2351 HRESULT post_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2353 unary_expression_t *expr = (unary_expression_t*)_expr;
2360 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2364 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2365 if(SUCCEEDED(hres)) {
2366 hres = to_number(ctx->parser->script, &val, ei, &num);
2370 if(SUCCEEDED(hres)) {
2372 num_set_val(&dec, num_val(&num)-1.0);
2373 hres = put_value(ctx->parser->script, &exprval, &dec, ei);
2376 exprval_release(&exprval);
2380 ret->type = EXPRVAL_VARIANT;
2385 /* ECMA-262 3rd Edition 11.4.4 */
2386 HRESULT pre_increment_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.4.5 */
2420 HRESULT pre_decrement_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2422 unary_expression_t *expr = (unary_expression_t*)_expr;
2429 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2433 hres = exprval_value(ctx->parser->script, &exprval, ei, &val);
2434 if(SUCCEEDED(hres)) {
2435 hres = to_number(ctx->parser->script, &val, ei, &num);
2439 if(SUCCEEDED(hres)) {
2440 num_set_val(&val, num_val(&num)-1.0);
2441 hres = put_value(ctx->parser->script, &exprval, &val, ei);
2444 exprval_release(&exprval);
2448 ret->type = EXPRVAL_VARIANT;
2453 /* ECMA-262 3rd Edition 11.9.3 */
2454 static HRESULT equal_values(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, BOOL *ret)
2456 if(V_VT(lval) == V_VT(rval) || (is_num_vt(V_VT(lval)) && is_num_vt(V_VT(rval))))
2457 return equal2_values(lval, rval, ret);
2459 /* FIXME: NULL disps should be handled in more general way */
2460 if(V_VT(lval) == VT_DISPATCH && !V_DISPATCH(lval)) {
2463 return equal_values(ctx, &v, rval, ei, ret);
2466 if(V_VT(rval) == VT_DISPATCH && !V_DISPATCH(rval)) {
2469 return equal_values(ctx, lval, &v, ei, ret);
2472 if((V_VT(lval) == VT_NULL && V_VT(rval) == VT_EMPTY) ||
2473 (V_VT(lval) == VT_EMPTY && V_VT(rval) == VT_NULL)) {
2478 if(V_VT(lval) == VT_BSTR && is_num_vt(V_VT(rval))) {
2482 hres = to_number(ctx->parser->script, lval, ei, &v);
2486 return equal_values(ctx, &v, rval, ei, ret);
2489 if(V_VT(rval) == VT_BSTR && is_num_vt(V_VT(lval))) {
2493 hres = to_number(ctx->parser->script, rval, ei, &v);
2497 return equal_values(ctx, lval, &v, ei, ret);
2500 if(V_VT(rval) == VT_BOOL) {
2504 V_I4(&v) = V_BOOL(rval) ? 1 : 0;
2505 return equal_values(ctx, lval, &v, ei, ret);
2508 if(V_VT(lval) == VT_BOOL) {
2512 V_I4(&v) = V_BOOL(lval) ? 1 : 0;
2513 return equal_values(ctx, &v, rval, ei, ret);
2517 if(V_VT(rval) == VT_DISPATCH && (V_VT(lval) == VT_BSTR || is_num_vt(V_VT(lval)))) {
2521 hres = to_primitive(ctx->parser->script, rval, ei, &v);
2525 hres = equal_values(ctx, lval, &v, ei, ret);
2532 if(V_VT(lval) == VT_DISPATCH && (V_VT(rval) == VT_BSTR || is_num_vt(V_VT(rval)))) {
2536 hres = to_primitive(ctx->parser->script, lval, ei, &v);
2540 hres = equal_values(ctx, &v, rval, ei, ret);
2551 /* ECMA-262 3rd Edition 11.9.1 */
2552 HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2554 binary_expression_t *expr = (binary_expression_t*)_expr;
2561 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2565 hres = equal_values(ctx, &rval, &lval, ei, &b);
2569 return return_bool(ret, b);
2572 /* ECMA-262 3rd Edition 11.9.4 */
2573 HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2575 binary_expression_t *expr = (binary_expression_t*)_expr;
2582 hres = get_binary_expr_values(ctx, expr, ei, &rval, &lval);
2586 hres = equal2_values(&rval, &lval, &b);
2590 return return_bool(ret, b);
2593 /* ECMA-262 3rd Edition 11.9.2 */
2594 HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2596 binary_expression_t *expr = (binary_expression_t*)_expr;
2603 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2607 hres = equal_values(ctx, &lval, &rval, ei, &b);
2611 return return_bool(ret, !b);
2614 /* ECMA-262 3rd Edition 11.9.5 */
2615 HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2617 binary_expression_t *expr = (binary_expression_t*)_expr;
2624 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2628 hres = equal2_values(&lval, &rval, &b);
2632 return return_bool(ret, !b);
2635 /* ECMA-262 3rd Edition 11.8.5 */
2636 static HRESULT less_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, BOOL greater, jsexcept_t *ei, BOOL *ret)
2638 VARIANT l, r, ln, rn;
2641 hres = to_primitive(ctx->parser->script, lval, ei, &l);
2645 hres = to_primitive(ctx->parser->script, rval, ei, &r);
2651 if(V_VT(&l) == VT_BSTR && V_VT(&r) == VT_BSTR) {
2652 *ret = (strcmpW(V_BSTR(&l), V_BSTR(&r)) < 0) ^ greater;
2653 SysFreeString(V_BSTR(&l));
2654 SysFreeString(V_BSTR(&r));
2658 hres = to_number(ctx->parser->script, &l, ei, &ln);
2661 hres = to_number(ctx->parser->script, &r, ei, &rn);
2666 if(V_VT(&ln) == VT_I4 && V_VT(&rn) == VT_I4) {
2667 *ret = (V_I4(&ln) < V_I4(&rn)) ^ greater;
2669 DOUBLE ld = num_val(&ln);
2670 DOUBLE rd = num_val(&rn);
2672 *ret = !isnan(ld) && !isnan(rd) && ((ld < rd) ^ greater);
2678 /* ECMA-262 3rd Edition 11.8.1 */
2679 HRESULT less_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2681 binary_expression_t *expr = (binary_expression_t*)_expr;
2688 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2692 hres = less_eval(ctx, &lval, &rval, FALSE, ei, &b);
2693 VariantClear(&lval);
2694 VariantClear(&rval);
2698 return return_bool(ret, b);
2701 /* ECMA-262 3rd Edition 11.8.3 */
2702 HRESULT lesseq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2704 binary_expression_t *expr = (binary_expression_t*)_expr;
2711 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2715 hres = less_eval(ctx, &rval, &lval, TRUE, ei, &b);
2716 VariantClear(&lval);
2717 VariantClear(&rval);
2721 return return_bool(ret, b);
2724 /* ECMA-262 3rd Edition 11.8.2 */
2725 HRESULT greater_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2727 binary_expression_t *expr = (binary_expression_t*)_expr;
2734 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2738 hres = less_eval(ctx, &rval, &lval, FALSE, ei, &b);
2739 VariantClear(&lval);
2740 VariantClear(&rval);
2744 return return_bool(ret, b);
2747 /* ECMA-262 3rd Edition 11.8.4 */
2748 HRESULT greatereq_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2750 binary_expression_t *expr = (binary_expression_t*)_expr;
2757 hres = get_binary_expr_values(ctx, expr, ei, &lval, &rval);
2761 hres = less_eval(ctx, &lval, &rval, TRUE, ei, &b);
2762 VariantClear(&lval);
2763 VariantClear(&rval);
2767 return return_bool(ret, b);
2770 /* ECMA-262 3rd Edition 11.4.8 */
2771 HRESULT binary_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2773 unary_expression_t *expr = (unary_expression_t*)_expr;
2781 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2785 hres = exprval_to_value(ctx->parser->script, &exprval, ei, &val);
2786 exprval_release(&exprval);
2790 hres = to_int32(ctx->parser->script, &val, ei, &i);
2794 ret->type = EXPRVAL_VARIANT;
2795 V_VT(&ret->u.var) = VT_I4;
2796 V_I4(&ret->u.var) = ~i;
2800 /* ECMA-262 3rd Edition 11.4.9 */
2801 HRESULT logical_negation_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2803 unary_expression_t *expr = (unary_expression_t*)_expr;
2810 hres = expr_eval(ctx, expr->expression, EXPR_NEWREF, ei, &exprval);
2814 hres = exprval_to_boolean(ctx->parser->script, &exprval, ei, &b);
2815 exprval_release(&exprval);
2819 return return_bool(ret, !b);
2822 /* ECMA-262 3rd Edition 11.7.1 */
2823 static HRESULT lshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2829 hres = to_int32(ctx->parser->script, lval, ei, &li);
2833 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2838 V_I4(retv) = li << (ri&0x1f);
2842 /* ECMA-262 3rd Edition 11.7.1 */
2843 HRESULT left_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2845 binary_expression_t *expr = (binary_expression_t*)_expr;
2849 return binary_expr_eval(ctx, expr, lshift_eval, ei, ret);
2852 /* ECMA-262 3rd Edition 11.7.2 */
2853 static HRESULT rshift_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2859 hres = to_int32(ctx->parser->script, lval, ei, &li);
2863 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2868 V_I4(retv) = li >> (ri&0x1f);
2872 /* ECMA-262 3rd Edition 11.7.2 */
2873 HRESULT right_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2875 binary_expression_t *expr = (binary_expression_t*)_expr;
2879 return binary_expr_eval(ctx, expr, rshift_eval, ei, ret);
2882 /* ECMA-262 3rd Edition 11.7.3 */
2883 static HRESULT rshift2_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *rval, jsexcept_t *ei, VARIANT *retv)
2888 hres = to_uint32(ctx->parser->script, lval, ei, &li);
2892 hres = to_uint32(ctx->parser->script, rval, ei, &ri);
2897 V_I4(retv) = li >> (ri&0x1f);
2901 /* ECMA-262 3rd Edition 11.7.3 */
2902 HRESULT right2_shift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2904 binary_expression_t *expr = (binary_expression_t*)_expr;
2908 return binary_expr_eval(ctx, expr, rshift2_eval, ei, ret);
2911 /* ECMA-262 3rd Edition 11.13.1 */
2912 HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2914 binary_expression_t *expr = (binary_expression_t*)_expr;
2915 exprval_t exprval, exprvalr;
2921 hres = expr_eval(ctx, expr->expression1, EXPR_NEWREF, ei, &exprval);
2925 hres = expr_eval(ctx, expr->expression2, 0, ei, &exprvalr);
2926 if(SUCCEEDED(hres)) {
2927 hres = exprval_to_value(ctx->parser->script, &exprvalr, ei, &rval);
2928 exprval_release(&exprvalr);
2932 hres = put_value(ctx->parser->script, &exprval, &rval, ei);
2934 exprval_release(&exprval);
2938 ret->type = EXPRVAL_VARIANT;
2943 /* ECMA-262 3rd Edition 11.13.2 */
2944 HRESULT assign_lshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2946 binary_expression_t *expr = (binary_expression_t*)_expr;
2950 return assign_oper_eval(ctx, expr->expression1, expr->expression2, lshift_eval, ei, ret);
2953 /* ECMA-262 3rd Edition 11.13.2 */
2954 HRESULT assign_rshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2956 binary_expression_t *expr = (binary_expression_t*)_expr;
2960 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift_eval, ei, ret);
2963 /* ECMA-262 3rd Edition 11.13.2 */
2964 HRESULT assign_rrshift_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2966 binary_expression_t *expr = (binary_expression_t*)_expr;
2970 return assign_oper_eval(ctx, expr->expression1, expr->expression2, rshift2_eval, ei, ret);
2973 /* ECMA-262 3rd Edition 11.13.2 */
2974 HRESULT assign_add_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2976 binary_expression_t *expr = (binary_expression_t*)_expr;
2980 return assign_oper_eval(ctx, expr->expression1, expr->expression2, add_eval, ei, ret);
2983 /* ECMA-262 3rd Edition 11.13.2 */
2984 HRESULT assign_sub_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2986 binary_expression_t *expr = (binary_expression_t*)_expr;
2990 return assign_oper_eval(ctx, expr->expression1, expr->expression2, sub_eval, ei, ret);
2993 /* ECMA-262 3rd Edition 11.13.2 */
2994 HRESULT assign_mul_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
2996 binary_expression_t *expr = (binary_expression_t*)_expr;
3000 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mul_eval, ei, ret);
3003 /* ECMA-262 3rd Edition 11.13.2 */
3004 HRESULT assign_div_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3006 binary_expression_t *expr = (binary_expression_t*)_expr;
3010 return assign_oper_eval(ctx, expr->expression1, expr->expression2, div_eval, ei, ret);
3013 /* ECMA-262 3rd Edition 11.13.2 */
3014 HRESULT assign_mod_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3016 binary_expression_t *expr = (binary_expression_t*)_expr;
3020 return assign_oper_eval(ctx, expr->expression1, expr->expression2, mod_eval, ei, ret);
3023 /* ECMA-262 3rd Edition 11.13.2 */
3024 HRESULT assign_and_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3026 binary_expression_t *expr = (binary_expression_t*)_expr;
3030 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitand_eval, ei, ret);
3033 /* ECMA-262 3rd Edition 11.13.2 */
3034 HRESULT assign_or_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3036 binary_expression_t *expr = (binary_expression_t*)_expr;
3040 return assign_oper_eval(ctx, expr->expression1, expr->expression2, bitor_eval, ei, ret);
3043 /* ECMA-262 3rd Edition 11.13.2 */
3044 HRESULT assign_xor_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
3046 binary_expression_t *expr = (binary_expression_t*)_expr;
3050 return assign_oper_eval(ctx, expr->expression1, expr->expression2, xor_eval, ei, ret);