winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
September 2011
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
996 discussions
Start a n
N
ew thread
Jacek Caban : vbscript: Added 'or' expression parser/ compiler implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: fae7352f93e35eaed32d486e1c91e3c15616f4e5 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=fae7352f93e35eaed32d486e1…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:59:26 2011 +0200 vbscript: Added 'or' expression parser/compiler implementation. --- dlls/vbscript/compile.c | 2 ++ dlls/vbscript/interp.c | 6 ++++++ dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 6 +++++- dlls/vbscript/vbscript.h | 1 + 5 files changed, 15 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 9b74bb7..8b75918 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -388,6 +388,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) return compile_unary_expression(ctx, (unary_expression_t*)expr, OP_not); case EXPR_NULL: return push_instr(ctx, OP_null) != -1 ? S_OK : E_OUTOFMEMORY; + case EXPR_OR: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_or); case EXPR_STRING: return push_instr_str(ctx, OP_string, ((string_expression_t*)expr)->value); case EXPR_SUB: diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index d5e0370..e55d328 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -588,6 +588,12 @@ static HRESULT interp_and(exec_ctx_t *ctx) return stack_push(ctx, &v); } +static HRESULT interp_or(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT cmp_oper(exec_ctx_t *ctx) { variant_val_t l, r; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index d61a5f0..b4a91c8 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -34,6 +34,7 @@ typedef enum { EXPR_NEQUAL, EXPR_NOT, EXPR_NULL, + EXPR_OR, EXPR_STRING, EXPR_SUB, EXPR_ULONG, diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 5c04681..48843e7 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -98,7 +98,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL); %type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression -%type <expression> NotExpression UnaryExpression AndExpression +%type <expression> NotExpression UnaryExpression AndExpression OrExpression %type <member> MemberExpression %type <expression> Arguments_opt ArgumentList_opt ArgumentList %type <bool> OptionExplicit_opt @@ -188,7 +188,11 @@ EmptyBrackets_opt | tEMPTYBRACKETS Expression + : OrExpression { $$ = $1; } + +OrExpression : AndExpression { $$ = $1; } + | OrExpression tOR AndExpression { $$ = new_binary_expression(ctx, EXPR_OR, $1, $3); CHECK_ERROR; } AndExpression : NotExpression { $$ = $1; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 1d2f95d..2a05998 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -139,6 +139,7 @@ typedef enum { X(nequal, 1, 0, 0) \ X(not, 1, 0, 0) \ X(null, 1, 0, 0) \ + X(or, 1, 0, 0) \ X(ret, 0, 0, 0) \ X(short, 1, ARG_INT, 0) \ X(string, 1, ARG_STR, 0) \
1
0
0
0
Jacek Caban : vbscript: Added interp_and implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 091f243051c80906f40edf544b0b1fab1f8a94fa URL:
http://source.winehq.org/git/wine.git/?a=commit;h=091f243051c80906f40edf544…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:59:14 2011 +0200 vbscript: Added interp_and implementation. --- dlls/vbscript/interp.c | 22 ++++++++++++++++++++-- dlls/vbscript/tests/lang.vbs | 5 +++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 5b57306..d5e0370 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -566,8 +566,26 @@ static HRESULT interp_not(exec_ctx_t *ctx) static HRESULT interp_and(exec_ctx_t *ctx) { - FIXME("\n"); - return E_NOTIMPL; + variant_val_t r, l; + VARIANT v; + HRESULT hres; + + TRACE("\n"); + + hres = stack_pop_val(ctx, &r); + if(FAILED(hres)) + return hres; + + hres = stack_pop_val(ctx, &l); + if(SUCCEEDED(hres)) { + hres = VarAnd(l.v, r.v, &v); + release_val(&l); + } + release_val(&r); + if(FAILED(hres)) + return hres; + + return stack_push(ctx, &v); } static HRESULT cmp_oper(exec_ctx_t *ctx) diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 10f03f0..69aeade 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -86,6 +86,11 @@ if(isEnglishLocale) then Call ok(true & false = "TrueFalse", "true & false = " & (true & false)) end if +call ok(true and true, "true and true is not true") +call ok(true and not false, "true and not false is not true") +call ok(not (false and true), "not (false and true) is not true") +call ok(getVT(null and true) = "VT_NULL", "getVT(null and true) = " & getVT(null and true)) + x = 3 Call ok(2+2 = 4, "2+2 = " & (2+2)) Call ok(false + 6 + true = 5, "false + 6 + true <> 5")
1
0
0
0
Jacek Caban : vbscript: Added 'and' expression parser/ compiler implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 69de07981a14cd74d44f98bc08034e5a4534a849 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=69de07981a14cd74d44f98bc0…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:59:02 2011 +0200 vbscript: Added 'and' expression parser/compiler implementation. --- dlls/vbscript/compile.c | 2 ++ dlls/vbscript/interp.c | 6 ++++++ dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 8 ++++++-- dlls/vbscript/vbscript.h | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 21b50bd..9b74bb7 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -356,6 +356,8 @@ static HRESULT compile_expression(compile_ctx_t *ctx, expression_t *expr) switch(expr->type) { case EXPR_ADD: return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_add); + case EXPR_AND: + return compile_binary_expression(ctx, (binary_expression_t*)expr, OP_and); case EXPR_BOOL: return push_instr_int(ctx, OP_bool, ((bool_expression_t*)expr)->value); case EXPR_CONCAT: diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 5c75a14..5b57306 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -564,6 +564,12 @@ static HRESULT interp_not(exec_ctx_t *ctx) return stack_push(ctx, &v); } +static HRESULT interp_and(exec_ctx_t *ctx) +{ + FIXME("\n"); + return E_NOTIMPL; +} + static HRESULT cmp_oper(exec_ctx_t *ctx) { variant_val_t l, r; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 6406fc2..d61a5f0 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -18,6 +18,7 @@ typedef enum { EXPR_ADD, + EXPR_AND, EXPR_BOOL, EXPR_CONCAT, EXPR_DIV, diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 870a665..5c04681 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -98,7 +98,7 @@ static arg_decl_t *new_argument_decl(parser_ctx_t*,const WCHAR*,BOOL); %type <statement> Statement StatementNl StatementsNl StatementsNl_opt IfStatement Else_opt %type <expression> Expression LiteralExpression PrimaryExpression EqualityExpression CallExpression %type <expression> ConcatExpression AdditiveExpression ModExpression IntdivExpression MultiplicativeExpression ExpExpression -%type <expression> NotExpression UnaryExpression +%type <expression> NotExpression UnaryExpression AndExpression %type <member> MemberExpression %type <expression> Arguments_opt ArgumentList_opt ArgumentList %type <bool> OptionExplicit_opt @@ -188,7 +188,11 @@ EmptyBrackets_opt | tEMPTYBRACKETS Expression - : NotExpression { $$ = $1; } + : AndExpression { $$ = $1; } + +AndExpression + : NotExpression { $$ = $1; } + | AndExpression tAND NotExpression { $$ = new_binary_expression(ctx, EXPR_AND, $1, $3); CHECK_ERROR; } NotExpression : EqualityExpression { $$ = $1; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 3fb57e4..1d2f95d 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -117,6 +117,7 @@ typedef enum { #define OP_LIST \ X(add, 1, 0, 0) \ + X(and, 1, 0, 0) \ X(assign_ident, 1, ARG_BSTR, 0) \ X(assign_member, 1, ARG_BSTR, 0) \ X(bool, 1, ARG_INT, 0) \
1
0
0
0
Jacek Caban : vbscript: Added support for returning value from function.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: f9edb683d260b2175da90e58119aa22ce98a7cd0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=f9edb683d260b2175da90e581…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:58:30 2011 +0200 vbscript: Added support for returning value from function. --- dlls/vbscript/interp.c | 29 +++++++++++++++++++++-------- dlls/vbscript/tests/lang.vbs | 17 +++++++++++++++++ dlls/vbscript/vbscript.h | 7 +++++++ 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index bb2c282..5c75a14 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -37,6 +37,8 @@ typedef struct { unsigned stack_size; unsigned top; VARIANT *stack; + + VARIANT ret_val; } exec_ctx_t; typedef HRESULT (*instr_func_t)(exec_ctx_t*); @@ -81,7 +83,7 @@ static BOOL lookup_dynamic_vars(dynamic_var_t *var, const WCHAR *name, ref_t *re return FALSE; } -static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref) +static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, vbdisp_invoke_type_t invoke_type, ref_t *ref) { named_item_t *item; function_t *func; @@ -89,6 +91,12 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref) DISPID id; HRESULT hres; + if(invoke_type == VBDISP_LET && ctx->func->type == FUNC_FUNCTION && !strcmpiW(name, ctx->func->name)) { + ref->type = REF_VAR; + ref->u.v = &ctx->ret_val; + return S_OK; + } + for(i=0; i < ctx->func->var_cnt; i++) { if(!strcmpiW(ctx->func->vars[i].name, name)) { ref->type = REF_VAR; @@ -259,7 +267,7 @@ static HRESULT do_icall(exec_ctx_t *ctx, VARIANT *res) DISPPARAMS dp; HRESULT hres; - hres = lookup_identifier(ctx, identifier, &ref); + hres = lookup_identifier(ctx, identifier, VBDISP_CALLGET, &ref); if(FAILED(hres)) return hres; @@ -324,7 +332,7 @@ static HRESULT assign_ident(exec_ctx_t *ctx, BSTR name, VARIANT *val, BOOL own_v ref_t ref; HRESULT hres; - hres = lookup_identifier(ctx, name, &ref); + hres = lookup_identifier(ctx, name, VBDISP_LET, &ref); if(FAILED(hres)) return hres; @@ -838,6 +846,8 @@ static void release_exec(exec_ctx_t *ctx) { unsigned i; + VariantClear(&ctx->ret_val); + if(ctx->args) { for(i=0; i < ctx->func->arg_cnt; i++) VariantClear(ctx->args+i); @@ -859,11 +869,6 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, DISPPARAMS *dp, VARIANT vbsop_t op; HRESULT hres = S_OK; - if(res) { - FIXME("returning value is not implemented\n"); - return E_NOTIMPL; - } - exec.code = func->code_ctx; if(dp ? func->arg_cnt != arg_cnt(dp) : func->arg_cnt) { @@ -935,6 +940,14 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, DISPPARAMS *dp, VARIANT } assert(!exec.top); + if(func->type != FUNC_FUNCTION) + assert(V_VT(&exec.ret_val) == VT_EMPTY); + + if(SUCCEEDED(hres) && res) { + *res = exec.ret_val; + V_VT(&exec.ret_val) = VT_EMPTY; + } + release_exec(&exec); return hres; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 93af6b6..10f03f0 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -313,4 +313,21 @@ End Function Call TestFuncExit(true) +Function ReturnTrue + ReturnTrue = false + ReturnTrue = true +End Function + +Call ok(ReturnTrue(), "ReturnTrue returned false?") + +Function SetVal(ByRef x, ByVal v) + x = v + SetVal = x + Exit Function +End Function + +x = false +ok SetVal(x, true), "SetVal returned false?" +Call ok(x, "x is not set to true by SetVal?") + reportSuccess() diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 5e86176..3fb57e4 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -61,6 +61,13 @@ typedef struct { LONG ref; } vbdisp_t; +typedef enum { + VBDISP_CALLGET, + VBDISP_LET, + VBDISP_SET, + VBDISP_ANY +} vbdisp_invoke_type_t; + HRESULT disp_get_id(IDispatch*,BSTR,DISPID*); HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*,VARIANT*); HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,VARIANT*);
1
0
0
0
Jacek Caban : vbscript: Added Exit Function statement implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 1cefcdb6b7085f23c17dcddd1e928ec26ebd867b URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1cefcdb6b7085f23c17dcddd1…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:58:10 2011 +0200 vbscript: Added Exit Function statement implementation. --- dlls/vbscript/compile.c | 23 ++++++++++++++++++++++- dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 1 + dlls/vbscript/tests/lang.vbs | 9 +++++++++ 4 files changed, 33 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index a4608be..21b50bd 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -39,6 +39,7 @@ typedef struct { unsigned labels_cnt; unsigned sub_end_label; + unsigned func_end_label; dim_decl_t *dim_decls; dynamic_var_t *global_vars; @@ -555,6 +556,16 @@ static HRESULT compile_exitsub_statement(compile_ctx_t *ctx) return push_instr_addr(ctx, OP_jmp, ctx->sub_end_label); } +static HRESULT compile_exitfunc_statement(compile_ctx_t *ctx) +{ + if(ctx->func_end_label == -1) { + FIXME("Exit Function outside Function?\n"); + return E_FAIL; + } + + return push_instr_addr(ctx, OP_jmp, ctx->func_end_label); +} + static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) { HRESULT hres; @@ -570,6 +581,9 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) case STAT_DIM: hres = compile_dim_statement(ctx, (dim_statement_t*)stat); break; + case STAT_EXITFUNC: + hres = compile_exitfunc_statement(ctx); + break; case STAT_EXITSUB: hres = compile_exitsub_statement(ctx); break; @@ -614,14 +628,19 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f func->code_off = ctx->instr_cnt; ctx->sub_end_label = -1; + ctx->func_end_label = -1; switch(func->type) { + case FUNC_FUNCTION: + ctx->func_end_label = alloc_label(ctx); + if(ctx->func_end_label == -1) + return E_OUTOFMEMORY; /* FIXME ! */ + break; case FUNC_SUB: ctx->sub_end_label = alloc_label(ctx); if(ctx->sub_end_label == -1) return E_OUTOFMEMORY; break; - case FUNC_FUNCTION: /* FIXME */ case FUNC_GLOBAL: break; } @@ -635,6 +654,8 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f if(ctx->sub_end_label != -1) label_set_addr(ctx, ctx->sub_end_label); + if(ctx->func_end_label != -1) + label_set_addr(ctx, ctx->func_end_label); if(push_instr(ctx, OP_ret) == -1) return E_OUTOFMEMORY; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 69eca61..6406fc2 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -86,6 +86,7 @@ typedef enum { STAT_ASSIGN, STAT_CALL, STAT_DIM, + STAT_EXITFUNC, STAT_EXITSUB, STAT_FUNC, STAT_IF diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 36edc02..870a665 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -139,6 +139,7 @@ Statement | tDIM DimDeclList { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; } | IfStatement { $$ = $1; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } + | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; } | tEXIT tSUB { $$ = new_statement(ctx, STAT_EXITSUB, 0); CHECK_ERROR; } MemberExpression diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 5f47360..93af6b6 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -304,4 +304,13 @@ y = true Call TestFuncLocalVal Call ok(x, "global x is not true?") +Function TestFuncExit(ByRef a) + If a Then + Exit Function + End If + Call ok(false, "Exit Function not called?") +End Function + +Call TestFuncExit(true) + reportSuccess()
1
0
0
0
Jacek Caban : vbscript: Added function parser implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 78957118fb91c3fc4aecb6ec19f1225f796f9d2f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=78957118fb91c3fc4aecb6ec1…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 16:55:51 2011 +0200 vbscript: Added function parser implementation. --- dlls/vbscript/compile.c | 2 + dlls/vbscript/parser.y | 2 + dlls/vbscript/tests/lang.vbs | 63 ++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/tests/vbscript.c | 3 -- dlls/vbscript/vbscript.h | 1 + 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index dd756b3..a4608be 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -621,6 +621,7 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f if(ctx->sub_end_label == -1) return E_OUTOFMEMORY; break; + case FUNC_FUNCTION: /* FIXME */ case FUNC_GLOBAL: break; } @@ -833,6 +834,7 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ret->bstr_pool = NULL; ret->bstr_pool_size = 0; ret->bstr_cnt = 0; + ret->global_executed = FALSE; ret->global_code.type = FUNC_GLOBAL; ret->global_code.name = NULL; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index f406f8e..36edc02 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -253,6 +253,8 @@ PrimaryExpression FunctionDecl : /* Storage_opt */ tSUB tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tSUB { $$ = new_function_decl(ctx, $2, FUNC_SUB, $3, $5); CHECK_ERROR; } + | /* Storage_opt */ tFUNCTION tIdentifier ArgumentsDecl_opt tNL StatementsNl_opt tEND tFUNCTION + { $$ = new_function_decl(ctx, $2, FUNC_FUNCTION, $3, $5); CHECK_ERROR; } ArgumentsDecl_opt : EmptyBrackets_opt { $$ = NULL; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index a46394b..5f47360 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -241,4 +241,67 @@ y = true Call TestSubLocalVal Call ok(x, "global x is not true?") +if false then +Function testfunc + x = true +End Function +end if + +x = false +Call TestFunc +Call ok(x, "x is false, testfunc not called?") + +Function FuncSetTrue(v) + Call ok(not v, "v is not true") + v = true +End Function + +x = false +FuncSetTrue x +Call ok(x, "x was not set by FuncSetTrue") + +FuncSetTrue false +Call ok(not false, "false is no longer false?") + +Function FuncSetTrue2(ByRef v) + Call ok(not v, "v is not true") + v = true +End Function + +x = false +FuncSetTrue2 x +Call ok(x, "x was not set by FuncSetTrue") + +Function TestFuncArgVal(ByVal v) + Call ok(not v, "v is not false") + v = true + Call ok(v, "v is not true?") +End Function + +x = false +Call TestFuncArgVal(x) +Call ok(not x, "x is true after TestFuncArgVal call?") + +Function TestFuncMultiArgs(a,b,c,d,e) + Call ok(a=1, "a = " & a) + Call ok(b=2, "b = " & b) + Call ok(c=3, "c = " & c) + Call ok(d=4, "d = " & d) + Call ok(e=5, "e = " & e) +End Function + +TestFuncMultiArgs 1, 2, 3, 4, 5 +Call TestFuncMultiArgs(1, 2, 3, 4, 5) + +Function TestFuncLocalVal + x = false + Call ok(not x, "local x is not false?") + Dim x +End Function + +x = true +y = true +Call TestFuncLocalVal +Call ok(x, "global x is not true?") + reportSuccess() diff --git a/dlls/vbscript/tests/vbscript.c b/dlls/vbscript/tests/vbscript.c index ab5c8af..6ead8f4 100644 --- a/dlls/vbscript/tests/vbscript.c +++ b/dlls/vbscript/tests/vbscript.c @@ -412,7 +412,6 @@ static void test_vbscript_uninitializing(void) test_state(script, SCRIPTSTATE_INITIALIZED); hres = IActiveScriptParse64_ParseScriptText(parse, script_textW, NULL, NULL, NULL, 0, 1, 0x42, NULL, NULL); - todo_wine ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite); @@ -441,9 +440,7 @@ static void test_vbscript_uninitializing(void) hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED); ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres); CHECK_CALLED(OnStateChange_CONNECTED); - todo_wine CHECK_CALLED(OnEnterScript); - todo_wine CHECK_CALLED(OnLeaveScript); test_state(script, SCRIPTSTATE_CONNECTED); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index cf625cc..5e86176 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -164,6 +164,7 @@ typedef struct { typedef enum { FUNC_GLOBAL, + FUNC_FUNCTION, FUNC_SUB } function_type_t;
1
0
0
0
Jacek Caban : vbscript: Added support for sub local variables.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 0b9b021aa3f3a9412f588d8a25f72bb9a7f524d7 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=0b9b021aa3f3a9412f588d8a2…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:57:37 2011 +0200 vbscript: Added support for sub local variables. --- dlls/vbscript/compile.c | 37 ++++++++++++++++++++++++++++++++++--- dlls/vbscript/interp.c | 29 +++++++++++++++++++++++++++-- dlls/vbscript/tests/lang.vbs | 11 +++++++++++ dlls/vbscript/vbscript.h | 6 ++++++ 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 84a97a7..dd756b3 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -500,12 +500,24 @@ static BOOL lookup_dim_decls(compile_ctx_t *ctx, const WCHAR *name) return FALSE; } +static BOOL lookup_args_name(compile_ctx_t *ctx, const WCHAR *name) +{ + unsigned i; + + for(i = 0; i < ctx->func->arg_cnt; i++) { + if(!strcmpiW(ctx->func->args[i].name, name)) + return TRUE; + } + + return FALSE; +} + static HRESULT compile_dim_statement(compile_ctx_t *ctx, dim_statement_t *stat) { dim_decl_t *dim_decl = stat->dim_decls; while(1) { - if(lookup_dim_decls(ctx, dim_decl->name)) { + if(lookup_dim_decls(ctx, dim_decl->name) || lookup_args_name(ctx, dim_decl->name)) { FIXME("dim %s name redefined\n", debugstr_w(dim_decl->name)); return E_FAIL; } @@ -517,6 +529,7 @@ static HRESULT compile_dim_statement(compile_ctx_t *ctx, dim_statement_t *stat) dim_decl->next = ctx->dim_decls; ctx->dim_decls = stat->dim_decls; + ctx->func->var_cnt++; return S_OK; } @@ -627,12 +640,14 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f resolve_labels(ctx, func->code_off); - if(ctx->dim_decls) { + if(func->var_cnt) { dim_decl_t *dim_decl; if(func->type == FUNC_GLOBAL) { dynamic_var_t *new_var; + func->var_cnt = 0; + for(dim_decl = ctx->dim_decls; dim_decl; dim_decl = dim_decl->next) { new_var = compiler_alloc(ctx->code, sizeof(*new_var)); if(!new_var) @@ -648,7 +663,19 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f ctx->global_vars = new_var; } }else { - FIXME("var not implemented for functions\n"); + unsigned i; + + func->vars = compiler_alloc(ctx->code, func->var_cnt * sizeof(var_desc_t)); + if(!func->vars) + return E_OUTOFMEMORY; + + for(dim_decl = ctx->dim_decls, i=0; dim_decl; dim_decl = dim_decl->next, i++) { + func->vars[i].name = compiler_alloc_string(ctx->code, dim_decl->name); + if(!func->vars[i].name) + return E_OUTOFMEMORY; + } + + assert(i == func->var_cnt); } } @@ -685,6 +712,8 @@ static HRESULT create_function(compile_ctx_t *ctx, function_decl_t *decl, functi if(!func->name) return E_OUTOFMEMORY; + func->vars = NULL; + func->var_cnt = 0; func->code_ctx = ctx->code; func->type = decl->type; @@ -808,6 +837,8 @@ static vbscode_t *alloc_vbscode(compile_ctx_t *ctx, const WCHAR *source) ret->global_code.type = FUNC_GLOBAL; ret->global_code.name = NULL; ret->global_code.code_ctx = ret; + ret->global_code.vars = NULL; + ret->global_code.var_cnt = 0; ret->global_code.arg_cnt = 0; ret->global_code.args = NULL; diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 9dbce68..bb2c282 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -32,6 +32,7 @@ typedef struct { function_t *func; VARIANT *args; + VARIANT *vars; unsigned stack_size; unsigned top; @@ -88,6 +89,14 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref) DISPID id; HRESULT hres; + for(i=0; i < ctx->func->var_cnt; i++) { + if(!strcmpiW(ctx->func->vars[i].name, name)) { + ref->type = REF_VAR; + ref->u.v = ctx->vars+i; + return TRUE; + } + } + for(i=0; i < ctx->func->arg_cnt; i++) { if(!strcmpiW(ctx->func->args[i].name, name)) { ref->type = REF_VAR; @@ -827,14 +836,20 @@ OP_LIST static void release_exec(exec_ctx_t *ctx) { - if(ctx->args) { - unsigned i; + unsigned i; + if(ctx->args) { for(i=0; i < ctx->func->arg_cnt; i++) VariantClear(ctx->args+i); } + if(ctx->vars) { + for(i=0; i < ctx->func->var_cnt; i++) + VariantClear(ctx->vars+i); + } + heap_free(ctx->args); + heap_free(ctx->vars); heap_free(ctx->stack); } @@ -885,6 +900,16 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, DISPPARAMS *dp, VARIANT exec.args = NULL; } + if(func->var_cnt) { + exec.vars = heap_alloc_zero(func->var_cnt * sizeof(VARIANT)); + if(!exec.vars) { + release_exec(&exec); + return E_OUTOFMEMORY; + } + }else { + exec.vars = NULL; + } + exec.stack_size = 16; exec.top = 0; exec.stack = heap_alloc(exec.stack_size * sizeof(VARIANT)); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 1140326..a46394b 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -230,4 +230,15 @@ Call TestSubExit(true) TestSubMultiArgs 1, 2, 3, 4, 5 Call TestSubMultiArgs(1, 2, 3, 4, 5) +Sub TestSubLocalVal + x = false + Call ok(not x, "local x is not false?") + Dim x +End Sub + +x = true +y = true +Call TestSubLocalVal +Call ok(x, "global x is not true?") + reportSuccess() diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 1362d9e..cf625cc 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -167,11 +167,17 @@ typedef enum { FUNC_SUB } function_type_t; +typedef struct { + const WCHAR *name; +} var_desc_t; + struct _function_t { function_type_t type; const WCHAR *name; arg_desc_t *args; unsigned arg_cnt; + var_desc_t *vars; + unsigned var_cnt; unsigned code_off; vbscode_t *code_ctx; function_t *next;
1
0
0
0
Jacek Caban : vbscript: Added exit sub statement implementation.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: d04ba41aa97f5e00ca4b1e05ecbc520a6491343e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=d04ba41aa97f5e00ca4b1e05e…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:57:27 2011 +0200 vbscript: Added exit sub statement implementation. --- dlls/vbscript/compile.c | 30 ++++++++++++++++++++++++++++++ dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 6 ++++-- dlls/vbscript/tests/lang.vbs | 9 +++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 386caf7..84a97a7 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -38,6 +38,8 @@ typedef struct { unsigned labels_size; unsigned labels_cnt; + unsigned sub_end_label; + dim_decl_t *dim_decls; dynamic_var_t *global_vars; @@ -530,6 +532,16 @@ static HRESULT compile_function_statement(compile_ctx_t *ctx, function_statement return S_OK; } +static HRESULT compile_exitsub_statement(compile_ctx_t *ctx) +{ + if(ctx->sub_end_label == -1) { + FIXME("Exit Sub outside Sub?\n"); + return E_FAIL; + } + + return push_instr_addr(ctx, OP_jmp, ctx->sub_end_label); +} + static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) { HRESULT hres; @@ -545,6 +557,9 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) case STAT_DIM: hres = compile_dim_statement(ctx, (dim_statement_t*)stat); break; + case STAT_EXITSUB: + hres = compile_exitsub_statement(ctx); + break; case STAT_FUNC: hres = compile_function_statement(ctx, (function_statement_t*)stat); break; @@ -585,6 +600,18 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f func->code_off = ctx->instr_cnt; + ctx->sub_end_label = -1; + + switch(func->type) { + case FUNC_SUB: + ctx->sub_end_label = alloc_label(ctx); + if(ctx->sub_end_label == -1) + return E_OUTOFMEMORY; + break; + case FUNC_GLOBAL: + break; + } + ctx->func = func; ctx->dim_decls = NULL; hres = compile_statement(ctx, stat); @@ -592,6 +619,9 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f if(FAILED(hres)) return hres; + if(ctx->sub_end_label != -1) + label_set_addr(ctx, ctx->sub_end_label); + if(push_instr(ctx, OP_ret) == -1) return E_OUTOFMEMORY; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 9b837c2..69eca61 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -86,6 +86,7 @@ typedef enum { STAT_ASSIGN, STAT_CALL, STAT_DIM, + STAT_EXITSUB, STAT_FUNC, STAT_IF } statement_type_t; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 4964d71..f406f8e 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -45,6 +45,7 @@ static expression_t *new_binary_expression(parser_ctx_t*,expression_type_t,expre static member_expression_t *new_member_expression(parser_ctx_t*,expression_t*,const WCHAR*); +static void *new_statement(parser_ctx_t*,statement_type_t,size_t); static statement_t *new_call_statement(parser_ctx_t*,member_expression_t*); static statement_t *new_assign_statement(parser_ctx_t*,member_expression_t*,expression_t*); static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*); @@ -138,6 +139,7 @@ Statement | tDIM DimDeclList { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; } | IfStatement { $$ = $1; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } + | tEXIT tSUB { $$ = new_statement(ctx, STAT_EXITSUB, 0); CHECK_ERROR; } MemberExpression : tIdentifier { $$ = new_member_expression(ctx, NULL, $1); CHECK_ERROR; } @@ -388,11 +390,11 @@ static member_expression_t *new_member_expression(parser_ctx_t *ctx, expression_ return expr; } -static void *new_statement(parser_ctx_t *ctx, statement_type_t type, unsigned size) +static void *new_statement(parser_ctx_t *ctx, statement_type_t type, size_t size) { statement_t *stat; - stat = parser_alloc(ctx, size); + stat = parser_alloc(ctx, size ? size : sizeof(*stat)); if(stat) { stat->type = type; stat->next = NULL; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 100f93b..1140326 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -218,6 +218,15 @@ Sub TestSubMultiArgs(a,b,c,d,e) Call ok(e=5, "e = " & e) End Sub +Sub TestSubExit(ByRef a) + If a Then + Exit Sub + End If + Call ok(false, "Exit Sub not called?") +End Sub + +Call TestSubExit(true) + TestSubMultiArgs 1, 2, 3, 4, 5 Call TestSubMultiArgs(1, 2, 3, 4, 5)
1
0
0
0
Jacek Caban : vbscript: Added sub argument tests.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: 1936dd7ee79a5f3a38c38e528f467883e0770aeb URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1936dd7ee79a5f3a38c38e528…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:57:14 2011 +0200 vbscript: Added sub argument tests. --- dlls/vbscript/tests/lang.vbs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 0c4c10f..100f93b 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -179,4 +179,46 @@ x = false Call testsub Call ok(x, "x is false, testsub not called?") +Sub SubSetTrue(v) + Call ok(not v, "v is not true") + v = true +End Sub + +x = false +SubSetTrue x +Call ok(x, "x was not set by SubSetTrue") + +SubSetTrue false +Call ok(not false, "false is no longer false?") + +Sub SubSetTrue2(ByRef v) + Call ok(not v, "v is not true") + v = true +End Sub + +x = false +SubSetTrue2 x +Call ok(x, "x was not set by SubSetTrue") + +Sub TestSubArgVal(ByVal v) + Call ok(not v, "v is not false") + v = true + Call ok(v, "v is not true?") +End Sub + +x = false +Call TestSubArgVal(x) +Call ok(not x, "x is true after TestSubArgVal call?") + +Sub TestSubMultiArgs(a,b,c,d,e) + Call ok(a=1, "a = " & a) + Call ok(b=2, "b = " & b) + Call ok(c=3, "c = " & c) + Call ok(d=4, "d = " & d) + Call ok(e=5, "e = " & e) +End Sub + +TestSubMultiArgs 1, 2, 3, 4, 5 +Call TestSubMultiArgs(1, 2, 3, 4, 5) + reportSuccess()
1
0
0
0
Jacek Caban : vbscript: Added interpreter support for sub arguments.
by Alexandre Julliard
14 Sep '11
14 Sep '11
Module: wine Branch: master Commit: c846a5925b7571a6a8ba1db4d651884c779ab813 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c846a5925b7571a6a8ba1db4d…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Wed Sep 14 12:56:45 2011 +0200 vbscript: Added interpreter support for sub arguments. --- dlls/vbscript/interp.c | 70 +++++++++++++++++++++++++++++++++++++++++---- dlls/vbscript/vbscript.h | 5 +++ 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index b697988..9dbce68 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -31,6 +31,8 @@ typedef struct { script_ctx_t *script; function_t *func; + VARIANT *args; + unsigned stack_size; unsigned top; VARIANT *stack; @@ -82,9 +84,18 @@ static HRESULT lookup_identifier(exec_ctx_t *ctx, BSTR name, ref_t *ref) { named_item_t *item; function_t *func; + unsigned i; DISPID id; HRESULT hres; + for(i=0; i < ctx->func->arg_cnt; i++) { + if(!strcmpiW(ctx->func->args[i].name, name)) { + ref->type = REF_VAR; + ref->u.v = ctx->args+i; + return S_OK; + } + } + if(lookup_dynamic_vars(ctx->script->global_vars, name, ref)) return S_OK; @@ -814,9 +825,22 @@ OP_LIST #undef X }; +static void release_exec(exec_ctx_t *ctx) +{ + if(ctx->args) { + unsigned i; + + for(i=0; i < ctx->func->arg_cnt; i++) + VariantClear(ctx->args+i); + } + + heap_free(ctx->args); + heap_free(ctx->stack); +} + HRESULT exec_script(script_ctx_t *ctx, function_t *func, DISPPARAMS *dp, VARIANT *res) { - exec_ctx_t exec; + exec_ctx_t exec = {func->code_ctx}; vbsop_t op; HRESULT hres = S_OK; @@ -825,18 +849,50 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, DISPPARAMS *dp, VARIANT return E_NOTIMPL; } - if(dp && arg_cnt(dp)) { - FIXME("arguments not implemented\n"); - return E_NOTIMPL; + exec.code = func->code_ctx; + + if(dp ? func->arg_cnt != arg_cnt(dp) : func->arg_cnt) { + FIXME("wrong arg_cnt %d, expected %d\n", dp ? arg_cnt(dp) : 0, func->arg_cnt); + return E_FAIL; + } + + if(func->arg_cnt) { + VARIANT *v; + unsigned i; + + exec.args = heap_alloc_zero(func->arg_cnt * sizeof(VARIANT)); + if(!exec.args) { + release_exec(&exec); + return E_OUTOFMEMORY; + } + + for(i=0; i < func->arg_cnt; i++) { + v = get_arg(dp, i); + if(V_VT(v) == (VT_VARIANT|VT_BYREF)) { + if(func->args[i].by_ref) + exec.args[i] = *v; + else + hres = VariantCopy(exec.args+i, V_VARIANTREF(v)); + }else { + hres = VariantCopy(exec.args+i, v); + } + if(FAILED(hres)) { + release_exec(&exec); + return hres; + } + } + }else { + exec.args = NULL; } exec.stack_size = 16; exec.top = 0; exec.stack = heap_alloc(exec.stack_size * sizeof(VARIANT)); - if(!exec.stack) + if(!exec.stack) { + release_exec(&exec); return E_OUTOFMEMORY; + } - exec.code = func->code_ctx; exec.instr = exec.code->instrs + func->code_off; exec.script = ctx; exec.func = func; @@ -854,7 +910,7 @@ HRESULT exec_script(script_ctx_t *ctx, function_t *func, DISPPARAMS *dp, VARIANT } assert(!exec.top); - heap_free(exec.stack); + release_exec(&exec); return hres; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 0e6d57e..1362d9e 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -70,6 +70,11 @@ static inline unsigned arg_cnt(const DISPPARAMS *dp) return dp->cArgs - dp->cNamedArgs; } +static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i) +{ + return dp->rgvarg + dp->cArgs-i-1; +} + typedef struct _dynamic_var_t { struct _dynamic_var_t *next; VARIANT v;
1
0
0
0
← Newer
1
...
46
47
48
49
50
51
52
...
100
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Results per page:
10
25
50
100
200