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 do..while and do.. until statements implementation.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 004210f1fb4abe85fd62a37a915696b66502a372 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=004210f1fb4abe85fd62a37a9…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:30:39 2011 +0200 vbscript: Added do..while and do..until statements implementation. --- dlls/vbscript/compile.c | 34 +++++++++++++++++++++++++++++++++- dlls/vbscript/parse.h | 2 ++ dlls/vbscript/parser.y | 3 +++ dlls/vbscript/tests/lang.vbs | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 5737676..1ff3c40 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -211,7 +211,7 @@ static BSTR alloc_bstr_arg(compile_ctx_t *ctx, const WCHAR *str) return NULL; ctx->code->bstr_pool_size = 8; }else if(ctx->code->bstr_pool_size == ctx->code->bstr_cnt) { - BSTR *new_pool; + BSTR *new_pool; new_pool = heap_realloc(ctx->code->bstr_pool, ctx->code->bstr_pool_size*2*sizeof(BSTR)); if(!new_pool) @@ -524,6 +524,34 @@ static HRESULT compile_while_statement(compile_ctx_t *ctx, while_statement_t *st return S_OK; } +static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t *stat) +{ + unsigned start_addr, prev_label; + HRESULT hres; + + start_addr = ctx->instr_cnt; + + prev_label = ctx->while_end_label; + if((ctx->while_end_label = alloc_label(ctx)) == -1) + return E_OUTOFMEMORY; + + hres = compile_statement(ctx, stat->body); + if(FAILED(hres)) + return hres; + + hres = compile_expression(ctx, stat->expr); + if(FAILED(hres)) + return hres; + + hres = push_instr_addr(ctx, stat->stat.type == STAT_DOUNTIL ? OP_jmp_false : OP_jmp_true, start_addr); + if(FAILED(hres)) + return hres; + + label_set_addr(ctx, ctx->while_end_label); + ctx->while_end_label = prev_label; + return S_OK; +} + static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat, BOOL is_set) { HRESULT hres; @@ -662,6 +690,10 @@ 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_DOWHILE: + case STAT_DOUNTIL: + hres = compile_dowhile_statement(ctx, (while_statement_t*)stat); + break; case STAT_EXITDO: hres = compile_exitdo_statement(ctx); break; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 624e49f..d121b72 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -93,6 +93,8 @@ typedef enum { STAT_ASSIGN, STAT_CALL, STAT_DIM, + STAT_DOUNTIL, + STAT_DOWHILE, STAT_EXITDO, STAT_EXITFUNC, STAT_EXITPROP, diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 820ae6c..b1b385b 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -159,6 +159,9 @@ Statement | tDO DoType Expression tNL StatementsNl_opt tLOOP { $$ = new_while_statement(ctx, $2 ? STAT_WHILELOOP : STAT_UNTIL, $3, $5); CHECK_ERROR; } + | tDO tNL StatementsNl_opt tLOOP DoType Expression + { $$ = new_while_statement(ctx, $5 ? STAT_DOWHILE : STAT_DOUNTIL, $6, $3); + CHECK_ERROR; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } | tEXIT tDO { $$ = new_statement(ctx, STAT_EXITDO, 0); CHECK_ERROR; } | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 8b1d1c3..c62f17f 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -248,6 +248,42 @@ do until false ok false, "exit do didn't work" loop +x = false +y = false +do + if x then + y = true + end if + x = true +loop until x and y +call ok((x and y), "x or y is false after while") + +do +loop until true + +do + exit do + ok false, "exit do didn't work" +loop until false + +x = false +y = false +do + if x then + y = true + end if + x = true +loop while not (x and y) +call ok((x and y), "x or y is false after while") + +do +loop while false + +do + exit do + ok false, "exit do didn't work" +loop while true + if false then Sub testsub x = true
1
0
0
0
Jacek Caban : vbscript: Added do until..loop statement implementation.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 223a407a7fd399a983d93b8ea10da821bb7f24b0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=223a407a7fd399a983d93b8ea…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:30:31 2011 +0200 vbscript: Added do until..loop statement implementation. --- dlls/vbscript/compile.c | 3 ++- dlls/vbscript/interp.c | 25 +++++++++++++++++++++++++ dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 11 ++++++++--- dlls/vbscript/tests/lang.vbs | 18 ++++++++++++++++++ dlls/vbscript/vbscript.h | 1 + 6 files changed, 55 insertions(+), 4 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 61854e3..5737676 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -496,7 +496,7 @@ static HRESULT compile_while_statement(compile_ctx_t *ctx, while_statement_t *st if(FAILED(hres)) return hres; - jmp_end = push_instr(ctx, OP_jmp_false); + jmp_end = push_instr(ctx, stat->stat.type == STAT_UNTIL ? OP_jmp_true : OP_jmp_false); if(jmp_end == -1) return E_OUTOFMEMORY; @@ -686,6 +686,7 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) case STAT_STOP: hres = push_instr(ctx, OP_stop) == -1 ? E_OUTOFMEMORY : S_OK; break; + case STAT_UNTIL: case STAT_WHILE: case STAT_WHILELOOP: hres = compile_while_statement(ctx, (while_statement_t*)stat); diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 474957c..c8e0514 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -611,6 +611,31 @@ static HRESULT interp_jmp_false(exec_ctx_t *ctx) return S_OK; } +static HRESULT interp_jmp_true(exec_ctx_t *ctx) +{ + const unsigned arg = ctx->instr->arg1.uint; + variant_val_t val; + HRESULT hres; + + TRACE("%u\n", arg); + + hres = stack_pop_val(ctx, &val); + if(FAILED(hres)) + return hres; + + if(V_VT(val.v) != VT_BOOL) { + FIXME("unsupported for %s\n", debugstr_variant(val.v)); + release_val(&val); + return E_NOTIMPL; + } + + if(V_BOOL(val.v)) + instr_jmp(ctx, ctx->instr->arg1.uint); + else + ctx->instr++; + return S_OK; +} + static HRESULT interp_ret(exec_ctx_t *ctx) { TRACE("\n"); diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 5e9c9ae..624e49f 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -101,6 +101,7 @@ typedef enum { STAT_IF, STAT_SET, STAT_STOP, + STAT_UNTIL, STAT_WHILE, STAT_WHILELOOP } statement_type_t; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index 1bd8f58..820ae6c 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -114,7 +114,7 @@ static class_decl_t *add_variant_prop(parser_ctx_t*,class_decl_t*,const WCHAR*,u %type <expression> NotExpression UnaryExpression AndExpression OrExpression XorExpression EqvExpression %type <member> MemberExpression %type <expression> Arguments_opt ArgumentList_opt ArgumentList -%type <bool> OptionExplicit_opt +%type <bool> OptionExplicit_opt DoType %type <arg_decl> ArgumentsDecl_opt ArgumentDeclList ArgumentDecl %type <func_decl> FunctionDecl PropertyDecl %type <elseif> ElseIfs_opt ElseIfs ElseIf @@ -156,8 +156,9 @@ Statement | IfStatement { $$ = $1; } | tWHILE Expression tNL StatementsNl_opt tWEND { $$ = new_while_statement(ctx, STAT_WHILE, $2, $4); CHECK_ERROR; } - | tDO tWHILE Expression tNL StatementsNl_opt tLOOP - { $$ = new_while_statement(ctx, STAT_WHILELOOP, $3, $5); CHECK_ERROR; } + | tDO DoType Expression tNL StatementsNl_opt tLOOP + { $$ = new_while_statement(ctx, $2 ? STAT_WHILELOOP : STAT_UNTIL, $3, $5); + CHECK_ERROR; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } | tEXIT tDO { $$ = new_statement(ctx, STAT_EXITDO, 0); CHECK_ERROR; } | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; } @@ -175,6 +176,10 @@ DimDeclList /* FIXME: Support arrays */ : tIdentifier { $$ = new_dim_decl(ctx, $1, NULL); CHECK_ERROR; } | tIdentifier ',' DimDeclList { $$ = new_dim_decl(ctx, $1, $3); CHECK_ERROR; } +DoType + : tWHILE { $$ = TRUE; } + | tUNTIL { $$ = FALSE; } + IfStatement : tIF Expression tTHEN tNL StatementsNl ElseIfs_opt Else_opt tEND tIF { $$ = new_if_statement(ctx, $2, $5, $6, $7); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 78083e6..8b1d1c3 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -230,6 +230,24 @@ do while true ok false, "exit do didn't work" loop +x = false +y = false +do until x and y + if x then + y = true + end if + x = true +loop +call ok((x and y), "x or y is false after do until") + +do until true +loop + +do until false + exit do + ok false, "exit do didn't work" +loop + if false then Sub testsub x = true diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index a2c23ea..12315ae 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -167,6 +167,7 @@ typedef enum { X(imp, 1, 0, 0) \ X(jmp, 0, ARG_ADDR, 0) \ X(jmp_false, 0, ARG_ADDR, 0) \ + X(jmp_true, 0, ARG_ADDR, 0) \ X(long, 1, ARG_INT, 0) \ X(mcall, 1, ARG_BSTR, ARG_UINT) \ X(mcallv, 1, ARG_BSTR, ARG_UINT) \
1
0
0
0
Jacek Caban : vbscript: Added support for exit do statement.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 9701bdb563046b1f7fa535882b4629c4b7417b11 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=9701bdb563046b1f7fa535882…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:30:20 2011 +0200 vbscript: Added support for exit do statement. --- dlls/vbscript/compile.c | 31 ++++++++++++++++++++++++++++++- dlls/vbscript/parse.h | 1 + dlls/vbscript/parser.y | 1 + dlls/vbscript/tests/lang.vbs | 5 +++++ 4 files changed, 37 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index e29513b..61854e3 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -38,6 +38,7 @@ typedef struct { unsigned labels_size; unsigned labels_cnt; + unsigned while_end_label; unsigned sub_end_label; unsigned func_end_label; unsigned prop_end_label; @@ -485,7 +486,7 @@ static HRESULT compile_if_statement(compile_ctx_t *ctx, if_statement_t *stat) static HRESULT compile_while_statement(compile_ctx_t *ctx, while_statement_t *stat) { - unsigned start_addr; + unsigned start_addr, prev_label; unsigned jmp_end; HRESULT hres; @@ -499,6 +500,12 @@ static HRESULT compile_while_statement(compile_ctx_t *ctx, while_statement_t *st if(jmp_end == -1) return E_OUTOFMEMORY; + if(stat->stat.type != STAT_WHILE) { + prev_label = ctx->while_end_label; + if((ctx->while_end_label = alloc_label(ctx)) == -1) + return E_OUTOFMEMORY; + } + hres = compile_statement(ctx, stat->body); if(FAILED(hres)) return hres; @@ -508,6 +515,12 @@ static HRESULT compile_while_statement(compile_ctx_t *ctx, while_statement_t *st return hres; instr_ptr(ctx, jmp_end)->arg1.uint = ctx->instr_cnt; + + if(stat->stat.type != STAT_WHILE) { + label_set_addr(ctx, ctx->while_end_label); + ctx->while_end_label = prev_label; + } + return S_OK; } @@ -594,6 +607,16 @@ static HRESULT compile_function_statement(compile_ctx_t *ctx, function_statement return S_OK; } +static HRESULT compile_exitdo_statement(compile_ctx_t *ctx) +{ + if(ctx->while_end_label == -1) { + FIXME("Exit Do outside Do Loop\n"); + return E_FAIL; + } + + return push_instr_addr(ctx, OP_jmp, ctx->while_end_label); +} + static HRESULT compile_exitsub_statement(compile_ctx_t *ctx) { if(ctx->sub_end_label == -1) { @@ -639,6 +662,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_EXITDO: + hres = compile_exitdo_statement(ctx); + break; case STAT_EXITFUNC: hres = compile_exitfunc_statement(ctx); break; @@ -698,6 +724,7 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f func->code_off = ctx->instr_cnt; + ctx->while_end_label = -1; ctx->sub_end_label = -1; ctx->func_end_label = -1; ctx->prop_end_label = -1; @@ -732,6 +759,8 @@ static HRESULT compile_func(compile_ctx_t *ctx, statement_t *stat, function_t *f if(FAILED(hres)) return hres; + assert(ctx->while_end_label == -1); + if(ctx->sub_end_label != -1) label_set_addr(ctx, ctx->sub_end_label); if(ctx->func_end_label != -1) diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index ff8c137..5e9c9ae 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -93,6 +93,7 @@ typedef enum { STAT_ASSIGN, STAT_CALL, STAT_DIM, + STAT_EXITDO, STAT_EXITFUNC, STAT_EXITPROP, STAT_EXITSUB, diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index c73f368..1bd8f58 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -159,6 +159,7 @@ Statement | tDO tWHILE Expression tNL StatementsNl_opt tLOOP { $$ = new_while_statement(ctx, STAT_WHILELOOP, $3, $5); CHECK_ERROR; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } + | tEXIT tDO { $$ = new_statement(ctx, STAT_EXITDO, 0); CHECK_ERROR; } | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; } | tEXIT tPROPERTY { $$ = new_statement(ctx, STAT_EXITPROP, 0); CHECK_ERROR; } | tEXIT tSUB { $$ = new_statement(ctx, STAT_EXITSUB, 0); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index da1e5cb..78083e6 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -225,6 +225,11 @@ call ok((x and y), "x or y is false after while") do while false loop +do while true + exit do + ok false, "exit do didn't work" +loop + if false then Sub testsub x = true
1
0
0
0
Jacek Caban : vbscript: Added do while..loop statement implementation.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 1f5c56d1a85c3508e6ba271479c572da8aaf35dc URL:
http://source.winehq.org/git/wine.git/?a=commit;h=1f5c56d1a85c3508e6ba27147…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:30:09 2011 +0200 vbscript: Added do while..loop statement implementation. --- dlls/vbscript/compile.c | 1 + dlls/vbscript/parse.h | 3 ++- dlls/vbscript/parser.y | 2 ++ dlls/vbscript/tests/lang.vbs | 13 +++++++++++++ 4 files changed, 18 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 814d9ea..e29513b 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -661,6 +661,7 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) hres = push_instr(ctx, OP_stop) == -1 ? E_OUTOFMEMORY : S_OK; break; case STAT_WHILE: + case STAT_WHILELOOP: hres = compile_while_statement(ctx, (while_statement_t*)stat); break; default: diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index efd3d67..ff8c137 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -100,7 +100,8 @@ typedef enum { STAT_IF, STAT_SET, STAT_STOP, - STAT_WHILE + STAT_WHILE, + STAT_WHILELOOP } statement_type_t; typedef struct _statement_t { diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index d06c84f..c73f368 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -156,6 +156,8 @@ Statement | IfStatement { $$ = $1; } | tWHILE Expression tNL StatementsNl_opt tWEND { $$ = new_while_statement(ctx, STAT_WHILE, $2, $4); CHECK_ERROR; } + | tDO tWHILE Expression tNL StatementsNl_opt tLOOP + { $$ = new_while_statement(ctx, STAT_WHILELOOP, $3, $5); CHECK_ERROR; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; } | tEXIT tPROPERTY { $$ = new_statement(ctx, STAT_EXITPROP, 0); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index d3886d6..da1e5cb 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -212,6 +212,19 @@ call ok((x and y), "x or y is false after while") while false wend +x = false +y = false +do while not (x and y) + if x then + y = true + end if + x = true +loop +call ok((x and y), "x or y is false after while") + +do while false +loop + if false then Sub testsub x = true
1
0
0
0
Jacek Caban : vbscript: Added while..wend statement implementation.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 3d34925802b62238ae9360ac1e210955cf63de91 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=3d34925802b62238ae9360ac1…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:29:59 2011 +0200 vbscript: Added while..wend statement implementation. --- dlls/vbscript/compile.c | 31 +++++++++++++++++++++++++++++++ dlls/vbscript/parse.h | 9 ++++++++- dlls/vbscript/parser.y | 16 ++++++++++++++++ dlls/vbscript/tests/lang.vbs | 13 +++++++++++++ 4 files changed, 68 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 6bacaa0..814d9ea 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -483,6 +483,34 @@ static HRESULT compile_if_statement(compile_ctx_t *ctx, if_statement_t *stat) return S_OK; } +static HRESULT compile_while_statement(compile_ctx_t *ctx, while_statement_t *stat) +{ + unsigned start_addr; + unsigned jmp_end; + HRESULT hres; + + start_addr = ctx->instr_cnt; + + hres = compile_expression(ctx, stat->expr); + if(FAILED(hres)) + return hres; + + jmp_end = push_instr(ctx, OP_jmp_false); + if(jmp_end == -1) + return E_OUTOFMEMORY; + + hres = compile_statement(ctx, stat->body); + if(FAILED(hres)) + return hres; + + hres = push_instr_addr(ctx, OP_jmp, start_addr); + if(FAILED(hres)) + return hres; + + instr_ptr(ctx, jmp_end)->arg1.uint = ctx->instr_cnt; + return S_OK; +} + static HRESULT compile_assign_statement(compile_ctx_t *ctx, assign_statement_t *stat, BOOL is_set) { HRESULT hres; @@ -632,6 +660,9 @@ static HRESULT compile_statement(compile_ctx_t *ctx, statement_t *stat) case STAT_STOP: hres = push_instr(ctx, OP_stop) == -1 ? E_OUTOFMEMORY : S_OK; break; + case STAT_WHILE: + hres = compile_while_statement(ctx, (while_statement_t*)stat); + break; default: FIXME("Unimplemented statement type %d\n", stat->type); hres = E_NOTIMPL; diff --git a/dlls/vbscript/parse.h b/dlls/vbscript/parse.h index 245badc..efd3d67 100644 --- a/dlls/vbscript/parse.h +++ b/dlls/vbscript/parse.h @@ -99,7 +99,8 @@ typedef enum { STAT_FUNC, STAT_IF, STAT_SET, - STAT_STOP + STAT_STOP, + STAT_WHILE } statement_type_t; typedef struct _statement_t { @@ -177,6 +178,12 @@ typedef struct { } if_statement_t; typedef struct { + statement_t stat; + expression_t *expr; + statement_t *body; +} while_statement_t; + +typedef struct { const WCHAR *code; const WCHAR *ptr; const WCHAR *end; diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index adf1aba..d06c84f 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -52,6 +52,7 @@ 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_set_statement(parser_ctx_t*,member_expression_t*,expression_t*); static statement_t *new_dim_statement(parser_ctx_t*,dim_decl_t*); +static statement_t *new_while_statement(parser_ctx_t*,statement_type_t,expression_t*,statement_t*); static statement_t *new_if_statement(parser_ctx_t*,expression_t*,statement_t*,elseif_decl_t*,statement_t*); static statement_t *new_function_statement(parser_ctx_t*,function_decl_t*); @@ -153,6 +154,8 @@ Statement { $1->args = $2; $$ = new_assign_statement(ctx, $1, $4); CHECK_ERROR; } | tDIM DimDeclList { $$ = new_dim_statement(ctx, $2); CHECK_ERROR; } | IfStatement { $$ = $1; } + | tWHILE Expression tNL StatementsNl_opt tWEND + { $$ = new_while_statement(ctx, STAT_WHILE, $2, $4); CHECK_ERROR; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0); CHECK_ERROR; } | tEXIT tPROPERTY { $$ = new_statement(ctx, STAT_EXITPROP, 0); CHECK_ERROR; } @@ -565,6 +568,19 @@ static elseif_decl_t *new_elseif_decl(parser_ctx_t *ctx, expression_t *expr, sta return decl; } +static statement_t *new_while_statement(parser_ctx_t *ctx, statement_type_t type, expression_t *expr, statement_t *body) +{ + while_statement_t *stat; + + stat = new_statement(ctx, type, sizeof(*stat)); + if(!stat) + return NULL; + + stat->expr = expr; + stat->body = body; + return &stat->stat; +} + static statement_t *new_if_statement(parser_ctx_t *ctx, expression_t *expr, statement_t *if_stat, elseif_decl_t *elseif_decl, statement_t *else_stat) { diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 961eea2..d3886d6 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -199,6 +199,19 @@ ElseIf not False Then End If Call ok(x, "elseif not called?") +x = false +y = false +while not (x and y) + if x then + y = true + end if + x = true +wend +call ok((x and y), "x or y is false after while") + +while false +wend + if false then Sub testsub x = true
1
0
0
0
Jacek Caban : vbscript: Added GC implementation.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: a99dc8cb3dc2ff90f894c746f17ea7b5d7e8c13f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a99dc8cb3dc2ff90f894c746f…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:29:47 2011 +0200 vbscript: Added GC implementation. --- dlls/vbscript/tests/run.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ dlls/vbscript/vbdisp.c | 24 ++++++++++++++++++ dlls/vbscript/vbscript.c | 3 ++ dlls/vbscript/vbscript.h | 3 ++ 4 files changed, 89 insertions(+), 0 deletions(-) diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 3fee711..9aba091 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -884,6 +884,8 @@ static HRESULT parse_script(DWORD flags, BSTR script_str) hres = IActiveScriptParse64_ParseScriptText(parser, script_str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); + IActiveScript_Close(engine); + IDispatch_Release(script_disp); IActiveScript_Release(engine); IUnknown_Release(parser); @@ -907,6 +909,61 @@ static void parse_script_a(const char *src) parse_script_af(SCRIPTITEM_GLOBALMEMBERS, src); } +static void test_gc(void) +{ + IActiveScriptParse *parser; + IActiveScript *engine; + BSTR src; + HRESULT hres; + + strict_dispid_check = FALSE; + + engine = create_script(); + if(!engine) + return; + + hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser); + ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres); + + hres = IActiveScriptParse64_InitNew(parser); + ok(hres == S_OK, "InitNew failed: %08x\n", hres); + + hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite); + ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres); + + hres = IActiveScript_AddNamedItem(engine, testW, + SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS); + ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres); + + hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED); + ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres); + + src = a2bstr( + "class C\n" + " Public ref\n" + " Public Sub Class_Terminate\n" + " Call reportSuccess()\n" + " End Sub\n" + "End Class\n" + "Dim x\n" + "set x = new C\n" + "set x.ref = x\n" + "set x = nothing\n"); + + hres = IActiveScriptParse64_ParseScriptText(parser, src, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + SysFreeString(src); + + SET_EXPECT(global_success_d); + SET_EXPECT(global_success_i); + IActiveScript_Close(engine); + CHECK_CALLED(global_success_d); + CHECK_CALLED(global_success_i); + + IActiveScript_Release(engine); + IUnknown_Release(parser); +} + static BSTR get_script_from_file(const char *filename) { DWORD size, len; @@ -1041,6 +1098,8 @@ static void run_tests(void) CHECK_CALLED(testobj_propput_i); run_from_res("lang.vbs"); + + test_gc(); } static BOOL check_vbscript(void) diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c index c948f13..c1eba23 100644 --- a/dlls/vbscript/vbdisp.c +++ b/dlls/vbscript/vbdisp.c @@ -144,6 +144,9 @@ static void clean_props(vbdisp_t *This) { unsigned i; + if(!This->desc) + return; + for(i=0; i < This->desc->prop_cnt; i++) VariantClear(This->props+i); } @@ -197,6 +200,7 @@ static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface) run_terminator(This); if(!ref) { clean_props(This); + list_remove(&This->entry); heap_free(This); } @@ -247,6 +251,9 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid); + if(!This->desc) + return E_UNEXPECTED; + if(grfdex & ~(fdexNameEnsure|fdexNameCaseInsensitive)) { FIXME("unsupported flags %x\n", grfdex); return E_NOTIMPL; @@ -262,6 +269,9 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); + if(!This->desc) + return E_UNEXPECTED; + if(pvarRes) V_VT(pvarRes) = VT_EMPTY; @@ -408,10 +418,24 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret) } } + list_add_tail(&desc->ctx->objects, &vbdisp->entry); *ret = vbdisp; return S_OK; } +void collect_objects(script_ctx_t *ctx) +{ + vbdisp_t *iter, *iter2; + + LIST_FOR_EACH_ENTRY_SAFE(iter, iter2, &ctx->objects, vbdisp_t, entry) + run_terminator(iter); + + LIST_FOR_EACH_ENTRY_SAFE(iter, iter2, &ctx->objects, vbdisp_t, entry) { + clean_props(iter); + iter->desc = NULL; + } +} + HRESULT init_global(script_ctx_t *ctx) { ctx->script_desc.ctx = ctx; diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index e0598a9..8074799 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -112,6 +112,8 @@ static HRESULT set_ctx_site(VBScript *This) static void destroy_script(script_ctx_t *ctx) { + collect_objects(ctx); + while(!list_empty(&ctx->code_list)) release_vbscode(LIST_ENTRY(list_head(&ctx->code_list), vbscode_t, entry)); @@ -509,6 +511,7 @@ static HRESULT WINAPI VBScriptParse_InitNew(IActiveScriptParse *iface) if(!ctx) return E_OUTOFMEMORY; + list_init(&ctx->objects); list_init(&ctx->code_list); list_init(&ctx->named_items); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 5dd434a..a2c23ea 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -90,6 +90,7 @@ typedef struct { LONG ref; BOOL terminator_ran; + struct list entry; const class_desc_t *desc; VARIANT props[1]; @@ -99,6 +100,7 @@ HRESULT create_vbdisp(const class_desc_t*,vbdisp_t**); HRESULT disp_get_id(IDispatch*,BSTR,vbdisp_invoke_type_t,BOOL,DISPID*); HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,DISPPARAMS*,VARIANT*); HRESULT disp_propput(script_ctx_t*,IDispatch*,DISPID,VARIANT*); +void collect_objects(script_ctx_t*); static inline unsigned arg_cnt(const DISPPARAMS *dp) { @@ -129,6 +131,7 @@ struct _script_ctx_t { function_t *global_funcs; class_desc_t *classes; + struct list objects; struct list code_list; struct list named_items; };
1
0
0
0
Jacek Caban : vbscript: Added class_terminate support.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 8b6b334c89e8414c5b8bb2d08b4a6123a4b0482f URL:
http://source.winehq.org/git/wine.git/?a=commit;h=8b6b334c89e8414c5b8bb2d08…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:29:37 2011 +0200 vbscript: Added class_terminate support. --- dlls/vbscript/compile.c | 9 +++++++++ dlls/vbscript/tests/lang.vbs | 19 +++++++++++++++++++ dlls/vbscript/vbdisp.c | 23 ++++++++++++++++++++++- dlls/vbscript/vbscript.h | 2 ++ 4 files changed, 52 insertions(+), 1 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 00dfc50..6bacaa0 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -894,6 +894,7 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) HRESULT hres; static const WCHAR class_initializeW[] = {'c','l','a','s','s','_','i','n','i','t','i','a','l','i','z','e',0}; + static const WCHAR class_terminateW[] = {'c','l','a','s','s','_','t','e','r','m','i','n','a','t','e',0}; if(lookup_dim_decls(ctx, class_decl->name) || lookup_funcs_name(ctx, class_decl->name) || lookup_class_name(ctx, class_decl->name)) { @@ -912,6 +913,7 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) class_desc->func_cnt = 1; /* always allocate slot for default getter */ class_desc->prop_cnt = 0; class_desc->class_initialize_id = 0; + class_desc->class_terminate_id = 0; for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) { for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) { @@ -942,6 +944,13 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) } class_desc->class_initialize_id = i; + }else if(!strcmpiW(class_terminateW, func_decl->name)) { + if(func_decl->type != FUNC_SUB) { + FIXME("class terminator is not sub\n"); + return E_FAIL; + } + + class_desc->class_terminate_id = i; } hres = create_class_funcprop(ctx, func_decl, class_desc->funcs + (func_prop_decl ? 0 : i)); diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 46317b9..961eea2 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -491,4 +491,23 @@ Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateP x = (New testclass).publicProp +Class TermTest + Public Sub Class_Terminate() + funcCalled = "terminate" + End Sub +End Class + +Set obj = New TermTest +funcCalled = "" +Set obj = Nothing +Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled) + +Set obj = New TermTest +funcCalled = "" +Call obj.Class_Terminate +Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled) +funcCalled = "" +Set obj = Nothing +Call ok(funcCalled = "terminate", "funcCalled = " & funcCalled) + reportSuccess() diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c index e1386be..c948f13 100644 --- a/dlls/vbscript/vbdisp.c +++ b/dlls/vbscript/vbdisp.c @@ -123,6 +123,23 @@ static HRESULT invoke_variant_prop(vbdisp_t *This, VARIANT *v, WORD flags, DISPP return hres; } +static void run_terminator(vbdisp_t *This) +{ + if(This->terminator_ran) + return; + This->terminator_ran = TRUE; + + if(This->desc->class_terminate_id) { + DISPPARAMS dp = {0}; + + 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->ref--; + } + +} + static void clean_props(vbdisp_t *This) { unsigned i; @@ -172,8 +189,12 @@ static ULONG WINAPI DispatchEx_AddRef(IDispatchEx *iface) static ULONG WINAPI DispatchEx_Release(IDispatchEx *iface) { vbdisp_t *This = impl_from_IDispatchEx(iface); - LONG ref = InterlockedIncrement(&This->ref); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + if(!ref) + run_terminator(This); if(!ref) { clean_props(This); heap_free(This); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 270e223..5dd434a 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -77,6 +77,7 @@ typedef struct _class_desc_t { const WCHAR *name; script_ctx_t *ctx; unsigned class_initialize_id; + unsigned class_terminate_id; unsigned func_cnt; vbdisp_funcprop_desc_t *funcs; unsigned prop_cnt; @@ -88,6 +89,7 @@ typedef struct { IDispatchEx IDispatchEx_iface; LONG ref; + BOOL terminator_ran; const class_desc_t *desc; VARIANT props[1];
1
0
0
0
Jacek Caban : vbscript: Added class_initializer support.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 28bddf8dd1599b00ca571d01636711b8f23f350c URL:
http://source.winehq.org/git/wine.git/?a=commit;h=28bddf8dd1599b00ca571d016…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:29:25 2011 +0200 vbscript: Added class_initializer support. --- dlls/vbscript/compile.c | 12 ++++++++++++ dlls/vbscript/tests/lang.vbs | 4 ++++ dlls/vbscript/vbdisp.c | 12 ++++++++++++ dlls/vbscript/vbscript.h | 1 + 4 files changed, 29 insertions(+), 0 deletions(-) diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index bcf7b52..00dfc50 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -893,6 +893,8 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) unsigned i; HRESULT hres; + static const WCHAR class_initializeW[] = {'c','l','a','s','s','_','i','n','i','t','i','a','l','i','z','e',0}; + if(lookup_dim_decls(ctx, class_decl->name) || lookup_funcs_name(ctx, class_decl->name) || lookup_class_name(ctx, class_decl->name)) { FIXME("%s: redefinition\n", debugstr_w(class_decl->name)); @@ -909,6 +911,7 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) class_desc->func_cnt = 1; /* always allocate slot for default getter */ class_desc->prop_cnt = 0; + class_desc->class_initialize_id = 0; for(func_decl = class_decl->funcs; func_decl; func_decl = func_decl->next) { for(func_prop_decl = func_decl; func_prop_decl; func_prop_decl = func_prop_decl->next_prop_func) { @@ -932,6 +935,15 @@ static HRESULT compile_class(compile_ctx_t *ctx, class_decl_t *class_decl) } } + if(!strcmpiW(class_initializeW, func_decl->name)) { + if(func_decl->type != FUNC_SUB) { + FIXME("class initializer is not sub\n"); + return E_FAIL; + } + + class_desc->class_initialize_id = i; + } + hres = create_class_funcprop(ctx, func_decl, class_desc->funcs + (func_prop_decl ? 0 : i)); if(FAILED(hres)) return hres; diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 08f4736..46317b9 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -465,6 +465,7 @@ obj.publicProp = 3 Call ok(obj.publicProp = 3, "obj.publicProp = " & obj.publicProp) obj.publicProp() = 3 +Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp()) Call obj.setPrivateProp(6) Call ok(obj.getPrivateProp = 6, "obj.getPrivateProp = " & obj.getPrivateProp) @@ -485,6 +486,9 @@ funcCalled = "" Call ok(obj = 3, "(x = obj) = " & obj) Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled) +Call obj.Class_Initialize +Call ok(obj.getPrivateProp() = true, "obj.getPrivateProp() = " & obj.getPrivateProp()) + x = (New testclass).publicProp reportSuccess() diff --git a/dlls/vbscript/vbdisp.c b/dlls/vbscript/vbdisp.c index a5fa63c..e1386be 100644 --- a/dlls/vbscript/vbdisp.c +++ b/dlls/vbscript/vbdisp.c @@ -375,6 +375,18 @@ HRESULT create_vbdisp(const class_desc_t *desc, vbdisp_t **ret) vbdisp->ref = 1; vbdisp->desc = desc; + if(desc->class_initialize_id) { + DISPPARAMS dp = {0}; + HRESULT hres; + + hres = exec_script(desc->ctx, desc->funcs[desc->class_initialize_id].entries[VBDISP_CALLGET], + (IDispatch*)&vbdisp->IDispatchEx_iface, &dp, NULL); + if(FAILED(hres)) { + IDispatchEx_Release(&vbdisp->IDispatchEx_iface); + return hres; + } + } + *ret = vbdisp; return S_OK; } diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 37931db..270e223 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -76,6 +76,7 @@ typedef struct { typedef struct _class_desc_t { const WCHAR *name; script_ctx_t *ctx; + unsigned class_initialize_id; unsigned func_cnt; vbdisp_funcprop_desc_t *funcs; unsigned prop_cnt;
1
0
0
0
Jacek Caban : vbscript: Added more IDispatchEx tests.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 888ce005316642e3253e724d3c676200322f3ca9 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=888ce005316642e3253e724d3…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:29:09 2011 +0200 vbscript: Added more IDispatchEx tests. --- dlls/vbscript/tests/lang.vbs | 5 +++ dlls/vbscript/tests/run.c | 59 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index cb0c7eb..08f4736 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -442,6 +442,11 @@ Class TestClass Private Sub privateSub End Sub + + Public Sub Class_Initialize + publicProp2 = 2 + privateProp = true + End Sub End Class Call testDisp(new testClass) diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index f524b81..3fee711 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -160,7 +160,7 @@ static BOOL is_lang_english(void) static void test_disp(IDispatch *disp) { - DISPID id, public_prop_id, public_prop2_id, public_func_id, public_sub_id; + DISPID id, public_prop_id, public_prop2_id, public_func_id, public_sub_id, defvalget_id; DISPID named_args[5] = {DISPID_PROPERTYPUT}; VARIANT v, args[5]; DISPPARAMS dp = {args, named_args}; @@ -188,6 +188,23 @@ static void test_disp(IDispatch *disp) SysFreeString(str); ok(hres == S_OK, "GetDispID(publicProp2) failed: %08x\n", hres); + str = a2bstr("defValGet"); + hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &defvalget_id); + SysFreeString(str); + ok(hres == S_OK, "GetDispID(defValGet) failed: %08x\n", hres); + ok(defvalget_id == DISPID_VALUE, "id = %d\n", defvalget_id); + + str = a2bstr("privateProp"); + hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id); + SysFreeString(str); + ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(privateProp) failed: %08x, expected DISP_E_UNKNOWNNAME\n", hres); + ok(id == -1, "id = %d\n", id); + + str = a2bstr("class_initialize"); + hres = IDispatchEx_GetDispID(dispex, str, fdexNameCaseInsensitive, &id); + SysFreeString(str); + ok(hres == S_OK, "GetDispID(publicProp2) failed: %08x\n", hres); + hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL); ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v)); @@ -202,7 +219,7 @@ static void test_disp(IDispatch *disp) dp.cArgs = dp.cNamedArgs = 0; hres = IDispatchEx_InvokeEx(dispex, public_prop_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL); - ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); ok(V_VT(&v) == VT_BOOL, "V_VT(v) = %d\n", V_VT(&v)); ok(V_BOOL(&v), "V_BOOL(v) = %x\n", V_BOOL(&v)); @@ -237,6 +254,44 @@ static void test_disp(IDispatch *disp) ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v)); dp.cArgs = dp.cNamedArgs = 0; + hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL); + ok(hres == DISP_E_MEMBERNOTFOUND, "InvokeEx failed: %08x, expected DISP_E_MEMBERNOTFOUND\n", hres); + ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v)); + + dp.cArgs = dp.cNamedArgs = 0; + hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v)); + ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v)); + + dp.cArgs = dp.cNamedArgs = 0; + hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v)); + + dp.cArgs = dp.cNamedArgs = 0; + hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYGET, &dp, &v, &ei, NULL); + ok(hres == DISP_E_MEMBERNOTFOUND, "InvokeEx failed: %08x, expected DISP_E_MEMBERNOTFOUND\n", hres); + ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v)); + + dp.cArgs = dp.cNamedArgs = 0; + hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&v) == VT_EMPTY, "V_VT(v) = %d\n", V_VT(&v)); + + V_VT(args) = VT_BOOL; + V_BOOL(args) = VARIANT_TRUE; + dp.cArgs = dp.cNamedArgs = 1; + hres = IDispatchEx_InvokeEx(dispex, public_sub_id, 0, DISPATCH_PROPERTYPUT, &dp, NULL, &ei, NULL); + ok(FAILED(hres), "InvokeEx succeeded: %08x\n", hres); + + dp.cArgs = dp.cNamedArgs = 0; + hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_PROPERTYGET|DISPATCH_METHOD, &dp, &v, &ei, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v)); + ok(V_I2(&v) == 4, "V_I2(v) = %d\n", V_I2(&v)); + + dp.cArgs = dp.cNamedArgs = 0; hres = IDispatchEx_InvokeEx(dispex, public_func_id, 0, DISPATCH_METHOD, &dp, &v, &ei, NULL); ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); ok(V_VT(&v) == VT_I2, "V_VT(v) = %d\n", V_VT(&v));
1
0
0
0
Jacek Caban : vbscript: Use default object value for objets in stack_pop_val.
by Alexandre Julliard
16 Sep '11
16 Sep '11
Module: wine Branch: master Commit: 603d053512c50036869c20df7f2034338efcb3dd URL:
http://source.winehq.org/git/wine.git/?a=commit;h=603d053512c50036869c20df7…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Sep 16 13:29:02 2011 +0200 vbscript: Use default object value for objets in stack_pop_val. --- dlls/vbscript/interp.c | 13 +++++++++++-- dlls/vbscript/tests/lang.vbs | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/interp.c b/dlls/vbscript/interp.c index 4599cbf..474957c 100644 --- a/dlls/vbscript/interp.c +++ b/dlls/vbscript/interp.c @@ -199,8 +199,17 @@ static HRESULT stack_pop_val(exec_ctx_t *ctx, variant_val_t *v) } if(V_VT(var) == VT_DISPATCH) { - FIXME("got dispatch - get its default value\n"); - return E_NOTIMPL; + DISPPARAMS dp = {0}; + HRESULT hres; + + hres = disp_call(ctx->script, V_DISPATCH(var), DISPID_VALUE, &dp, &v->store); + if(v->owned) + IDispatch_Release(V_DISPATCH(var)); + if(FAILED(hres)) + return hres; + + v->owned = TRUE; + v->v = &v->store; }else { v->v = var; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index 24bfecc..cb0c7eb 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -473,4 +473,13 @@ Call ok(obj.getPrivateProp = 3, "obj.getPrivateProp = " & obj.getPrivateProp) Set obj.gsProp = New testclass Call ok(funcCalled = "gsProp set", "funcCalled = " & funcCalled) +x = obj +Call ok(x = 3, "(x = obj) = " & x) +Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled) +funcCalled = "" +Call ok(obj = 3, "(x = obj) = " & obj) +Call ok(funcCalled = "GetDefVal", "funcCalled = " & funcCalled) + +x = (New testclass).publicProp + reportSuccess()
1
0
0
0
← Newer
1
...
34
35
36
37
38
39
40
...
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