Commit 7ad740cd authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Get rid of the variable_obj parameter to exec_source.

parent 838de56e
......@@ -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,
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;
unsigned i;
HRESULT hres;
......@@ -3024,6 +3025,15 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
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)) {
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);
if(FAILED(hres))
return hres;
goto fail;
hres = jsdisp_propput_name(variable_obj, function->variables[i].name, jsval_obj(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);
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)) {
hres = detach_variable_object(ctx, ctx->call_ctx, FALSE);
if(FAILED(hres))
return hres;
goto fail;
}
frame = heap_alloc_zero(sizeof(*frame));
if(!frame)
return E_OUTOFMEMORY;
if(!frame) {
hres = E_OUTOFMEMORY;
goto fail;
}
frame->function = function;
frame->ret = jsval_undefined();
......@@ -3080,7 +3092,7 @@ HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, functi
if(FAILED(hres)) {
release_bytecode(frame->bytecode);
heap_free(frame);
return hres;
goto fail;
}
}else if(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->flags = flags;
frame->variable_obj = jsdisp_addref(variable_obj);
frame->variable_obj = variable_obj;
frame->prev_frame = ctx->call_ctx;
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);
fail:
jsdisp_release(variable_obj);
return hres;
}
......@@ -281,7 +281,7 @@ typedef struct _call_frame_t {
#define EXEC_EVAL 0x0008
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 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)
{
InterpretedFunction *function = (InterpretedFunction*)func;
jsdisp_t *var_disp, *new_obj = NULL;
jsdisp_t *new_obj = NULL;
DWORD exec_flags = 0;
HRESULT hres;
......@@ -744,15 +744,10 @@ static HRESULT InterpretedFunction_call(script_ctx_t *ctx, FunctionInstance *fun
exec_flags |= EXEC_RETURN_TO_INTERP;
if(flags & DISPATCH_CONSTRUCT)
exec_flags |= EXEC_CONSTRUCTOR;
hres = create_dispex(ctx, NULL, NULL, &var_disp);
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);
hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj,
&function->function.dispex, argc, argv, r);
if(new_obj)
jsdisp_release(new_obj);
jsdisp_release(var_disp);
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)
exec_flags |= EXEC_RETURN_TO_INTERP;
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);
return hres;
}
......
......@@ -408,7 +408,7 @@ static void exec_queued_code(JScript *This)
LIST_FOR_EACH_ENTRY(iter, &This->queued_code, bytecode_t, entry) {
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);
if(FAILED(hres))
break;
......@@ -1053,7 +1053,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if(dwFlags & SCRIPTTEXT_ISEXPRESSION) {
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(pvarResult)
hres = jsval_to_variant(r, pvarResult);
......@@ -1072,7 +1072,7 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
if(!pvarResult && !is_started(This->ctx)) {
list_add_tail(&This->queued_code, &code->entry);
}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)
list_add_tail(&This->persistent_code, &code->entry);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment