vbscript: Added support for do..loop statement without an expression.

oldstable
Jacek Caban 2012-09-18 12:25:42 +02:00 committed by Alexandre Julliard
parent 3fa7860145
commit 5a2b3e0de6
3 changed files with 19 additions and 4 deletions

View File

@ -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;
hres = push_instr_addr(ctx, stat->stat.type == STAT_DOUNTIL ? OP_jmp_false : OP_jmp_true, start_addr);
jmp_op = stat->stat.type == STAT_DOUNTIL ? OP_jmp_false : OP_jmp_true;
}else {
jmp_op = OP_jmp;
}
hres = push_instr_addr(ctx, jmp_op, start_addr);
if(FAILED(hres))
return hres;

View File

@ -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; }

View File

@ -345,6 +345,13 @@ do until false
ok false, "exit do didn't work"
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