mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 22:31:27 +00:00
jscript: Get rid of the variable_obj parameter to exec_source.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
838de56e0a
commit
7ad740cd29
|
@ -2990,8 +2990,9 @@ static HRESULT setup_scope(script_ctx_t *ctx, call_frame_t *frame, scope_chain_t
|
||||||
}
|
}
|
||||||
|
|
||||||
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 *function_instance, jsdisp_t *variable_obj, unsigned argc, jsval_t *argv, jsval_t *r)
|
IDispatch *this_obj, jsdisp_t *function_instance, unsigned argc, jsval_t *argv, jsval_t *r)
|
||||||
{
|
{
|
||||||
|
jsdisp_t *variable_obj;
|
||||||
call_frame_t *frame;
|
call_frame_t *frame;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -3024,6 +3025,15 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((flags & EXEC_EVAL) && ctx->call_ctx) {
|
||||||
|
variable_obj = jsdisp_addref(ctx->call_ctx->variable_obj);
|
||||||
|
}else if(!(flags & (EXEC_GLOBAL | EXEC_EVAL))) {
|
||||||
|
hres = create_dispex(ctx, NULL, NULL, &variable_obj);
|
||||||
|
if(FAILED(hres)) return hres;
|
||||||
|
}else {
|
||||||
|
variable_obj = jsdisp_addref(ctx->global);
|
||||||
|
}
|
||||||
|
|
||||||
if(flags & (EXEC_GLOBAL | EXEC_EVAL)) {
|
if(flags & (EXEC_GLOBAL | EXEC_EVAL)) {
|
||||||
BOOL lookup_globals = (flags & EXEC_GLOBAL) && !bytecode->named_item;
|
BOOL lookup_globals = (flags & EXEC_GLOBAL) && !bytecode->named_item;
|
||||||
|
|
||||||
|
@ -3034,7 +3044,7 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
|
|
||||||
hres = create_source_function(ctx, bytecode, function->funcs+function->variables[i].func_id, scope, &func_obj);
|
hres = create_source_function(ctx, bytecode, function->funcs+function->variables[i].func_id, scope, &func_obj);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
goto fail;
|
||||||
|
|
||||||
hres = jsdisp_propput_name(variable_obj, function->variables[i].name, jsval_obj(func_obj));
|
hres = jsdisp_propput_name(variable_obj, function->variables[i].name, jsval_obj(func_obj));
|
||||||
jsdisp_release(func_obj);
|
jsdisp_release(func_obj);
|
||||||
|
@ -3043,7 +3053,7 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
|
|
||||||
hres = jsdisp_get_id(variable_obj, function->variables[i].name, fdexNameEnsure, &id);
|
hres = jsdisp_get_id(variable_obj, function->variables[i].name, fdexNameEnsure, &id);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3063,12 +3073,14 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
if(ctx->call_ctx && (flags & EXEC_EVAL)) {
|
if(ctx->call_ctx && (flags & EXEC_EVAL)) {
|
||||||
hres = detach_variable_object(ctx, ctx->call_ctx, FALSE);
|
hres = detach_variable_object(ctx, ctx->call_ctx, FALSE);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = heap_alloc_zero(sizeof(*frame));
|
frame = heap_alloc_zero(sizeof(*frame));
|
||||||
if(!frame)
|
if(!frame) {
|
||||||
return E_OUTOFMEMORY;
|
hres = E_OUTOFMEMORY;
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
frame->function = function;
|
frame->function = function;
|
||||||
frame->ret = jsval_undefined();
|
frame->ret = jsval_undefined();
|
||||||
|
@ -3080,7 +3092,7 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
if(FAILED(hres)) {
|
if(FAILED(hres)) {
|
||||||
release_bytecode(frame->bytecode);
|
release_bytecode(frame->bytecode);
|
||||||
heap_free(frame);
|
heap_free(frame);
|
||||||
return hres;
|
goto fail;
|
||||||
}
|
}
|
||||||
}else if(scope) {
|
}else if(scope) {
|
||||||
frame->base_scope = frame->scope = scope_addref(scope);
|
frame->base_scope = frame->scope = scope_addref(scope);
|
||||||
|
@ -3097,7 +3109,7 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
frame->function_instance = jsdisp_addref(function_instance);
|
frame->function_instance = jsdisp_addref(function_instance);
|
||||||
|
|
||||||
frame->flags = flags;
|
frame->flags = flags;
|
||||||
frame->variable_obj = jsdisp_addref(variable_obj);
|
frame->variable_obj = variable_obj;
|
||||||
|
|
||||||
frame->prev_frame = ctx->call_ctx;
|
frame->prev_frame = ctx->call_ctx;
|
||||||
ctx->call_ctx = frame;
|
ctx->call_ctx = frame;
|
||||||
|
@ -3113,4 +3125,8 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
|
||||||
}
|
}
|
||||||
|
|
||||||
return enter_bytecode(ctx, r);
|
return enter_bytecode(ctx, r);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
jsdisp_release(variable_obj);
|
||||||
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,7 +281,7 @@ typedef struct _call_frame_t {
|
||||||
#define EXEC_EVAL 0x0008
|
#define EXEC_EVAL 0x0008
|
||||||
|
|
||||||
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*,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
|
jsdisp_t*,unsigned,jsval_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;
|
||||||
HRESULT setup_arguments_object(script_ctx_t*,call_frame_t*) DECLSPEC_HIDDEN;
|
HRESULT setup_arguments_object(script_ctx_t*,call_frame_t*) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -722,7 +722,7 @@ static HRESULT InterpretedFunction_call(script_ctx_t *ctx, FunctionInstance *fun
|
||||||
unsigned argc, jsval_t *argv, jsval_t *r)
|
unsigned argc, jsval_t *argv, jsval_t *r)
|
||||||
{
|
{
|
||||||
InterpretedFunction *function = (InterpretedFunction*)func;
|
InterpretedFunction *function = (InterpretedFunction*)func;
|
||||||
jsdisp_t *var_disp, *new_obj = NULL;
|
jsdisp_t *new_obj = NULL;
|
||||||
DWORD exec_flags = 0;
|
DWORD exec_flags = 0;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
|
@ -744,15 +744,10 @@ static HRESULT InterpretedFunction_call(script_ctx_t *ctx, FunctionInstance *fun
|
||||||
exec_flags |= EXEC_RETURN_TO_INTERP;
|
exec_flags |= EXEC_RETURN_TO_INTERP;
|
||||||
if(flags & DISPATCH_CONSTRUCT)
|
if(flags & DISPATCH_CONSTRUCT)
|
||||||
exec_flags |= EXEC_CONSTRUCTOR;
|
exec_flags |= EXEC_CONSTRUCTOR;
|
||||||
|
hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj,
|
||||||
hres = create_dispex(ctx, NULL, NULL, &var_disp);
|
&function->function.dispex, argc, argv, r);
|
||||||
if(SUCCEEDED(hres))
|
|
||||||
hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj,
|
|
||||||
&function->function.dispex, var_disp, argc, argv, r);
|
|
||||||
if(new_obj)
|
if(new_obj)
|
||||||
jsdisp_release(new_obj);
|
jsdisp_release(new_obj);
|
||||||
|
|
||||||
jsdisp_release(var_disp);
|
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned a
|
||||||
if(flags & DISPATCH_JSCRIPT_CALLEREXECSSOURCE)
|
if(flags & DISPATCH_JSCRIPT_CALLEREXECSSOURCE)
|
||||||
exec_flags |= EXEC_RETURN_TO_INTERP;
|
exec_flags |= EXEC_RETURN_TO_INTERP;
|
||||||
hres = exec_source(ctx, exec_flags, code, &code->global_code, frame ? frame->scope : NULL,
|
hres = exec_source(ctx, exec_flags, code, &code->global_code, frame ? frame->scope : NULL,
|
||||||
frame ? frame->this_obj : NULL, NULL, frame ? frame->variable_obj : ctx->global, 0, NULL, r);
|
frame ? frame->this_obj : NULL, NULL, 0, NULL, r);
|
||||||
release_bytecode(code);
|
release_bytecode(code);
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
|
@ -408,7 +408,7 @@ static void exec_queued_code(JScript *This)
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(iter, &This->queued_code, bytecode_t, entry) {
|
LIST_FOR_EACH_ENTRY(iter, &This->queued_code, bytecode_t, entry) {
|
||||||
enter_script(This->ctx, &ei);
|
enter_script(This->ctx, &ei);
|
||||||
hres = exec_source(This->ctx, EXEC_GLOBAL, iter, &iter->global_code, NULL, NULL, NULL, This->ctx->global, 0, NULL, NULL);
|
hres = exec_source(This->ctx, EXEC_GLOBAL, iter, &iter->global_code, NULL, NULL, NULL, 0, NULL, NULL);
|
||||||
leave_script(This->ctx, hres);
|
leave_script(This->ctx, hres);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
break;
|
break;
|
||||||
|
@ -1053,7 +1053,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
||||||
if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
|
if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
|
||||||
jsval_t r;
|
jsval_t r;
|
||||||
|
|
||||||
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, This->ctx->global, 0, NULL, &r);
|
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, 0, NULL, &r);
|
||||||
if(SUCCEEDED(hres)) {
|
if(SUCCEEDED(hres)) {
|
||||||
if(pvarResult)
|
if(pvarResult)
|
||||||
hres = jsval_to_variant(r, pvarResult);
|
hres = jsval_to_variant(r, pvarResult);
|
||||||
|
@ -1072,7 +1072,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
||||||
if(!pvarResult && !is_started(This->ctx)) {
|
if(!pvarResult && !is_started(This->ctx)) {
|
||||||
list_add_tail(&This->queued_code, &code->entry);
|
list_add_tail(&This->queued_code, &code->entry);
|
||||||
}else {
|
}else {
|
||||||
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, This->ctx->global, 0, NULL, NULL);
|
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, 0, NULL, NULL);
|
||||||
if(code->is_persistent)
|
if(code->is_persistent)
|
||||||
list_add_tail(&This->persistent_code, &code->entry);
|
list_add_tail(&This->persistent_code, &code->entry);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue