[JSCRIPT] Sync with Wine Staging 3.3. CORE-14434

This commit is contained in:
Amine Khaldi 2018-03-17 13:11:29 +01:00
parent 919215fd3b
commit 8dba275bd6
38 changed files with 859 additions and 453 deletions

View file

@ -16,7 +16,18 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <math.h>
#include <assert.h>
#include "jscript.h"
#include "engine.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(jscript);
static const WCHAR booleanW[] = {'b','o','o','l','e','a','n',0};
static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0};
@ -514,7 +525,7 @@ static HRESULT disp_cmp(IDispatch *disp1, IDispatch *disp2, BOOL *ret)
}
/* ECMA-262 3rd Edition 11.9.6 */
static HRESULT equal2_values(jsval_t lval, jsval_t rval, BOOL *ret)
HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
{
jsval_type_t type = jsval_type(lval);
@ -843,7 +854,7 @@ static HRESULT interp_case(script_ctx_t *ctx)
TRACE("\n");
v = stack_pop(ctx);
hres = equal2_values(stack_top(ctx), v, &b);
hres = jsval_strict_equal(stack_top(ctx), v, &b);
jsval_release(v);
if(FAILED(hres))
return hres;
@ -1290,7 +1301,7 @@ static HRESULT interp_local(script_ctx_t *ctx)
jsval_t copy;
HRESULT hres;
TRACE("%d\n", arg);
TRACE("%d: %s\n", arg, debugstr_w(local_name(frame, arg)));
if(!frame->base_scope || !frame->base_scope->frame)
return identifier_value(ctx, local_name(frame, arg));
@ -1393,8 +1404,6 @@ static HRESULT interp_carray(script_ctx_t *ctx)
{
const unsigned arg = get_op_uint(ctx, 0);
jsdisp_t *array;
jsval_t val;
unsigned i;
HRESULT hres;
TRACE("%u\n", arg);
@ -1403,20 +1412,27 @@ static HRESULT interp_carray(script_ctx_t *ctx)
if(FAILED(hres))
return hres;
i = arg;
while(i--) {
val = stack_pop(ctx);
hres = jsdisp_propput_idx(array, i, val);
jsval_release(val);
if(FAILED(hres)) {
jsdisp_release(array);
return hres;
}
}
return stack_push(ctx, jsval_obj(array));
}
static HRESULT interp_carray_set(script_ctx_t *ctx)
{
const unsigned index = get_op_uint(ctx, 0);
jsval_t value, array;
HRESULT hres;
value = stack_pop(ctx);
TRACE("[%u] = %s\n", index, debugstr_jsval(value));
array = stack_top(ctx);
assert(is_object_instance(array));
hres = jsdisp_propput_idx(iface_to_jsdisp(get_object(array)), index, value);
jsval_release(value);
return hres;
}
/* ECMA-262 3rd Edition 11.1.5 */
static HRESULT interp_new_obj(script_ctx_t *ctx)
{
@ -2092,7 +2108,7 @@ static HRESULT interp_preinc(script_ctx_t *ctx)
static HRESULT equal_values(script_ctx_t *ctx, jsval_t lval, jsval_t rval, BOOL *ret)
{
if(jsval_type(lval) == jsval_type(rval) || (is_number(lval) && is_number(rval)))
return equal2_values(lval, rval, ret);
return jsval_strict_equal(lval, rval, ret);
/* FIXME: NULL disps should be handled in more general way */
if(is_object_instance(lval) && !get_object(lval))
@ -2222,7 +2238,7 @@ static HRESULT interp_eq2(script_ctx_t *ctx)
TRACE("%s === %s\n", debugstr_jsval(l), debugstr_jsval(r));
hres = equal2_values(r, l, &b);
hres = jsval_strict_equal(r, l, &b);
jsval_release(l);
jsval_release(r);
if(FAILED(hres))
@ -2243,7 +2259,7 @@ static HRESULT interp_neq2(script_ctx_t *ctx)
r = stack_pop(ctx);
l = stack_pop(ctx);
hres = equal2_values(r, l, &b);
hres = jsval_strict_equal(r, l, &b);
jsval_release(l);
jsval_release(r);
if(FAILED(hres))