static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface, LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine, DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo) { JScript *This = impl_from_IActiveScriptParse(iface); bytecode_t *code; HRESULT hres; TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode), debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter), wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo); if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED) return E_UNEXPECTED; hres = compile_script(This->ctx, pstrCode, NULL, pstrDelimiter, (dwFlags & SCRIPTTEXT_ISEXPRESSION) != 0, This->is_encode, &code); if(FAILED(hres)) return hres; if(dwFlags & SCRIPTTEXT_ISEXPRESSION) { jsval_t r; IActiveScriptSite_OnEnterScript(This->site); clear_ei(This->ctx); hres = exec_source(This->ctx, EXEC_GLOBAL, code, &code->global_code, NULL, NULL, NULL, This->ctx->global, 0, NULL, &r); if(SUCCEEDED(hres)) { if(pvarResult) hres = jsval_to_variant(r, pvarResult); jsval_release(r); } IActiveScriptSite_OnLeaveScript(This->site); return hres; } /* * 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. */ if(!pvarResult && !is_started(This->ctx)) { if(This->queue_tail) This->queue_tail = This->queue_tail->next = code; else This->queue_head = This->queue_tail = code; return S_OK; } hres = exec_global_code(This, code); release_bytecode(code); if(FAILED(hres)) return hres; if(pvarResult) V_VT(pvarResult) = VT_EMPTY; return S_OK; }
static HRESULT WINAPI JScriptParse_ParseScriptText(IActiveScriptParse *iface, LPCOLESTR pstrCode, LPCOLESTR pstrItemName, IUnknown *punkContext, LPCOLESTR pstrDelimiter, CTXARG_T dwSourceContextCookie, ULONG ulStartingLine, DWORD dwFlags, VARIANT *pvarResult, EXCEPINFO *pexcepinfo) { JScript *This = impl_from_IActiveScriptParse(iface); bytecode_t *code; HRESULT hres; TRACE("(%p)->(%s %s %p %s %s %u %x %p %p)\n", This, debugstr_w(pstrCode), debugstr_w(pstrItemName), punkContext, debugstr_w(pstrDelimiter), wine_dbgstr_longlong(dwSourceContextCookie), ulStartingLine, dwFlags, pvarResult, pexcepinfo); if(This->thread_id != GetCurrentThreadId() || This->ctx->state == SCRIPTSTATE_CLOSED) return E_UNEXPECTED; hres = compile_script(This->ctx, pstrCode, NULL, pstrDelimiter, (dwFlags & SCRIPTTEXT_ISEXPRESSION) != 0, This->is_encode, &code); if(FAILED(hres)) return hres; if(dwFlags & SCRIPTTEXT_ISEXPRESSION) { exec_ctx_t *exec_ctx; hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, TRUE, &exec_ctx); if(SUCCEEDED(hres)) { jsval_t r; IActiveScriptSite_OnEnterScript(This->site); clear_ei(This->ctx); hres = exec_source(exec_ctx, code, &code->global_code, TRUE, &r); if(SUCCEEDED(hres)) { hres = jsval_to_variant(r, pvarResult); jsval_release(r); } exec_release(exec_ctx); IActiveScriptSite_OnLeaveScript(This->site); } return hres; } if(!is_started(This->ctx)) { if(This->queue_tail) This->queue_tail = This->queue_tail->next = code; else This->queue_head = This->queue_tail = code; return S_OK; } hres = exec_global_code(This, code); release_bytecode(code); return hres; }