From 8c353150eec30131a3bff1b0175e8385f01971c8 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Tue, 2 Mar 2010 19:46:01 +0000 Subject: [PATCH] [JSCRIPT] sync jscript to wine 1.1.39 svn path=/trunk/; revision=45765 --- reactos/dll/win32/jscript/activex.c | 5 +- reactos/dll/win32/jscript/array.c | 226 ++-- reactos/dll/win32/jscript/bool.c | 3 +- reactos/dll/win32/jscript/date.c | 3 +- reactos/dll/win32/jscript/dispex.c | 154 ++- reactos/dll/win32/jscript/engine.c | 102 +- reactos/dll/win32/jscript/engine.h | 34 +- reactos/dll/win32/jscript/error.c | 83 +- reactos/dll/win32/jscript/function.c | 186 ++- reactos/dll/win32/jscript/global.c | 276 ++++- reactos/dll/win32/jscript/jscript.c | 31 +- reactos/dll/win32/jscript/jscript.h | 16 +- reactos/dll/win32/jscript/jscript.inf | 44 +- reactos/dll/win32/jscript/jscript_De.rc | 1 + reactos/dll/win32/jscript/jscript_En.rc | 1 + reactos/dll/win32/jscript/jscript_Fr.rc | 1 + reactos/dll/win32/jscript/jscript_Ko.rc | 51 + reactos/dll/win32/jscript/jscript_Lt.rc | 1 + reactos/dll/win32/jscript/jscript_Ru.rc | 50 + reactos/dll/win32/jscript/jsutils.c | 18 +- reactos/dll/win32/jscript/lex.c | 31 +- reactos/dll/win32/jscript/number.c | 3 +- reactos/dll/win32/jscript/parser.tab.c | 1488 +++++++++++------------ reactos/dll/win32/jscript/parser.tab.h | 59 +- reactos/dll/win32/jscript/parser.y | 36 +- reactos/dll/win32/jscript/regexp.c | 231 ++-- reactos/dll/win32/jscript/resource.h | 1 + reactos/dll/win32/jscript/rsrc.rc | 2 + reactos/dll/win32/jscript/string.c | 77 +- 29 files changed, 1991 insertions(+), 1223 deletions(-) create mode 100644 reactos/dll/win32/jscript/jscript_Ko.rc create mode 100644 reactos/dll/win32/jscript/jscript_Ru.rc diff --git a/reactos/dll/win32/jscript/activex.c b/reactos/dll/win32/jscript/activex.c index cb94d4e5f34..947e4cfd289 100644 --- a/reactos/dll/win32/jscript/activex.c +++ b/reactos/dll/win32/jscript/activex.c @@ -86,7 +86,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid) if(FAILED(hres) || policy != URLPOLICY_ALLOW) return NULL; - hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, NULL, &IID_IClassFactory, (void**)&cf); + hres = CoGetClassObject(&guid, CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void**)&cf); if(FAILED(hres)) return NULL; @@ -192,7 +192,8 @@ HRESULT create_activex_constr(script_ctx_t *ctx, DispatchEx **ret) if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, PROPF_CONSTR, prototype, ret); + hres = create_builtin_function(ctx, ActiveXObject_value, ActiveXObjectW, NULL, + PROPF_CONSTR|1, prototype, ret); jsdisp_release(prototype); return hres; diff --git a/reactos/dll/win32/jscript/array.c b/reactos/dll/win32/jscript/array.c index 941e414567b..1268d59638b 100644 --- a/reactos/dll/win32/jscript/array.c +++ b/reactos/dll/win32/jscript/array.c @@ -166,7 +166,7 @@ static HRESULT concat_array(DispatchEx *array, ArrayInstance *obj, DWORD *len, HRESULT hres; for(i=0; i < obj->length; i++) { - hres = jsdisp_propget_idx(&obj->dispex, i, &var, ei, caller); + hres = jsdisp_get_idx(&obj->dispex, i, &var, ei, caller); if(hres == DISP_E_UNKNOWNNAME) continue; if(FAILED(hres)) @@ -267,8 +267,11 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co return E_OUTOFMEMORY; for(i=0; i < length; i++) { - hres = jsdisp_propget_idx(array, i, &var, ei, caller); - if(FAILED(hres)) + hres = jsdisp_get_idx(array, i, &var, ei, caller); + if(hres == DISP_E_UNKNOWNNAME) { + hres = S_OK; + continue; + } else if(FAILED(hres)) break; if(V_VT(&var) != VT_EMPTY && V_VT(&var) != VT_NULL) @@ -342,20 +345,18 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co } /* ECMA-262 3rd Edition 15.4.4.5 */ -static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, +static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + DispatchEx *jsthis; DWORD length; HRESULT hres; TRACE("\n"); - if(is_vclass(jsthis, JSCLASS_ARRAY)) { - length = array_from_vdisp(jsthis)->length; - }else { - FIXME("dispid is not Array\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(arg_cnt(dp)) { BSTR sep; @@ -364,62 +365,52 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA if(FAILED(hres)) return hres; - hres = array_join(ctx, jsthis->u.jsdisp, length, sep, retv, ei, caller); + hres = array_join(ctx, jsthis, length, sep, retv, ei, caller); SysFreeString(sep); }else { - hres = array_join(ctx, jsthis->u.jsdisp, length, default_separatorW, retv, ei, caller); + hres = array_join(ctx, jsthis, length, default_separatorW, retv, ei, caller); } return hres; } -static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, +static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + DispatchEx *jsthis; VARIANT val; DWORD length; - WCHAR buf[14]; - DISPID id; HRESULT hres; - static const WCHAR formatW[] = {'%','d',0}; - TRACE("\n"); - if(is_vclass(jsthis, JSCLASS_ARRAY)) { - ArrayInstance *array = array_from_vdisp(jsthis); - length = array->length; - }else { - FIXME("not Array this\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(!length) { + hres = set_length(jsthis, ei, 0); + if(FAILED(hres)) + return hres; + if(retv) V_VT(retv) = VT_EMPTY; return S_OK; } - sprintfW(buf, formatW, --length); - hres = jsdisp_get_id(jsthis->u.jsdisp, buf, 0, &id); + length--; + hres = jsdisp_get_idx(jsthis, length, &val, ei, caller); if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis->u.jsdisp, id, &val, ei, caller); - if(FAILED(hres)) - return hres; - - hres = IDispatchEx_DeleteMemberByDispID(jsthis->u.dispex, id); - }else if(hres == DISP_E_UNKNOWNNAME) { + hres = jsdisp_delete_idx(jsthis, length); + } else if(hres == DISP_E_UNKNOWNNAME) { V_VT(&val) = VT_EMPTY; hres = S_OK; - }else { + } else return hres; - } - if(SUCCEEDED(hres)) { - ArrayInstance *array = array_from_vdisp(jsthis); - array->length = length; - } + if(SUCCEEDED(hres)) + hres = set_length(jsthis, ei, length); if(FAILED(hres)) { VariantClear(&val); @@ -430,6 +421,7 @@ static HRESULT Array_pop(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPAR *retv = val; else VariantClear(&val); + return S_OK; } @@ -469,8 +461,59 @@ static HRESULT Array_push(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPAR static HRESULT Array_reverse(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + DispatchEx *jsthis; + DWORD length, k, l; + VARIANT v1, v2; + HRESULT hres1, hres2; + + TRACE("\n"); + + hres1 = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres1)) + return hres1; + + for(k=0; klength; - }else { - FIXME("unsupported this not array\n"); - return E_NOTIMPL; - } + hres = get_length(ctx, vthis, ei, &jsthis, &length); + if(FAILED(hres)) + return hres; if(arg_cnt(dp) > 1) { WARN("invalid arg_cnt %d\n", arg_cnt(dp)); @@ -707,8 +749,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA jsdisp_release(cmp_func); if(retv) { V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = jsthis->u.disp; - IDispatch_AddRef(jsthis->u.disp); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(jsthis); + IDispatch_AddRef(V_DISPATCH(retv)); } return S_OK; } @@ -716,8 +758,11 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA vtab = heap_alloc_zero(length * sizeof(VARIANT)); if(vtab) { for(i=0; iu.jsdisp, i, vtab+i, ei, caller); - if(FAILED(hres) && hres != DISP_E_UNKNOWNNAME) { + hres = jsdisp_get_idx(jsthis, i, vtab+i, ei, caller); + if(hres == DISP_E_UNKNOWNNAME) { + V_VT(vtab+i) = VT_EMPTY; + hres = S_OK; + } else if(FAILED(hres)) { WARN("Could not get elem %d: %08x\n", i, hres); break; } @@ -793,7 +838,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA } for(i=0; SUCCEEDED(hres) && i < length; i++) - hres = jsdisp_propput_idx(jsthis->u.jsdisp, i, sorttab[i], ei, caller); + hres = jsdisp_propput_idx(jsthis, i, sorttab[i], ei, caller); } if(vtab) { @@ -810,8 +855,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA if(retv) { V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = jsthis->u.disp; - IDispatch_AddRef(jsthis->u.disp); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(jsthis); + IDispatch_AddRef(V_DISPATCH(retv)); } return S_OK; @@ -869,7 +914,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP return hres; for(i=0; SUCCEEDED(hres) && i < delete_cnt; i++) { - hres = jsdisp_propget_idx(jsthis, start+i, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, start+i, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = S_OK; else if(SUCCEEDED(hres)) @@ -886,7 +931,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP if(add_args < delete_cnt) { for(i = start; SUCCEEDED(hres) && i < length-delete_cnt; i++) { - hres = jsdisp_propget_idx(jsthis, i+delete_cnt, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, i+delete_cnt, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i+add_args); else if(SUCCEEDED(hres)) @@ -897,7 +942,7 @@ static HRESULT Array_splice(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPP hres = jsdisp_delete_idx(jsthis, i-1); }else if(add_args > delete_cnt) { for(i=length-delete_cnt; SUCCEEDED(hres) && i != start; i--) { - hres = jsdisp_propget_idx(jsthis, i+delete_cnt-1, &v, ei, caller); + hres = jsdisp_get_idx(jsthis, i+delete_cnt-1, &v, ei, caller); if(hres == DISP_E_UNKNOWNNAME) hres = jsdisp_delete_idx(jsthis, i+add_args-1); else if(SUCCEEDED(hres)) @@ -967,29 +1012,25 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres; argc = arg_cnt(dp); - if(!argc) { - if(retv) - V_VT(retv) = VT_EMPTY; - return S_OK; - } + if(argc) { + buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; + *buf_end-- = 0; + i = length; - buf_end = buf + sizeof(buf)/sizeof(WCHAR)-1; - *buf_end-- = 0; - i = length; + while(i--) { + str = idx_to_str(i, buf_end); - while(i--) { - str = idx_to_str(i, buf_end); + hres = jsdisp_get_id(jsthis, str, 0, &id); + if(SUCCEEDED(hres)) { + hres = jsdisp_propget(jsthis, id, &var, ei, caller); + if(FAILED(hres)) + return hres; - hres = jsdisp_get_id(jsthis, str, 0, &id); - if(SUCCEEDED(hres)) { - hres = jsdisp_propget(jsthis, id, &var, ei, caller); - if(FAILED(hres)) - return hres; - - hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller); - VariantClear(&var); - }else if(hres == DISP_E_UNKNOWNNAME) { - hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); + hres = jsdisp_propput_idx(jsthis, i+argc, &var, ei, caller); + VariantClear(&var); + }else if(hres == DISP_E_UNKNOWNNAME) { + hres = IDispatchEx_DeleteMemberByDispID(vthis->u.dispex, id); + } } if(FAILED(hres)) @@ -1002,12 +1043,21 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISP return hres; } - hres = set_length(jsthis, ei, length+argc); - if(FAILED(hres)) - return hres; + if(argc) { + length += argc; + hres = set_length(jsthis, ei, length); + if(FAILED(hres)) + return hres; + } - if(retv) - V_VT(retv) = VT_EMPTY; + if(retv) { + if(ctx->version < 2) { + V_VT(retv) = VT_EMPTY; + }else { + V_VT(retv) = VT_I4; + V_I4(retv) = length; + } + } return S_OK; } @@ -1166,7 +1216,7 @@ HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Dis if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, ArrayConstr_value, ArrayW, NULL, PROPF_CONSTR, &array->dispex, ret); + hres = create_builtin_function(ctx, ArrayConstr_value, ArrayW, NULL, PROPF_CONSTR|1, &array->dispex, ret); jsdisp_release(&array->dispex); return hres; diff --git a/reactos/dll/win32/jscript/bool.c b/reactos/dll/win32/jscript/bool.c index 1fca406c184..4f23678a2e3 100644 --- a/reactos/dll/win32/jscript/bool.c +++ b/reactos/dll/win32/jscript/bool.c @@ -191,7 +191,8 @@ HRESULT create_bool_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Disp if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, BoolConstr_value, BooleanW, NULL, PROPF_CONSTR, &bool->dispex, ret); + hres = create_builtin_function(ctx, BoolConstr_value, BooleanW, NULL, + PROPF_CONSTR|1, &bool->dispex, ret); jsdisp_release(&bool->dispex); return hres; diff --git a/reactos/dll/win32/jscript/date.c b/reactos/dll/win32/jscript/date.c index f8d3522939b..71d37519fd7 100644 --- a/reactos/dll/win32/jscript/date.c +++ b/reactos/dll/win32/jscript/date.c @@ -2624,7 +2624,8 @@ HRESULT create_date_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Disp if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, DateConstr_value, DateW, &DateConstr_info, PROPF_CONSTR, date, ret); + hres = create_builtin_function(ctx, DateConstr_value, DateW, &DateConstr_info, + PROPF_CONSTR|7, date, ret); jsdisp_release(date); return hres; diff --git a/reactos/dll/win32/jscript/dispex.c b/reactos/dll/win32/jscript/dispex.c index 307efd97a22..6894eae0515 100644 --- a/reactos/dll/win32/jscript/dispex.c +++ b/reactos/dll/win32/jscript/dispex.c @@ -30,6 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); static const IID IID_IDispatchJS = {0x719c3050,0xf9d3,0x11cf,{0xa4,0x93,0x00,0x40,0x05,0x23,0xa8,0xa6}}; +#define FDEX_VERSION_MASK 0xf0000000 + typedef enum { PROP_VARIANT, PROP_BUILTIN, @@ -158,7 +160,7 @@ static HRESULT find_prop_name(DispatchEx *This, const WCHAR *name, dispex_prop_t return S_OK; } -static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL alloc, dispex_prop_t **ret) +static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, dispex_prop_t **ret) { dispex_prop_t *prop; HRESULT hres; @@ -172,7 +174,7 @@ static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL all } if(This->prototype) { - hres = find_prop_name_prot(This->prototype, name, FALSE, &prop); + hres = find_prop_name_prot(This->prototype, name, &prop); if(FAILED(hres)) return hres; if(prop) { @@ -184,17 +186,30 @@ static HRESULT find_prop_name_prot(DispatchEx *This, const WCHAR *name, BOOL all } } - if(alloc) { + *ret = prop; + return S_OK; +} + +static HRESULT ensure_prop_name(DispatchEx *This, const WCHAR *name, BOOL search_prot, DWORD create_flags, dispex_prop_t **ret) +{ + dispex_prop_t *prop; + HRESULT hres; + + if(search_prot) + hres = find_prop_name_prot(This, name, &prop); + else + hres = find_prop_name(This, name, &prop); + if(SUCCEEDED(hres) && !prop) { TRACE("creating prop %s\n", debugstr_w(name)); - prop = alloc_prop(This, name, PROP_VARIANT, PROPF_ENUM); + prop = alloc_prop(This, name, PROP_VARIANT, create_flags); if(!prop) return E_OUTOFMEMORY; VariantInit(&prop->u.var); } *ret = prop; - return S_OK; + return hres; } static HRESULT set_this(DISPPARAMS *dp, DISPPARAMS *olddp, IDispatch *jsthis) @@ -338,19 +353,19 @@ static HRESULT prop_get(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, return hres; } -static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, +static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DWORD i; HRESULT hres; switch(prop->type) { case PROP_BUILTIN: if(!(prop->flags & PROPF_METHOD)) { + DISPPARAMS dp = {val, NULL, 1, 0}; vdisp_t vthis; set_jsdisp(&vthis, This); - hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, dp, NULL, ei, caller); + hres = prop->u.p->invoke(This->ctx, &vthis, DISPATCH_PROPERTYPUT, &dp, NULL, ei, caller); vdisp_release(&vthis); return hres; } @@ -367,24 +382,14 @@ static HRESULT prop_put(DispatchEx *This, dispex_prop_t *prop, DISPPARAMS *dp, return E_FAIL; } - for(i=0; i < dp->cNamedArgs; i++) { - if(dp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT) - break; - } - - if(i == dp->cNamedArgs) { - TRACE("no value to set\n"); - return DISP_E_PARAMNOTOPTIONAL; - } - - hres = VariantCopy(&prop->u.var, dp->rgvarg+i); + hres = VariantCopy(&prop->u.var, val); if(FAILED(hres)) return hres; if(This->builtin_info->on_put) This->builtin_info->on_put(This, prop->name); - TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_variant(dp->rgvarg+i)); + TRACE("%s = %s\n", debugstr_w(prop->name), debugstr_variant(val)); return S_OK; } @@ -471,6 +476,8 @@ static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface) } heap_free(This->props); script_release(This->ctx); + if(This->prototype) + jsdisp_release(This->prototype); if(This->builtin_info->destructor) This->builtin_info->destructor(This); @@ -538,7 +545,7 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid); - if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit)) { + if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit|FDEX_VERSION_MASK)) { FIXME("Unsupported grfdex %x\n", grfdex); return E_NOTIMPL; } @@ -575,9 +582,22 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc case DISPATCH_PROPERTYGET: hres = prop_get(This, prop, pdp, pvarRes, &jsexcept, pspCaller); break; - case DISPATCH_PROPERTYPUT: - hres = prop_put(This, prop, pdp, &jsexcept, pspCaller); + case DISPATCH_PROPERTYPUT: { + DWORD i; + + for(i=0; i < pdp->cNamedArgs; i++) { + if(pdp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT) + break; + } + + if(i == pdp->cNamedArgs) { + TRACE("no value to set\n"); + return DISP_E_PARAMNOTOPTIONAL; + } + + hres = prop_put(This, prop, pdp->rgvarg+i, &jsexcept, pspCaller); break; + } default: FIXME("Unimplemented flags %x\n", wFlags); return E_INVALIDARG; @@ -606,7 +626,7 @@ static HRESULT WINAPI DispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bst TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex); - if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit)) + if(grfdex & ~(fdexNameCaseSensitive|fdexNameEnsure|fdexNameImplicit|FDEX_VERSION_MASK)) FIXME("Unsupported grfdex %x\n", grfdex); hres = find_prop_name(This, bstrName, &prop); @@ -783,9 +803,10 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui dispex_prop_t *prop; HRESULT hres; + static const WCHAR constructorW[] = {'c','o','n','s','t','r','u','c','t','o','r'}; static const WCHAR prototypeW[] = {'p','r','o','t','o','t','y','p','e',0}; - hres = find_prop_name_prot(constr, prototypeW, FALSE, &prop); + hres = find_prop_name_prot(constr, prototypeW, &prop); if(SUCCEEDED(hres) && prop) { jsexcept_t jsexcept; VARIANT var; @@ -807,6 +828,22 @@ HRESULT init_dispex_from_constr(DispatchEx *dispex, script_ctx_t *ctx, const bui if(prot) jsdisp_release(prot); + if(FAILED(hres)) + return hres; + + hres = ensure_prop_name(dispex, constructorW, FALSE, 0, &prop); + if(SUCCEEDED(hres)) { + jsexcept_t jsexcept; + VARIANT var; + + V_VT(&var) = VT_DISPATCH; + V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(constr); + memset(&jsexcept, 0, sizeof(jsexcept)); + hres = prop_put(dispex, prop, &var, &jsexcept, NULL/*FIXME*/); + } + if(FAILED(hres)) + jsdisp_release(dispex); + return hres; } @@ -827,7 +864,10 @@ HRESULT jsdisp_get_id(DispatchEx *jsdisp, const WCHAR *name, DWORD flags, DISPID dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(jsdisp, name, (flags&fdexNameEnsure) != 0, &prop); + if(flags & fdexNameEnsure) + hres = ensure_prop_name(jsdisp, name, TRUE, PROPF_ENUM, &prop); + else + hres = find_prop_name_prot(jsdisp, name, &prop); if(FAILED(hres)) return hres; @@ -874,7 +914,7 @@ HRESULT jsdisp_call_name(DispatchEx *disp, const WCHAR *name, WORD flags, DISPPA dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(disp, name, TRUE, &prop); + hres = find_prop_name_prot(disp, name, &prop); if(FAILED(hres)) return hres; @@ -924,16 +964,14 @@ HRESULT disp_call(script_ctx_t *ctx, IDispatch *disp, DISPID id, WORD flags, DIS HRESULT jsdisp_propput_name(DispatchEx *obj, const WCHAR *name, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DISPID named_arg = DISPID_PROPERTYPUT; - DISPPARAMS dp = {val, &named_arg, 1, 1}; dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(obj, name, TRUE, &prop); + hres = ensure_prop_name(obj, name, FALSE, PROPF_ENUM, &prop); if(FAILED(hres)) return hres; - return prop_put(obj, prop, &dp, ei, caller); + return prop_put(obj, prop, val, ei, caller); } HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) @@ -948,9 +986,6 @@ HRESULT jsdisp_propput_idx(DispatchEx *obj, DWORD idx, VARIANT *val, jsexcept_t HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) { - DISPID dispid = DISPID_PROPERTYPUT; - DISPPARAMS dp = {val, &dispid, 1, 1}; - IDispatchEx *dispex; DispatchEx *jsdisp; HRESULT hres; @@ -960,25 +995,28 @@ HRESULT disp_propput(script_ctx_t *ctx, IDispatch *disp, DISPID id, VARIANT *val prop = get_prop(jsdisp, id); if(prop) - hres = prop_put(jsdisp, prop, &dp, ei, caller); + hres = prop_put(jsdisp, prop, val, ei, caller); else hres = DISP_E_MEMBERNOTFOUND; jsdisp_release(jsdisp); - return hres; + }else { + DISPID dispid = DISPID_PROPERTYPUT; + DISPPARAMS dp = {val, &dispid, 1, 1}; + IDispatchEx *dispex; + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(SUCCEEDED(hres)) { + hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, caller); + IDispatchEx_Release(dispex); + }else { + ULONG err = 0; + + TRACE("using IDispatch\n"); + hres = IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, &err); + } } - hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); - if(FAILED(hres)) { - ULONG err = 0; - - TRACE("using IDispatch\n"); - return IDispatch_Invoke(disp, id, &IID_NULL, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, &err); - } - - hres = IDispatchEx_InvokeEx(dispex, id, ctx->lcid, DISPATCH_PROPERTYPUT, &dp, NULL, &ei->ei, caller); - - IDispatchEx_Release(dispex); return hres; } @@ -988,7 +1026,7 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, js dispex_prop_t *prop; HRESULT hres; - hres = find_prop_name_prot(obj, name, FALSE, &prop); + hres = find_prop_name_prot(obj, name, &prop); if(FAILED(hres)) return hres; @@ -999,14 +1037,26 @@ HRESULT jsdisp_propget_name(DispatchEx *obj, const WCHAR *name, VARIANT *var, js return prop_get(obj, prop, &dp, var, ei, caller); } -HRESULT jsdisp_propget_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) +HRESULT jsdisp_get_idx(DispatchEx *obj, DWORD idx, VARIANT *var, jsexcept_t *ei, IServiceProvider *caller) { - WCHAR buf[12]; + WCHAR name[12]; + DISPPARAMS dp = {NULL, NULL, 0, 0}; + dispex_prop_t *prop; + HRESULT hres; static const WCHAR formatW[] = {'%','d',0}; - sprintfW(buf, formatW, idx); - return jsdisp_propget_name(obj, buf, var, ei, caller); + sprintfW(name, formatW, idx); + + hres = find_prop_name_prot(obj, name, &prop); + if(FAILED(hres)) + return hres; + + V_VT(var) = VT_EMPTY; + if(!prop) + return DISP_E_UNKNOWNNAME; + + return prop_get(obj, prop, &dp, var, ei, caller); } HRESULT jsdisp_propget(DispatchEx *jsdisp, DISPID id, VARIANT *val, jsexcept_t *ei, IServiceProvider *caller) diff --git a/reactos/dll/win32/jscript/engine.c b/reactos/dll/win32/jscript/engine.c index cecfd62b606..b40a88eb591 100644 --- a/reactos/dll/win32/jscript/engine.c +++ b/reactos/dll/win32/jscript/engine.c @@ -223,7 +223,7 @@ void exec_release(exec_ctx_t *ctx) heap_free(ctx); } -static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id) +static HRESULT disp_get_id(script_ctx_t *ctx, IDispatch *disp, BSTR name, DWORD flags, DISPID *id) { IDispatchEx *dispex; HRESULT hres; @@ -237,7 +237,7 @@ static HRESULT disp_get_id(IDispatch *disp, BSTR name, DWORD flags, DISPID *id) } *id = 0; - hres = IDispatchEx_GetDispID(dispex, name, flags|fdexNameCaseSensitive, id); + hres = IDispatchEx_GetDispID(dispex, name, make_grfdex(ctx, flags|fdexNameCaseSensitive), id); IDispatchEx_Release(dispex); return hres; } @@ -347,33 +347,45 @@ static HRESULT equal2_values(VARIANT *lval, VARIANT *rval, BOOL *ret) return S_OK; } -static HRESULT literal_to_var(literal_t *literal, VARIANT *v) +static HRESULT literal_to_var(script_ctx_t *ctx, literal_t *literal, VARIANT *v) { - V_VT(v) = literal->vt; - - switch(V_VT(v)) { - case VT_EMPTY: - case VT_NULL: + switch(literal->type) { + case LT_NULL: + V_VT(v) = VT_NULL; break; - case VT_I4: + case LT_INT: + V_VT(v) = VT_I4; V_I4(v) = literal->u.lval; break; - case VT_R8: + case LT_DOUBLE: + V_VT(v) = VT_R8; V_R8(v) = literal->u.dval; break; - case VT_BSTR: - V_BSTR(v) = SysAllocString(literal->u.wstr); + case LT_STRING: { + BSTR str = SysAllocString(literal->u.wstr); + if(!str) + return E_OUTOFMEMORY; + + V_VT(v) = VT_BSTR; + V_BSTR(v) = str; break; - case VT_BOOL: + } + case LT_BOOL: + V_VT(v) = VT_BOOL; V_BOOL(v) = literal->u.bval; break; - case VT_DISPATCH: - IDispatch_AddRef(literal->u.disp); - V_DISPATCH(v) = literal->u.disp; - break; - default: - ERR("wrong type %d\n", V_VT(v)); - return E_NOTIMPL; + case LT_REGEXP: { + DispatchEx *regexp; + HRESULT hres; + + hres = create_regexp(ctx, literal->u.regexp.str, literal->u.regexp.str_len, + literal->u.regexp.flags, ®exp); + if(FAILED(hres)) + return hres; + + V_VT(v) = VT_DISPATCH; + V_DISPATCH(v) = (IDispatch*)_IDispatchEx_(regexp); + } } return S_OK; @@ -387,7 +399,7 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t for(item = ctx->named_items; item; item = item->next) { if(item->flags & SCRIPTITEM_GLOBALMEMBERS) { - hres = disp_get_id(item->disp, identifier, 0, &id); + hres = disp_get_id(ctx, item->disp, identifier, 0, &id); if(SUCCEEDED(hres)) { if(ret) exprval_set_idref(ret, item->disp, id); @@ -399,7 +411,8 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t return FALSE; } -HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, jsexcept_t *ei, VARIANT *retv) +HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *source, exec_type_t exec_type, + jsexcept_t *ei, VARIANT *retv) { script_ctx_t *script = parser->script; function_declaration_t *func; @@ -478,10 +491,14 @@ HRESULT exec_source(exec_ctx_t *ctx, parser_ctx_t *parser, source_elements_t *so return hres; } - if(retv) + if(retv && (exec_type == EXECT_EVAL || rt.type == RT_RETURN)) *retv = val; - else + else { + if (retv) { + VariantInit(retv); + } VariantClear(&val); + } return S_OK; } @@ -1380,7 +1397,7 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, TRACE("\n"); - hres = expr_eval(ctx, expr->member_expr, EXPR_NEWREF, ei, &exprval); + hres = expr_eval(ctx, expr->member_expr, 0, ei, &exprval); if(FAILED(hres)) return hres; @@ -1395,11 +1412,15 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, exprval_release(&exprval); } - if(SUCCEEDED(hres)) + if(SUCCEEDED(hres)) { hres = to_object(ctx->parser->script, &member, &obj); + if(FAILED(hres)) + VariantClear(&val); + } VariantClear(&member); if(SUCCEEDED(hres)) { hres = to_string(ctx->parser->script, &val, ei, &str); + VariantClear(&val); if(SUCCEEDED(hres)) { if(flags & EXPR_STRREF) { ret->type = EXPRVAL_NAMEREF; @@ -1408,7 +1429,8 @@ HRESULT array_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return S_OK; } - hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx->parser->script, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + SysFreeString(str); } if(SUCCEEDED(hres)) { @@ -1459,7 +1481,7 @@ HRESULT member_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags return S_OK; } - hres = disp_get_id(obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); + hres = disp_get_id(ctx->parser->script, obj, str, flags & EXPR_NEWREF ? fdexNameEnsure : 0, &id); SysFreeString(str); if(SUCCEEDED(hres)) { exprval_set_idref(ret, obj, id); @@ -1552,6 +1574,7 @@ HRESULT new_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, j hres = disp_call(ctx->parser->script, V_DISPATCH(&constr), DISPID_VALUE, DISPATCH_CONSTRUCT, &dp, &var, ei, NULL/*FIXME*/); IDispatch_Release(V_DISPATCH(&constr)); + free_dp(&dp); if(FAILED(hres)) return hres; @@ -1654,7 +1677,7 @@ HRESULT literal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flag TRACE("\n"); - hres = literal_to_var(expr->literal, &var); + hres = literal_to_var(ctx->parser->script, expr->literal, &var); if(FAILED(hres)) return hres; @@ -1733,7 +1756,7 @@ HRESULT property_value_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWO return hres; for(iter = expr->property_list; iter; iter = iter->next) { - hres = literal_to_var(iter->name, &tmp); + hres = literal_to_var(ctx->parser->script, iter->name, &tmp); if(FAILED(hres)) break; @@ -2053,7 +2076,7 @@ static HRESULT in_eval(exec_ctx_t *ctx, VARIANT *lval, VARIANT *obj, jsexcept_t if(FAILED(hres)) return hres; - hres = disp_get_id(V_DISPATCH(obj), str, 0, &id); + hres = disp_get_id(ctx->parser->script, V_DISPATCH(obj), str, 0, &id); SysFreeString(str); if(SUCCEEDED(hres)) ret = VARIANT_TRUE; @@ -2293,7 +2316,8 @@ HRESULT delete_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags hres = IDispatch_QueryInterface(exprval.u.nameref.disp, &IID_IDispatchEx, (void**)&dispex); if(SUCCEEDED(hres)) { - hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, fdexNameCaseSensitive); + hres = IDispatchEx_DeleteMemberByName(dispex, exprval.u.nameref.name, + make_grfdex(ctx->parser->script, fdexNameCaseSensitive)); b = VARIANT_TRUE; IDispatchEx_Release(dispex); } @@ -2472,6 +2496,7 @@ HRESULT plus_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return hres; hres = to_number(ctx->parser->script, &val, ei, &num); + VariantClear(&val); if(FAILED(hres)) return hres; @@ -2731,6 +2756,8 @@ HRESULT equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, return hres; hres = equal_values(ctx, &rval, &lval, ei, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2752,6 +2779,8 @@ HRESULT equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags return hres; hres = equal2_values(&rval, &lval, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2773,6 +2802,8 @@ HRESULT not_equal_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD fl return hres; hres = equal_values(ctx, &lval, &rval, ei, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -2794,6 +2825,8 @@ HRESULT not_equal2_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD f return hres; hres = equal2_values(&lval, &rval, &b); + VariantClear(&lval); + VariantClear(&rval); if(FAILED(hres)) return hres; @@ -3096,8 +3129,11 @@ HRESULT assign_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags exprval_release(&exprvalr); } - if(SUCCEEDED(hres)) + if(SUCCEEDED(hres)) { hres = put_value(ctx->parser->script, &exprval, &rval, ei); + if(FAILED(hres)) + VariantClear(&rval); + } exprval_release(&exprval); if(FAILED(hres)) diff --git a/reactos/dll/win32/jscript/engine.h b/reactos/dll/win32/jscript/engine.h index 386f38b51fd..0bcabf614d2 100644 --- a/reactos/dll/win32/jscript/engine.h +++ b/reactos/dll/win32/jscript/engine.h @@ -19,11 +19,6 @@ typedef struct _source_elements_t source_elements_t; typedef struct _function_expression_t function_expression_t; -typedef struct _obj_literal_t { - DispatchEx *obj; - struct _obj_literal_t *next; -} obj_literal_t; - typedef struct _function_declaration_t { function_expression_t *expr; @@ -48,9 +43,9 @@ typedef struct _func_stack { typedef struct _parser_ctx_t { LONG ref; - const WCHAR *ptr; - const WCHAR *begin; + WCHAR *begin; const WCHAR *end; + const WCHAR *ptr; script_ctx_t *script; source_elements_t *source; @@ -61,7 +56,6 @@ typedef struct _parser_ctx_t { jsheap_t heap; - obj_literal_t *obj_literals; func_stack_t *func_stack; struct _parser_ctx_t *next; @@ -115,9 +109,15 @@ static inline void exec_addref(exec_ctx_t *ctx) ctx->ref++; } +typedef enum { + EXECT_PROGRAM, + EXECT_FUNCTION, + EXECT_EVAL +} exec_type_t; + void exec_release(exec_ctx_t*); HRESULT create_exec_ctx(script_ctx_t*,IDispatch*,DispatchEx*,scope_chain_t*,exec_ctx_t**); -HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*); +HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,exec_type_t,jsexcept_t*,VARIANT*); typedef struct _statement_t statement_t; typedef struct _expression_t expression_t; @@ -126,14 +126,28 @@ typedef struct _parameter_t parameter_t; HRESULT create_source_function(parser_ctx_t*,parameter_t*,source_elements_t*,scope_chain_t*, const WCHAR*,DWORD,DispatchEx**); +typedef enum { + LT_INT, + LT_DOUBLE, + LT_STRING, + LT_BOOL, + LT_NULL, + LT_REGEXP +}literal_type_t; + typedef struct { - VARTYPE vt; + literal_type_t type; union { LONG lval; double dval; const WCHAR *wstr; VARIANT_BOOL bval; IDispatch *disp; + struct { + const WCHAR *str; + DWORD str_len; + DWORD flags; + } regexp; } u; } literal_t; diff --git a/reactos/dll/win32/jscript/error.c b/reactos/dll/win32/jscript/error.c index 9530a4ce52a..e3cfce634ee 100644 --- a/reactos/dll/win32/jscript/error.c +++ b/reactos/dll/win32/jscript/error.c @@ -36,6 +36,7 @@ typedef struct { static const WCHAR descriptionW[] = {'d','e','s','c','r','i','p','t','i','o','n',0}; static const WCHAR messageW[] = {'m','e','s','s','a','g','e',0}; +static const WCHAR nameW[] = {'n','a','m','e',0}; static const WCHAR numberW[] = {'n','u','m','b','e','r',0}; static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; @@ -44,6 +45,11 @@ static inline ErrorInstance *error_from_vdisp(vdisp_t *vdisp) return (ErrorInstance*)vdisp->u.jsdisp; } +static inline ErrorInstance *error_this(vdisp_t *jsthis) +{ + return is_vclass(jsthis, JSCLASS_ERROR) ? error_from_vdisp(jsthis) : NULL; +} + static HRESULT Error_number(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { @@ -101,17 +107,77 @@ static HRESULT Error_message(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, /* ECMA-262 3rd Edition 15.11.4.4 */ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, - DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) + DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { + ErrorInstance *error; + BSTR name, msg = NULL, ret = NULL; + VARIANT v; + HRESULT hres; + static const WCHAR str[] = {'[','o','b','j','e','c','t',' ','E','r','r','o','r',']',0}; TRACE("\n"); + error = error_this(jsthis); + if(ctx->version < 2 || !error) { + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = SysAllocString(str); + if(!V_BSTR(retv)) + return E_OUTOFMEMORY; + } + return S_OK; + } + + hres = jsdisp_propget_name(&error->dispex, nameW, &v, ei, caller); + if(FAILED(hres)) + return hres; + + hres = to_string(ctx, &v, ei, &name); + VariantClear(&v); + if(FAILED(hres)) + return hres; + + if(V_VT(&error->message) != VT_EMPTY) { + hres = to_string(ctx, &error->message, ei, &msg); + if(SUCCEEDED(hres) && !*msg) { + SysFreeString(msg); + msg = NULL; + } + } + + if(SUCCEEDED(hres)) { + if(msg) { + DWORD name_len, msg_len; + + name_len = SysStringLen(name); + msg_len = SysStringLen(msg); + + ret = SysAllocStringLen(NULL, name_len + msg_len + 2); + if(ret) { + memcpy(ret, name, name_len*sizeof(WCHAR)); + ret[name_len] = ':'; + ret[name_len+1] = ' '; + memcpy(ret+name_len+2, msg, msg_len*sizeof(WCHAR)); + } + }else { + ret = name; + name = NULL; + } + } + + SysFreeString(msg); + SysFreeString(name); + if(FAILED(hres)) + return hres; + if(!ret) + return E_OUTOFMEMORY; + if(retv) { V_VT(retv) = VT_BSTR; - V_BSTR(retv) = SysAllocString(str); - if(!V_BSTR(retv)) - return E_OUTOFMEMORY; + V_BSTR(retv) = ret; + }else { + SysFreeString(ret); } return S_OK; @@ -264,6 +330,7 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, DISPPARAMS *dp, hres = create_error(ctx, constr, NULL, msg, &err); else hres = create_error(ctx, constr, &num, msg, &err); + SysFreeString(msg); if(FAILED(hres)) return hres; @@ -341,7 +408,6 @@ static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype) { - static const WCHAR nameW[] = {'n','a','m','e',0}; static const WCHAR ErrorW[] = {'E','r','r','o','r',0}; static const WCHAR EvalErrorW[] = {'E','v','a','l','E','r','r','o','r',0}; static const WCHAR RangeErrorW[] = {'R','a','n','g','e','E','r','r','o','r',0}; @@ -381,7 +447,7 @@ HRESULT init_error_constr(script_ctx_t *ctx, DispatchEx *object_prototype) if(SUCCEEDED(hres)) hres = create_builtin_function(ctx, constr_val[i], names[i], NULL, - PROPF_CONSTR, &err->dispex, constr_addr[i]); + PROPF_CONSTR|1, &err->dispex, constr_addr[i]); jsdisp_release(&err->dispex); VariantClear(&v); @@ -424,11 +490,6 @@ static HRESULT throw_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCH return id; } -HRESULT throw_eval_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str) -{ - return throw_error(ctx, ei, id, str, ctx->eval_error_constr); -} - HRESULT throw_generic_error(script_ctx_t *ctx, jsexcept_t *ei, UINT id, const WCHAR *str) { return throw_error(ctx, ei, id, str, ctx->error_constr); diff --git a/reactos/dll/win32/jscript/function.c b/reactos/dll/win32/jscript/function.c index b0fb79d711d..c7494cfce6c 100644 --- a/reactos/dll/win32/jscript/function.c +++ b/reactos/dll/win32/jscript/function.c @@ -213,10 +213,11 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis hres = create_exec_ctx(ctx, this_obj, var_disp, scope, &exec_ctx); scope_release(scope); } + jsdisp_release(var_disp); if(FAILED(hres)) return hres; - hres = exec_source(exec_ctx, function->parser, function->source, ei, retv); + hres = exec_source(exec_ctx, function->parser, function->source, EXECT_FUNCTION, ei, retv); exec_release(exec_ctx); return hres; @@ -226,20 +227,27 @@ static HRESULT invoke_constructor(script_ctx_t *ctx, FunctionInstance *function, VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller) { DispatchEx *this_obj; + VARIANT var; HRESULT hres; hres = create_object(ctx, &function->dispex, &this_obj); if(FAILED(hres)) return hres; - hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, retv, ei, caller); + hres = invoke_source(ctx, function, (IDispatch*)_IDispatchEx_(this_obj), dp, &var, ei, caller); if(FAILED(hres)) { jsdisp_release(this_obj); return hres; } V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj); + if(V_VT(&var) == VT_DISPATCH) { + jsdisp_release(this_obj); + V_DISPATCH(retv) = V_DISPATCH(&var); + }else { + VariantClear(&var); + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(this_obj); + } return S_OK; } @@ -366,8 +374,10 @@ static HRESULT array_to_args(script_ctx_t *ctx, DispatchEx *arg_array, jsexcept_ return E_OUTOFMEMORY; for(i=0; i= 2) { @@ -406,8 +420,8 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI if(V_VT(get_arg(dp,1)) == VT_DISPATCH) { arg_array = iface_to_jsdisp((IUnknown*)V_DISPATCH(get_arg(dp,1))); - if(arg_array && ( - !is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { + if(arg_array && + (!is_class(arg_array, JSCLASS_ARRAY) && !is_class(arg_array, JSCLASS_ARGUMENTS) )) { jsdisp_release(arg_array); arg_array = NULL; } @@ -448,9 +462,14 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS argc = arg_cnt(dp); if(argc) { - hres = to_object(ctx, get_arg(dp,0), &this_obj); - if(FAILED(hres)) - return hres; + VARIANT *v = get_arg(dp,0); + + if(V_VT(v) != VT_EMPTY && V_VT(v) != VT_NULL) { + hres = to_object(ctx, v, &this_obj); + if(FAILED(hres)) + return hres; + } + args.cArgs = argc-1; } @@ -539,20 +558,6 @@ static const builtin_info_t Function_info = { NULL }; -static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, - VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) -{ - FIXME("\n"); - return E_NOTIMPL; -} - -static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, - VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) -{ - FIXME("\n"); - return E_NOTIMPL; -} - static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, DWORD flags, BOOL funcprot, DispatchEx *prototype, FunctionInstance **ret) { @@ -659,6 +664,131 @@ HRESULT create_source_function(parser_ctx_t *ctx, parameter_t *parameters, sourc return S_OK; } +static HRESULT construct_function(script_ctx_t *ctx, DISPPARAMS *dp, jsexcept_t *ei, IDispatch **ret) +{ + function_expression_t *expr; + WCHAR *str = NULL, *ptr; + DWORD argc, len = 0, l; + parser_ctx_t *parser; + DispatchEx *function; + BSTR *params = NULL; + int i=0, j=0; + HRESULT hres = S_OK; + + static const WCHAR function_anonymousW[] = {'f','u','n','c','t','i','o','n',' ','a','n','o','n','y','m','o','u','s','('}; + static const WCHAR function_beginW[] = {')',' ','{','\n'}; + static const WCHAR function_endW[] = {'\n','}',0}; + + argc = arg_cnt(dp); + if(argc) { + params = heap_alloc(argc*sizeof(BSTR)); + if(!params) + return E_OUTOFMEMORY; + + if(argc > 2) + len = (argc-2)*2; /* separating commas */ + for(i=0; i < argc; i++) { + hres = to_string(ctx, get_arg(dp,i), ei, params+i); + if(FAILED(hres)) + break; + len += SysStringLen(params[i]); + } + } + + if(SUCCEEDED(hres)) { + len += (sizeof(function_anonymousW) + sizeof(function_beginW) + sizeof(function_endW)) / sizeof(WCHAR); + str = heap_alloc(len*sizeof(WCHAR)); + if(str) { + memcpy(str, function_anonymousW, sizeof(function_anonymousW)); + ptr = str + sizeof(function_anonymousW)/sizeof(WCHAR); + if(argc > 1) { + while(1) { + l = SysStringLen(params[j]); + memcpy(ptr, params[j], l*sizeof(WCHAR)); + ptr += l; + if(++j == argc-1) + break; + *ptr++ = ','; + *ptr++ = ' '; + } + } + memcpy(ptr, function_beginW, sizeof(function_beginW)); + ptr += sizeof(function_beginW)/sizeof(WCHAR); + if(argc) { + l = SysStringLen(params[argc-1]); + memcpy(ptr, params[argc-1], l*sizeof(WCHAR)); + ptr += l; + } + memcpy(ptr, function_endW, sizeof(function_endW)); + + TRACE("%s\n", debugstr_w(str)); + }else { + hres = E_OUTOFMEMORY; + } + } + + while(--i >= 0) + SysFreeString(params[i]); + heap_free(params); + if(FAILED(hres)) + return hres; + + hres = script_parse(ctx, str, NULL, &parser); + heap_free(str); + if(FAILED(hres)) + return hres; + + if(!parser->source || !parser->source->functions || parser->source->functions->next || parser->source->variables) { + ERR("Invalid parser result!\n"); + parser_release(parser); + return E_UNEXPECTED; + } + expr = parser->source->functions->expr; + + hres = create_source_function(parser, expr->parameter_list, expr->source_elements, NULL, expr->src_str, + expr->src_len, &function); + parser_release(parser); + if(FAILED(hres)) + return hres; + + *ret = (IDispatch*)_IDispatchEx_(function); + return S_OK; +} + +static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + HRESULT hres; + + TRACE("\n"); + + switch(flags) { + case DISPATCH_CONSTRUCT: { + IDispatch *ret; + + hres = construct_function(ctx, dp, ei, &ret); + if(FAILED(hres)) + return hres; + + V_VT(retv) = VT_DISPATCH; + V_DISPATCH(retv) = ret; + break; + } + default: + FIXME("unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; +} + +static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, + VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) +{ + FIXME("\n"); + return E_NOTIMPL; +} + HRESULT init_function_constr(script_ctx_t *ctx, DispatchEx *object_prototype) { FunctionInstance *prot, *constr; @@ -673,7 +803,7 @@ HRESULT init_function_constr(script_ctx_t *ctx, DispatchEx *object_prototype) prot->value_proc = FunctionProt_value; prot->name = prototypeW; - hres = create_function(ctx, NULL, PROPF_CONSTR, TRUE, &prot->dispex, &constr); + hres = create_function(ctx, NULL, PROPF_CONSTR|1, TRUE, &prot->dispex, &constr); if(SUCCEEDED(hres)) { constr->value_proc = FunctionConstr_value; constr->name = FunctionW; diff --git a/reactos/dll/win32/jscript/global.c b/reactos/dll/win32/jscript/global.c index ef86f2663d4..af142ed4db3 100644 --- a/reactos/dll/win32/jscript/global.c +++ b/reactos/dll/win32/jscript/global.c @@ -334,8 +334,10 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D } ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } len = 0; for(ptr=str; *ptr; ptr++) { @@ -357,6 +359,8 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, D } } + SysFreeString(str); + if(retv) { V_VT(retv) = VT_BSTR; V_BSTR(retv) = ret; @@ -404,7 +408,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS return throw_syntax_error(ctx, ei, hres, NULL); } - hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, ei, retv); + hres = exec_source(ctx->exec_ctx, parser_ctx, parser_ctx->source, EXECT_EVAL, ei, retv); parser_release(parser_ctx); return hres; @@ -690,8 +694,10 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, } ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } len = 0; for(ptr=str; *ptr; ptr++) { @@ -715,6 +721,8 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, len++; } + SysFreeString(str); + if(retv) { V_VT(retv) = VT_BSTR; V_BSTR(retv) = ret; @@ -802,8 +810,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags }else { i = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL)*3; if(!i) { - FIXME("throw URIError\n"); - return E_FAIL; + SysFreeString(str); + return throw_uri_error(ctx, ei, IDS_URI_INVALID_CHAR, NULL); } len += i; @@ -811,8 +819,10 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } rptr = ret = SysAllocStringLen(NULL, len); - if(!ret) + if(!ret) { + SysFreeString(str); return E_OUTOFMEMORY; + } for(ptr = str; *ptr; ptr++) { if(is_uri_unescaped(*ptr) || is_uri_reserved(*ptr) || *ptr == '#') { @@ -827,6 +837,8 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } } + SysFreeString(str); + TRACE("%s -> %s\n", debugstr_w(str), debugstr_w(ret)); if(retv) { V_VT(retv) = VT_BSTR; @@ -847,56 +859,239 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + BSTR str, ret; + char buf[4]; + const WCHAR *ptr; + DWORD len = 0, size, i; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) { + ret = SysAllocString(undefinedW); + if(!ret) + return E_OUTOFMEMORY; + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } + + return S_OK; + } + + hres = to_string(ctx, get_arg(dp, 0), ei, &str); + if(FAILED(hres)) + return hres; + + for(ptr=str; *ptr; ptr++) { + if(is_uri_unescaped(*ptr)) + len++; + else { + size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, NULL, 0, NULL, NULL); + if(!size) { + SysFreeString(str); + FIXME("throw Error\n"); + return E_FAIL; + } + len += size*3; + } + } + + ret = SysAllocStringLen(NULL, len); + if(!ret) { + SysFreeString(str); + return E_OUTOFMEMORY; + } + + len = 0; + for(ptr=str; *ptr; ptr++) { + if(is_uri_unescaped(*ptr)) + ret[len++] = *ptr; + else { + size = WideCharToMultiByte(CP_UTF8, 0, ptr, 1, buf, sizeof(buf), NULL, NULL); + for(i=0; i> 4); + ret[len++] = int_to_char(buf[i] & 0x0f); + } + } + } + + SysFreeString(str); + + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } else { + SysFreeString(ret); + } + + return S_OK; } +/* ECMA-262 3rd Edition 15.1.3.2 */ static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + BSTR str, ret; + const WCHAR *ptr; + WCHAR *out_ptr; + DWORD len = 0; + HRESULT hres; + + TRACE("\n"); + + if(!arg_cnt(dp)) { + if(retv) { + ret = SysAllocString(undefinedW); + if(!ret) + return E_OUTOFMEMORY; + + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + } + + return S_OK; + } + + hres = to_string(ctx, get_arg(dp, 0), ei, &str); + if(FAILED(hres)) + return hres; + + ptr = str; + while(*ptr) { + if(*ptr == '%') { + char octets[4]; + unsigned char mask = 0x80; + int i, size, num_bytes = 0; + if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) { + FIXME("Throw URIError: Invalid hex sequence\n"); + SysFreeString(str); + return E_FAIL; + } + octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + while(octets[0] & mask) { + mask = mask >> 1; + ++num_bytes; + } + if(num_bytes == 1 || num_bytes > 4) { + FIXME("Throw URIError: Invalid initial UTF character\n"); + SysFreeString(str); + return E_FAIL; + } + for(i = 1; i < num_bytes; ++i) { + if(*ptr != '%'){ + FIXME("Throw URIError: Incomplete UTF sequence\n"); + SysFreeString(str); + return E_FAIL; + } + if(hex_to_int(*(ptr+1)) < 0 || hex_to_int(*(ptr+2)) < 0) { + FIXME("Throw URIError: Invalid hex sequence\n"); + SysFreeString(str); + return E_FAIL; + } + octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + } + size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, octets, + num_bytes ? num_bytes : 1, NULL, 0); + if(size == 0) { + FIXME("Throw URIError: Invalid UTF sequence\n"); + SysFreeString(str); + return E_FAIL; + } + len += size; + }else { + ++ptr; + ++len; + } + } + + out_ptr = ret = SysAllocStringLen(NULL, len); + if(!ret) { + SysFreeString(str); + return E_OUTOFMEMORY; + } + + ptr = str; + while(*ptr) { + if(*ptr == '%') { + char octets[4]; + unsigned char mask = 0x80; + int i, size, num_bytes = 0; + octets[0] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + while(octets[0] & mask) { + mask = mask >> 1; + ++num_bytes; + } + for(i = 1; i < num_bytes; ++i) { + octets[i] = (hex_to_int(*(ptr+1)) << 4) + hex_to_int(*(ptr+2)); + ptr += 3; + } + size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, octets, + num_bytes ? num_bytes : 1, out_ptr, len); + len -= size; + out_ptr += size; + }else { + *out_ptr++ = *ptr++; + --len; + } + } + + SysFreeString(str); + + if(retv) { + V_VT(retv) = VT_BSTR; + V_BSTR(retv) = ret; + }else { + SysFreeString(ret); + } + + return S_OK; } static const builtin_prop_t JSGlobal_props[] = { - {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_CONSTR}, - {ArrayW, JSGlobal_Array, PROPF_CONSTR}, - {BooleanW, JSGlobal_Boolean, PROPF_CONSTR}, + {ActiveXObjectW, JSGlobal_ActiveXObject, PROPF_CONSTR|1}, + {ArrayW, JSGlobal_Array, PROPF_CONSTR|1}, + {BooleanW, JSGlobal_Boolean, PROPF_CONSTR|1}, {CollectGarbageW, JSGlobal_CollectGarbage, PROPF_METHOD}, - {DateW, JSGlobal_Date, PROPF_CONSTR}, - {EnumeratorW, JSGlobal_Enumerator, PROPF_METHOD}, - {ErrorW, JSGlobal_Error, PROPF_CONSTR}, - {EvalErrorW, JSGlobal_EvalError, PROPF_CONSTR}, - {FunctionW, JSGlobal_Function, PROPF_CONSTR}, - {_GetObjectW, JSGlobal_GetObject, PROPF_METHOD}, + {DateW, JSGlobal_Date, PROPF_CONSTR|7}, + {EnumeratorW, JSGlobal_Enumerator, PROPF_METHOD|7}, + {ErrorW, JSGlobal_Error, PROPF_CONSTR|1}, + {EvalErrorW, JSGlobal_EvalError, PROPF_CONSTR|1}, + {FunctionW, JSGlobal_Function, PROPF_CONSTR|1}, + {_GetObjectW, JSGlobal_GetObject, PROPF_METHOD|2}, {InfinityW, JSGlobal_Infinity, 0}, /* {MathW, JSGlobal_Math, 0}, */ {NaNW, JSGlobal_NaN, 0}, - {NumberW, JSGlobal_Number, PROPF_CONSTR}, - {ObjectW, JSGlobal_Object, PROPF_CONSTR}, - {RangeErrorW, JSGlobal_RangeError, PROPF_CONSTR}, - {ReferenceErrorW, JSGlobal_ReferenceError, PROPF_CONSTR}, - {RegExpW, JSGlobal_RegExp, PROPF_CONSTR}, + {NumberW, JSGlobal_Number, PROPF_CONSTR|1}, + {ObjectW, JSGlobal_Object, PROPF_CONSTR|1}, + {RangeErrorW, JSGlobal_RangeError, PROPF_CONSTR|1}, + {ReferenceErrorW, JSGlobal_ReferenceError, PROPF_CONSTR|1}, + {RegExpW, JSGlobal_RegExp, PROPF_CONSTR|2}, {ScriptEngineW, JSGlobal_ScriptEngine, PROPF_METHOD}, {ScriptEngineBuildVersionW, JSGlobal_ScriptEngineBuildVersion, PROPF_METHOD}, {ScriptEngineMajorVersionW, JSGlobal_ScriptEngineMajorVersion, PROPF_METHOD}, {ScriptEngineMinorVersionW, JSGlobal_ScriptEngineMinorVersion, PROPF_METHOD}, - {StringW, JSGlobal_String, PROPF_CONSTR}, - {SyntaxErrorW, JSGlobal_SyntaxError, PROPF_CONSTR}, - {TypeErrorW, JSGlobal_TypeError, PROPF_CONSTR}, - {URIErrorW, JSGlobal_URIError, PROPF_CONSTR}, - {VBArrayW, JSGlobal_VBArray, PROPF_METHOD}, - {decodeURIW, JSGlobal_decodeURI, PROPF_METHOD}, - {decodeURIComponentW, JSGlobal_decodeURIComponent, PROPF_METHOD}, - {encodeURIW, JSGlobal_encodeURI, PROPF_METHOD}, - {encodeURIComponentW, JSGlobal_encodeURIComponent, PROPF_METHOD}, - {escapeW, JSGlobal_escape, PROPF_METHOD}, + {StringW, JSGlobal_String, PROPF_CONSTR|1}, + {SyntaxErrorW, JSGlobal_SyntaxError, PROPF_CONSTR|1}, + {TypeErrorW, JSGlobal_TypeError, PROPF_CONSTR|1}, + {URIErrorW, JSGlobal_URIError, PROPF_CONSTR|1}, + {VBArrayW, JSGlobal_VBArray, PROPF_METHOD|1}, + {decodeURIW, JSGlobal_decodeURI, PROPF_METHOD|1}, + {decodeURIComponentW, JSGlobal_decodeURIComponent, PROPF_METHOD|1}, + {encodeURIW, JSGlobal_encodeURI, PROPF_METHOD|1}, + {encodeURIComponentW, JSGlobal_encodeURIComponent, PROPF_METHOD|1}, + {escapeW, JSGlobal_escape, PROPF_METHOD|1}, {evalW, JSGlobal_eval, PROPF_METHOD|1}, - {isFiniteW, JSGlobal_isFinite, PROPF_METHOD}, - {isNaNW, JSGlobal_isNaN, PROPF_METHOD}, - {parseFloatW, JSGlobal_parseFloat, PROPF_METHOD}, + {isFiniteW, JSGlobal_isFinite, PROPF_METHOD|1}, + {isNaNW, JSGlobal_isNaN, PROPF_METHOD|1}, + {parseFloatW, JSGlobal_parseFloat, PROPF_METHOD|1}, {parseIntW, JSGlobal_parseInt, PROPF_METHOD|2}, - {unescapeW, JSGlobal_unescape, PROPF_METHOD} + {unescapeW, JSGlobal_unescape, PROPF_METHOD|1} }; static const builtin_info_t JSGlobal_info = { @@ -981,6 +1176,11 @@ HRESULT init_global(script_ctx_t *ctx) if(FAILED(hres)) return hres; + V_VT(&var) = VT_EMPTY; + hres = jsdisp_propput_name(ctx->global, undefinedW, &var, NULL/*FIXME*/, NULL/*FIXME*/); + if(FAILED(hres)) + return hres; + V_VT(&var) = VT_DISPATCH; V_DISPATCH(&var) = (IDispatch*)_IDispatchEx_(math); hres = jsdisp_propput_name(ctx->global, MathW, &var, NULL/*FIXME*/, NULL/*FIXME*/); diff --git a/reactos/dll/win32/jscript/jscript.c b/reactos/dll/win32/jscript/jscript.c index eb4183526be..9a516aa5d71 100644 --- a/reactos/dll/win32/jscript/jscript.c +++ b/reactos/dll/win32/jscript/jscript.c @@ -51,6 +51,7 @@ typedef struct { script_ctx_t *ctx; LONG thread_id; LCID lcid; + DWORD version; IActiveScriptSite *site; @@ -93,7 +94,6 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) { exec_ctx_t *exec_ctx; jsexcept_t jsexcept; - VARIANT var; HRESULT hres; hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, &exec_ctx); @@ -103,14 +103,11 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) IActiveScriptSite_OnEnterScript(This->site); memset(&jsexcept, 0, sizeof(jsexcept)); - hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, &jsexcept, &var); + hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, EXECT_PROGRAM, &jsexcept, NULL); VariantClear(&jsexcept.var); exec_release(exec_ctx); - if(SUCCEEDED(hres)) - VariantClear(&var); IActiveScriptSite_OnLeaveScript(This->site); - return hres; } @@ -659,6 +656,7 @@ static HRESULT WINAPI JScriptParse_InitNew(IActiveScriptParse *iface) ctx->ref = 1; ctx->state = SCRIPTSTATE_UNINITIALIZED; ctx->safeopt = This->safeopt; + ctx->version = This->version; jsheap_init(&ctx->tmp_heap); ctx = InterlockedCompareExchangePointer((void**)&This->ctx, ctx, NULL); @@ -822,8 +820,27 @@ static HRESULT WINAPI JScriptProperty_SetProperty(IActiveScriptProperty *iface, VARIANT *pvarIndex, VARIANT *pvarValue) { JScript *This = ACTSCPPROP_THIS(iface); - FIXME("(%p)->(%x %p %p)\n", This, dwProperty, pvarIndex, pvarValue); - return E_NOTIMPL; + + TRACE("(%p)->(%x %s %s)\n", This, dwProperty, debugstr_variant(pvarIndex), debugstr_variant(pvarValue)); + + if(pvarIndex) + FIXME("unsupported pvarIndex\n"); + + switch(dwProperty) { + case SCRIPTPROP_INVOKEVERSIONING: + if(V_VT(pvarValue) != VT_I4 || V_I4(pvarValue) < 0 || V_I4(pvarValue) > 15) { + WARN("invalid value %s\n", debugstr_variant(pvarValue)); + return E_INVALIDARG; + } + + This->version = V_I4(pvarValue); + break; + default: + FIXME("Unimplemented property %x\n", dwProperty); + return E_NOTIMPL; + } + + return S_OK; } #undef ACTSCPPROP_THIS diff --git a/reactos/dll/win32/jscript/jscript.h b/reactos/dll/win32/jscript/jscript.h index cde1e1bf67c..00688273de8 100644 --- a/reactos/dll/win32/jscript/jscript.h +++ b/reactos/dll/win32/jscript/jscript.h @@ -205,7 +205,7 @@ HRESULT jsdisp_propget(DispatchEx*,DISPID,VARIANT*,jsexcept_t*,IServiceProvider* HRESULT jsdisp_propput_name(DispatchEx*,const WCHAR*,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propput_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_propget_name(DispatchEx*,LPCWSTR,VARIANT*,jsexcept_t*,IServiceProvider*); -HRESULT jsdisp_propget_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); +HRESULT jsdisp_get_idx(DispatchEx*,DWORD,VARIANT*,jsexcept_t*,IServiceProvider*); HRESULT jsdisp_get_id(DispatchEx*,const WCHAR*,DWORD,DISPID*); HRESULT jsdisp_delete_idx(DispatchEx*,DWORD); @@ -225,7 +225,8 @@ HRESULT throw_uri_error(script_ctx_t*,jsexcept_t*,UINT,const WCHAR*); HRESULT create_object(script_ctx_t*,DispatchEx*,DispatchEx**); HRESULT create_math(script_ctx_t*,DispatchEx**); HRESULT create_array(script_ctx_t*,DWORD,DispatchEx**); -HRESULT create_regexp_str(script_ctx_t*,const WCHAR*,DWORD,const WCHAR*,DWORD,DispatchEx**); +HRESULT create_regexp(script_ctx_t*,const WCHAR *,int,DWORD,DispatchEx**); +HRESULT create_regexp_var(script_ctx_t*,VARIANT*,VARIANT*,DispatchEx**); HRESULT create_string(script_ctx_t*,const WCHAR*,DWORD,DispatchEx**); HRESULT create_bool(script_ctx_t*,VARIANT_BOOL,DispatchEx**); HRESULT create_number(script_ctx_t*,VARIANT*,DispatchEx**); @@ -262,6 +263,7 @@ struct _script_ctx_t { IActiveScriptSite *site; IInternetHostSecurityManager *secmgr; DWORD safeopt; + DWORD version; LCID lcid; jsheap_t tmp_heap; @@ -316,9 +318,12 @@ typedef struct { DWORD len; } match_result_t; -HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,BOOL,const WCHAR*,DWORD,const WCHAR**,match_result_t**, +#define REM_CHECK_GLOBAL 0x0001 +#define REM_RESET_INDEX 0x0002 +HRESULT regexp_match_next(script_ctx_t*,DispatchEx*,DWORD,const WCHAR*,DWORD,const WCHAR**,match_result_t**, DWORD*,DWORD*,match_result_t*); HRESULT regexp_match(script_ctx_t*,DispatchEx*,const WCHAR*,DWORD,BOOL,match_result_t**,DWORD*); +HRESULT parse_regexp_flags(const WCHAR*,DWORD,DWORD*); static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i) { @@ -390,6 +395,11 @@ static inline void num_set_inf(VARIANT *v, BOOL positive) #endif } +static inline DWORD make_grfdex(script_ctx_t *ctx, DWORD flags) +{ + return (ctx->version << 28) | flags; +} + const char *debugstr_variant(const VARIANT*); HRESULT WINAPI JScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**); diff --git a/reactos/dll/win32/jscript/jscript.inf b/reactos/dll/win32/jscript/jscript.inf index bdec721c040..9f683ed78e1 100644 --- a/reactos/dll/win32/jscript/jscript.inf +++ b/reactos/dll/win32/jscript/jscript.inf @@ -12,27 +12,27 @@ DelReg=Classes.Reg [Classes.Reg] HKCR,"CLSID\%CLSID_JScript%",,,"JScript Language" -HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScript%",,, -HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScriptParse%",,, +HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScript%",,16 +HKCR,"CLSID\%CLSID_JScript%\Implemented Categories\%CATID_ActiveScriptParse%",,16 HKCR,"CLSID\%CLSID_JScript%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScript%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScript%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScript%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScript%\ProgID",,,"JScript" HKCR,"CLSID\%CLSID_JScriptAuthor%",,,"JScript Language Authoring" -HKCR,"CLSID\%CLSID_JScriptAuthor%\Implemented Categories\%CATID_ActiveScriptAuthor%",,, +HKCR,"CLSID\%CLSID_JScriptAuthor%\Implemented Categories\%CATID_ActiveScriptAuthor%",,16 HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScriptAuthor%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScriptAuthor%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScriptAuthor%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScriptAuthor%\ProgID",,,"JScript Author" HKCR,"CLSID\%CLSID_JScriptEncode%",,,"JScript Language Encoding" -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScript%",,, -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptParse%",,, -HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptEncode%",,, +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScript%",,16 +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptParse%",,16 +HKCR,"CLSID\%CLSID_JScriptEncode%\Implemented Categories\%CATID_ActiveScriptEncode%",,16 HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32",,,"%MODULE%" HKCR,"CLSID\%CLSID_JScriptEncode%\InprocServer32","ThreadingModel",,"Both" -HKCR,"CLSID\%CLSID_JScriptEncode%\OLEScript",,, +HKCR,"CLSID\%CLSID_JScriptEncode%\OLEScript",,16 HKCR,"CLSID\%CLSID_JScriptEncode%\ProgID",,,"JScript.Encode" HKCR,"Component Categories\%CATID_ActiveScriptAuthor%","409",,"Active Scripting Engine with Authoring" @@ -42,55 +42,55 @@ HKCR,"Component Categories\%CATID_ActiveScriptEncode%","409",,"Active Scripting HKCR,"ECMAScript",,,"JScript Language" HKCR,"ECMAScript\CLSID",,,"%CLSID_JScript%" -HKCR,"ECMAScript\OLEScript",,, +HKCR,"ECMAScript\OLEScript",,16 HKCR,"JavaScript",,,"JScript Language" HKCR,"JavaScript\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript\OLEScript",,, +HKCR,"JavaScript\OLEScript",,16 HKCR,"JavaScript Author",,,"JScript Language Authoring" HKCR,"JavaScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript Author\OLEScript",,, +HKCR,"JavaScript Author\OLEScript",,16 HKCR,"JavaScript1.1",,,"JScript Language" HKCR,"JavaScript1.1\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.1\OLEScript",,, +HKCR,"JavaScript1.1\OLEScript",,16 HKCR,"JavaScript1.1 Author",,,"JScript Language Authoring" HKCR,"JavaScript1.1 Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript1.1 Author\OLEScript",,, +HKCR,"JavaScript1.1 Author\OLEScript",,16 HKCR,"JavaScript1.2",,,"JScript Language" HKCR,"JavaScript1.2\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.2\OLEScript",,, +HKCR,"JavaScript1.2\OLEScript",,16 HKCR,"JavaScript1.2 Author",,,"JScript Language Authoring" HKCR,"JavaScript1.2 Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JavaScript1.2 Author\OLEScript",,, +HKCR,"JavaScript1.2 Author\OLEScript",,16 HKCR,"JavaScript1.3",,,"JScript Language" HKCR,"JavaScript1.3\CLSID",,,"%CLSID_JScript%" -HKCR,"JavaScript1.3\OLEScript",,, +HKCR,"JavaScript1.3\OLEScript",,16 HKCR,"JScript",,,"JScript Language" HKCR,"JScript\CLSID",,,"%CLSID_JScript%" -HKCR,"JScript\OLEScript",,, +HKCR,"JScript\OLEScript",,16 HKCR,"JScript Author",,,"JScript Language Authoring" HKCR,"JScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"JScript Author\OLEScript",,, +HKCR,"JScript Author\OLEScript",,16 HKCR,"JScript.Encode",,,"JScript Language Encoding" HKCR,"JScript.Encode\CLSID",,,"%CLSID_JScriptEncode%" -HKCR,"JScript.Encode\OLEScript",,, +HKCR,"JScript.Encode\OLEScript",,16 HKCR,"LiveScript",,,"JScript Language" HKCR,"LiveScript\CLSID",,,"%CLSID_JScript%" -HKCR,"LiveScript\OLEScript",,, +HKCR,"LiveScript\OLEScript",,16 HKCR,"LiveScript Author",,,"JScript Language Authoring" HKCR,"LiveScript Author\CLSID",,,"%CLSID_JScriptAuthor%" -HKCR,"LiveScript Author\OLEScript",,, +HKCR,"LiveScript Author\OLEScript",,16 [Strings] diff --git a/reactos/dll/win32/jscript/jscript_De.rc b/reactos/dll/win32/jscript/jscript_De.rc index 02b52f38dbf..7e4e9a13050 100644 --- a/reactos/dll/win32/jscript/jscript_De.rc +++ b/reactos/dll/win32/jscript/jscript_De.rc @@ -43,6 +43,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Boolisches Objekt erwartet" IDS_JSCRIPT_EXPECTED "JScript Objekt erwartet" IDS_REGEXP_SYNTAX_ERROR "Syntax Fehler in regulärem Ausdruck" + IDS_URI_INVALID_CHAR "Zu verschlüsselnde URI enthält ungültige Zeichen" IDS_INVALID_LENGTH "Array-Größe muss eine endliche, positive Ganzzahl sein" IDS_ARRAY_EXPECTED "Array Objekt erwartet" } diff --git a/reactos/dll/win32/jscript/jscript_En.rc b/reactos/dll/win32/jscript/jscript_En.rc index 14be9bddbde..bd3c09d2a5d 100644 --- a/reactos/dll/win32/jscript/jscript_En.rc +++ b/reactos/dll/win32/jscript/jscript_En.rc @@ -41,6 +41,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Boolean object expected" IDS_JSCRIPT_EXPECTED "JScript object expected" IDS_REGEXP_SYNTAX_ERROR "Syntax error in regular expression" + IDS_URI_INVALID_CHAR "URI to be encoded contains invalid characters" IDS_INVALID_LENGTH "Array length must be a finite positive integer" IDS_ARRAY_EXPECTED "Array object expected" } diff --git a/reactos/dll/win32/jscript/jscript_Fr.rc b/reactos/dll/win32/jscript/jscript_Fr.rc index 8c23e412c40..f70029db13f 100644 --- a/reactos/dll/win32/jscript/jscript_Fr.rc +++ b/reactos/dll/win32/jscript/jscript_Fr.rc @@ -46,6 +46,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Objet booléen attendu" IDS_JSCRIPT_EXPECTED "Objet JScript attendu" IDS_REGEXP_SYNTAX_ERROR "Erreur de syntaxe dans l'expression rationnelle" + IDS_URI_INVALID_CHAR "L'URI à coder contient des caractères invalides" IDS_INVALID_LENGTH "La longueur d'un tableau doit être un entier positif" IDS_ARRAY_EXPECTED "Objet tableau attendu" } diff --git a/reactos/dll/win32/jscript/jscript_Ko.rc b/reactos/dll/win32/jscript/jscript_Ko.rc new file mode 100644 index 00000000000..164d6beb128 --- /dev/null +++ b/reactos/dll/win32/jscript/jscript_Ko.rc @@ -0,0 +1,51 @@ +/* + * Copyright 2009 Piotr Caban + * Copyright 2010 YunSong Hwang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_TO_PRIMITIVE "객페를 기본 형식으로 변환하는 중에 에러 발생" + IDS_INVALID_CALL_ARG "올바르지 않은 프로시져 호출이나 인수" + IDS_CREATE_OBJ_ERROR "자동화 서버가 객체를 만들 수 없습니다" + IDS_NO_PROPERTY "객체는 이 속성이나 메소드를 지원하지 않습니다" + IDS_ARG_NOT_OPT "인수는 옵션이 아닙니다" + IDS_SYNTAX_ERROR "문법 에러" + IDS_SEMICOLON "';' 가 필요합니다" + IDS_LBRACKET "'(' 가 필요합니다" + IDS_RBRACKET "')' 가 필요합니다" + IDS_UNTERMINATED_STR "띁나지 않은 문자열 상수" + IDS_NOT_FUNC "함수가 필요합니다" + IDS_NOT_DATE "'[객체]' 는 날짜 객체가 아닙니다" + IDS_NOT_NUM "숫자가 필요합니다" + IDS_OBJECT_EXPECTED "객체가 필요합니다" + IDS_ILLEGAL_ASSIGN "잘못된 할당" + IDS_UNDEFINED "'|' 는 정의되지 않았습니다" + IDS_NOT_BOOL "볼린 객제가 필요합니다" + IDS_JSCRIPT_EXPECTED "JScript 객체가 필요합니다" + IDS_REGEXP_SYNTAX_ERROR "정규 표현식에 문법에러가 있습니다" + IDS_URI_INVALID_CHAR "URI 는 올바르지 않은 문자를 포함해서 인코딩되었습니다" + IDS_INVALID_LENGTH "배열 길이는 반드시 한정된 양의 정수이어야 합니다" + IDS_ARRAY_EXPECTED "배열 객체가 필요합니다" +} diff --git a/reactos/dll/win32/jscript/jscript_Lt.rc b/reactos/dll/win32/jscript/jscript_Lt.rc index 4d3989574fd..a7b451eb8c9 100644 --- a/reactos/dll/win32/jscript/jscript_Lt.rc +++ b/reactos/dll/win32/jscript/jscript_Lt.rc @@ -44,6 +44,7 @@ STRINGTABLE DISCARDABLE IDS_NOT_BOOL "Tikėtasi loginio objekto" IDS_JSCRIPT_EXPECTED "Tikėtasi JScript objekto" IDS_REGEXP_SYNTAX_ERROR "Sintaksės klaida reguliariajame reiškinyje" + IDS_URI_INVALID_CHAR "Koduotiname URI yra netinkamų simbolių" IDS_INVALID_LENGTH "Masyvo dydis turi būti teigiamas sveikasis skaičius" IDS_ARRAY_EXPECTED "Tikėtasi masyvo objekto" } diff --git a/reactos/dll/win32/jscript/jscript_Ru.rc b/reactos/dll/win32/jscript/jscript_Ru.rc new file mode 100644 index 00000000000..9632d3f3693 --- /dev/null +++ b/reactos/dll/win32/jscript/jscript_Ru.rc @@ -0,0 +1,50 @@ +/* + * Copyright 2009 Vladimir Pankratov + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "resource.h" + +/* UTF-8 */ +#pragma code_page(65001) + +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT + +STRINGTABLE DISCARDABLE +{ + IDS_TO_PRIMITIVE "Ошибка конвертирования объекта в примитивный тип" + IDS_INVALID_CALL_ARG "Неверный вызов процедуры или аргумент" + IDS_CREATE_OBJ_ERROR "Сервер автоматизации не может создать объект" + IDS_NO_PROPERTY "Объект не поддерживает это свойство или метод" + IDS_ARG_NOT_OPT "Отсутствует обязательный аргумент" + IDS_SYNTAX_ERROR "Синтаксическая ошибка" + IDS_SEMICOLON "Ожидается ';'" + IDS_LBRACKET "Ожидается '('" + IDS_RBRACKET "Ожидается ')'" + IDS_UNTERMINATED_STR "Незавершённая строковая константа" + IDS_NOT_FUNC "Ожидается функция" + IDS_NOT_DATE "'[object]' не объект типа 'date'" + IDS_NOT_NUM "Ожидается число" + IDS_OBJECT_EXPECTED "Ожидается объект" + IDS_ILLEGAL_ASSIGN "Неверное присваивание" + IDS_UNDEFINED "'|' не определён" + IDS_NOT_BOOL "Ожидается объект типа 'bool'" + IDS_JSCRIPT_EXPECTED "Ожидается объект типа 'JScript'" + IDS_REGEXP_SYNTAX_ERROR "Синтаксическая ошибка в регулярном выражении" + IDS_URI_INVALID_CHAR "URI содержит неверные символы" + IDS_INVALID_LENGTH "Длиной массива должно быть конечное положительное число" + IDS_ARRAY_EXPECTED "Ожидается объект типа 'Array'" +} diff --git a/reactos/dll/win32/jscript/jsutils.c b/reactos/dll/win32/jscript/jsutils.c index 80cce597481..9e49cc7b8a3 100644 --- a/reactos/dll/win32/jscript/jsutils.c +++ b/reactos/dll/win32/jscript/jsutils.c @@ -449,10 +449,14 @@ HRESULT to_integer(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, VARIANT *ret) if(FAILED(hres)) return hres; - if(V_VT(&num) == VT_I4) + if(V_VT(&num) == VT_I4) { *ret = num; - else + }else if(isnan(V_R8(&num))) { + V_VT(ret) = VT_I4; + V_I4(ret) = 0; + }else { num_set_val(ret, V_R8(&num) >= 0.0 ? floor(V_R8(&num)) : -floor(-V_R8(&num))); + } return S_OK; } @@ -467,7 +471,10 @@ HRESULT to_int32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, INT *ret) if(FAILED(hres)) return hres; - *ret = V_VT(&num) == VT_I4 ? V_I4(&num) : (INT)V_R8(&num); + if(V_VT(&num) == VT_I4) + *ret = V_I4(&num); + else + *ret = isnan(V_R8(&num)) || isinf(V_R8(&num)) ? 0 : (INT)V_R8(&num); return S_OK; } @@ -481,7 +488,10 @@ HRESULT to_uint32(script_ctx_t *ctx, VARIANT *v, jsexcept_t *ei, DWORD *ret) if(FAILED(hres)) return hres; - *ret = V_VT(&num) == VT_I4 ? V_I4(&num) : (DWORD)V_R8(&num); + if(V_VT(&num) == VT_I4) + *ret = V_I4(&num); + else + *ret = isnan(V_R8(&num)) || isinf(V_R8(&num)) ? 0 : (DWORD)V_R8(&num); return S_OK; } diff --git a/reactos/dll/win32/jscript/lex.c b/reactos/dll/win32/jscript/lex.c index 43089d3e210..2e79db9878a 100644 --- a/reactos/dll/win32/jscript/lex.c +++ b/reactos/dll/win32/jscript/lex.c @@ -91,7 +91,6 @@ static const struct { {trueW, kTRUE}, {tryW, kTRY}, {typeofW, kTYPEOF}, - {undefinedW, kUNDEFINED}, {varW, kVAR}, {voidW, kVOID}, {whileW, kWHILE}, @@ -369,7 +368,7 @@ static literal_t *alloc_int_literal(parser_ctx_t *ctx, LONG l) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_I4; + ret->type = LT_INT; ret->u.lval = l; return ret; @@ -447,7 +446,7 @@ static int parse_double_literal(parser_ctx_t *ctx, LONG int_part, literal_t **li } *literal = parser_alloc(ctx, sizeof(literal_t)); - (*literal)->vt = VT_R8; + (*literal)->type = LT_DOUBLE; (*literal)->u.dval = (double)d*pow(10, exp); return tNumericLiteral; @@ -755,21 +754,11 @@ int parser_lex(void *lval, parser_ctx_t *ctx) return 0; } -static void add_object_literal(parser_ctx_t *ctx, DispatchEx *obj) -{ - obj_literal_t *literal = parser_alloc(ctx, sizeof(obj_literal_t)); - - literal->obj = obj; - literal->next = ctx->obj_literals; - ctx->obj_literals = literal; -} - literal_t *parse_regexp(parser_ctx_t *ctx) { - const WCHAR *re, *flags; - DispatchEx *regexp; + const WCHAR *re, *flags_ptr; + DWORD re_len, flags; literal_t *ret; - DWORD re_len; HRESULT hres; TRACE("\n"); @@ -790,18 +779,18 @@ literal_t *parse_regexp(parser_ctx_t *ctx) re_len = ctx->ptr-re; - flags = ++ctx->ptr; + flags_ptr = ++ctx->ptr; while(ctx->ptr < ctx->end && isalnumW(*ctx->ptr)) ctx->ptr++; - hres = create_regexp_str(ctx->script, re, re_len, flags, ctx->ptr-flags, ®exp); + hres = parse_regexp_flags(flags_ptr, ctx->ptr-flags_ptr, &flags); if(FAILED(hres)) return NULL; - add_object_literal(ctx, regexp); - ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_DISPATCH; - ret->u.disp = (IDispatch*)_IDispatchEx_(regexp); + ret->type = LT_REGEXP; + ret->u.regexp.str = re; + ret->u.regexp.str_len = re_len; + ret->u.regexp.flags = flags; return ret; } diff --git a/reactos/dll/win32/jscript/number.c b/reactos/dll/win32/jscript/number.c index 757316cee86..00de9abba85 100644 --- a/reactos/dll/win32/jscript/number.c +++ b/reactos/dll/win32/jscript/number.c @@ -346,7 +346,8 @@ HRESULT create_number_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di return hres; V_VT(&number->num) = VT_I4; - hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL, PROPF_CONSTR, &number->dispex, ret); + hres = create_builtin_function(ctx, NumberConstr_value, NumberW, NULL, + PROPF_CONSTR|1, &number->dispex, ret); jsdisp_release(&number->dispex); return hres; diff --git a/reactos/dll/win32/jscript/parser.tab.c b/reactos/dll/win32/jscript/parser.tab.c index 3262aa07a8d..e3307bdbec6 100644 --- a/reactos/dll/win32/jscript/parser.tab.c +++ b/reactos/dll/win32/jscript/parser.tab.c @@ -99,7 +99,6 @@ typedef struct _statement_list_t { static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); static literal_t *new_null_literal(parser_ctx_t*); -static literal_t *new_undefined_literal(parser_ctx_t*); static literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_BOOL); typedef struct _property_list_t { @@ -207,7 +206,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state /* Line 189 of yacc.c */ -#line 211 "parser.tab.c" +#line 210 "parser.tab.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -249,34 +248,33 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state kINSTANCEOF = 270, kNEW = 271, kNULL = 272, - kUNDEFINED = 273, - kRETURN = 274, - kSWITCH = 275, - kTHIS = 276, - kTHROW = 277, - kTRUE = 278, - kFALSE = 279, - kTRY = 280, - kTYPEOF = 281, - kVAR = 282, - kVOID = 283, - kWHILE = 284, - kWITH = 285, - tANDAND = 286, - tOROR = 287, - tINC = 288, - tDEC = 289, - tHTMLCOMMENT = 290, - kDIVEQ = 291, - kFUNCTION = 292, - tIdentifier = 293, - tAssignOper = 294, - tEqOper = 295, - tShiftOper = 296, - tRelOper = 297, - tNumericLiteral = 298, - tStringLiteral = 299, - LOWER_THAN_ELSE = 300 + kRETURN = 273, + kSWITCH = 274, + kTHIS = 275, + kTHROW = 276, + kTRUE = 277, + kFALSE = 278, + kTRY = 279, + kTYPEOF = 280, + kVAR = 281, + kVOID = 282, + kWHILE = 283, + kWITH = 284, + tANDAND = 285, + tOROR = 286, + tINC = 287, + tDEC = 288, + tHTMLCOMMENT = 289, + kDIVEQ = 290, + kFUNCTION = 291, + tIdentifier = 292, + tAssignOper = 293, + tEqOper = 294, + tShiftOper = 295, + tRelOper = 296, + tNumericLiteral = 297, + tStringLiteral = 298, + LOWER_THAN_ELSE = 299 }; #endif @@ -287,7 +285,7 @@ typedef union YYSTYPE { /* Line 214 of yacc.c */ -#line 151 "parser.y" +#line 150 "parser.y" int ival; const WCHAR *srcptr; @@ -311,7 +309,7 @@ typedef union YYSTYPE /* Line 214 of yacc.c */ -#line 315 "parser.tab.c" +#line 313 "parser.tab.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -323,7 +321,7 @@ typedef union YYSTYPE /* Line 264 of yacc.c */ -#line 327 "parser.tab.c" +#line 325 "parser.tab.c" #ifdef short # undef short @@ -538,20 +536,20 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 1042 +#define YYLAST 1030 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 68 +#define YYNTOKENS 67 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 95 /* YYNRULES -- Number of rules. */ -#define YYNRULES 215 +#define YYNRULES 214 /* YYNRULES -- Number of states. */ -#define YYNSTATES 374 +#define YYNSTATES 373 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 300 +#define YYMAXUTOK 299 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -562,16 +560,16 @@ static const yytype_uint8 yytranslate[] = 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 62, 2, 2, 2, 60, 55, 2, - 66, 67, 58, 56, 48, 57, 65, 59, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 51, 50, - 2, 49, 2, 52, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 61, 2, 2, 2, 59, 54, 2, + 65, 66, 57, 55, 47, 56, 64, 58, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 50, 49, + 2, 48, 2, 51, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 63, 2, 64, 54, 2, 2, 2, 2, 2, + 2, 62, 2, 63, 53, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 47, 53, 38, 61, 2, 2, 2, + 2, 2, 2, 46, 52, 37, 60, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -588,8 +586,7 @@ static const yytype_uint8 yytranslate[] = 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, - 46 + 35, 36, 38, 39, 40, 41, 42, 43, 44, 45 }; #if YYDEBUG @@ -618,105 +615,105 @@ static const yytype_uint16 yyprhs[] = 567, 570, 574, 578, 584, 587, 592, 594, 597, 598, 600, 603, 607, 611, 617, 619, 621, 623, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, - 648, 650, 652, 654, 656, 658 + 648, 650, 652, 654, 656 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int16 yyrhs[] = { - 69, 0, -1, 71, 70, -1, 35, -1, -1, -1, - 71, 77, -1, 73, 156, 160, 76, 161, 47, 74, - 38, -1, 37, -1, 71, -1, 39, -1, 75, 48, - 39, -1, -1, 75, -1, 80, -1, 81, -1, 90, - -1, 72, -1, 91, -1, 92, -1, 93, -1, 98, - -1, 99, -1, 100, -1, 101, -1, 102, -1, 103, - -1, 109, -1, 110, -1, 77, -1, 78, 77, -1, - -1, 78, -1, 47, 78, 38, -1, 47, 38, -1, - 27, 82, 159, -1, 84, -1, 82, 48, 84, -1, - 85, -1, 83, 48, 85, -1, 39, 86, -1, 39, - 88, -1, -1, 87, -1, 49, 119, -1, -1, 89, - -1, 49, 120, -1, 50, -1, 115, 159, -1, 11, - 160, 114, 161, 77, 10, 77, -1, 11, 160, 114, - 161, 77, -1, 9, 77, 29, 160, 114, 161, 159, - -1, 29, 160, 114, 161, 77, -1, -1, -1, 13, - 160, 116, 94, 162, 113, 95, 162, 113, 161, 77, - -1, -1, -1, 13, 160, 27, 83, 96, 162, 113, - 97, 162, 113, 161, 77, -1, 13, 160, 142, 14, - 114, 161, 77, -1, 13, 160, 27, 85, 14, 114, - 161, 77, -1, 6, 156, 159, -1, 3, 156, 159, - -1, 19, 113, 159, -1, 30, 160, 115, 161, 77, - -1, 39, 51, 77, -1, 20, 160, 115, 161, 104, - -1, 47, 105, 38, -1, 47, 105, 108, 105, 38, - -1, -1, 106, -1, 107, -1, 106, 107, -1, 4, - 115, 51, 79, -1, 7, 51, 79, -1, 22, 115, - 159, -1, 25, 80, 111, -1, 25, 80, 112, -1, - 25, 80, 111, 112, -1, 5, 160, 39, 161, 80, - -1, 12, 80, -1, -1, 115, -1, 115, -1, 1, - -1, 119, -1, 115, 48, 119, -1, -1, 117, -1, - 120, -1, 117, 48, 120, -1, 40, -1, 36, -1, - 121, -1, 142, 49, 119, -1, 142, 118, 119, -1, - 122, -1, 142, 49, 120, -1, 142, 118, 120, -1, - 123, -1, 123, 52, 119, 51, 119, -1, 124, -1, - 124, 52, 120, 51, 120, -1, 125, -1, 123, 32, - 125, -1, 126, -1, 124, 32, 126, -1, 127, -1, - 125, 31, 127, -1, 128, -1, 126, 31, 128, -1, - 129, -1, 127, 53, 129, -1, 130, -1, 128, 53, - 130, -1, 131, -1, 129, 54, 131, -1, 132, -1, - 130, 54, 132, -1, 133, -1, 131, 55, 133, -1, - 134, -1, 132, 55, 134, -1, 135, -1, 133, 41, - 135, -1, 136, -1, 134, 41, 136, -1, 137, -1, - 135, 43, 137, -1, 135, 15, 137, -1, 135, 14, - 137, -1, 137, -1, 136, 43, 137, -1, 136, 15, - 137, -1, 138, -1, 137, 42, 138, -1, 139, -1, - 138, 56, 139, -1, 138, 57, 139, -1, 140, -1, - 139, 58, 140, -1, 139, 59, 140, -1, 139, 60, - 140, -1, 141, -1, 8, 140, -1, 28, 140, -1, - 26, 140, -1, 33, 140, -1, 34, 140, -1, 56, - 140, -1, 57, 140, -1, 61, 140, -1, 62, 140, - -1, 142, -1, 142, 33, -1, 142, 34, -1, 143, - -1, 145, -1, 144, -1, 16, 143, -1, 148, -1, - 72, -1, 144, 63, 115, 64, -1, 144, 65, 39, - -1, 16, 144, 146, -1, 144, 146, -1, 145, 146, - -1, 145, 63, 115, 64, -1, 145, 65, 39, -1, - 66, 67, -1, 66, 147, 67, -1, 119, -1, 147, - 48, 119, -1, 21, -1, 39, -1, 157, -1, 149, - -1, 153, -1, 66, 115, 67, -1, 63, 64, -1, - 63, 151, 64, -1, 63, 150, 64, -1, 63, 150, - 48, 152, 64, -1, 152, 119, -1, 150, 48, 152, - 119, -1, 48, -1, 151, 48, -1, -1, 151, -1, - 47, 38, -1, 47, 154, 38, -1, 155, 51, 119, - -1, 154, 48, 155, 51, 119, -1, 39, -1, 45, - -1, 44, -1, -1, 39, -1, 17, -1, 18, -1, - 158, -1, 44, -1, 45, -1, 59, -1, 36, -1, - 23, -1, 24, -1, 50, -1, 1, -1, 66, -1, - 1, -1, 67, -1, 1, -1, 50, -1, 1, -1 + 68, 0, -1, 70, 69, -1, 34, -1, -1, -1, + 70, 76, -1, 72, 155, 159, 75, 160, 46, 73, + 37, -1, 36, -1, 70, -1, 38, -1, 74, 47, + 38, -1, -1, 74, -1, 79, -1, 80, -1, 89, + -1, 71, -1, 90, -1, 91, -1, 92, -1, 97, + -1, 98, -1, 99, -1, 100, -1, 101, -1, 102, + -1, 108, -1, 109, -1, 76, -1, 77, 76, -1, + -1, 77, -1, 46, 77, 37, -1, 46, 37, -1, + 26, 81, 158, -1, 83, -1, 81, 47, 83, -1, + 84, -1, 82, 47, 84, -1, 38, 85, -1, 38, + 87, -1, -1, 86, -1, 48, 118, -1, -1, 88, + -1, 48, 119, -1, 49, -1, 114, 158, -1, 11, + 159, 113, 160, 76, 10, 76, -1, 11, 159, 113, + 160, 76, -1, 9, 76, 28, 159, 113, 160, 158, + -1, 28, 159, 113, 160, 76, -1, -1, -1, 13, + 159, 115, 93, 161, 112, 94, 161, 112, 160, 76, + -1, -1, -1, 13, 159, 26, 82, 95, 161, 112, + 96, 161, 112, 160, 76, -1, 13, 159, 141, 14, + 113, 160, 76, -1, 13, 159, 26, 84, 14, 113, + 160, 76, -1, 6, 155, 158, -1, 3, 155, 158, + -1, 18, 112, 158, -1, 29, 159, 114, 160, 76, + -1, 38, 50, 76, -1, 19, 159, 114, 160, 103, + -1, 46, 104, 37, -1, 46, 104, 107, 104, 37, + -1, -1, 105, -1, 106, -1, 105, 106, -1, 4, + 114, 50, 78, -1, 7, 50, 78, -1, 21, 114, + 158, -1, 24, 79, 110, -1, 24, 79, 111, -1, + 24, 79, 110, 111, -1, 5, 159, 38, 160, 79, + -1, 12, 79, -1, -1, 114, -1, 114, -1, 1, + -1, 118, -1, 114, 47, 118, -1, -1, 116, -1, + 119, -1, 116, 47, 119, -1, 39, -1, 35, -1, + 120, -1, 141, 48, 118, -1, 141, 117, 118, -1, + 121, -1, 141, 48, 119, -1, 141, 117, 119, -1, + 122, -1, 122, 51, 118, 50, 118, -1, 123, -1, + 123, 51, 119, 50, 119, -1, 124, -1, 122, 31, + 124, -1, 125, -1, 123, 31, 125, -1, 126, -1, + 124, 30, 126, -1, 127, -1, 125, 30, 127, -1, + 128, -1, 126, 52, 128, -1, 129, -1, 127, 52, + 129, -1, 130, -1, 128, 53, 130, -1, 131, -1, + 129, 53, 131, -1, 132, -1, 130, 54, 132, -1, + 133, -1, 131, 54, 133, -1, 134, -1, 132, 40, + 134, -1, 135, -1, 133, 40, 135, -1, 136, -1, + 134, 42, 136, -1, 134, 15, 136, -1, 134, 14, + 136, -1, 136, -1, 135, 42, 136, -1, 135, 15, + 136, -1, 137, -1, 136, 41, 137, -1, 138, -1, + 137, 55, 138, -1, 137, 56, 138, -1, 139, -1, + 138, 57, 139, -1, 138, 58, 139, -1, 138, 59, + 139, -1, 140, -1, 8, 139, -1, 27, 139, -1, + 25, 139, -1, 32, 139, -1, 33, 139, -1, 55, + 139, -1, 56, 139, -1, 60, 139, -1, 61, 139, + -1, 141, -1, 141, 32, -1, 141, 33, -1, 142, + -1, 144, -1, 143, -1, 16, 142, -1, 147, -1, + 71, -1, 143, 62, 114, 63, -1, 143, 64, 38, + -1, 16, 143, 145, -1, 143, 145, -1, 144, 145, + -1, 144, 62, 114, 63, -1, 144, 64, 38, -1, + 65, 66, -1, 65, 146, 66, -1, 118, -1, 146, + 47, 118, -1, 20, -1, 38, -1, 156, -1, 148, + -1, 152, -1, 65, 114, 66, -1, 62, 63, -1, + 62, 150, 63, -1, 62, 149, 63, -1, 62, 149, + 47, 151, 63, -1, 151, 118, -1, 149, 47, 151, + 118, -1, 47, -1, 150, 47, -1, -1, 150, -1, + 46, 37, -1, 46, 153, 37, -1, 154, 50, 118, + -1, 153, 47, 154, 50, 118, -1, 38, -1, 44, + -1, 43, -1, -1, 38, -1, 17, -1, 157, -1, + 43, -1, 44, -1, 58, -1, 35, -1, 22, -1, + 23, -1, 49, -1, 1, -1, 65, -1, 1, -1, + 66, -1, 1, -1, 49, -1, 1, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 257, 257, 261, 262, 266, 267, 272, 276, 280, - 284, 285, 290, 291, 295, 296, 297, 298, 299, 300, - 301, 302, 303, 304, 305, 306, 307, 308, 309, 313, - 314, 319, 320, 324, 325, 329, 334, 335, 340, 342, - 347, 352, 357, 358, 362, 367, 368, 372, 377, 381, - 386, 388, 393, 395, 398, 400, 397, 404, 406, 403, - 409, 411, 416, 421, 426, 431, 436, 441, 446, 448, - 453, 454, 458, 459, 464, 469, 474, 479, 480, 481, - 486, 491, 495, 496, 499, 500, 504, 505, 510, 511, - 515, 517, 521, 522, 526, 527, 529, 534, 536, 538, - 543, 544, 549, 551, 556, 557, 562, 564, 569, 570, - 575, 577, 582, 583, 588, 590, 595, 596, 601, 603, - 608, 609, 614, 616, 621, 622, 627, 628, 633, 634, - 636, 638, 643, 644, 646, 651, 652, 657, 659, 661, - 666, 667, 669, 671, 676, 677, 679, 680, 682, 683, - 684, 685, 686, 687, 691, 693, 695, 701, 702, 706, - 707, 711, 712, 713, 715, 717, 722, 724, 726, 728, - 733, 734, 738, 739, 744, 745, 746, 747, 748, 749, - 753, 754, 755, 756, 761, 763, 768, 769, 773, 774, - 778, 779, 784, 786, 791, 792, 793, 797, 798, 802, - 803, 804, 805, 806, 807, 809, 814, 815, 818, 819, - 822, 823, 826, 827, 830, 831 + 0, 256, 256, 260, 261, 265, 266, 271, 275, 279, + 283, 284, 289, 290, 294, 295, 296, 297, 298, 299, + 300, 301, 302, 303, 304, 305, 306, 307, 308, 312, + 313, 318, 319, 323, 324, 328, 333, 334, 339, 341, + 346, 351, 356, 357, 361, 366, 367, 371, 376, 380, + 385, 387, 392, 394, 397, 399, 396, 403, 405, 402, + 408, 410, 415, 420, 425, 430, 435, 440, 445, 447, + 452, 453, 457, 458, 463, 468, 473, 478, 479, 480, + 485, 490, 494, 495, 498, 499, 503, 504, 509, 510, + 514, 516, 520, 521, 525, 526, 528, 533, 535, 537, + 542, 543, 548, 550, 555, 556, 561, 563, 568, 569, + 574, 576, 581, 582, 587, 589, 594, 595, 600, 602, + 607, 608, 613, 615, 620, 621, 626, 627, 632, 633, + 635, 637, 642, 643, 645, 650, 651, 656, 658, 660, + 665, 666, 668, 670, 675, 676, 678, 679, 681, 682, + 683, 684, 685, 686, 690, 692, 694, 700, 701, 705, + 706, 710, 711, 712, 714, 716, 721, 723, 725, 727, + 732, 733, 737, 738, 743, 744, 745, 746, 747, 748, + 752, 753, 754, 755, 760, 762, 767, 768, 772, 773, + 777, 778, 783, 785, 790, 791, 792, 796, 797, 801, + 802, 803, 804, 805, 807, 812, 813, 816, 817, 820, + 821, 824, 825, 828, 829 }; #endif @@ -727,10 +724,10 @@ static const char *const yytname[] = { "$end", "error", "$undefined", "kBREAK", "kCASE", "kCATCH", "kCONTINUE", "kDEFAULT", "kDELETE", "kDO", "kELSE", "kIF", "kFINALLY", "kFOR", "kIN", - "kINSTANCEOF", "kNEW", "kNULL", "kUNDEFINED", "kRETURN", "kSWITCH", - "kTHIS", "kTHROW", "kTRUE", "kFALSE", "kTRY", "kTYPEOF", "kVAR", "kVOID", - "kWHILE", "kWITH", "tANDAND", "tOROR", "tINC", "tDEC", "tHTMLCOMMENT", - "kDIVEQ", "kFUNCTION", "'}'", "tIdentifier", "tAssignOper", "tEqOper", + "kINSTANCEOF", "kNEW", "kNULL", "kRETURN", "kSWITCH", "kTHIS", "kTHROW", + "kTRUE", "kFALSE", "kTRY", "kTYPEOF", "kVAR", "kVOID", "kWHILE", "kWITH", + "tANDAND", "tOROR", "tINC", "tDEC", "tHTMLCOMMENT", "kDIVEQ", + "kFUNCTION", "'}'", "tIdentifier", "tAssignOper", "tEqOper", "tShiftOper", "tRelOper", "tNumericLiteral", "tStringLiteral", "LOWER_THAN_ELSE", "'{'", "','", "'='", "';'", "':'", "'?'", "'|'", "'^'", "'&'", "'+'", "'-'", "'*'", "'/'", "'%'", "'~'", "'!'", "'['", @@ -775,38 +772,38 @@ static const yytype_uint16 yytoknum[] = 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 125, 293, - 294, 295, 296, 297, 298, 299, 300, 123, 44, 61, - 59, 58, 63, 124, 94, 38, 43, 45, 42, 47, - 37, 126, 33, 91, 93, 46, 40, 41 + 285, 286, 287, 288, 289, 290, 291, 125, 292, 293, + 294, 295, 296, 297, 298, 299, 123, 44, 61, 59, + 58, 63, 124, 94, 38, 43, 45, 42, 47, 37, + 126, 33, 91, 93, 46, 40, 41 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 68, 69, 70, 70, 71, 71, 72, 73, 74, - 75, 75, 76, 76, 77, 77, 77, 77, 77, 77, - 77, 77, 77, 77, 77, 77, 77, 77, 77, 78, - 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, - 84, 85, 86, 86, 87, 88, 88, 89, 90, 91, - 92, 92, 93, 93, 94, 95, 93, 96, 97, 93, - 93, 93, 98, 99, 100, 101, 102, 103, 104, 104, - 105, 105, 106, 106, 107, 108, 109, 110, 110, 110, - 111, 112, 113, 113, 114, 114, 115, 115, 116, 116, - 117, 117, 118, 118, 119, 119, 119, 120, 120, 120, - 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, - 126, 126, 127, 127, 128, 128, 129, 129, 130, 130, - 131, 131, 132, 132, 133, 133, 134, 134, 135, 135, - 135, 135, 136, 136, 136, 137, 137, 138, 138, 138, - 139, 139, 139, 139, 140, 140, 140, 140, 140, 140, - 140, 140, 140, 140, 141, 141, 141, 142, 142, 143, - 143, 144, 144, 144, 144, 144, 145, 145, 145, 145, - 146, 146, 147, 147, 148, 148, 148, 148, 148, 148, - 149, 149, 149, 149, 150, 150, 151, 151, 152, 152, - 153, 153, 154, 154, 155, 155, 155, 156, 156, 157, - 157, 157, 157, 157, 157, 157, 158, 158, 159, 159, - 160, 160, 161, 161, 162, 162 + 0, 67, 68, 69, 69, 70, 70, 71, 72, 73, + 74, 74, 75, 75, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 77, + 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, + 83, 84, 85, 85, 86, 87, 87, 88, 89, 90, + 91, 91, 92, 92, 93, 94, 92, 95, 96, 92, + 92, 92, 97, 98, 99, 100, 101, 102, 103, 103, + 104, 104, 105, 105, 106, 107, 108, 109, 109, 109, + 110, 111, 112, 112, 113, 113, 114, 114, 115, 115, + 116, 116, 117, 117, 118, 118, 118, 119, 119, 119, + 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, + 125, 125, 126, 126, 127, 127, 128, 128, 129, 129, + 130, 130, 131, 131, 132, 132, 133, 133, 134, 134, + 134, 134, 135, 135, 135, 136, 136, 137, 137, 137, + 138, 138, 138, 138, 139, 139, 139, 139, 139, 139, + 139, 139, 139, 139, 140, 140, 140, 141, 141, 142, + 142, 143, 143, 143, 143, 143, 144, 144, 144, 144, + 145, 145, 146, 146, 147, 147, 147, 147, 147, 147, + 148, 148, 148, 148, 149, 149, 150, 150, 151, 151, + 152, 152, 153, 153, 154, 154, 154, 155, 155, 156, + 156, 156, 156, 156, 156, 157, 157, 158, 158, 159, + 159, 160, 160, 161, 161 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -833,7 +830,7 @@ static const yytype_uint8 yyr2[] = 2, 3, 3, 5, 2, 4, 1, 2, 0, 1, 2, 3, 3, 5, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -842,118 +839,118 @@ static const yytype_uint8 yyr2[] = static const yytype_uint8 yydefact[] = { 5, 0, 4, 1, 197, 197, 0, 0, 0, 0, - 0, 199, 200, 82, 0, 174, 0, 206, 207, 0, - 0, 0, 0, 0, 0, 0, 0, 3, 205, 8, - 175, 202, 203, 0, 48, 0, 0, 204, 0, 0, - 188, 0, 2, 17, 197, 6, 14, 15, 16, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 0, 86, 94, 100, 104, 108, 112, 116, 120, 124, - 128, 135, 137, 140, 144, 154, 157, 159, 158, 161, - 177, 178, 176, 201, 198, 0, 0, 175, 0, 162, - 145, 154, 0, 211, 210, 0, 88, 160, 159, 0, - 83, 0, 0, 0, 0, 147, 42, 0, 36, 146, - 0, 0, 148, 149, 0, 34, 175, 202, 203, 29, - 0, 0, 0, 150, 151, 152, 153, 186, 180, 0, - 189, 0, 0, 0, 209, 0, 208, 49, 0, 0, + 0, 199, 82, 0, 174, 0, 205, 206, 0, 0, + 0, 0, 0, 0, 0, 0, 3, 204, 8, 175, + 201, 202, 0, 48, 0, 0, 203, 0, 0, 188, + 0, 2, 17, 197, 6, 14, 15, 16, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 0, + 86, 94, 100, 104, 108, 112, 116, 120, 124, 128, + 135, 137, 140, 144, 154, 157, 159, 158, 161, 177, + 178, 176, 200, 198, 0, 0, 175, 0, 162, 145, + 154, 0, 210, 209, 0, 88, 160, 159, 0, 83, + 0, 0, 0, 0, 147, 42, 0, 36, 146, 0, + 0, 148, 149, 0, 34, 175, 201, 202, 29, 0, + 0, 0, 150, 151, 152, 153, 186, 180, 0, 189, + 0, 0, 0, 208, 0, 207, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 155, 156, 93, 92, 0, 0, - 0, 0, 0, 166, 0, 0, 167, 63, 62, 190, - 194, 196, 195, 0, 85, 0, 84, 0, 54, 89, - 90, 97, 102, 106, 110, 114, 118, 122, 126, 132, - 154, 165, 64, 0, 76, 34, 0, 0, 77, 78, - 0, 40, 43, 0, 35, 0, 0, 66, 33, 30, - 191, 0, 0, 188, 182, 187, 181, 184, 179, 12, - 87, 105, 0, 109, 113, 117, 121, 125, 131, 130, - 129, 136, 138, 139, 141, 142, 143, 95, 96, 0, - 164, 170, 172, 0, 0, 169, 0, 213, 212, 0, - 45, 57, 38, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, - 79, 44, 37, 0, 0, 0, 192, 189, 0, 10, - 13, 0, 0, 163, 0, 171, 168, 0, 51, 0, - 41, 46, 0, 0, 0, 215, 214, 82, 91, 154, - 107, 0, 111, 115, 119, 123, 127, 134, 133, 0, - 98, 99, 70, 67, 0, 53, 65, 0, 183, 185, - 0, 0, 101, 173, 0, 0, 47, 39, 82, 0, - 55, 0, 0, 0, 0, 71, 72, 0, 193, 11, - 5, 52, 50, 58, 0, 0, 103, 60, 0, 0, - 68, 70, 73, 80, 9, 0, 0, 61, 82, 31, - 31, 0, 7, 82, 0, 32, 74, 75, 69, 0, - 0, 0, 56, 59 + 0, 0, 0, 155, 156, 93, 92, 0, 0, 0, + 0, 0, 166, 0, 0, 167, 63, 62, 190, 194, + 196, 195, 0, 85, 0, 84, 0, 54, 89, 90, + 97, 102, 106, 110, 114, 118, 122, 126, 132, 154, + 165, 64, 0, 76, 34, 0, 0, 77, 78, 0, + 40, 43, 0, 35, 0, 0, 66, 33, 30, 191, + 0, 0, 188, 182, 187, 181, 184, 179, 12, 87, + 105, 0, 109, 113, 117, 121, 125, 131, 130, 129, + 136, 138, 139, 141, 142, 143, 95, 96, 0, 164, + 170, 172, 0, 0, 169, 0, 212, 211, 0, 45, + 57, 38, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 81, 79, + 44, 37, 0, 0, 0, 192, 189, 0, 10, 13, + 0, 0, 163, 0, 171, 168, 0, 51, 0, 41, + 46, 0, 0, 0, 214, 213, 82, 91, 154, 107, + 0, 111, 115, 119, 123, 127, 134, 133, 0, 98, + 99, 70, 67, 0, 53, 65, 0, 183, 185, 0, + 0, 101, 173, 0, 0, 47, 39, 82, 0, 55, + 0, 0, 0, 0, 71, 72, 0, 193, 11, 5, + 52, 50, 58, 0, 0, 103, 60, 0, 0, 68, + 70, 73, 80, 9, 0, 0, 61, 82, 31, 31, + 0, 7, 82, 0, 32, 74, 75, 69, 0, 0, + 0, 56, 59 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 1, 42, 2, 89, 44, 355, 280, 281, 119, - 120, 366, 46, 47, 107, 251, 108, 252, 201, 202, - 290, 291, 48, 49, 50, 51, 253, 345, 293, 356, - 52, 53, 54, 55, 56, 57, 313, 334, 335, 336, - 351, 58, 59, 198, 199, 99, 175, 60, 178, 179, - 266, 61, 180, 62, 181, 63, 182, 64, 183, 65, - 184, 66, 185, 67, 186, 68, 187, 69, 188, 70, - 71, 72, 73, 74, 75, 76, 77, 78, 163, 243, - 79, 80, 129, 130, 131, 81, 121, 122, 85, 82, - 83, 137, 95, 249, 297 + -1, 1, 41, 2, 88, 43, 354, 279, 280, 118, + 119, 365, 45, 46, 106, 250, 107, 251, 200, 201, + 289, 290, 47, 48, 49, 50, 252, 344, 292, 355, + 51, 52, 53, 54, 55, 56, 312, 333, 334, 335, + 350, 57, 58, 197, 198, 98, 174, 59, 177, 178, + 265, 60, 179, 61, 180, 62, 181, 63, 182, 64, + 183, 65, 184, 66, 185, 67, 186, 68, 187, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 162, 242, + 78, 79, 128, 129, 130, 80, 120, 121, 84, 81, + 82, 136, 94, 248, 296 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -273 +#define YYPACT_NINF -287 static const yytype_int16 yypact[] = { - -273, 19, 524, -273, -7, -7, 976, 768, 12, 12, - 192, -273, -273, 976, 12, -273, 976, -273, -273, 57, - 976, 24, 976, 12, 12, 976, 976, -273, -273, -273, - -3, -273, -273, 585, -273, 976, 976, -273, 976, 976, - 22, 976, -273, 416, -7, -273, -273, -273, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -273, -273, -273, - 40, -273, -273, 8, 30, 49, 54, 61, 84, 21, - 96, 155, 83, -273, -273, 88, -273, 99, 140, -273, - -273, -273, -273, -273, -273, 17, 17, -273, 115, -273, - -273, 184, 118, -273, -273, 379, 872, -273, 99, 17, - 107, 976, 40, 646, 134, -273, 109, 55, -273, -273, - 379, 976, -273, -273, 768, 471, -3, 119, 121, -273, - 707, 58, 153, -273, -273, -273, -273, -273, -273, 45, - 59, 976, -45, 12, -273, 976, -273, -273, 976, 976, - 976, 976, 976, 976, 976, 976, 976, 976, 976, 976, - 976, 976, 976, 976, -273, -273, -273, -273, 976, 976, - 976, 127, 820, -273, 976, 168, -273, -273, -273, -273, - -273, -273, -273, 12, -273, 7, 107, 175, -273, 171, - -273, -273, 14, 194, 174, 176, 177, 197, 34, 96, - 77, -273, -273, 9, -273, -273, 12, 57, 221, -273, - 976, -273, -273, 24, -273, 7, 9, -273, -273, -273, - -273, 112, 976, 187, -273, -273, -273, -273, -273, 203, - -273, 30, 193, 49, 54, 61, 84, 21, 96, 96, - 96, 155, 83, 83, -273, -273, -273, -273, -273, 67, - -273, -273, -273, 27, 71, -273, 379, -273, -273, 768, - 196, 195, 232, 37, 976, 976, 976, 976, 976, 976, - 976, 976, 976, 976, 379, 976, 976, 207, 217, -273, - -273, -273, -273, 768, 768, 206, -273, 211, 924, -273, - 212, 7, 976, -273, 976, -273, -273, 7, 251, 976, - -273, -273, 175, 37, 379, -273, -273, 976, -273, 100, - 194, 213, 174, 176, 177, 197, 34, 96, 96, 7, - -273, -273, 258, -273, 7, -273, -273, 976, -273, -273, - 224, 219, -273, -273, 17, 768, -273, -273, 976, 7, - -273, 976, 768, 976, 16, 258, -273, 57, -273, -273, - -273, -273, -273, -273, 768, 37, -273, -273, 79, 216, - -273, 258, -273, -273, 768, 231, 37, -273, 976, 768, - 768, 237, -273, 976, 7, 768, -273, -273, -273, 7, - 768, 768, -273, -273 + -287, 29, 490, -287, -18, -18, 934, 730, 21, 21, + 965, -287, 934, 21, -287, 934, -287, -287, 36, 934, + 89, 934, 21, 21, 934, 934, -287, -287, -287, 105, + -287, -287, 550, -287, 934, 934, -287, 934, 934, 61, + 934, -287, 403, -18, -287, -287, -287, -287, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -287, -287, 15, + -287, -287, 41, 106, 117, 129, 142, 158, 76, 162, + 131, 47, -287, -287, 141, -287, 113, 148, -287, -287, + -287, -287, -287, -287, 5, 5, -287, 147, -287, -287, + 169, 177, -287, -287, 370, 832, -287, 113, 5, 164, + 934, 15, 610, 123, -287, 159, 16, -287, -287, 370, + 934, -287, -287, 730, 438, 105, 175, 176, -287, 670, + 86, 178, -287, -287, -287, -287, -287, -287, 62, 63, + 934, 28, 21, -287, 934, -287, -287, 934, 934, 934, + 934, 934, 934, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, -287, -287, -287, -287, 934, 934, 934, + 181, 781, -287, 934, 189, -287, -287, -287, -287, -287, + -287, -287, 21, -287, 8, 164, 191, -287, 183, -287, + -287, 56, 201, 180, 182, 179, 194, 53, 162, 10, + -287, -287, 12, -287, -287, 21, 36, 225, -287, 934, + -287, -287, 89, -287, 8, 12, -287, -287, -287, -287, + 94, 934, 193, -287, -287, -287, -287, -287, 200, -287, + 106, 192, 117, 129, 142, 158, 76, 162, 162, 162, + 131, 47, 47, -287, -287, -287, -287, -287, 68, -287, + -287, -287, 46, 109, -287, 370, -287, -287, 730, 195, + 197, 227, 18, 934, 934, 934, 934, 934, 934, 934, + 934, 934, 934, 370, 934, 934, 199, 209, -287, -287, + -287, -287, 730, 730, 202, -287, 204, 883, -287, 206, + 8, 934, -287, 934, -287, -287, 8, 239, 934, -287, + -287, 191, 18, 370, -287, -287, 934, -287, 160, 201, + 218, 180, 182, 179, 194, 53, 162, 162, 8, -287, + -287, 250, -287, 8, -287, -287, 934, -287, -287, 231, + 228, -287, -287, 5, 730, -287, -287, 934, 8, -287, + 934, 730, 934, 66, 250, -287, 36, -287, -287, -287, + -287, -287, -287, 730, 18, -287, -287, -32, 226, -287, + 250, -287, -287, 730, 238, 18, -287, 934, 730, 730, + 240, -287, 934, 8, 730, -287, -287, -287, 8, 730, + 730, -287, -287 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -273, -273, -273, -70, -2, -273, -273, -273, -273, 0, - -138, -84, -10, -273, -273, -273, 74, -14, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -273, -273, -273, - -273, -273, -273, -273, -273, -273, -273, -72, -273, -55, - -273, -273, -273, -273, 85, -263, -96, -12, -273, -273, - 209, -115, -239, -273, -273, -273, -273, 143, 31, 157, - 43, 160, 44, 162, 46, 163, 47, 165, 50, -66, - 164, 91, 353, -273, 33, 300, 303, -273, -16, -273, - -273, -273, -273, 101, 102, -273, -273, 106, 1, -273, - -273, -74, 28, -61, -272 + -287, -287, -287, -61, -2, -287, -287, -287, -287, 0, + -141, -80, -15, -287, -287, -287, 78, -10, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -287, -287, -287, + -287, -287, -287, -287, -287, -287, -287, -68, -287, -50, + -287, -287, -287, -287, 88, -286, -105, 20, -287, -287, + 212, -77, -209, -287, -287, -287, -287, 150, 34, 152, + 33, 153, 35, 154, 38, 156, 40, 151, 42, -94, + 157, 75, 64, -287, 2, 290, 291, -287, 19, -287, + -287, -287, -287, 93, 95, -287, -287, 96, 26, -287, + -287, -73, 25, 17, -278 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -963,264 +960,262 @@ static const yytype_int16 yypgoto[] = #define YYTABLE_NINF -197 static const yytype_int16 yytable[] = { - 43, 100, 45, 135, 102, 43, 86, 92, 247, 104, - 247, 167, 168, 93, 205, 298, 217, 301, 134, 3, - 220, 328, 218, 349, 222, 192, 310, 311, 194, 132, - 189, 43, 84, 204, 330, 145, 146, 96, 295, 91, - 138, 134, 101, 237, 238, 133, 255, 242, 114, 262, - 326, 110, 111, 91, 350, 91, 134, 135, 91, 91, - 139, 140, 166, 106, 147, 343, 256, 136, 91, 91, - 127, 91, 91, 358, 248, 284, 248, 263, 94, 228, - 229, 230, 191, 176, 363, 271, 128, 296, 135, 193, - 136, 264, 346, 213, 285, 364, 210, 276, 176, 206, - 369, 43, 141, 203, 103, 136, 211, 215, 142, 214, - 154, 155, 43, 156, 207, 135, 143, 157, 43, 135, - 209, 154, 155, 216, 156, 144, 265, 135, 157, 190, - 359, 283, 267, 154, 155, 286, 156, 158, 148, 196, - 157, 151, 152, 153, 273, 274, 197, 173, 239, 265, - 287, 170, 244, 169, 170, 135, 171, 172, 200, 171, - 172, 219, 160, 319, 161, 162, 240, 322, 309, 323, - -196, 91, -195, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 269, 189, 189, - 189, 189, 189, 189, 189, 189, 307, 308, 329, 189, - 189, 246, 338, 164, 212, 165, 162, 245, 10, 11, - 12, 149, 150, 15, 250, 17, 18, 154, 155, 254, - 321, 365, 365, 189, 268, 257, 324, 258, 28, 29, - 259, 87, 260, 197, 176, 127, 31, 32, 261, 88, - 232, 233, 279, 292, 282, 289, 294, 43, 332, 288, - 341, 37, 176, 337, 312, 40, 314, 317, 41, 215, - 320, 325, 333, 339, 331, 189, 340, 360, 344, 362, - 354, 43, 43, 315, 316, 368, 367, 272, 327, 361, - 352, 221, 176, 270, 159, 100, 300, 299, 91, 299, - 91, 91, 91, 91, 91, 91, 91, 223, 299, 299, - 302, 224, 303, 370, 225, 304, 226, 305, 371, 227, - 97, 306, 231, 98, 277, 278, 100, 275, 0, 0, - 0, 348, 299, 43, 0, 342, 0, 353, 0, 0, - 43, 0, 347, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 43, 0, 357, 0, 100, 0, 0, 0, - 0, 100, 43, 0, 45, 0, 0, 43, 43, 90, - 0, 0, 0, 43, 299, 209, 0, 0, 43, 43, - 372, 373, 0, 105, 0, 109, 0, 0, 112, 113, - 174, 0, 0, 0, 0, 0, 0, 6, 123, 124, - 0, 125, 126, 0, 0, 10, 11, 12, 0, 0, - 15, 0, 17, 18, 0, 20, 0, 22, 0, 0, - 0, 0, 25, 26, 0, 28, 29, -162, 87, 0, - 0, 0, 0, 31, 32, 0, 88, 0, 0, 0, - -162, -162, 0, 0, 0, 35, 36, 0, 37, 0, - 38, 39, 40, 0, 0, 41, 0, -162, -162, 0, - 0, 0, 0, 0, 0, 0, -162, -162, -162, -162, - 0, 0, 0, 0, -162, -162, 0, 0, -162, -162, - -162, -162, -190, 0, -162, 0, -162, 0, 0, 0, - 0, -162, 0, 0, 0, -190, -190, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -190, -190, 234, 235, 236, 0, 0, 0, - 0, -190, -190, -190, -190, 0, 0, 0, 0, -190, - -190, 0, 0, -190, -190, -190, -190, 4, 0, -190, - 5, -190, 6, 7, 0, 8, -190, 9, 0, 0, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 0, 0, 25, 26, 27, - 28, 29, 0, 30, 0, 0, 0, 0, 31, 32, - 0, 33, 0, 0, 34, 0, 0, 0, 0, 0, - 35, 36, 0, 37, 0, 38, 39, 40, 4, 0, - 41, 5, 0, 6, 7, 0, 8, 0, 9, 0, - 0, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 0, 0, 25, 26, - 0, 28, 29, 115, 116, 0, 0, 0, 0, 117, - 118, 0, 33, 0, 0, 34, 0, 0, 0, 0, - 0, 35, 36, 0, 37, 0, 38, 39, 40, 4, - 0, 41, 5, 0, 6, 7, 0, 8, 0, 9, - 0, 0, 10, 11, 12, 13, 14, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 24, 0, 0, 25, - 26, 0, 28, 29, 195, 30, 0, 0, 0, 0, - 31, 32, 0, 33, 0, 0, 34, 0, 0, 0, - 0, 0, 35, 36, 0, 37, 0, 38, 39, 40, - 4, 0, 41, 5, 0, 6, 7, 0, 8, 0, - 9, 0, 0, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 0, 0, - 25, 26, 0, 28, 29, 208, 30, 0, 0, 0, - 0, 31, 32, 0, 33, 0, 0, 34, 0, 0, - 0, 0, 0, 35, 36, 0, 37, 0, 38, 39, - 40, 4, 0, 41, 5, 0, 6, 7, 0, 8, - 0, 9, 0, 0, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, - 0, 25, 26, 0, 28, 29, 0, 30, 0, 0, - 0, 0, 31, 32, 0, 33, 0, 0, 34, 0, - 0, 0, 0, 0, 35, 36, 0, 37, 6, 38, - 39, 40, 0, 0, 41, 0, 10, 11, 12, 0, - 0, 15, 0, 17, 18, 0, 20, 0, 22, 0, - 0, 0, 0, 25, 26, 0, 28, 29, 0, 87, - 0, 0, 0, 0, 31, 32, 0, 88, 0, 0, - 0, 0, 0, 0, 0, 0, 35, 36, 0, 37, - 6, 38, 39, 40, 0, 0, 41, 241, 10, 11, - 12, 0, 0, 15, 0, 17, 18, 0, 20, 177, - 22, 0, 0, 0, 0, 25, 26, 0, 28, 29, - 0, 87, 0, 0, 0, 0, 31, 32, 0, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, - 0, 37, 6, 38, 39, 40, 0, 0, 41, 0, - 10, 11, 12, 0, 0, 15, 0, 17, 18, 0, - 20, 0, 22, 0, 0, 0, 0, 25, 26, 0, - 28, 29, 0, 87, 0, 0, 0, 0, 31, 32, - 0, 88, 0, 0, 0, 0, 0, 0, 0, 0, - 35, 36, 0, 37, 6, 38, 39, 40, 318, 0, - 41, 0, 10, 11, 12, 0, 0, 15, 0, 17, - 18, 0, 20, 0, 22, 0, 0, 0, 0, 25, - 26, 0, 28, 29, 0, 87, 0, 0, 0, 0, - 31, 32, 0, 88, 0, 0, 0, 0, 0, 0, - 0, 0, 35, 36, 0, 37, 0, 38, 39, 40, - 0, 0, 41 + 42, 188, 44, 103, 204, 42, 133, 91, 90, 246, + 329, 166, 167, 246, 327, 134, 133, 133, 358, 294, + 83, 90, 92, 90, 263, 191, 90, 90, 193, 3, + 42, 85, 99, 203, 95, 101, 90, 90, 100, 90, + 90, 342, 153, 154, 297, 155, 300, 109, 110, 156, + 227, 228, 229, 216, 135, 309, 310, 219, 264, 134, + 131, 221, 134, 202, 135, 135, 357, 295, 261, 132, + 89, 363, 137, 348, 247, 134, 368, 362, 247, 325, + 236, 237, 102, 104, 241, 108, 93, 254, 111, 112, + 144, 145, 138, 283, 217, 262, 165, 189, 122, 123, + 42, 124, 125, 349, 150, 151, 152, 255, 126, 212, + 214, 42, 284, 206, 175, 134, 190, 42, 146, 208, + 192, 345, 270, 209, 127, 213, 215, 105, 195, 175, + 205, 282, 169, 210, 275, 196, 139, 170, 171, 90, + 286, 90, 90, 90, 90, 90, 90, 90, 90, 90, + 90, 90, 90, 90, 90, 113, 134, 218, 308, 188, + 188, 188, 188, 188, 188, 188, 188, 306, 307, 140, + 188, 188, 285, 153, 154, 159, 155, 160, 161, 238, + 156, 268, 141, 243, 168, 169, 148, 149, 328, 157, + 170, 171, 153, 154, 188, 155, 142, 245, 143, 156, + 318, 153, 154, 147, 321, 172, 322, 199, 264, 266, + 163, 134, 164, 161, 233, 234, 235, 364, 364, 239, + 267, 272, 273, 231, 232, -196, -195, 244, 211, 249, + 253, 256, 257, 259, 260, 258, 188, 196, 278, 337, + 126, 293, 281, 288, 291, 311, 42, 313, 287, 324, + 340, 214, 316, 319, 332, 298, 90, 298, 90, 90, + 90, 90, 90, 90, 90, 175, 298, 298, 330, 338, + 42, 42, 314, 315, 339, 361, 359, 367, 353, 366, + 271, 326, 360, 175, 351, 269, 158, 220, 299, 301, + 298, 222, 302, 223, 226, 224, 303, 320, 225, 304, + 96, 97, 305, 323, 230, 276, 274, 277, 0, 0, + 0, 0, 0, 175, 0, 0, 99, 0, 0, 0, + 0, 352, 42, 0, 341, 331, 0, 0, 0, 42, + 336, 346, 298, 0, 0, 0, 0, 0, 0, 0, + 0, 42, 0, 356, 0, 343, 0, 99, 0, 0, + 0, 42, 347, 44, 0, 0, 42, 42, 0, 0, + 0, 0, 42, 0, 208, 0, 0, 42, 42, 371, + 372, 173, 0, 0, 0, 0, 0, 99, 6, 0, + 369, 0, 99, 0, 0, 370, 10, 11, 0, 0, + 14, 0, 16, 17, 0, 19, 0, 21, 0, 0, + 0, 0, 24, 25, -162, 27, 28, 0, 86, 0, + 0, 0, 0, 30, 31, 0, 87, -162, -162, 0, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, -162, -162, 40, 0, 0, 0, -190, + 0, 0, -162, -162, -162, -162, 0, 0, 0, 0, + -162, -162, -190, -190, -162, -162, -162, -162, 0, 0, + -162, 0, -162, 0, 0, 0, 0, -162, -190, -190, + 0, 0, 0, 0, 0, 0, 0, -190, -190, -190, + -190, 0, 0, 0, 0, -190, -190, 0, 0, -190, + -190, -190, -190, 4, 0, -190, 5, -190, 6, 7, + 0, 8, -190, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 26, 27, 28, 0, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 114, 115, 0, + 0, 0, 0, 116, 117, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 194, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 207, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 0, + 37, 38, 39, 4, 0, 40, 5, 0, 6, 7, + 0, 8, 0, 9, 0, 0, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 24, 25, 0, 27, 28, 0, 29, 0, + 0, 0, 0, 30, 31, 0, 32, 0, 0, 33, + 0, 0, 0, 0, 0, 34, 35, 0, 36, 6, + 37, 38, 39, 0, 0, 40, 0, 10, 11, 0, + 0, 14, 0, 16, 17, 0, 19, 0, 21, 0, + 0, 0, 0, 24, 25, 0, 27, 28, 0, 86, + 0, 0, 0, 0, 30, 31, 0, 87, 0, 0, + 0, 0, 0, 0, 0, 0, 34, 35, 0, 36, + 6, 37, 38, 39, 0, 0, 40, 240, 10, 11, + 0, 0, 14, 0, 16, 17, 0, 19, 176, 21, + 0, 0, 0, 0, 24, 25, 0, 27, 28, 0, + 86, 0, 0, 0, 0, 30, 31, 0, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 34, 35, 0, + 36, 6, 37, 38, 39, 0, 0, 40, 0, 10, + 11, 0, 0, 14, 0, 16, 17, 0, 19, 0, + 21, 0, 0, 0, 0, 24, 25, 0, 27, 28, + 0, 86, 0, 0, 0, 0, 30, 31, 0, 87, + 0, 0, 0, 0, 0, 0, 0, 0, 34, 35, + 0, 36, 6, 37, 38, 39, 317, 0, 40, 0, + 10, 11, 0, 0, 14, 0, 16, 17, 0, 19, + 0, 21, 0, 0, 0, 0, 24, 25, 0, 27, + 28, 0, 86, 0, 0, 0, 0, 30, 31, 0, + 87, 10, 11, 0, 0, 14, 0, 16, 17, 34, + 35, 0, 36, 0, 37, 38, 39, 0, 0, 40, + 27, 28, 0, 86, 0, 0, 0, 0, 30, 31, + 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 36, 0, 0, 0, 39, 0, 0, + 40 }; static const yytype_int16 yycheck[] = { - 2, 13, 2, 48, 16, 7, 5, 7, 1, 19, - 1, 85, 86, 1, 110, 254, 131, 256, 1, 0, - 135, 293, 67, 7, 139, 99, 265, 266, 102, 41, - 96, 33, 39, 107, 297, 14, 15, 9, 1, 6, - 32, 1, 14, 158, 159, 44, 32, 162, 51, 15, - 289, 23, 24, 20, 38, 22, 1, 48, 25, 26, - 52, 31, 78, 39, 43, 328, 52, 50, 35, 36, - 48, 38, 39, 345, 67, 48, 67, 43, 66, 145, - 146, 147, 98, 95, 356, 200, 64, 50, 48, 101, - 50, 14, 331, 48, 67, 358, 38, 212, 110, 111, - 363, 103, 53, 48, 47, 50, 48, 48, 54, 64, - 33, 34, 114, 36, 114, 48, 55, 40, 120, 48, - 120, 33, 34, 64, 36, 41, 49, 48, 40, 96, - 51, 64, 193, 33, 34, 64, 36, 49, 42, 5, - 40, 58, 59, 60, 205, 206, 12, 29, 160, 49, - 246, 39, 164, 38, 39, 48, 44, 45, 49, 44, - 45, 133, 63, 278, 65, 66, 39, 282, 264, 284, - 51, 138, 51, 140, 141, 142, 143, 144, 145, 146, - 147, 148, 149, 150, 151, 152, 153, 197, 254, 255, - 256, 257, 258, 259, 260, 261, 262, 263, 294, 265, - 266, 173, 317, 63, 51, 65, 66, 39, 16, 17, - 18, 56, 57, 21, 39, 23, 24, 33, 34, 48, - 281, 359, 360, 289, 196, 31, 287, 53, 36, 37, - 54, 39, 55, 12, 246, 48, 44, 45, 41, 47, - 149, 150, 39, 48, 51, 49, 14, 249, 309, 249, - 324, 59, 264, 314, 47, 63, 39, 51, 66, 48, - 48, 10, 4, 39, 51, 331, 47, 51, 329, 38, - 340, 273, 274, 273, 274, 38, 360, 203, 292, 351, - 335, 138, 294, 198, 75, 297, 255, 254, 255, 256, - 257, 258, 259, 260, 261, 262, 263, 140, 265, 266, - 257, 141, 258, 364, 142, 259, 143, 260, 369, 144, - 10, 261, 148, 10, 213, 213, 328, 211, -1, -1, - -1, 333, 289, 325, -1, 325, -1, 337, -1, -1, - 332, -1, 332, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 344, -1, 344, -1, 358, -1, -1, -1, - -1, 363, 354, -1, 354, -1, -1, 359, 360, 6, - -1, -1, -1, 365, 331, 365, -1, -1, 370, 371, - 370, 371, -1, 20, -1, 22, -1, -1, 25, 26, - 1, -1, -1, -1, -1, -1, -1, 8, 35, 36, - -1, 38, 39, -1, -1, 16, 17, 18, -1, -1, - 21, -1, 23, 24, -1, 26, -1, 28, -1, -1, - -1, -1, 33, 34, -1, 36, 37, 1, 39, -1, - -1, -1, -1, 44, 45, -1, 47, -1, -1, -1, - 14, 15, -1, -1, -1, 56, 57, -1, 59, -1, - 61, 62, 63, -1, -1, 66, -1, 31, 32, -1, - -1, -1, -1, -1, -1, -1, 40, 41, 42, 43, - -1, -1, -1, -1, 48, 49, -1, -1, 52, 53, - 54, 55, 1, -1, 58, -1, 60, -1, -1, -1, - -1, 65, -1, -1, -1, 14, 15, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 31, 32, 151, 152, 153, -1, -1, -1, - -1, 40, 41, 42, 43, -1, -1, -1, -1, 48, - 49, -1, -1, 52, 53, 54, 55, 3, -1, 58, - 6, 60, 8, 9, -1, 11, 65, 13, -1, -1, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, -1, -1, 33, 34, 35, - 36, 37, -1, 39, -1, -1, -1, -1, 44, 45, - -1, 47, -1, -1, 50, -1, -1, -1, -1, -1, - 56, 57, -1, 59, -1, 61, 62, 63, 3, -1, - 66, 6, -1, 8, 9, -1, 11, -1, 13, -1, - -1, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, -1, -1, 33, 34, - -1, 36, 37, 38, 39, -1, -1, -1, -1, 44, - 45, -1, 47, -1, -1, 50, -1, -1, -1, -1, - -1, 56, 57, -1, 59, -1, 61, 62, 63, 3, - -1, 66, 6, -1, 8, 9, -1, 11, -1, 13, - -1, -1, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, -1, -1, 33, - 34, -1, 36, 37, 38, 39, -1, -1, -1, -1, - 44, 45, -1, 47, -1, -1, 50, -1, -1, -1, - -1, -1, 56, 57, -1, 59, -1, 61, 62, 63, - 3, -1, 66, 6, -1, 8, 9, -1, 11, -1, - 13, -1, -1, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, - 33, 34, -1, 36, 37, 38, 39, -1, -1, -1, - -1, 44, 45, -1, 47, -1, -1, 50, -1, -1, - -1, -1, -1, 56, 57, -1, 59, -1, 61, 62, - 63, 3, -1, 66, 6, -1, 8, 9, -1, 11, - -1, 13, -1, -1, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, - -1, 33, 34, -1, 36, 37, -1, 39, -1, -1, - -1, -1, 44, 45, -1, 47, -1, -1, 50, -1, - -1, -1, -1, -1, 56, 57, -1, 59, 8, 61, - 62, 63, -1, -1, 66, -1, 16, 17, 18, -1, - -1, 21, -1, 23, 24, -1, 26, -1, 28, -1, - -1, -1, -1, 33, 34, -1, 36, 37, -1, 39, - -1, -1, -1, -1, 44, 45, -1, 47, -1, -1, - -1, -1, -1, -1, -1, -1, 56, 57, -1, 59, - 8, 61, 62, 63, -1, -1, 66, 67, 16, 17, - 18, -1, -1, 21, -1, 23, 24, -1, 26, 27, - 28, -1, -1, -1, -1, 33, 34, -1, 36, 37, - -1, 39, -1, -1, -1, -1, 44, 45, -1, 47, - -1, -1, -1, -1, -1, -1, -1, -1, 56, 57, - -1, 59, 8, 61, 62, 63, -1, -1, 66, -1, - 16, 17, 18, -1, -1, 21, -1, 23, 24, -1, - 26, -1, 28, -1, -1, -1, -1, 33, 34, -1, - 36, 37, -1, 39, -1, -1, -1, -1, 44, 45, - -1, 47, -1, -1, -1, -1, -1, -1, -1, -1, - 56, 57, -1, 59, 8, 61, 62, 63, 64, -1, - 66, -1, 16, 17, 18, -1, -1, 21, -1, 23, - 24, -1, 26, -1, 28, -1, -1, -1, -1, 33, - 34, -1, 36, 37, -1, 39, -1, -1, -1, -1, - 44, 45, -1, 47, -1, -1, -1, -1, -1, -1, - -1, -1, 56, 57, -1, 59, -1, 61, 62, 63, - -1, -1, 66 + 2, 95, 2, 18, 109, 7, 1, 7, 6, 1, + 296, 84, 85, 1, 292, 47, 1, 1, 50, 1, + 38, 19, 1, 21, 14, 98, 24, 25, 101, 0, + 32, 5, 12, 106, 9, 15, 34, 35, 13, 37, + 38, 327, 32, 33, 253, 35, 255, 22, 23, 39, + 144, 145, 146, 130, 49, 264, 265, 134, 48, 47, + 40, 138, 47, 47, 49, 49, 344, 49, 15, 43, + 6, 357, 31, 7, 66, 47, 362, 355, 66, 288, + 157, 158, 46, 19, 161, 21, 65, 31, 24, 25, + 14, 15, 51, 47, 66, 42, 77, 95, 34, 35, + 102, 37, 38, 37, 57, 58, 59, 51, 47, 47, + 47, 113, 66, 113, 94, 47, 97, 119, 42, 119, + 100, 330, 199, 37, 63, 63, 63, 38, 5, 109, + 110, 63, 38, 47, 211, 12, 30, 43, 44, 137, + 245, 139, 140, 141, 142, 143, 144, 145, 146, 147, + 148, 149, 150, 151, 152, 50, 47, 132, 263, 253, + 254, 255, 256, 257, 258, 259, 260, 261, 262, 52, + 264, 265, 63, 32, 33, 62, 35, 64, 65, 159, + 39, 196, 53, 163, 37, 38, 55, 56, 293, 48, + 43, 44, 32, 33, 288, 35, 54, 172, 40, 39, + 277, 32, 33, 41, 281, 28, 283, 48, 48, 192, + 62, 47, 64, 65, 150, 151, 152, 358, 359, 38, + 195, 204, 205, 148, 149, 50, 50, 38, 50, 38, + 47, 30, 52, 54, 40, 53, 330, 12, 38, 316, + 47, 14, 50, 48, 47, 46, 248, 38, 248, 10, + 323, 47, 50, 47, 4, 253, 254, 255, 256, 257, + 258, 259, 260, 261, 262, 245, 264, 265, 50, 38, + 272, 273, 272, 273, 46, 37, 50, 37, 339, 359, + 202, 291, 350, 263, 334, 197, 74, 137, 254, 256, + 288, 139, 257, 140, 143, 141, 258, 280, 142, 259, + 10, 10, 260, 286, 147, 212, 210, 212, -1, -1, + -1, -1, -1, 293, -1, -1, 296, -1, -1, -1, + -1, 336, 324, -1, 324, 308, -1, -1, -1, 331, + 313, 331, 330, -1, -1, -1, -1, -1, -1, -1, + -1, 343, -1, 343, -1, 328, -1, 327, -1, -1, + -1, 353, 332, 353, -1, -1, 358, 359, -1, -1, + -1, -1, 364, -1, 364, -1, -1, 369, 370, 369, + 370, 1, -1, -1, -1, -1, -1, 357, 8, -1, + 363, -1, 362, -1, -1, 368, 16, 17, -1, -1, + 20, -1, 22, 23, -1, 25, -1, 27, -1, -1, + -1, -1, 32, 33, 1, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, 14, 15, -1, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 30, 31, 65, -1, -1, -1, 1, + -1, -1, 39, 40, 41, 42, -1, -1, -1, -1, + 47, 48, 14, 15, 51, 52, 53, 54, -1, -1, + 57, -1, 59, -1, -1, -1, -1, 64, 30, 31, + -1, -1, -1, -1, -1, -1, -1, 39, 40, 41, + 42, -1, -1, -1, -1, 47, 48, -1, -1, 51, + 52, 53, 54, 3, -1, 57, 6, 59, 8, 9, + -1, 11, 64, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, 34, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, 37, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, -1, + 60, 61, 62, 3, -1, 65, 6, -1, 8, 9, + -1, 11, -1, 13, -1, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + -1, -1, 32, 33, -1, 35, 36, -1, 38, -1, + -1, -1, -1, 43, 44, -1, 46, -1, -1, 49, + -1, -1, -1, -1, -1, 55, 56, -1, 58, 8, + 60, 61, 62, -1, -1, 65, -1, 16, 17, -1, + -1, 20, -1, 22, 23, -1, 25, -1, 27, -1, + -1, -1, -1, 32, 33, -1, 35, 36, -1, 38, + -1, -1, -1, -1, 43, 44, -1, 46, -1, -1, + -1, -1, -1, -1, -1, -1, 55, 56, -1, 58, + 8, 60, 61, 62, -1, -1, 65, 66, 16, 17, + -1, -1, 20, -1, 22, 23, -1, 25, 26, 27, + -1, -1, -1, -1, 32, 33, -1, 35, 36, -1, + 38, -1, -1, -1, -1, 43, 44, -1, 46, -1, + -1, -1, -1, -1, -1, -1, -1, 55, 56, -1, + 58, 8, 60, 61, 62, -1, -1, 65, -1, 16, + 17, -1, -1, 20, -1, 22, 23, -1, 25, -1, + 27, -1, -1, -1, -1, 32, 33, -1, 35, 36, + -1, 38, -1, -1, -1, -1, 43, 44, -1, 46, + -1, -1, -1, -1, -1, -1, -1, -1, 55, 56, + -1, 58, 8, 60, 61, 62, 63, -1, 65, -1, + 16, 17, -1, -1, 20, -1, 22, 23, -1, 25, + -1, 27, -1, -1, -1, -1, 32, 33, -1, 35, + 36, -1, 38, -1, -1, -1, -1, 43, 44, -1, + 46, 16, 17, -1, -1, 20, -1, 22, 23, 55, + 56, -1, 58, -1, 60, 61, 62, -1, -1, 65, + 35, 36, -1, 38, -1, -1, -1, -1, 43, 44, + -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 58, -1, -1, -1, 62, -1, -1, + 65 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 69, 71, 0, 3, 6, 8, 9, 11, 13, + 0, 68, 70, 0, 3, 6, 8, 9, 11, 13, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, - 39, 44, 45, 47, 50, 56, 57, 59, 61, 62, - 63, 66, 70, 72, 73, 77, 80, 81, 90, 91, - 92, 93, 98, 99, 100, 101, 102, 103, 109, 110, - 115, 119, 121, 123, 125, 127, 129, 131, 133, 135, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 148, - 149, 153, 157, 158, 39, 156, 156, 39, 47, 72, - 140, 142, 77, 1, 66, 160, 160, 143, 144, 113, - 115, 160, 115, 47, 80, 140, 39, 82, 84, 140, - 160, 160, 140, 140, 51, 38, 39, 44, 45, 77, - 78, 154, 155, 140, 140, 140, 140, 48, 64, 150, - 151, 152, 115, 156, 1, 48, 50, 159, 32, 52, - 31, 53, 54, 55, 41, 14, 15, 43, 42, 56, - 57, 58, 59, 60, 33, 34, 36, 40, 49, 118, - 63, 65, 66, 146, 63, 65, 146, 159, 159, 38, - 39, 44, 45, 29, 1, 114, 115, 27, 116, 117, - 120, 122, 124, 126, 128, 130, 132, 134, 136, 137, - 142, 146, 159, 115, 159, 38, 5, 12, 111, 112, - 49, 86, 87, 48, 159, 114, 115, 77, 38, 77, - 38, 48, 51, 48, 64, 48, 64, 119, 67, 160, - 119, 125, 119, 127, 129, 131, 133, 135, 137, 137, - 137, 138, 139, 139, 140, 140, 140, 119, 119, 115, - 39, 67, 119, 147, 115, 39, 160, 1, 67, 161, - 39, 83, 85, 94, 48, 32, 52, 31, 53, 54, - 55, 41, 15, 43, 14, 49, 118, 161, 160, 80, - 112, 119, 84, 161, 161, 155, 119, 151, 152, 39, - 75, 76, 51, 64, 48, 67, 64, 114, 77, 49, - 88, 89, 48, 96, 14, 1, 50, 162, 120, 142, - 126, 120, 128, 130, 132, 134, 136, 137, 137, 114, - 120, 120, 47, 104, 39, 77, 77, 51, 64, 119, - 48, 161, 119, 119, 161, 10, 120, 85, 162, 114, - 113, 51, 161, 4, 105, 106, 107, 161, 119, 39, - 47, 159, 77, 113, 161, 95, 120, 77, 115, 7, - 38, 108, 107, 80, 71, 74, 97, 77, 162, 51, - 51, 105, 38, 162, 113, 78, 79, 79, 38, 113, - 161, 161, 77, 77 + 26, 27, 28, 29, 32, 33, 34, 35, 36, 38, + 43, 44, 46, 49, 55, 56, 58, 60, 61, 62, + 65, 69, 71, 72, 76, 79, 80, 89, 90, 91, + 92, 97, 98, 99, 100, 101, 102, 108, 109, 114, + 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 147, 148, + 152, 156, 157, 38, 155, 155, 38, 46, 71, 139, + 141, 76, 1, 65, 159, 159, 142, 143, 112, 114, + 159, 114, 46, 79, 139, 38, 81, 83, 139, 159, + 159, 139, 139, 50, 37, 38, 43, 44, 76, 77, + 153, 154, 139, 139, 139, 139, 47, 63, 149, 150, + 151, 114, 155, 1, 47, 49, 158, 31, 51, 30, + 52, 53, 54, 40, 14, 15, 42, 41, 55, 56, + 57, 58, 59, 32, 33, 35, 39, 48, 117, 62, + 64, 65, 145, 62, 64, 145, 158, 158, 37, 38, + 43, 44, 28, 1, 113, 114, 26, 115, 116, 119, + 121, 123, 125, 127, 129, 131, 133, 135, 136, 141, + 145, 158, 114, 158, 37, 5, 12, 110, 111, 48, + 85, 86, 47, 158, 113, 114, 76, 37, 76, 37, + 47, 50, 47, 63, 47, 63, 118, 66, 159, 118, + 124, 118, 126, 128, 130, 132, 134, 136, 136, 136, + 137, 138, 138, 139, 139, 139, 118, 118, 114, 38, + 66, 118, 146, 114, 38, 159, 1, 66, 160, 38, + 82, 84, 93, 47, 31, 51, 30, 52, 53, 54, + 40, 15, 42, 14, 48, 117, 160, 159, 79, 111, + 118, 83, 160, 160, 154, 118, 150, 151, 38, 74, + 75, 50, 63, 47, 66, 63, 113, 76, 48, 87, + 88, 47, 95, 14, 1, 49, 161, 119, 141, 125, + 119, 127, 129, 131, 133, 135, 136, 136, 113, 119, + 119, 46, 103, 38, 76, 76, 50, 63, 118, 47, + 160, 118, 118, 160, 10, 119, 84, 161, 113, 112, + 50, 160, 4, 104, 105, 106, 160, 118, 38, 46, + 158, 76, 112, 160, 94, 119, 76, 114, 7, 37, + 107, 106, 79, 70, 73, 96, 76, 161, 50, 50, + 104, 37, 161, 112, 77, 78, 78, 37, 112, 160, + 160, 76, 76 }; #define yyerrok (yyerrstatus = 0) @@ -2033,1415 +2028,1416 @@ yyreduce: case 2: /* Line 1455 of yacc.c */ -#line 258 "parser.y" +#line 257 "parser.y" { program_parsed(ctx, (yyvsp[(1) - (2)].source_elements)); ;} break; case 3: /* Line 1455 of yacc.c */ -#line 261 "parser.y" +#line 260 "parser.y" {;} break; case 4: /* Line 1455 of yacc.c */ -#line 262 "parser.y" +#line 261 "parser.y" {;} break; case 5: /* Line 1455 of yacc.c */ -#line 266 "parser.y" +#line 265 "parser.y" { (yyval.source_elements) = new_source_elements(ctx); ;} break; case 6: /* Line 1455 of yacc.c */ -#line 268 "parser.y" +#line 267 "parser.y" { (yyval.source_elements) = source_elements_add_statement((yyvsp[(1) - (2)].source_elements), (yyvsp[(2) - (2)].statement)); ;} break; case 7: /* Line 1455 of yacc.c */ -#line 273 "parser.y" +#line 272 "parser.y" { (yyval.expr) = new_function_expression(ctx, (yyvsp[(2) - (8)].identifier), (yyvsp[(4) - (8)].parameter_list), (yyvsp[(7) - (8)].source_elements), (yyvsp[(1) - (8)].srcptr), (yyvsp[(8) - (8)].srcptr)-(yyvsp[(1) - (8)].srcptr)+1); ;} break; case 8: /* Line 1455 of yacc.c */ -#line 276 "parser.y" +#line 275 "parser.y" { push_func(ctx); (yyval.srcptr) = (yyvsp[(1) - (1)].srcptr); ;} break; case 9: /* Line 1455 of yacc.c */ -#line 280 "parser.y" +#line 279 "parser.y" { (yyval.source_elements) = function_body_parsed(ctx, (yyvsp[(1) - (1)].source_elements)); ;} break; case 10: /* Line 1455 of yacc.c */ -#line 284 "parser.y" +#line 283 "parser.y" { (yyval.parameter_list) = new_parameter_list(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 11: /* Line 1455 of yacc.c */ -#line 286 "parser.y" +#line 285 "parser.y" { (yyval.parameter_list) = parameter_list_add(ctx, (yyvsp[(1) - (3)].parameter_list), (yyvsp[(3) - (3)].identifier)); ;} break; case 12: /* Line 1455 of yacc.c */ -#line 290 "parser.y" +#line 289 "parser.y" { (yyval.parameter_list) = NULL; ;} break; case 13: /* Line 1455 of yacc.c */ -#line 291 "parser.y" +#line 290 "parser.y" { (yyval.parameter_list) = (yyvsp[(1) - (1)].parameter_list); ;} break; case 14: /* Line 1455 of yacc.c */ -#line 295 "parser.y" +#line 294 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 15: /* Line 1455 of yacc.c */ -#line 296 "parser.y" +#line 295 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 16: /* Line 1455 of yacc.c */ -#line 297 "parser.y" +#line 296 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 17: /* Line 1455 of yacc.c */ -#line 298 "parser.y" +#line 297 "parser.y" { (yyval.statement) = new_empty_statement(ctx); ;} break; case 18: /* Line 1455 of yacc.c */ -#line 299 "parser.y" +#line 298 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 19: /* Line 1455 of yacc.c */ -#line 300 "parser.y" +#line 299 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 20: /* Line 1455 of yacc.c */ -#line 301 "parser.y" +#line 300 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 21: /* Line 1455 of yacc.c */ -#line 302 "parser.y" +#line 301 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 22: /* Line 1455 of yacc.c */ -#line 303 "parser.y" +#line 302 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 23: /* Line 1455 of yacc.c */ -#line 304 "parser.y" +#line 303 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 24: /* Line 1455 of yacc.c */ -#line 305 "parser.y" +#line 304 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 25: /* Line 1455 of yacc.c */ -#line 306 "parser.y" +#line 305 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 26: /* Line 1455 of yacc.c */ -#line 307 "parser.y" +#line 306 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 27: /* Line 1455 of yacc.c */ -#line 308 "parser.y" +#line 307 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 28: /* Line 1455 of yacc.c */ -#line 309 "parser.y" +#line 308 "parser.y" { (yyval.statement) = (yyvsp[(1) - (1)].statement); ;} break; case 29: /* Line 1455 of yacc.c */ -#line 313 "parser.y" +#line 312 "parser.y" { (yyval.statement_list) = new_statement_list(ctx, (yyvsp[(1) - (1)].statement)); ;} break; case 30: /* Line 1455 of yacc.c */ -#line 315 "parser.y" +#line 314 "parser.y" { (yyval.statement_list) = statement_list_add((yyvsp[(1) - (2)].statement_list), (yyvsp[(2) - (2)].statement)); ;} break; case 31: /* Line 1455 of yacc.c */ -#line 319 "parser.y" +#line 318 "parser.y" { (yyval.statement_list) = NULL; ;} break; case 32: /* Line 1455 of yacc.c */ -#line 320 "parser.y" +#line 319 "parser.y" { (yyval.statement_list) = (yyvsp[(1) - (1)].statement_list); ;} break; case 33: /* Line 1455 of yacc.c */ -#line 324 "parser.y" +#line 323 "parser.y" { (yyval.statement) = new_block_statement(ctx, (yyvsp[(2) - (3)].statement_list)); ;} break; case 34: /* Line 1455 of yacc.c */ -#line 325 "parser.y" +#line 324 "parser.y" { (yyval.statement) = new_block_statement(ctx, NULL); ;} break; case 35: /* Line 1455 of yacc.c */ -#line 330 "parser.y" +#line 329 "parser.y" { (yyval.statement) = new_var_statement(ctx, (yyvsp[(2) - (3)].variable_list)); ;} break; case 36: /* Line 1455 of yacc.c */ -#line 334 "parser.y" +#line 333 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[(1) - (1)].variable_declaration)); ;} break; case 37: /* Line 1455 of yacc.c */ -#line 336 "parser.y" +#line 335 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[(1) - (3)].variable_list), (yyvsp[(3) - (3)].variable_declaration)); ;} break; case 38: /* Line 1455 of yacc.c */ -#line 341 "parser.y" +#line 340 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[(1) - (1)].variable_declaration)); ;} break; case 39: /* Line 1455 of yacc.c */ -#line 343 "parser.y" +#line 342 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[(1) - (3)].variable_list), (yyvsp[(3) - (3)].variable_declaration)); ;} break; case 40: /* Line 1455 of yacc.c */ -#line 348 "parser.y" +#line 347 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[(1) - (2)].identifier), (yyvsp[(2) - (2)].expr)); ;} break; case 41: /* Line 1455 of yacc.c */ -#line 353 "parser.y" +#line 352 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[(1) - (2)].identifier), (yyvsp[(2) - (2)].expr)); ;} break; case 42: /* Line 1455 of yacc.c */ -#line 357 "parser.y" +#line 356 "parser.y" { (yyval.expr) = NULL; ;} break; case 43: /* Line 1455 of yacc.c */ -#line 358 "parser.y" +#line 357 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 44: /* Line 1455 of yacc.c */ -#line 363 "parser.y" +#line 362 "parser.y" { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 45: /* Line 1455 of yacc.c */ -#line 367 "parser.y" +#line 366 "parser.y" { (yyval.expr) = NULL; ;} break; case 46: /* Line 1455 of yacc.c */ -#line 368 "parser.y" +#line 367 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 47: /* Line 1455 of yacc.c */ -#line 373 "parser.y" +#line 372 "parser.y" { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} break; case 48: /* Line 1455 of yacc.c */ -#line 377 "parser.y" +#line 376 "parser.y" { (yyval.statement) = new_empty_statement(ctx); ;} break; case 49: /* Line 1455 of yacc.c */ -#line 382 "parser.y" +#line 381 "parser.y" { (yyval.statement) = new_expression_statement(ctx, (yyvsp[(1) - (2)].expr)); ;} break; case 50: /* Line 1455 of yacc.c */ -#line 387 "parser.y" +#line 386 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[(3) - (7)].expr), (yyvsp[(5) - (7)].statement), (yyvsp[(7) - (7)].statement)); ;} break; case 51: /* Line 1455 of yacc.c */ -#line 389 "parser.y" +#line 388 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement), NULL); ;} break; case 52: /* Line 1455 of yacc.c */ -#line 394 "parser.y" +#line 393 "parser.y" { (yyval.statement) = new_while_statement(ctx, TRUE, (yyvsp[(5) - (7)].expr), (yyvsp[(2) - (7)].statement)); ;} break; case 53: /* Line 1455 of yacc.c */ -#line 396 "parser.y" +#line 395 "parser.y" { (yyval.statement) = new_while_statement(ctx, FALSE, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement)); ;} break; case 54: /* Line 1455 of yacc.c */ -#line 398 "parser.y" +#line 397 "parser.y" { if(!explicit_error(ctx, (yyvsp[(3) - (3)].expr), ';')) YYABORT; ;} break; case 55: /* Line 1455 of yacc.c */ -#line 400 "parser.y" +#line 399 "parser.y" { if(!explicit_error(ctx, (yyvsp[(6) - (6)].expr), ';')) YYABORT; ;} break; case 56: /* Line 1455 of yacc.c */ -#line 402 "parser.y" +#line 401 "parser.y" { (yyval.statement) = new_for_statement(ctx, NULL, (yyvsp[(3) - (11)].expr), (yyvsp[(6) - (11)].expr), (yyvsp[(9) - (11)].expr), (yyvsp[(11) - (11)].statement)); ;} break; case 57: /* Line 1455 of yacc.c */ -#line 404 "parser.y" +#line 403 "parser.y" { if(!explicit_error(ctx, (yyvsp[(4) - (4)].variable_list), ';')) YYABORT; ;} break; case 58: /* Line 1455 of yacc.c */ -#line 406 "parser.y" +#line 405 "parser.y" { if(!explicit_error(ctx, (yyvsp[(7) - (7)].expr), ';')) YYABORT; ;} break; case 59: /* Line 1455 of yacc.c */ -#line 408 "parser.y" +#line 407 "parser.y" { (yyval.statement) = new_for_statement(ctx, (yyvsp[(4) - (12)].variable_list), NULL, (yyvsp[(7) - (12)].expr), (yyvsp[(10) - (12)].expr), (yyvsp[(12) - (12)].statement)); ;} break; case 60: /* Line 1455 of yacc.c */ -#line 410 "parser.y" +#line 409 "parser.y" { (yyval.statement) = new_forin_statement(ctx, NULL, (yyvsp[(3) - (7)].expr), (yyvsp[(5) - (7)].expr), (yyvsp[(7) - (7)].statement)); ;} break; case 61: /* Line 1455 of yacc.c */ -#line 412 "parser.y" +#line 411 "parser.y" { (yyval.statement) = new_forin_statement(ctx, (yyvsp[(4) - (8)].variable_declaration), NULL, (yyvsp[(6) - (8)].expr), (yyvsp[(8) - (8)].statement)); ;} break; case 62: /* Line 1455 of yacc.c */ -#line 417 "parser.y" +#line 416 "parser.y" { (yyval.statement) = new_continue_statement(ctx, (yyvsp[(2) - (3)].identifier)); ;} break; case 63: /* Line 1455 of yacc.c */ -#line 422 "parser.y" +#line 421 "parser.y" { (yyval.statement) = new_break_statement(ctx, (yyvsp[(2) - (3)].identifier)); ;} break; case 64: /* Line 1455 of yacc.c */ -#line 427 "parser.y" +#line 426 "parser.y" { (yyval.statement) = new_return_statement(ctx, (yyvsp[(2) - (3)].expr)); ;} break; case 65: /* Line 1455 of yacc.c */ -#line 432 "parser.y" +#line 431 "parser.y" { (yyval.statement) = new_with_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].statement)); ;} break; case 66: /* Line 1455 of yacc.c */ -#line 437 "parser.y" +#line 436 "parser.y" { (yyval.statement) = new_labelled_statement(ctx, (yyvsp[(1) - (3)].identifier), (yyvsp[(3) - (3)].statement)); ;} break; case 67: /* Line 1455 of yacc.c */ -#line 442 "parser.y" +#line 441 "parser.y" { (yyval.statement) = new_switch_statement(ctx, (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].case_clausule)); ;} break; case 68: /* Line 1455 of yacc.c */ -#line 447 "parser.y" +#line 446 "parser.y" { (yyval.case_clausule) = new_case_block(ctx, (yyvsp[(2) - (3)].case_list), NULL, NULL); ;} break; case 69: /* Line 1455 of yacc.c */ -#line 449 "parser.y" +#line 448 "parser.y" { (yyval.case_clausule) = new_case_block(ctx, (yyvsp[(2) - (5)].case_list), (yyvsp[(3) - (5)].case_clausule), (yyvsp[(4) - (5)].case_list)); ;} break; case 70: /* Line 1455 of yacc.c */ -#line 453 "parser.y" +#line 452 "parser.y" { (yyval.case_list) = NULL; ;} break; case 71: /* Line 1455 of yacc.c */ -#line 454 "parser.y" +#line 453 "parser.y" { (yyval.case_list) = (yyvsp[(1) - (1)].case_list); ;} break; case 72: /* Line 1455 of yacc.c */ -#line 458 "parser.y" +#line 457 "parser.y" { (yyval.case_list) = new_case_list(ctx, (yyvsp[(1) - (1)].case_clausule)); ;} break; case 73: /* Line 1455 of yacc.c */ -#line 460 "parser.y" +#line 459 "parser.y" { (yyval.case_list) = case_list_add(ctx, (yyvsp[(1) - (2)].case_list), (yyvsp[(2) - (2)].case_clausule)); ;} break; case 74: /* Line 1455 of yacc.c */ -#line 465 "parser.y" +#line 464 "parser.y" { (yyval.case_clausule) = new_case_clausule(ctx, (yyvsp[(2) - (4)].expr), (yyvsp[(4) - (4)].statement_list)); ;} break; case 75: /* Line 1455 of yacc.c */ -#line 470 "parser.y" +#line 469 "parser.y" { (yyval.case_clausule) = new_case_clausule(ctx, NULL, (yyvsp[(3) - (3)].statement_list)); ;} break; case 76: /* Line 1455 of yacc.c */ -#line 475 "parser.y" +#line 474 "parser.y" { (yyval.statement) = new_throw_statement(ctx, (yyvsp[(2) - (3)].expr)); ;} break; case 77: /* Line 1455 of yacc.c */ -#line 479 "parser.y" +#line 478 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (3)].statement), (yyvsp[(3) - (3)].catch_block), NULL); ;} break; case 78: /* Line 1455 of yacc.c */ -#line 480 "parser.y" +#line 479 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (3)].statement), NULL, (yyvsp[(3) - (3)].statement)); ;} break; case 79: /* Line 1455 of yacc.c */ -#line 482 "parser.y" +#line 481 "parser.y" { (yyval.statement) = new_try_statement(ctx, (yyvsp[(2) - (4)].statement), (yyvsp[(3) - (4)].catch_block), (yyvsp[(4) - (4)].statement)); ;} break; case 80: /* Line 1455 of yacc.c */ -#line 487 "parser.y" +#line 486 "parser.y" { (yyval.catch_block) = new_catch_block(ctx, (yyvsp[(3) - (5)].identifier), (yyvsp[(5) - (5)].statement)); ;} break; case 81: /* Line 1455 of yacc.c */ -#line 491 "parser.y" +#line 490 "parser.y" { (yyval.statement) = (yyvsp[(2) - (2)].statement); ;} break; case 82: /* Line 1455 of yacc.c */ -#line 495 "parser.y" +#line 494 "parser.y" { (yyval.expr) = NULL; ;} break; case 83: /* Line 1455 of yacc.c */ -#line 496 "parser.y" +#line 495 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 84: /* Line 1455 of yacc.c */ -#line 499 "parser.y" +#line 498 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 85: /* Line 1455 of yacc.c */ -#line 500 "parser.y" +#line 499 "parser.y" { set_error(ctx, IDS_SYNTAX_ERROR); YYABORT; ;} break; case 86: /* Line 1455 of yacc.c */ -#line 504 "parser.y" +#line 503 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 87: /* Line 1455 of yacc.c */ -#line 506 "parser.y" +#line 505 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_COMMA, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 88: /* Line 1455 of yacc.c */ -#line 510 "parser.y" +#line 509 "parser.y" { (yyval.expr) = NULL; ;} break; case 89: /* Line 1455 of yacc.c */ -#line 511 "parser.y" +#line 510 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 90: /* Line 1455 of yacc.c */ -#line 516 "parser.y" +#line 515 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 91: /* Line 1455 of yacc.c */ -#line 518 "parser.y" +#line 517 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_COMMA, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 92: /* Line 1455 of yacc.c */ -#line 521 "parser.y" +#line 520 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; case 93: /* Line 1455 of yacc.c */ -#line 522 "parser.y" +#line 521 "parser.y" { (yyval.ival) = EXPR_ASSIGNDIV; ;} break; case 94: /* Line 1455 of yacc.c */ -#line 526 "parser.y" +#line 525 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 95: /* Line 1455 of yacc.c */ -#line 528 "parser.y" +#line 527 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ASSIGN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 96: /* Line 1455 of yacc.c */ -#line 530 "parser.y" +#line 529 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 97: /* Line 1455 of yacc.c */ -#line 535 "parser.y" +#line 534 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 98: /* Line 1455 of yacc.c */ -#line 537 "parser.y" +#line 536 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ASSIGN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 99: /* Line 1455 of yacc.c */ -#line 539 "parser.y" +#line 538 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 100: /* Line 1455 of yacc.c */ -#line 543 "parser.y" +#line 542 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 101: /* Line 1455 of yacc.c */ -#line 545 "parser.y" +#line 544 "parser.y" { (yyval.expr) = new_conditional_expression(ctx, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 102: /* Line 1455 of yacc.c */ -#line 550 "parser.y" +#line 549 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 103: /* Line 1455 of yacc.c */ -#line 552 "parser.y" +#line 551 "parser.y" { (yyval.expr) = new_conditional_expression(ctx, (yyvsp[(1) - (5)].expr), (yyvsp[(3) - (5)].expr), (yyvsp[(5) - (5)].expr)); ;} break; case 104: /* Line 1455 of yacc.c */ -#line 556 "parser.y" +#line 555 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 105: /* Line 1455 of yacc.c */ -#line 558 "parser.y" +#line 557 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 106: /* Line 1455 of yacc.c */ -#line 563 "parser.y" +#line 562 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 107: /* Line 1455 of yacc.c */ -#line 565 "parser.y" +#line 564 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 108: /* Line 1455 of yacc.c */ -#line 569 "parser.y" +#line 568 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 109: /* Line 1455 of yacc.c */ -#line 571 "parser.y" +#line 570 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 110: /* Line 1455 of yacc.c */ -#line 576 "parser.y" +#line 575 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 111: /* Line 1455 of yacc.c */ -#line 578 "parser.y" +#line 577 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 112: /* Line 1455 of yacc.c */ -#line 582 "parser.y" +#line 581 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 113: /* Line 1455 of yacc.c */ -#line 584 "parser.y" +#line 583 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 114: /* Line 1455 of yacc.c */ -#line 589 "parser.y" +#line 588 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 115: /* Line 1455 of yacc.c */ -#line 591 "parser.y" +#line 590 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 116: /* Line 1455 of yacc.c */ -#line 595 "parser.y" +#line 594 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 117: /* Line 1455 of yacc.c */ -#line 597 "parser.y" +#line 596 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BXOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 118: /* Line 1455 of yacc.c */ -#line 602 "parser.y" +#line 601 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 119: /* Line 1455 of yacc.c */ -#line 604 "parser.y" +#line 603 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BXOR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 120: /* Line 1455 of yacc.c */ -#line 608 "parser.y" +#line 607 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 121: /* Line 1455 of yacc.c */ -#line 610 "parser.y" +#line 609 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 122: /* Line 1455 of yacc.c */ -#line 615 "parser.y" +#line 614 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 123: /* Line 1455 of yacc.c */ -#line 617 "parser.y" +#line 616 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_BAND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 124: /* Line 1455 of yacc.c */ -#line 621 "parser.y" +#line 620 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 125: /* Line 1455 of yacc.c */ -#line 623 "parser.y" +#line 622 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 126: /* Line 1455 of yacc.c */ -#line 627 "parser.y" +#line 626 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 127: /* Line 1455 of yacc.c */ -#line 629 "parser.y" +#line 628 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 128: /* Line 1455 of yacc.c */ -#line 633 "parser.y" +#line 632 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 129: /* Line 1455 of yacc.c */ -#line 635 "parser.y" +#line 634 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 130: /* Line 1455 of yacc.c */ -#line 637 "parser.y" +#line 636 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_INSTANCEOF, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 131: /* Line 1455 of yacc.c */ -#line 639 "parser.y" +#line 638 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_IN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 132: /* Line 1455 of yacc.c */ -#line 643 "parser.y" +#line 642 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 133: /* Line 1455 of yacc.c */ -#line 645 "parser.y" +#line 644 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 134: /* Line 1455 of yacc.c */ -#line 647 "parser.y" +#line 646 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_INSTANCEOF, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 135: /* Line 1455 of yacc.c */ -#line 651 "parser.y" +#line 650 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 136: /* Line 1455 of yacc.c */ -#line 653 "parser.y" +#line 652 "parser.y" { (yyval.expr) = new_binary_expression(ctx, (yyvsp[(2) - (3)].ival), (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 137: /* Line 1455 of yacc.c */ -#line 658 "parser.y" +#line 657 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 138: /* Line 1455 of yacc.c */ -#line 660 "parser.y" +#line 659 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 139: /* Line 1455 of yacc.c */ -#line 662 "parser.y" +#line 661 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_SUB, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 140: /* Line 1455 of yacc.c */ -#line 666 "parser.y" +#line 665 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 141: /* Line 1455 of yacc.c */ -#line 668 "parser.y" +#line 667 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_MUL, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 142: /* Line 1455 of yacc.c */ -#line 670 "parser.y" +#line 669 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_DIV, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 143: /* Line 1455 of yacc.c */ -#line 672 "parser.y" +#line 671 "parser.y" { (yyval.expr) = new_binary_expression(ctx, EXPR_MOD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} break; case 144: /* Line 1455 of yacc.c */ -#line 676 "parser.y" +#line 675 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 145: /* Line 1455 of yacc.c */ -#line 678 "parser.y" +#line 677 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_DELETE, (yyvsp[(2) - (2)].expr)); ;} break; case 146: /* Line 1455 of yacc.c */ -#line 679 "parser.y" +#line 678 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_VOID, (yyvsp[(2) - (2)].expr)); ;} break; case 147: /* Line 1455 of yacc.c */ -#line 681 "parser.y" +#line 680 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_TYPEOF, (yyvsp[(2) - (2)].expr)); ;} break; case 148: /* Line 1455 of yacc.c */ -#line 682 "parser.y" +#line 681 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PREINC, (yyvsp[(2) - (2)].expr)); ;} break; case 149: /* Line 1455 of yacc.c */ -#line 683 "parser.y" +#line 682 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PREDEC, (yyvsp[(2) - (2)].expr)); ;} break; case 150: /* Line 1455 of yacc.c */ -#line 684 "parser.y" +#line 683 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_PLUS, (yyvsp[(2) - (2)].expr)); ;} break; case 151: /* Line 1455 of yacc.c */ -#line 685 "parser.y" +#line 684 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_MINUS, (yyvsp[(2) - (2)].expr)); ;} break; case 152: /* Line 1455 of yacc.c */ -#line 686 "parser.y" +#line 685 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_BITNEG, (yyvsp[(2) - (2)].expr)); ;} break; case 153: /* Line 1455 of yacc.c */ -#line 687 "parser.y" +#line 686 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_LOGNEG, (yyvsp[(2) - (2)].expr)); ;} break; case 154: /* Line 1455 of yacc.c */ -#line 692 "parser.y" +#line 691 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 155: /* Line 1455 of yacc.c */ -#line 694 "parser.y" +#line 693 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_POSTINC, (yyvsp[(1) - (2)].expr)); ;} break; case 156: /* Line 1455 of yacc.c */ -#line 696 "parser.y" +#line 695 "parser.y" { (yyval.expr) = new_unary_expression(ctx, EXPR_POSTDEC, (yyvsp[(1) - (2)].expr)); ;} break; case 157: /* Line 1455 of yacc.c */ -#line 701 "parser.y" +#line 700 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 158: /* Line 1455 of yacc.c */ -#line 702 "parser.y" +#line 701 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 159: /* Line 1455 of yacc.c */ -#line 706 "parser.y" +#line 705 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 160: /* Line 1455 of yacc.c */ -#line 707 "parser.y" +#line 706 "parser.y" { (yyval.expr) = new_new_expression(ctx, (yyvsp[(2) - (2)].expr), NULL); ;} break; case 161: /* Line 1455 of yacc.c */ -#line 711 "parser.y" +#line 710 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 162: /* Line 1455 of yacc.c */ -#line 712 "parser.y" +#line 711 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 163: /* Line 1455 of yacc.c */ -#line 714 "parser.y" +#line 713 "parser.y" { (yyval.expr) = new_array_expression(ctx, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} break; case 164: /* Line 1455 of yacc.c */ -#line 716 "parser.y" +#line 715 "parser.y" { (yyval.expr) = new_member_expression(ctx, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].identifier)); ;} break; case 165: /* Line 1455 of yacc.c */ -#line 718 "parser.y" +#line 717 "parser.y" { (yyval.expr) = new_new_expression(ctx, (yyvsp[(2) - (3)].expr), (yyvsp[(3) - (3)].argument_list)); ;} break; case 166: /* Line 1455 of yacc.c */ -#line 723 "parser.y" +#line 722 "parser.y" { (yyval.expr) = new_call_expression(ctx, (yyvsp[(1) - (2)].expr), (yyvsp[(2) - (2)].argument_list)); ;} break; case 167: /* Line 1455 of yacc.c */ -#line 725 "parser.y" +#line 724 "parser.y" { (yyval.expr) = new_call_expression(ctx, (yyvsp[(1) - (2)].expr), (yyvsp[(2) - (2)].argument_list)); ;} break; case 168: /* Line 1455 of yacc.c */ -#line 727 "parser.y" +#line 726 "parser.y" { (yyval.expr) = new_array_expression(ctx, (yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); ;} break; case 169: /* Line 1455 of yacc.c */ -#line 729 "parser.y" +#line 728 "parser.y" { (yyval.expr) = new_member_expression(ctx, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].identifier)); ;} break; case 170: /* Line 1455 of yacc.c */ -#line 733 "parser.y" +#line 732 "parser.y" { (yyval.argument_list) = NULL; ;} break; case 171: /* Line 1455 of yacc.c */ -#line 734 "parser.y" +#line 733 "parser.y" { (yyval.argument_list) = (yyvsp[(2) - (3)].argument_list); ;} break; case 172: /* Line 1455 of yacc.c */ -#line 738 "parser.y" +#line 737 "parser.y" { (yyval.argument_list) = new_argument_list(ctx, (yyvsp[(1) - (1)].expr)); ;} break; case 173: /* Line 1455 of yacc.c */ -#line 740 "parser.y" +#line 739 "parser.y" { (yyval.argument_list) = argument_list_add(ctx, (yyvsp[(1) - (3)].argument_list), (yyvsp[(3) - (3)].expr)); ;} break; case 174: /* Line 1455 of yacc.c */ -#line 744 "parser.y" +#line 743 "parser.y" { (yyval.expr) = new_this_expression(ctx); ;} break; case 175: /* Line 1455 of yacc.c */ -#line 745 "parser.y" +#line 744 "parser.y" { (yyval.expr) = new_identifier_expression(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 176: /* Line 1455 of yacc.c */ -#line 746 "parser.y" +#line 745 "parser.y" { (yyval.expr) = new_literal_expression(ctx, (yyvsp[(1) - (1)].literal)); ;} break; case 177: /* Line 1455 of yacc.c */ -#line 747 "parser.y" +#line 746 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 178: /* Line 1455 of yacc.c */ -#line 748 "parser.y" +#line 747 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); ;} break; case 179: /* Line 1455 of yacc.c */ -#line 749 "parser.y" +#line 748 "parser.y" { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} break; case 180: /* Line 1455 of yacc.c */ -#line 753 "parser.y" +#line 752 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, NULL, 0); ;} break; case 181: /* Line 1455 of yacc.c */ -#line 754 "parser.y" +#line 753 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, NULL, (yyvsp[(2) - (3)].ival)+1); ;} break; case 182: /* Line 1455 of yacc.c */ -#line 755 "parser.y" +#line 754 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, (yyvsp[(2) - (3)].element_list), 0); ;} break; case 183: /* Line 1455 of yacc.c */ -#line 757 "parser.y" +#line 756 "parser.y" { (yyval.expr) = new_array_literal_expression(ctx, (yyvsp[(2) - (5)].element_list), (yyvsp[(4) - (5)].ival)+1); ;} break; case 184: /* Line 1455 of yacc.c */ -#line 762 "parser.y" +#line 761 "parser.y" { (yyval.element_list) = new_element_list(ctx, (yyvsp[(1) - (2)].ival), (yyvsp[(2) - (2)].expr)); ;} break; case 185: /* Line 1455 of yacc.c */ -#line 764 "parser.y" +#line 763 "parser.y" { (yyval.element_list) = element_list_add(ctx, (yyvsp[(1) - (4)].element_list), (yyvsp[(3) - (4)].ival), (yyvsp[(4) - (4)].expr)); ;} break; case 186: /* Line 1455 of yacc.c */ -#line 768 "parser.y" +#line 767 "parser.y" { (yyval.ival) = 1; ;} break; case 187: /* Line 1455 of yacc.c */ -#line 769 "parser.y" +#line 768 "parser.y" { (yyval.ival) = (yyvsp[(1) - (2)].ival) + 1; ;} break; case 188: /* Line 1455 of yacc.c */ -#line 773 "parser.y" +#line 772 "parser.y" { (yyval.ival) = 0; ;} break; case 189: /* Line 1455 of yacc.c */ -#line 774 "parser.y" +#line 773 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} break; case 190: /* Line 1455 of yacc.c */ -#line 778 "parser.y" +#line 777 "parser.y" { (yyval.expr) = new_prop_and_value_expression(ctx, NULL); ;} break; case 191: /* Line 1455 of yacc.c */ -#line 780 "parser.y" +#line 779 "parser.y" { (yyval.expr) = new_prop_and_value_expression(ctx, (yyvsp[(2) - (3)].property_list)); ;} break; case 192: /* Line 1455 of yacc.c */ -#line 785 "parser.y" +#line 784 "parser.y" { (yyval.property_list) = new_property_list(ctx, (yyvsp[(1) - (3)].literal), (yyvsp[(3) - (3)].expr)); ;} break; case 193: /* Line 1455 of yacc.c */ -#line 787 "parser.y" +#line 786 "parser.y" { (yyval.property_list) = property_list_add(ctx, (yyvsp[(1) - (5)].property_list), (yyvsp[(3) - (5)].literal), (yyvsp[(5) - (5)].expr)); ;} break; case 194: /* Line 1455 of yacc.c */ -#line 791 "parser.y" +#line 790 "parser.y" { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].identifier)); ;} break; case 195: /* Line 1455 of yacc.c */ -#line 792 "parser.y" +#line 791 "parser.y" { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} break; case 196: /* Line 1455 of yacc.c */ -#line 793 "parser.y" +#line 792 "parser.y" { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 197: /* Line 1455 of yacc.c */ -#line 797 "parser.y" +#line 796 "parser.y" { (yyval.identifier) = NULL; ;} break; case 198: /* Line 1455 of yacc.c */ -#line 798 "parser.y" +#line 797 "parser.y" { (yyval.identifier) = (yyvsp[(1) - (1)].identifier); ;} break; case 199: /* Line 1455 of yacc.c */ -#line 802 "parser.y" +#line 801 "parser.y" { (yyval.literal) = new_null_literal(ctx); ;} break; case 200: /* Line 1455 of yacc.c */ -#line 803 "parser.y" - { (yyval.literal) = new_undefined_literal(ctx); ;} +#line 802 "parser.y" + { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 201: /* Line 1455 of yacc.c */ -#line 804 "parser.y" +#line 803 "parser.y" { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} break; case 202: /* Line 1455 of yacc.c */ -#line 805 "parser.y" - { (yyval.literal) = (yyvsp[(1) - (1)].literal); ;} +#line 804 "parser.y" + { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} break; case 203: /* Line 1455 of yacc.c */ -#line 806 "parser.y" - { (yyval.literal) = new_string_literal(ctx, (yyvsp[(1) - (1)].wstr)); ;} +#line 805 "parser.y" + { (yyval.literal) = parse_regexp(ctx); + if(!(yyval.literal)) YYABORT; ;} break; case 204: @@ -3455,57 +3451,49 @@ yyreduce: case 205: /* Line 1455 of yacc.c */ -#line 809 "parser.y" - { (yyval.literal) = parse_regexp(ctx); - if(!(yyval.literal)) YYABORT; ;} +#line 812 "parser.y" + { (yyval.literal) = new_boolean_literal(ctx, VARIANT_TRUE); ;} break; case 206: /* Line 1455 of yacc.c */ -#line 814 "parser.y" - { (yyval.literal) = new_boolean_literal(ctx, VARIANT_TRUE); ;} - break; - - case 207: - -/* Line 1455 of yacc.c */ -#line 815 "parser.y" +#line 813 "parser.y" { (yyval.literal) = new_boolean_literal(ctx, VARIANT_FALSE); ;} break; - case 209: + case 208: /* Line 1455 of yacc.c */ -#line 819 "parser.y" +#line 817 "parser.y" { if(!allow_auto_semicolon(ctx)) {YYABORT;} ;} break; - case 211: + case 210: /* Line 1455 of yacc.c */ -#line 823 "parser.y" +#line 821 "parser.y" { set_error(ctx, IDS_LBRACKET); YYABORT; ;} break; - case 213: + case 212: /* Line 1455 of yacc.c */ -#line 827 "parser.y" +#line 825 "parser.y" { set_error(ctx, IDS_RBRACKET); YYABORT; ;} break; - case 215: + case 214: /* Line 1455 of yacc.c */ -#line 831 "parser.y" +#line 829 "parser.y" { set_error(ctx, IDS_SEMICOLON); YYABORT; ;} break; /* Line 1455 of yacc.c */ -#line 3509 "parser.tab.c" +#line 3497 "parser.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -3717,7 +3705,7 @@ yyreturn: /* Line 1675 of yacc.c */ -#line 833 "parser.y" +#line 831 "parser.y" static BOOL allow_auto_semicolon(parser_ctx_t *ctx) @@ -3729,7 +3717,7 @@ static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BSTR; + ret->type = LT_STRING; ret->u.wstr = str; return ret; @@ -3739,16 +3727,7 @@ static literal_t *new_null_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_NULL; - - return ret; -} - -static literal_t *new_undefined_literal(parser_ctx_t *ctx) -{ - literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - - ret->vt = VT_EMPTY; + ret->type = LT_NULL; return ret; } @@ -3757,7 +3736,7 @@ static literal_t *new_boolean_literal(parser_ctx_t *ctx, VARIANT_BOOL bval) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BOOL; + ret->type = LT_BOOL; ret->u.bval = bval; return ret; @@ -4479,14 +4458,11 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source) void parser_release(parser_ctx_t *ctx) { - obj_literal_t *iter; - if(--ctx->ref) return; - for(iter = ctx->obj_literals; iter; iter = iter->next) - jsdisp_release(iter->obj); - + script_release(ctx->script); + heap_free(ctx->begin); jsheap_free(&ctx->heap); heap_free(ctx); } @@ -4508,8 +4484,14 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite parser_ctx->hres = JSCRIPT_ERROR|IDS_SYNTAX_ERROR; parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW); - parser_ctx->begin = parser_ctx->ptr = code; - parser_ctx->end = code + strlenW(code); + parser_ctx->begin = heap_strdupW(code); + if(!parser_ctx->begin) { + heap_free(parser_ctx); + return E_OUTOFMEMORY; + } + + parser_ctx->ptr = parser_ctx->begin; + parser_ctx->end = parser_ctx->begin + strlenW(parser_ctx->begin); script_addref(ctx); parser_ctx->script = ctx; diff --git a/reactos/dll/win32/jscript/parser.tab.h b/reactos/dll/win32/jscript/parser.tab.h index deed458a2f6..cdc4c1c2851 100644 --- a/reactos/dll/win32/jscript/parser.tab.h +++ b/reactos/dll/win32/jscript/parser.tab.h @@ -54,34 +54,33 @@ kINSTANCEOF = 270, kNEW = 271, kNULL = 272, - kUNDEFINED = 273, - kRETURN = 274, - kSWITCH = 275, - kTHIS = 276, - kTHROW = 277, - kTRUE = 278, - kFALSE = 279, - kTRY = 280, - kTYPEOF = 281, - kVAR = 282, - kVOID = 283, - kWHILE = 284, - kWITH = 285, - tANDAND = 286, - tOROR = 287, - tINC = 288, - tDEC = 289, - tHTMLCOMMENT = 290, - kDIVEQ = 291, - kFUNCTION = 292, - tIdentifier = 293, - tAssignOper = 294, - tEqOper = 295, - tShiftOper = 296, - tRelOper = 297, - tNumericLiteral = 298, - tStringLiteral = 299, - LOWER_THAN_ELSE = 300 + kRETURN = 273, + kSWITCH = 274, + kTHIS = 275, + kTHROW = 276, + kTRUE = 277, + kFALSE = 278, + kTRY = 279, + kTYPEOF = 280, + kVAR = 281, + kVOID = 282, + kWHILE = 283, + kWITH = 284, + tANDAND = 285, + tOROR = 286, + tINC = 287, + tDEC = 288, + tHTMLCOMMENT = 289, + kDIVEQ = 290, + kFUNCTION = 291, + tIdentifier = 292, + tAssignOper = 293, + tEqOper = 294, + tShiftOper = 295, + tRelOper = 296, + tNumericLiteral = 297, + tStringLiteral = 298, + LOWER_THAN_ELSE = 299 }; #endif @@ -92,7 +91,7 @@ typedef union YYSTYPE { /* Line 1676 of yacc.c */ -#line 151 "parser.y" +#line 150 "parser.y" int ival; const WCHAR *srcptr; @@ -116,7 +115,7 @@ typedef union YYSTYPE /* Line 1676 of yacc.c */ -#line 120 "parser.tab.h" +#line 119 "parser.tab.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/reactos/dll/win32/jscript/parser.y b/reactos/dll/win32/jscript/parser.y index d4b49089424..f062cd0117d 100644 --- a/reactos/dll/win32/jscript/parser.y +++ b/reactos/dll/win32/jscript/parser.y @@ -38,7 +38,6 @@ typedef struct _statement_list_t { static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); static literal_t *new_null_literal(parser_ctx_t*); -static literal_t *new_undefined_literal(parser_ctx_t*); static literal_t *new_boolean_literal(parser_ctx_t*,VARIANT_BOOL); typedef struct _property_list_t { @@ -171,7 +170,7 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state /* keywords */ %token kBREAK kCASE kCATCH kCONTINUE kDEFAULT kDELETE kDO kELSE kIF kFINALLY kFOR kIN -%token kINSTANCEOF kNEW kNULL kUNDEFINED kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH +%token kINSTANCEOF kNEW kNULL kRETURN kSWITCH kTHIS kTHROW kTRUE kFALSE kTRY kTYPEOF kVAR kVOID kWHILE kWITH %token tANDAND tOROR tINC tDEC tHTMLCOMMENT kDIVEQ %token kFUNCTION '}' @@ -800,7 +799,6 @@ Identifier_opt /* ECMA-262 3rd Edition 7.8 */ Literal : kNULL { $$ = new_null_literal(ctx); } - | kUNDEFINED { $$ = new_undefined_literal(ctx); } | BooleanLiteral { $$ = $1; } | tNumericLiteral { $$ = $1; } | tStringLiteral { $$ = new_string_literal(ctx, $1); } @@ -841,7 +839,7 @@ static literal_t *new_string_literal(parser_ctx_t *ctx, const WCHAR *str) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BSTR; + ret->type = LT_STRING; ret->u.wstr = str; return ret; @@ -851,16 +849,7 @@ static literal_t *new_null_literal(parser_ctx_t *ctx) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_NULL; - - return ret; -} - -static literal_t *new_undefined_literal(parser_ctx_t *ctx) -{ - literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - - ret->vt = VT_EMPTY; + ret->type = LT_NULL; return ret; } @@ -869,7 +858,7 @@ static literal_t *new_boolean_literal(parser_ctx_t *ctx, VARIANT_BOOL bval) { literal_t *ret = parser_alloc(ctx, sizeof(literal_t)); - ret->vt = VT_BOOL; + ret->type = LT_BOOL; ret->u.bval = bval; return ret; @@ -1591,14 +1580,11 @@ static void program_parsed(parser_ctx_t *ctx, source_elements_t *source) void parser_release(parser_ctx_t *ctx) { - obj_literal_t *iter; - if(--ctx->ref) return; - for(iter = ctx->obj_literals; iter; iter = iter->next) - jsdisp_release(iter->obj); - + script_release(ctx->script); + heap_free(ctx->begin); jsheap_free(&ctx->heap); heap_free(ctx); } @@ -1620,8 +1606,14 @@ HRESULT script_parse(script_ctx_t *ctx, const WCHAR *code, const WCHAR *delimite parser_ctx->hres = JSCRIPT_ERROR|IDS_SYNTAX_ERROR; parser_ctx->is_html = delimiter && !strcmpiW(delimiter, html_tagW); - parser_ctx->begin = parser_ctx->ptr = code; - parser_ctx->end = code + strlenW(code); + parser_ctx->begin = heap_strdupW(code); + if(!parser_ctx->begin) { + heap_free(parser_ctx); + return E_OUTOFMEMORY; + } + + parser_ctx->ptr = parser_ctx->begin; + parser_ctx->end = parser_ctx->begin + strlenW(parser_ctx->begin); script_addref(ctx); parser_ctx->script = ctx; diff --git a/reactos/dll/win32/jscript/regexp.c b/reactos/dll/win32/jscript/regexp.c index e911d0f5fdf..04575458105 100644 --- a/reactos/dll/win32/jscript/regexp.c +++ b/reactos/dll/win32/jscript/regexp.c @@ -32,6 +32,7 @@ */ #include +#include #include "jscript.h" @@ -82,7 +83,8 @@ typedef struct { JSRegExp *jsregexp; BSTR str; - DWORD last_index; + INT last_index; + VARIANT last_index_var; } RegExpInstance; static const WCHAR sourceW[] = {'s','o','u','r','c','e',0}; @@ -3299,8 +3301,16 @@ static inline RegExpInstance *regexp_from_vdisp(vdisp_t *vdisp) return (RegExpInstance*)vdisp->u.jsdisp; } -static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, const WCHAR *str, DWORD len, - const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret) +static void set_last_index(RegExpInstance *This, DWORD last_index) +{ + This->last_index = last_index; + VariantClear(&This->last_index_var); + num_set_val(&This->last_index_var, last_index); +} + +static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, DWORD rem_flags, + const WCHAR *str, DWORD len, const WCHAR **cp, match_result_t **parens, DWORD *parens_size, + DWORD *parens_cnt, match_result_t *ret) { REMatchState *x, *result; REGlobalData gData; @@ -3325,8 +3335,11 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c return E_FAIL; } - if(!result) + if(!result) { + if(rem_flags & REM_RESET_INDEX) + set_last_index(regexp, 0); return S_FALSE; + } if(parens) { DWORD i; @@ -3347,8 +3360,13 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c *parens_cnt = regexp->jsregexp->parenCount; for(i=0; i < regexp->jsregexp->parenCount; i++) { - (*parens)[i].str = *cp + result->parens[i].index; - (*parens)[i].len = result->parens[i].length; + if(result->parens[i].index == -1) { + (*parens)[i].str = NULL; + (*parens)[i].len = 0; + }else { + (*parens)[i].str = *cp + result->parens[i].index; + (*parens)[i].len = result->parens[i].length; + } } } @@ -3356,23 +3374,25 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp, c *cp = result->cp; ret->str = result->cp-matchlen; ret->len = matchlen; + set_last_index(regexp, result->cp-str); return S_OK; } -HRESULT regexp_match_next(script_ctx_t *ctx, DispatchEx *dispex, BOOL gcheck, const WCHAR *str, DWORD len, - const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, match_result_t *ret) +HRESULT regexp_match_next(script_ctx_t *ctx, DispatchEx *dispex, DWORD rem_flags, const WCHAR *str, + DWORD len, const WCHAR **cp, match_result_t **parens, DWORD *parens_size, DWORD *parens_cnt, + match_result_t *ret) { RegExpInstance *regexp = (RegExpInstance*)dispex; jsheap_t *mark; HRESULT hres; - if(gcheck && !(regexp->jsregexp->flags & JSREG_GLOB)) + if((rem_flags & REM_CHECK_GLOBAL) && !(regexp->jsregexp->flags & JSREG_GLOB)) return S_FALSE; mark = jsheap_mark(&ctx->tmp_heap); - hres = do_regexp_match_next(ctx, regexp, str, len, cp, parens, parens_size, parens_cnt, ret); + hres = do_regexp_match_next(ctx, regexp, rem_flags, str, len, cp, parens, parens_size, parens_cnt, ret); jsheap_clear(mark); return hres; @@ -3391,7 +3411,7 @@ HRESULT regexp_match(script_ctx_t *ctx, DispatchEx *dispex, const WCHAR *str, DW mark = jsheap_mark(&ctx->tmp_heap); while(1) { - hres = do_regexp_match_next(ctx, This, str, len, &cp, NULL, NULL, NULL, &cres); + hres = do_regexp_match_next(ctx, This, 0, str, len, &cp, NULL, NULL, NULL, &cres); if(hres == S_FALSE) { hres = S_OK; break; @@ -3474,6 +3494,27 @@ static HRESULT RegExp_multiline(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, return E_NOTIMPL; } +static INT index_from_var(script_ctx_t *ctx, VARIANT *v) +{ + jsexcept_t ei; + VARIANT num; + HRESULT hres; + + memset(&ei, 0, sizeof(ei)); + hres = to_number(ctx, v, &ei, &num); + if(FAILED(hres)) { /* FIXME: Move ignoring exceptions to to_promitive */ + VariantClear(&ei.var); + return 0; + } + + if(V_VT(&num) == VT_R8) { + DOUBLE d = floor(V_R8(&num)); + return (DOUBLE)(INT)d == d ? d : 0; + } + + return V_I4(&num); +} + static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { @@ -3482,8 +3523,21 @@ static HRESULT RegExp_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, switch(flags) { case DISPATCH_PROPERTYGET: { RegExpInstance *regexp = regexp_from_vdisp(jsthis); - V_VT(retv) = VT_I4; - V_I4(retv) = regexp->last_index; + + V_VT(retv) = VT_EMPTY; + return VariantCopy(retv, ®exp->last_index_var); + } + case DISPATCH_PROPERTYPUT: { + RegExpInstance *regexp = regexp_from_vdisp(jsthis); + VARIANT *arg; + HRESULT hres; + + arg = get_arg(dp,0); + hres = VariantCopy(®exp->last_index_var, arg); + if(FAILED(hres)) + return hres; + + regexp->last_index = index_from_var(ctx, arg); break; } default: @@ -3589,28 +3643,34 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, VARIANT *arg, jsexce return E_OUTOFMEMORY; } + if(regexp->last_index < 0) { + SysFreeString(string); + set_last_index(regexp, 0); + *ret = VARIANT_FALSE; + if(input) { + *input = NULL; + } + return S_OK; + } + length = SysStringLen(string); if(regexp->jsregexp->flags & JSREG_GLOB) last_index = regexp->last_index; cp = string + last_index; - hres = regexp_match_next(ctx, ®exp->dispex, FALSE, string, length, &cp, parens, parens ? &parens_size : NULL, - parens_cnt, match); + hres = regexp_match_next(ctx, ®exp->dispex, REM_RESET_INDEX, string, length, &cp, parens, + parens ? &parens_size : NULL, parens_cnt, match); if(FAILED(hres)) { SysFreeString(string); return hres; } - if(hres == S_OK) { - regexp->last_index = cp-string; - *ret = VARIANT_TRUE; - }else { - regexp->last_index = 0; - *ret = VARIANT_FALSE; - } - - if(input) + *ret = hres == S_OK ? VARIANT_TRUE : VARIANT_FALSE; + if(input) { *input = string; + }else { + SysFreeString(string); + } return S_OK; } @@ -3690,6 +3750,7 @@ static void RegExp_destructor(DispatchEx *dispex) if(This->jsregexp) js_DestroyRegExp(This->jsregexp); + VariantClear(&This->last_index_var); SysFreeString(This->str); heap_free(This); } @@ -3737,7 +3798,7 @@ static HRESULT alloc_regexp(script_ctx_t *ctx, DispatchEx *object_prototype, Reg return S_OK; } -static HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags, DispatchEx **ret) +HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD flags, DispatchEx **ret) { RegExpInstance *regexp; HRESULT hres; @@ -3764,73 +3825,57 @@ static HRESULT create_regexp(script_ctx_t *ctx, const WCHAR *exp, int len, DWORD return E_FAIL; } + V_VT(®exp->last_index_var) = VT_I4; + V_I4(®exp->last_index_var) = 0; + *ret = ®exp->dispex; return S_OK; } -static HRESULT regexp_constructor(script_ctx_t *ctx, DISPPARAMS *dp, VARIANT *retv) +HRESULT create_regexp_var(script_ctx_t *ctx, VARIANT *src_arg, VARIANT *flags_arg, DispatchEx **ret) { const WCHAR *opt = emptyW, *src; - DispatchEx *ret; - VARIANT *arg; + DWORD flags; HRESULT hres; - if(!arg_cnt(dp)) { - FIXME("no args\n"); - return E_NOTIMPL; - } - - arg = get_arg(dp,0); - if(V_VT(arg) == VT_DISPATCH) { + if(V_VT(src_arg) == VT_DISPATCH) { DispatchEx *obj; - obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); + obj = iface_to_jsdisp((IUnknown*)V_DISPATCH(src_arg)); if(obj) { if(is_class(obj, JSCLASS_REGEXP)) { RegExpInstance *regexp = (RegExpInstance*)obj; - hres = create_regexp(ctx, regexp->str, -1, regexp->jsregexp->flags, &ret); + hres = create_regexp(ctx, regexp->str, -1, regexp->jsregexp->flags, ret); jsdisp_release(obj); - if(FAILED(hres)) - return hres; - - V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); - return S_OK; + return hres; } jsdisp_release(obj); } } - if(V_VT(arg) != VT_BSTR) { - FIXME("vt arg0 = %d\n", V_VT(arg)); + if(V_VT(src_arg) != VT_BSTR) { + FIXME("flags_arg = %s\n", debugstr_variant(flags_arg)); return E_NOTIMPL; } - src = V_BSTR(arg); + src = V_BSTR(src_arg); - if(arg_cnt(dp) >= 2) { - arg = get_arg(dp,1); - if(V_VT(arg) != VT_BSTR) { - FIXME("unimplemented for vt %d\n", V_VT(arg)); + if(flags_arg) { + if(V_VT(flags_arg) != VT_BSTR) { + FIXME("unimplemented for vt %d\n", V_VT(flags_arg)); return E_NOTIMPL; } - opt = V_BSTR(arg); + opt = V_BSTR(flags_arg); } - hres = create_regexp_str(ctx, src, -1, opt, strlenW(opt), &ret); + hres = parse_regexp_flags(opt, strlenW(opt), &flags); if(FAILED(hres)) return hres; - if(retv) { - V_VT(retv) = VT_DISPATCH; - V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); - }else { - jsdisp_release(ret); - } - return S_OK; + return create_regexp(ctx, src, -1, flags, ret); } static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, @@ -3864,8 +3909,27 @@ static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags } } /* fall through */ - case DISPATCH_CONSTRUCT: - return regexp_constructor(ctx, dp, retv); + case DISPATCH_CONSTRUCT: { + DispatchEx *ret; + HRESULT hres; + + if(!arg_cnt(dp)) { + FIXME("no args\n"); + return E_NOTIMPL; + } + + hres = create_regexp_var(ctx, get_arg(dp,0), arg_cnt(dp) > 1 ? get_arg(dp,1) : NULL, &ret); + if(FAILED(hres)) + return hres; + + if(retv) { + V_VT(retv) = VT_DISPATCH; + V_DISPATCH(retv) = (IDispatch*)_IDispatchEx_(ret); + }else { + jsdisp_release(ret); + } + return S_OK; + } default: FIXME("unimplemented flags: %x\n", flags); return E_NOTIMPL; @@ -3885,39 +3949,38 @@ HRESULT create_regexp_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di if(FAILED(hres)) return hres; - hres = create_builtin_function(ctx, RegExpConstr_value, RegExpW, NULL, PROPF_CONSTR, ®exp->dispex, ret); + hres = create_builtin_function(ctx, RegExpConstr_value, RegExpW, NULL, + PROPF_CONSTR|2, ®exp->dispex, ret); jsdisp_release(®exp->dispex); return hres; } -HRESULT create_regexp_str(script_ctx_t *ctx, const WCHAR *exp, DWORD exp_len, const WCHAR *opt, - DWORD opt_len, DispatchEx **ret) +HRESULT parse_regexp_flags(const WCHAR *str, DWORD str_len, DWORD *ret) { const WCHAR *p; DWORD flags = 0; - if(opt) { - for (p = opt; p < opt+opt_len; p++) { - switch (*p) { - case 'g': - flags |= JSREG_GLOB; - break; - case 'i': - flags |= JSREG_FOLD; - break; - case 'm': - flags |= JSREG_MULTILINE; - break; - case 'y': - flags |= JSREG_STICKY; - break; - default: - WARN("wrong flag %c\n", *p); - return E_FAIL; - } + for (p = str; p < str+str_len; p++) { + switch (*p) { + case 'g': + flags |= JSREG_GLOB; + break; + case 'i': + flags |= JSREG_FOLD; + break; + case 'm': + flags |= JSREG_MULTILINE; + break; + case 'y': + flags |= JSREG_STICKY; + break; + default: + WARN("wrong flag %c\n", *p); + return E_FAIL; } } - return create_regexp(ctx, exp, exp_len, flags, ret); + *ret = flags; + return S_OK; } diff --git a/reactos/dll/win32/jscript/resource.h b/reactos/dll/win32/jscript/resource.h index 17c0df09f6d..b88621fb58c 100644 --- a/reactos/dll/win32/jscript/resource.h +++ b/reactos/dll/win32/jscript/resource.h @@ -37,5 +37,6 @@ #define IDS_NOT_BOOL 0x1392 #define IDS_JSCRIPT_EXPECTED 0x1396 #define IDS_REGEXP_SYNTAX_ERROR 0x1399 +#define IDS_URI_INVALID_CHAR 0x13A0 #define IDS_INVALID_LENGTH 0x13A5 #define IDS_ARRAY_EXPECTED 0x13A7 diff --git a/reactos/dll/win32/jscript/rsrc.rc b/reactos/dll/win32/jscript/rsrc.rc index d57f83c09dc..d23ea33a2f3 100644 --- a/reactos/dll/win32/jscript/rsrc.rc +++ b/reactos/dll/win32/jscript/rsrc.rc @@ -25,6 +25,8 @@ REGINST REGINST jscript.inf #include "jscript_De.rc" #include "jscript_En.rc" #include "jscript_Fr.rc" +#include "jscript_Ko.rc" #include "jscript_Lt.rc" #include "jscript_Nl.rc" #include "jscript_Pt.rc" +#include "jscript_Ru.rc" diff --git a/reactos/dll/win32/jscript/string.c b/reactos/dll/win32/jscript/string.c index 55b6b858fb6..df43fee27ed 100644 --- a/reactos/dll/win32/jscript/string.c +++ b/reactos/dll/win32/jscript/string.c @@ -656,7 +656,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(FAILED(hres)) return hres; - hres = create_regexp_str(ctx, match_str, SysStringLen(match_str), NULL, 0, ®exp); + hres = create_regexp(ctx, match_str, SysStringLen(match_str), 0, ®exp); SysFreeString(match_str); if(FAILED(hres)) return hres; @@ -703,6 +703,7 @@ static HRESULT String_match(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP break; } + heap_free(match_result); SysFreeString(val_str); if(SUCCEEDED(hres) && retv) { @@ -795,7 +796,7 @@ static HRESULT rep_call(script_ctx_t *ctx, DispatchEx *func, const WCHAR *str, m if(SUCCEEDED(hres)) hres = jsdisp_call_value(func, DISPATCH_METHOD, &dp, &var, ei, caller); - for(i=0; i < parens_cnt+1; i++) { + for(i=0; i < parens_cnt+3; i++) { if(i != parens_cnt+1) SysFreeString(V_BSTR(get_arg(&dp,i))); } @@ -819,7 +820,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI DispatchEx *rep_func = NULL, *regexp = NULL; match_result_t *parens = NULL, match, **parens_ptr = &parens; strbuf_t ret = {NULL,0,0}; - BOOL gcheck = FALSE; + DWORD re_flags = 0; VARIANT *arg_var; HRESULT hres = S_OK; @@ -896,9 +897,9 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI while(1) { if(regexp) { - hres = regexp_match_next(ctx, regexp, gcheck, str, length, &cp, parens_ptr, + hres = regexp_match_next(ctx, regexp, re_flags, str, length, &cp, parens_ptr, &parens_size, &parens_cnt, &match); - gcheck = TRUE; + re_flags = REM_CHECK_GLOBAL; if(hres == S_FALSE) { hres = S_OK; @@ -965,7 +966,7 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI } idx = ptr2[1] - '0'; - if(isdigitW(ptr[3]) && idx*10 + (ptr[2]-'0') <= parens_cnt) { + if(isdigitW(ptr2[2]) && idx*10 + (ptr2[2]-'0') <= parens_cnt) { idx = idx*10 + (ptr[2]-'0'); ptr = ptr2+3; }else if(idx && idx <= parens_cnt) { @@ -1031,8 +1032,58 @@ static HRESULT String_replace(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI static HRESULT String_search(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp, VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp) { - FIXME("\n"); - return E_NOTIMPL; + DispatchEx *regexp = NULL; + const WCHAR *str, *cp; + match_result_t match; + VARIANT *arg; + DWORD length; + BSTR val_str; + HRESULT hres; + + TRACE("\n"); + + hres = get_string_val(ctx, jsthis, ei, &str, &length, &val_str); + if(FAILED(hres)) + return hres; + + if(!arg_cnt(dp)) { + if(retv) + V_VT(retv) = VT_NULL; + SysFreeString(val_str); + return S_OK; + } + + arg = get_arg(dp,0); + if(V_VT(arg) == VT_DISPATCH) { + regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); + if(regexp) { + if(!is_class(regexp, JSCLASS_REGEXP)) { + jsdisp_release(regexp); + regexp = NULL; + } + } + } + + if(!regexp) { + hres = create_regexp_var(ctx, arg, NULL, ®exp); + if(FAILED(hres)) { + SysFreeString(val_str); + return hres; + } + } + + cp = str; + hres = regexp_match_next(ctx, regexp, REM_RESET_INDEX, str, length, &cp, NULL, NULL, NULL, &match); + SysFreeString(val_str); + jsdisp_release(regexp); + if(FAILED(hres)) + return hres; + + if(retv) { + V_VT(retv) = VT_I4; + V_I4(retv) = hres == S_OK ? match.str-str : -1; + } + return S_OK; } /* ECMA-262 3rd Edition 15.5.4.13 */ @@ -1129,6 +1180,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP match_result_t *match_result = NULL; DWORD length, match_cnt, i, match_len = 0; const WCHAR *str, *ptr, *ptr2; + BOOL use_regexp = FALSE; VARIANT *arg, var; DispatchEx *array; BSTR val_str, match_str = NULL; @@ -1153,6 +1205,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP regexp = iface_to_jsdisp((IUnknown*)V_DISPATCH(arg)); if(regexp) { if(is_class(regexp, JSCLASS_REGEXP)) { + use_regexp = TRUE; hres = regexp_match(ctx, regexp, str, length, TRUE, &match_result, &match_cnt); jsdisp_release(regexp); if(FAILED(hres)) { @@ -1183,7 +1236,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(SUCCEEDED(hres)) { ptr = str; for(i=0;; i++) { - if(match_result) { + if(use_regexp) { if(i == match_cnt) break; ptr2 = match_result[i].str; @@ -1209,7 +1262,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP if(FAILED(hres)) break; - if(match_result) + if(use_regexp) ptr = match_result[i].str + match_result[i].len; else if(match_str) ptr = ptr2 + match_len; @@ -1218,7 +1271,7 @@ static HRESULT String_split(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISP } } - if(SUCCEEDED(hres) && (match_str || match_result)) { + if(SUCCEEDED(hres) && (match_str || use_regexp)) { DWORD len = (str+length) - ptr; if(len || match_str) { @@ -1705,7 +1758,7 @@ HRESULT create_string_constr(script_ctx_t *ctx, DispatchEx *object_prototype, Di return hres; hres = create_builtin_function(ctx, StringConstr_value, StringW, &StringConstr_info, - PROPF_CONSTR, &string->dispex, ret); + PROPF_CONSTR|1, &string->dispex, ret); jsdisp_release(&string->dispex); return hres;