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; }
static HRESULT exec_global_code(JScript *This, bytecode_t *code) { HRESULT hres; 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, NULL); IActiveScriptSite_OnLeaveScript(This->site); return hres; }
static HRESULT Procedure_invoke(vbdisp_t *This, VARIANT *args, unsigned args_cnt, VARIANT *res) { script_ctx_t *ctx = This->desc->ctx; HRESULT hres; TRACE("\n"); IActiveScriptSite_OnEnterScript(ctx->site); hres = exec_script(ctx, This->desc->value_func, NULL, NULL, NULL); IActiveScriptSite_OnLeaveScript(ctx->site); return hres; }
static HRESULT exec_global_code(JScript *This, bytecode_t *code) { exec_ctx_t *exec_ctx; HRESULT hres; hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, TRUE, &exec_ctx); if(FAILED(hres)) return hres; IActiveScriptSite_OnEnterScript(This->site); clear_ei(This->ctx); hres = exec_source(exec_ctx, code, &code->global_code, FALSE, NULL); exec_release(exec_ctx); IActiveScriptSite_OnLeaveScript(This->site); return hres; }
static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) { exec_ctx_t *exec_ctx; jsexcept_t jsexcept; HRESULT hres; hres = create_exec_ctx(This->ctx, NULL, This->ctx->global, NULL, &exec_ctx); if(FAILED(hres)) return hres; IActiveScriptSite_OnEnterScript(This->site); memset(&jsexcept, 0, sizeof(jsexcept)); hres = exec_source(exec_ctx, parser_ctx, parser_ctx->source, EXECT_PROGRAM, &jsexcept, NULL); VariantClear(&jsexcept.var); exec_release(exec_ctx); IActiveScriptSite_OnLeaveScript(This->site); return hres; }
static HRESULT WINAPI ScriptDisp_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp, VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller) { ScriptDisp *This = ScriptDisp_from_IDispatchEx(iface); ident_map_t *ident; HRESULT hres; TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); ident = id_to_ident(This, id); if(!ident) return DISP_E_MEMBERNOTFOUND; if(ident->is_var) { if(ident->u.var->is_const) { FIXME("const not supported\n"); return E_NOTIMPL; } return invoke_variant_prop(This->ctx, &ident->u.var->v, wFlags, pdp, pvarRes); } switch(wFlags) { case DISPATCH_METHOD: case DISPATCH_METHOD|DISPATCH_PROPERTYGET: IActiveScriptSite_OnEnterScript(This->ctx->site); hres = exec_script(This->ctx, ident->u.func, NULL, pdp, pvarRes); IActiveScriptSite_OnLeaveScript(This->ctx->site); break; default: FIXME("Unsupported flags %x\n", wFlags); hres = E_NOTIMPL; } return hres; }