jscript: Implement script persistence.
Persistent code has to be re-executed if the script is uninitialized and then reinitialized and restarted. 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
5e4f0f4086
commit
a42666f590
@ -169,6 +169,7 @@ local_ref_t *lookup_local(const function_code_t*,const WCHAR*) DECLSPEC_HIDDEN;
|
|||||||
|
|
||||||
typedef struct _bytecode_t {
|
typedef struct _bytecode_t {
|
||||||
LONG ref;
|
LONG ref;
|
||||||
|
BOOL is_persistent;
|
||||||
|
|
||||||
instr_t *instrs;
|
instr_t *instrs;
|
||||||
heap_pool_t heap;
|
heap_pool_t heap;
|
||||||
|
@ -60,6 +60,7 @@ typedef struct {
|
|||||||
|
|
||||||
IActiveScriptSite *site;
|
IActiveScriptSite *site;
|
||||||
|
|
||||||
|
struct list persistent_code;
|
||||||
struct list queued_code;
|
struct list queued_code;
|
||||||
} JScript;
|
} JScript;
|
||||||
|
|
||||||
@ -120,6 +121,19 @@ static void clear_script_queue(JScript *This)
|
|||||||
{
|
{
|
||||||
bytecode_t *iter = LIST_ENTRY(list_head(&This->queued_code), bytecode_t, entry);
|
bytecode_t *iter = LIST_ENTRY(list_head(&This->queued_code), bytecode_t, entry);
|
||||||
list_remove(&iter->entry);
|
list_remove(&iter->entry);
|
||||||
|
if (iter->is_persistent)
|
||||||
|
list_add_tail(&This->persistent_code, &iter->entry);
|
||||||
|
else
|
||||||
|
release_bytecode(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clear_persistent_code_list(JScript *This)
|
||||||
|
{
|
||||||
|
while(!list_empty(&This->queued_code))
|
||||||
|
{
|
||||||
|
bytecode_t *iter = LIST_ENTRY(list_head(&This->persistent_code), bytecode_t, entry);
|
||||||
|
list_remove(&iter->entry);
|
||||||
release_bytecode(iter);
|
release_bytecode(iter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,6 +223,7 @@ static void decrease_state(JScript *This, SCRIPTSTATE state)
|
|||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SCRIPTSTATE_UNINITIALIZED:
|
case SCRIPTSTATE_UNINITIALIZED:
|
||||||
change_state(This, state);
|
change_state(This, state);
|
||||||
|
clear_script_queue(This);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -463,6 +478,7 @@ static HRESULT WINAPI JScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE s
|
|||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
||||||
decrease_state(This, SCRIPTSTATE_UNINITIALIZED);
|
decrease_state(This, SCRIPTSTATE_UNINITIALIZED);
|
||||||
|
list_move_tail(&This->queued_code, &This->persistent_code);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,6 +531,7 @@ static HRESULT WINAPI JScript_Close(IActiveScript *iface)
|
|||||||
return E_UNEXPECTED;
|
return E_UNEXPECTED;
|
||||||
|
|
||||||
decrease_state(This, SCRIPTSTATE_CLOSED);
|
decrease_state(This, SCRIPTSTATE_CLOSED);
|
||||||
|
clear_persistent_code_list(This);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,6 +796,8 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
|||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code->is_persistent = (dwFlags & SCRIPTTEXT_ISPERSISTENT) != 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Although pvarResult is not really used without SCRIPTTEXT_ISEXPRESSION flag, if it's not NULL,
|
* Although pvarResult is not really used without SCRIPTTEXT_ISEXPRESSION flag, if it's not NULL,
|
||||||
* script is executed immediately, even if it's not in started state yet.
|
* script is executed immediately, even if it's not in started state yet.
|
||||||
@ -789,7 +808,12 @@ static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface,
|
|||||||
}
|
}
|
||||||
|
|
||||||
hres = exec_global_code(This, code);
|
hres = exec_global_code(This, code);
|
||||||
|
|
||||||
|
if(code->is_persistent)
|
||||||
|
list_add_tail(&This->persistent_code, &code->entry);
|
||||||
|
else
|
||||||
release_bytecode(code);
|
release_bytecode(code);
|
||||||
|
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
@ -1077,6 +1101,7 @@ HRESULT create_jscript_object(BOOL is_encode, REFIID riid, void **ppv)
|
|||||||
ret->ref = 1;
|
ret->ref = 1;
|
||||||
ret->safeopt = INTERFACE_USES_DISPEX;
|
ret->safeopt = INTERFACE_USES_DISPEX;
|
||||||
ret->is_encode = is_encode;
|
ret->is_encode = is_encode;
|
||||||
|
list_init(&ret->persistent_code);
|
||||||
list_init(&ret->queued_code);
|
list_init(&ret->queued_code);
|
||||||
|
|
||||||
hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv);
|
hres = IActiveScript_QueryInterface(&ret->IActiveScript_iface, riid, ppv);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user