jscript: Sore is_global as a flag.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4bef35fd48
commit
2bb824b7c9
|
@ -2520,8 +2520,8 @@ static HRESULT bind_event_target(script_ctx_t *ctx, function_code_t *func, jsdis
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT setup_call_frame(script_ctx_t *ctx, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope,
|
static HRESULT setup_call_frame(script_ctx_t *ctx, DWORD flags, bytecode_t *bytecode, function_code_t *function, scope_chain_t *scope,
|
||||||
IDispatch *this_obj, BOOL is_global, jsdisp_t *variable_obj)
|
IDispatch *this_obj, jsdisp_t *variable_obj)
|
||||||
{
|
{
|
||||||
call_frame_t *frame;
|
call_frame_t *frame;
|
||||||
|
|
||||||
|
@ -2558,7 +2558,7 @@ static HRESULT setup_call_frame(script_ctx_t *ctx, bytecode_t *bytecode, functio
|
||||||
frame->this_obj = to_disp(ctx->global);
|
frame->this_obj = to_disp(ctx->global);
|
||||||
IDispatch_AddRef(frame->this_obj);
|
IDispatch_AddRef(frame->this_obj);
|
||||||
|
|
||||||
frame->is_global = is_global;
|
frame->flags = flags;
|
||||||
frame->variable_obj = jsdisp_addref(variable_obj);
|
frame->variable_obj = jsdisp_addref(variable_obj);
|
||||||
|
|
||||||
frame->prev_frame = ctx->call_ctx;
|
frame->prev_frame = ctx->call_ctx;
|
||||||
|
@ -2566,8 +2566,8 @@ static HRESULT setup_call_frame(script_ctx_t *ctx, bytecode_t *bytecode, functio
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT exec_source(script_ctx_t *ctx, bytecode_t *code, function_code_t *func, scope_chain_t *scope,
|
HRESULT exec_source(script_ctx_t *ctx, DWORD flags, bytecode_t *code, function_code_t *func, scope_chain_t *scope,
|
||||||
IDispatch *this_obj, BOOL is_global, jsdisp_t *variable_obj, jsval_t *ret)
|
IDispatch *this_obj, jsdisp_t *variable_obj, jsval_t *ret)
|
||||||
{
|
{
|
||||||
jsval_t val;
|
jsval_t val;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -2593,7 +2593,7 @@ HRESULT exec_source(script_ctx_t *ctx, bytecode_t *code, function_code_t *func,
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i=0; i < func->var_cnt; i++) {
|
for(i=0; i < func->var_cnt; i++) {
|
||||||
if(!is_global || !lookup_global_members(ctx, func->variables[i], NULL)) {
|
if(!(flags & EXEC_GLOBAL) || !lookup_global_members(ctx, func->variables[i], NULL)) {
|
||||||
DISPID id = 0;
|
DISPID id = 0;
|
||||||
|
|
||||||
hres = jsdisp_get_id(variable_obj, func->variables[i], fdexNameEnsure, &id);
|
hres = jsdisp_get_id(variable_obj, func->variables[i], fdexNameEnsure, &id);
|
||||||
|
@ -2602,7 +2602,7 @@ HRESULT exec_source(script_ctx_t *ctx, bytecode_t *code, function_code_t *func,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = setup_call_frame(ctx, code, func, scope, this_obj, is_global, variable_obj);
|
hres = setup_call_frame(ctx, flags, code, func, scope, this_obj, variable_obj);
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ typedef struct _call_frame_t {
|
||||||
|
|
||||||
IDispatch *this_obj;
|
IDispatch *this_obj;
|
||||||
jsdisp_t *variable_obj;
|
jsdisp_t *variable_obj;
|
||||||
BOOL is_global;
|
DWORD flags;
|
||||||
|
|
||||||
bytecode_t *bytecode;
|
bytecode_t *bytecode;
|
||||||
function_code_t *function;
|
function_code_t *function;
|
||||||
|
@ -211,5 +211,7 @@ typedef struct _call_frame_t {
|
||||||
struct _call_frame_t *prev_frame;
|
struct _call_frame_t *prev_frame;
|
||||||
} call_frame_t;
|
} call_frame_t;
|
||||||
|
|
||||||
HRESULT exec_source(script_ctx_t*,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,BOOL,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
|
#define EXEC_GLOBAL 0x0001
|
||||||
|
|
||||||
|
HRESULT exec_source(script_ctx_t*,DWORD,bytecode_t*,function_code_t*,scope_chain_t*,IDispatch*,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;
|
||||||
|
|
|
@ -242,7 +242,7 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
|
||||||
|
|
||||||
prev_args = function->arguments;
|
prev_args = function->arguments;
|
||||||
function->arguments = arg_disp;
|
function->arguments = arg_disp;
|
||||||
hres = exec_source(ctx, function->code, function->func_code, scope, this_obj, FALSE, var_disp, r);
|
hres = exec_source(ctx, 0, function->code, function->func_code, scope, this_obj, var_disp, r);
|
||||||
function->arguments = prev_args;
|
function->arguments = prev_args;
|
||||||
|
|
||||||
scope_release(scope);
|
scope_release(scope);
|
||||||
|
|
|
@ -189,6 +189,7 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
|
||||||
jsval_t *r)
|
jsval_t *r)
|
||||||
{
|
{
|
||||||
call_frame_t *frame;
|
call_frame_t *frame;
|
||||||
|
DWORD exec_flags = 0;
|
||||||
bytecode_t *code;
|
bytecode_t *code;
|
||||||
const WCHAR *src;
|
const WCHAR *src;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
@ -223,8 +224,10 @@ static HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
|
||||||
return throw_syntax_error(ctx, hres, NULL);
|
return throw_syntax_error(ctx, hres, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
hres = exec_source(ctx, code, &code->global_code, frame->scope,
|
if(frame->flags & EXEC_GLOBAL)
|
||||||
frame->this_obj, frame->is_global, frame->variable_obj, r);
|
exec_flags |= EXEC_GLOBAL;
|
||||||
|
hres = exec_source(ctx, exec_flags, code, &code->global_code, frame->scope,
|
||||||
|
frame->this_obj, frame->variable_obj, 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, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, NULL);
|
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, 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, code, &code->global_code, NULL, NULL, TRUE, This->ctx->global, &r);
|
hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, This->ctx->global, &r);
|
||||||
if(SUCCEEDED(hres)) {
|
if(SUCCEEDED(hres)) {
|
||||||
if(pvarResult)
|
if(pvarResult)
|
||||||
hres = jsval_to_variant(r, pvarResult);
|
hres = jsval_to_variant(r, pvarResult);
|
||||||
|
|
Loading…
Reference in New Issue