Commit 0bd508db authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added this expression implementation.

parent 6b24d897
...@@ -132,7 +132,7 @@ void scope_release(scope_chain_t *scope) ...@@ -132,7 +132,7 @@ void scope_release(scope_chain_t *scope)
heap_free(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; exec_ctx_t *ctx;
...@@ -140,6 +140,9 @@ HRESULT create_exec_ctx(DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t * ...@@ -140,6 +140,9 @@ HRESULT create_exec_ctx(DispatchEx *var_disp, scope_chain_t *scope, exec_ctx_t *
if(!ctx) if(!ctx)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
IDispatch_AddRef(this_obj);
ctx->this_obj = this_obj;
IDispatchEx_AddRef(_IDispatchEx_(var_disp)); IDispatchEx_AddRef(_IDispatchEx_(var_disp));
ctx->var_disp = var_disp; ctx->var_disp = var_disp;
...@@ -161,6 +164,8 @@ void exec_release(exec_ctx_t *ctx) ...@@ -161,6 +164,8 @@ void exec_release(exec_ctx_t *ctx)
scope_release(ctx->scope_chain); scope_release(ctx->scope_chain);
if(ctx->var_disp) if(ctx->var_disp)
IDispatchEx_Release(_IDispatchEx_(ctx->var_disp)); IDispatchEx_Release(_IDispatchEx_(ctx->var_disp));
if(ctx->this_obj)
IDispatch_Release(ctx->this_obj);
heap_free(ctx); heap_free(ctx);
} }
...@@ -816,8 +821,13 @@ HRESULT call_expression_eval(exec_ctx_t *ctx, expression_t *_expr, DWORD flags, ...@@ -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) HRESULT this_expression_eval(exec_ctx_t *ctx, expression_t *expr, DWORD flags, jsexcept_t *ei, exprval_t *ret)
{ {
FIXME("\n"); TRACE("\n");
return E_NOTIMPL;
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 */ /* ECMA-262 3rd Edition 10.1.4 */
......
...@@ -76,6 +76,7 @@ struct _exec_ctx_t { ...@@ -76,6 +76,7 @@ struct _exec_ctx_t {
parser_ctx_t *parser; parser_ctx_t *parser;
scope_chain_t *scope_chain; scope_chain_t *scope_chain;
DispatchEx *var_disp; DispatchEx *var_disp;
IDispatch *this_obj;
}; };
static inline void exec_addref(exec_ctx_t *ctx) static inline void exec_addref(exec_ctx_t *ctx)
...@@ -84,7 +85,7 @@ 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*); 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*); HRESULT exec_source(exec_ctx_t*,parser_ctx_t*,source_elements_t*,jsexcept_t*,VARIANT*);
typedef struct _statement_t statement_t; typedef struct _statement_t statement_t;
......
...@@ -80,7 +80,7 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx) ...@@ -80,7 +80,7 @@ static HRESULT exec_global_code(JScript *This, parser_ctx_t *parser_ctx)
VARIANT var; VARIANT var;
HRESULT hres; 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)) if(FAILED(hres))
return hres; return hres;
......
...@@ -68,5 +68,6 @@ ok(typeof(String.prototype) === "object", "typeof(String.prototype) is not objec ...@@ -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(testFunc1) === "function", "typeof(testFunc1) is not function");
ok(typeof(String) === "function", "typeof(String) is not function"); ok(typeof(String) === "function", "typeof(String) is not function");
ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function"); ok(typeof(ScriptEngine) === "function", "typeof(ScriptEngine) is not function");
ok(typeof(this) === "object", "typeof(this) is not object");
reportSuccess(); reportSuccess();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment