Module: wine Branch: master Commit: 5a2b3e0de64bdebf71400ed70eccf06758f29adb URL: http://source.winehq.org/git/wine.git/?a=commit;h=5a2b3e0de64bdebf71400ed70e...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Sep 18 12:25:42 2012 +0200
vbscript: Added support for do..loop statement without an expression.
---
dlls/vbscript/compile.c | 15 +++++++++++---- dlls/vbscript/parser.y | 1 + dlls/vbscript/tests/lang.vbs | 7 +++++++ 3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c index 89e290d..327d97b 100644 --- a/dlls/vbscript/compile.c +++ b/dlls/vbscript/compile.c @@ -625,6 +625,7 @@ static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t * { statement_ctx_t loop_ctx = {0}; unsigned start_addr; + vbsop_t jmp_op; HRESULT hres;
start_addr = ctx->instr_cnt; @@ -636,11 +637,17 @@ static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t * if(FAILED(hres)) return hres;
- hres = compile_expression(ctx, stat->expr); - if(FAILED(hres)) - return hres; + if(stat->expr) { + hres = compile_expression(ctx, stat->expr); + if(FAILED(hres)) + return hres; + + jmp_op = stat->stat.type == STAT_DOUNTIL ? OP_jmp_false : OP_jmp_true; + }else { + jmp_op = OP_jmp; + }
- hres = push_instr_addr(ctx, stat->stat.type == STAT_DOUNTIL ? OP_jmp_false : OP_jmp_true, start_addr); + hres = push_instr_addr(ctx, jmp_op, start_addr); if(FAILED(hres)) return hres;
diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index d5a9934..3f86b04 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -185,6 +185,7 @@ SimpleStatement | tDO tNL StatementsNl_opt tLOOP DoType Expression { $$ = new_while_statement(ctx, $5 ? STAT_DOWHILE : STAT_DOUNTIL, $6, $3); CHECK_ERROR; } + | tDO tNL StatementsNl_opt tLOOP { $$ = new_while_statement(ctx, STAT_DOWHILE, NULL, $3); CHECK_ERROR; } | FunctionDecl { $$ = new_function_statement(ctx, $1); CHECK_ERROR; } | tEXIT tDO { $$ = new_statement(ctx, STAT_EXITDO, 0); CHECK_ERROR; } | tEXIT tFOR { $$ = new_statement(ctx, STAT_EXITFOR, 0); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index fd93df6..76f4003 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -346,6 +346,13 @@ do until false loop
x = false +do + if x then exit do + x = true +loop +call ok(x, "x is false after do..loop?") + +x = false y = false do if x then