jscript: Find Function.arguments on the stack instead of storing it in FunctionInstance object.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
42e90ca592
commit
35133dbe58
|
@ -2388,6 +2388,8 @@ static void release_call_frame(call_frame_t *frame)
|
||||||
jsdisp_propput_name(frame->variable_obj, argumentsW, jsval_undefined());
|
jsdisp_propput_name(frame->variable_obj, argumentsW, jsval_undefined());
|
||||||
jsdisp_release(frame->arguments_obj);
|
jsdisp_release(frame->arguments_obj);
|
||||||
}
|
}
|
||||||
|
if(frame->function_instance)
|
||||||
|
jsdisp_release(frame->function_instance);
|
||||||
if(frame->variable_obj)
|
if(frame->variable_obj)
|
||||||
jsdisp_release(frame->variable_obj);
|
jsdisp_release(frame->variable_obj);
|
||||||
if(frame->this_obj)
|
if(frame->this_obj)
|
||||||
|
@ -2536,7 +2538,7 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope,
|
HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope,
|
||||||
IDispatch *this_obj, jsdisp_t *variable_obj, jsdisp_t *arguments_obj, jsval_t *r)
|
IDispatch *this_obj, jsdisp_t *function_instance, jsdisp_t *variable_obj, jsdisp_t *arguments_obj, jsval_t *r)
|
||||||
{
|
{
|
||||||
call_frame_t *frame;
|
call_frame_t *frame;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -2604,6 +2606,8 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
frame->this_obj = to_disp(ctx->global);
|
frame->this_obj = to_disp(ctx->global);
|
||||||
IDispatch_AddRef(frame->this_obj);
|
IDispatch_AddRef(frame->this_obj);
|
||||||
|
|
||||||
|
if(function_instance)
|
||||||
|
frame->function_instance = jsdisp_addref(function_instance);
|
||||||
if(arguments_obj)
|
if(arguments_obj)
|
||||||
frame->arguments_obj = jsdisp_addref(arguments_obj);
|
frame->arguments_obj = jsdisp_addref(arguments_obj);
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,7 @@ typedef struct _call_frame_t {
|
||||||
jsval_t ret;
|
jsval_t ret;
|
||||||
|
|
||||||
IDispatch *this_obj;
|
IDispatch *this_obj;
|
||||||
|
jsdisp_t *function_instance;
|
||||||
jsdisp_t *variable_obj;
|
jsdisp_t *variable_obj;
|
||||||
jsdisp_t *arguments_obj;
|
jsdisp_t *arguments_obj;
|
||||||
DWORD flags;
|
DWORD flags;
|
||||||
|
@ -217,5 +218,6 @@ typedef struct _call_frame_t {
|
||||||
#define EXEC_CONSTRUCTOR 0x0002
|
#define EXEC_CONSTRUCTOR 0x0002
|
||||||
|
|
||||||
HRESULT exec_source(script_ctx_t*,DWORD,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,
|
HRESULT exec_source(script_ctx_t*,DWORD,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,
|
||||||
jsdisp_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
|
jsdisp_t*,jsdisp_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
HRESULT create_source_function(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,jsdisp_t**) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -34,7 +34,6 @@ typedef struct {
|
||||||
bytecode_t *code;
|
bytecode_t *code;
|
||||||
function_code_t *func_code;
|
function_code_t *func_code;
|
||||||
DWORD length;
|
DWORD length;
|
||||||
jsdisp_t *arguments;
|
|
||||||
} FunctionInstance;
|
} FunctionInstance;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -239,14 +238,11 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
|
||||||
hres = scope_push(function->scope_chain, var_disp, to_disp(var_disp), &scope);
|
hres = scope_push(function->scope_chain, var_disp, to_disp(var_disp), &scope);
|
||||||
if(SUCCEEDED(hres)) {
|
if(SUCCEEDED(hres)) {
|
||||||
DWORD exec_flags = 0;
|
DWORD exec_flags = 0;
|
||||||
jsdisp_t *prev_args;
|
|
||||||
|
|
||||||
if(is_constructor)
|
if(is_constructor)
|
||||||
exec_flags |= EXEC_CONSTRUCTOR;
|
exec_flags |= EXEC_CONSTRUCTOR;
|
||||||
prev_args = function->arguments;
|
hres = exec_source(ctx, exec_flags, function->code, function->func_code, scope, this_obj,
|
||||||
function->arguments = arg_disp;
|
&function->dispex, var_disp, arg_disp, r);
|
||||||
hres = exec_source(ctx, exec_flags, function->code, function->func_code, scope, this_obj, var_disp, arg_disp, r);
|
|
||||||
function->arguments = prev_args;
|
|
||||||
|
|
||||||
scope_release(scope);
|
scope_release(scope);
|
||||||
}
|
}
|
||||||
|
@ -535,10 +531,18 @@ HRESULT Function_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
||||||
static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
||||||
{
|
{
|
||||||
FunctionInstance *function = function_from_jsdisp(jsthis);
|
FunctionInstance *function = function_from_jsdisp(jsthis);
|
||||||
|
call_frame_t *frame;
|
||||||
|
|
||||||
TRACE("\n");
|
TRACE("\n");
|
||||||
|
|
||||||
*r = function->arguments ? jsval_obj(jsdisp_addref(function->arguments)) : jsval_null();
|
for(frame = ctx->call_ctx; frame; frame = frame->prev_frame) {
|
||||||
|
if(frame->function_instance == &function->dispex) {
|
||||||
|
*r = jsval_obj(jsdisp_addref(frame->arguments_obj));
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*r = jsval_null();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
|
||||||
if(frame->flags & EXEC_GLOBAL)
|
if(frame->flags & EXEC_GLOBAL)
|
||||||
exec_flags |= EXEC_GLOBAL;
|
exec_flags |= EXEC_GLOBAL;
|
||||||
hres = exec_source(ctx, exec_flags, code, &code->global_code, frame->scope,
|
hres = exec_source(ctx, exec_flags, code, &code->global_code, frame->scope,
|
||||||
frame->this_obj, frame->variable_obj, NULL, r);
|
frame->this_obj, NULL, frame->variable_obj, NULL, r);
|
||||||
release_bytecode(code);
|
release_bytecode(code);
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ static HRESULT exec_global_code(JScript *This, bytecode_t *code)
|
||||||
IActiveScriptSite_OnEnterScript(This->site);
|
IActiveScriptSite_OnEnterScript(This->site);
|
||||||
|
|
||||||
clear_ei(This->ctx);
|
clear_ei(This->ctx);
|
||||||
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, NULL, NULL);
|
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, This->ctx->global, NULL, NULL);
|
||||||
|
|
||||||
IActiveScriptSite_OnLeaveScript(This->site);
|
IActiveScriptSite_OnLeaveScript(This->site);
|
||||||
return hres;
|
return hres;
|
||||||
|
@ -773,7 +773,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
||||||
IActiveScriptSite_OnEnterScript(This->site);
|
IActiveScriptSite_OnEnterScript(This->site);
|
||||||
|
|
||||||
clear_ei(This->ctx);
|
clear_ei(This->ctx);
|
||||||
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, NULL, &r);
|
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, This->ctx->global, NULL, &r);
|
||||||
if(SUCCEEDED(hres)) {
|
if(SUCCEEDED(hres)) {
|
||||||
if(pvarResult)
|
if(pvarResult)
|
||||||
hres = jsval_to_variant(r, pvarResult);
|
hres = jsval_to_variant(r, pvarResult);
|
||||||
|
|
|
@ -205,8 +205,12 @@ function argumentsTest() {
|
||||||
eval('ok(arguments === save, "unexpected arguments");');
|
eval('ok(arguments === save, "unexpected arguments");');
|
||||||
[1,2].sort(function() {
|
[1,2].sort(function() {
|
||||||
ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
|
ok(argumentsTest.arguments === save, "unexpected argumentsTest.arguments");
|
||||||
|
return 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/* FIXME: It seems that when function is called as an expression, instance object arguments is not set.
|
||||||
|
* We currently always set it in Wine. */
|
||||||
|
argumentsTest();
|
||||||
|
|
||||||
tmp = (function() {1;})();
|
tmp = (function() {1;})();
|
||||||
ok(tmp === undefined, "tmp = " + tmp);
|
ok(tmp === undefined, "tmp = " + tmp);
|
||||||
|
|
Loading…
Reference in New Issue