jscript: Added this expression implementation.

This commit is contained in:
Jacek Caban 2008-09-10 21:05:14 +02:00 committed by Alexandre Julliard
parent 6b24d897fd
commit 0bd508db2f
4 changed files with 17 additions and 5 deletions

View File

@ -132,7 +132,7 @@ void scope_release(scope_chain_t *scope)
heap_free(scope);
}
HRESULT create_exec_ctx(DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t **ret)
HRESULT create_exec_ctx(IDispatch *this_obj, DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t **ret)
{
exec_ctx_t *ctx;
@ -140,6 +140,9 @@ HRESULT create_exec_ctx(DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t *
if(!ctx)
return E_OUTOFMEMORY;
IDispatch_AddRef(this_obj);
ctx->this_obj = this_obj;
IDispatchEx_AddRef(_IDispatchEx_(var_disp));
ctx->var_disp = var_disp;
@ -161,6 +164,8 @@ void exec_release(exec_ctx_t *ctx)
scope_release(ctx->scope_chain);
if(ctx->var_disp)
IDispatchEx_Release(_IDispatchEx_(ctx->var_disp));
if(ctx->this_obj)
IDispatch_Release(ctx->this_obj);
heap_free(ctx);
}
@ -816,8 +821,13 @@ HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags,
HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{
FIXME("\n");
return E_NOTIMPL;
TRACE("\n");
ret->type = EXPRVAL_VARIANT;
V_VT(&ret->u.var) = VT_DISPATCH;
V_DISPATCH(&ret->u.var) = ctx->this_obj;
IDispatch_AddRef(ctx->this_obj);
return S_OK;
}
/* ECMA-262 3rd Edition 10.1.4 */

View File

@ -76,6 +76,7 @@ struct _exec_ctx_t {
parser_ctx_t *parser;
scope_chain_t *scope_chain;
DispatchEx *var_disp;
IDispatch *this_obj;
};
static inline void exec_addref(exec_ctx_t *ctx)
@ -84,7 +85,7 @@ static inline void exec_addref(exec_ctx_t *ctx)
}
void exec_release(exec_ctx_t*);
HRESULT create_exec_ctx(DispatchEx*,scope_chain_t*,exec_ctx_t**);
HRESULT create_exec_ctx(IDispatch*,DispatchEx*,scope_chain_t*,exec_ctx_t**);
HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*);
typedef struct _statement_t statement_t;

View File

@ -80,7 +80,7 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx)
VARIANT var;
HRESULT hres;
hres = create_exec_ctx(This->ctx->script_disp, NULL, &exec_ctx);
hres = create_exec_ctx((IDispatch*)_IDispatchEx_(This->ctx->script_disp), This->ctx->script_disp, NULL, &exec_ctx);
if(FAILED(hres))
return hres;

View File

@ -68,5 +68,6 @@ ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not objec
ok(typeof(testFunc1) === "function", "typeof(testFunc1) is not function");
ok(typeof(String) === "function", "typeof(String) is not function");
ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
ok(typeof(this) === "object", "typeof(this) is not object");
reportSuccess();