Commit 70628f80 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Directly access 'this' object properties in interpreter.

parent 82cace0f
......@@ -32,6 +32,7 @@ typedef struct {
script_ctx_t *script;
function_t *func;
IDispatch *this_obj;
vbdisp_t *vbthis;
VARIANT *args;
VARIANT *vars;
......@@ -132,6 +133,17 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_
return S_OK;
if(ctx->func->type != FUNC_GLOBAL) {
if(ctx->vbthis) {
/* FIXME: Bind such identifier while generating bytecode. */
for(i=0; i < ctx->vbthis->desc->prop_cnt; i++) {
if(!strcmpiW(ctx->vbthis->desc->props[i].name, name)) {
ref->type = REF_VAR;
ref->u.v = ctx->vbthis->props+i;
return S_OK;
}
}
}
hres = disp_get_id(ctx->this_obj, name, invoke_type, TRUE, &id);
if(SUCCEEDED(hres)) {
ref->type = REF_DISP;
......@@ -1986,7 +1998,7 @@ static void release_exec(exec_ctx_t *ctx)
heap_free(ctx->stack);
}
HRESULT exec_script(script_ctx_t *ctx, function_t *func, IDispatch *this_obj, DISPPARAMS *dp, VARIANT *res)
HRESULT exec_script(script_ctx_t *ctx, function_t *func, vbdisp_t *vbthis, DISPPARAMS *dp, VARIANT *res)
{
exec_ctx_t exec = {func->code_ctx};
vbsop_t op;
......@@ -2048,12 +2060,14 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, IDispatch *this_obj, DI
return E_OUTOFMEMORY;
}
if(this_obj)
exec.this_obj = this_obj;
else if (ctx->host_global)
if(vbthis) {
exec.this_obj = (IDispatch*)&vbthis->IDispatchEx_iface;
exec.vbthis = vbthis;
}else if (ctx->host_global) {
exec.this_obj = ctx->host_global;
else
}else {
exec.this_obj = (IDispatch*)&ctx->script_obj->IDispatchEx_iface;
}
IDispatch_AddRef(exec.this_obj);
exec.instr = exec.code->instrs + func->code_off;
......
......@@ -814,8 +814,8 @@ Class TestClass
Public Sub Class_Initialize
publicProp2 = 2
privateProp = true
'todo_wine Call ok(getVT(privateProp) = "VT_BOOL*", "getVT(privateProp) = " & getVT(privateProp))
'todo_wine Call ok(getVT(publicProp2) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2))
Call ok(getVT(privateProp) = "VT_BOOL*", "getVT(privateProp) = " & getVT(privateProp))
Call ok(getVT(publicProp2) = "VT_I2*", "getVT(publicProp2) = " & getVT(publicProp2))
Call ok(getVT(Me.publicProp2) = "VT_I2", "getVT(Me.publicProp2) = " & getVT(Me.publicProp2))
End Sub
End Class
......@@ -1054,12 +1054,12 @@ Class ArrClass
Dim var
Private Sub Class_Initialize
'todo_wine Call ok(getVT(classarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(classarr) = " & getVT(classarr))
'todo_wine Call testArray(-1, classnoarr)
'classarr(0) = 1
'classarr(1) = 2
'classarr(2) = 3
'classarr(3) = 4
Call ok(getVT(classarr) = "VT_ARRAY|VT_BYREF|VT_VARIANT*", "getVT(classarr) = " & getVT(classarr))
Call testArray(-1, classnoarr)
classarr(0) = 1
classarr(1) = 2
classarr(2) = 3
classarr(3) = 4
End Sub
End Class
......
......@@ -233,7 +233,7 @@ static BOOL run_terminator(vbdisp_t *This)
This->ref++;
exec_script(This->desc->ctx, This->desc->funcs[This->desc->class_terminate_id].entries[VBDISP_CALLGET],
(IDispatch*)&This->IDispatchEx_iface, &dp, NULL);
This, &dp, NULL);
return !--This->ref;
}
......@@ -397,7 +397,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
return DISP_E_MEMBERNOTFOUND;
}
return exec_script(This->desc->ctx, func, (IDispatch*)&This->IDispatchEx_iface, pdp, pvarRes);
return exec_script(This->desc->ctx, func, This, pdp, pvarRes);
case DISPATCH_PROPERTYPUT: {
VARIANT *put_val;
DISPPARAMS dp = {NULL, NULL, 1, 0};
......@@ -420,7 +420,7 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
return DISP_E_MEMBERNOTFOUND;
}
return exec_script(This->desc->ctx, func, (IDispatch*)&This->IDispatchEx_iface, &dp, NULL);
return exec_script(This->desc->ctx, func, This, &dp, NULL);
}
default:
FIXME("flags %x\n", wFlags);
......@@ -562,7 +562,7 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret)
if(SUCCEEDED(hres) && desc->class_initialize_id) {
DISPPARAMS dp = {0};
hres = exec_script(desc->ctx, desc->funcs[desc->class_initialize_id].entries[VBDISP_CALLGET],
(IDispatch*)&vbdisp->IDispatchEx_iface, &dp, NULL);
vbdisp, &dp, NULL);
}
if(FAILED(hres)) {
......
......@@ -347,7 +347,7 @@ struct _vbscode_t {
void release_vbscode(vbscode_t*) DECLSPEC_HIDDEN;
HRESULT compile_script(script_ctx_t*,const WCHAR*,const WCHAR*,vbscode_t**) DECLSPEC_HIDDEN;
HRESULT exec_script(script_ctx_t*,function_t*,IDispatch*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
HRESULT exec_script(script_ctx_t*,function_t*,vbdisp_t*,DISPPARAMS*,VARIANT*) DECLSPEC_HIDDEN;
void release_dynamic_vars(dynamic_var_t*) DECLSPEC_HIDDEN;
typedef struct {
......
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