vbscript: Always pass arguments inside parentheses by value.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-10-28 18:41:05 +01:00 committed by Alexandre Julliard
parent 216f7146ef
commit 2d419b7d7b
4 changed files with 26 additions and 5 deletions

View File

@ -417,6 +417,9 @@ static HRESULT compile_args(compile_ctx_t *ctx, expression_t *args, unsigned *re
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
if(args->type == EXPR_BRACKETS && !push_instr(ctx, OP_deref))
return E_OUTOFMEMORY;
arg_cnt++; arg_cnt++;
args = args->next; args = args->next;
} }

View File

@ -1028,6 +1028,23 @@ static HRESULT interp_pop(exec_ctx_t *ctx)
return S_OK; return S_OK;
} }
static HRESULT interp_deref(exec_ctx_t *ctx)
{
VARIANT copy, *v = stack_top(ctx, 0);
HRESULT hres;
TRACE("%s\n", debugstr_variant(v));
if(V_VT(v) != (VT_BYREF|VT_VARIANT))
return S_OK;
V_VT(&copy) = VT_EMPTY;
hres = VariantCopy(&copy, V_VARIANTREF(v));
if(SUCCEEDED(hres))
*v = copy;
return hres;
}
static HRESULT interp_new(exec_ctx_t *ctx) static HRESULT interp_new(exec_ctx_t *ctx)
{ {
const WCHAR *arg = ctx->instr->arg1.bstr; const WCHAR *arg = ctx->instr->arg1.bstr;

View File

@ -1277,11 +1277,11 @@ ok x(0) = 2, "x(0) = " & x(0)
x = Array(1) x = Array(1)
seta0 (x) seta0 (x)
todo_wine_ok x(0) = 1, "x(0) = " & x(0) ok x(0) = 1, "x(0) = " & x(0)
x = Array(1) x = Array(1)
call (((seta0))) ((x)) call (((seta0))) ((x))
todo_wine_ok x(0) = 1, "x(0) = " & x(0) ok x(0) = 1, "x(0) = " & x(0)
x = Array(1) x = Array(1)
call (((seta0))) (x) call (((seta0))) (x)
@ -1293,7 +1293,7 @@ call ok(x(0)(0) = 2, "x(0)(0) = " & x(0)(0))
x = Array(Array(3)) x = Array(Array(3))
seta0 (x(0)) seta0 (x(0))
call todo_wine_ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0)) call ok(x(0)(0) = 3, "x(0)(0) = " & x(0)(0))
y = (seta0)(x) y = (seta0)(x)
ok y = 1, "y = " & y ok y = 1, "y = " & y
@ -1311,7 +1311,7 @@ ok x(0) = 2, "x(0) = " & x(0)
x = Array(1) x = Array(1)
changearg (x(0)) changearg (x(0))
todo_wine_ok x(0) = 1, "x(0) = " & x(0) ok x(0) = 1, "x(0) = " & x(0)
Class ArrClass Class ArrClass
Dim classarr(3) Dim classarr(3)
@ -1377,7 +1377,7 @@ Call ok(arr(0) = "modified", "arr(0) = " & arr(0))
arr(0) = "not modified" arr(0) = "not modified"
modifyarr(arr) modifyarr(arr)
Call todo_wine_ok(arr(0) = "not modified", "arr(0) = " & arr(0)) Call ok(arr(0) = "not modified", "arr(0) = " & arr(0))
for x = 0 to UBound(arr) for x = 0 to UBound(arr)
arr(x) = x arr(x) = x

View File

@ -224,6 +224,7 @@ typedef enum {
X(case, 0, ARG_ADDR, 0) \ X(case, 0, ARG_ADDR, 0) \
X(concat, 1, 0, 0) \ X(concat, 1, 0, 0) \
X(const, 1, ARG_BSTR, 0) \ X(const, 1, ARG_BSTR, 0) \
X(deref, 1, 0, 0) \
X(dim, 1, ARG_BSTR, ARG_UINT) \ X(dim, 1, ARG_BSTR, ARG_UINT) \
X(div, 1, 0, 0) \ X(div, 1, 0, 0) \
X(double, 1, ARG_DOUBLE, 0) \ X(double, 1, ARG_DOUBLE, 0) \