Jacek Caban : vbscript: Added support for exit for statement in 'for in' loops.
Alexandre Julliard
julliard at winehq.org
Mon Jul 9 14:56:35 CDT 2012
Module: wine
Branch: master
Commit: 00dfcb08b83976dfd824c776eedd267bf0037b02
URL: http://source.winehq.org/git/wine.git/?a=commit;h=00dfcb08b83976dfd824c776eedd267bf0037b02
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Jul 3 19:18:00 2012 +0200
vbscript: Added support for exit for statement in 'for in' loops.
---
dlls/vbscript/compile.c | 11 ++++++-----
dlls/vbscript/tests/lang.vbs | 9 +++++++++
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/vbscript/compile.c b/dlls/vbscript/compile.c
index de29777..7c4b0e6 100644
--- a/dlls/vbscript/compile.c
+++ b/dlls/vbscript/compile.c
@@ -650,7 +650,8 @@ static HRESULT compile_dowhile_statement(compile_ctx_t *ctx, while_statement_t *
static HRESULT compile_foreach_statement(compile_ctx_t *ctx, foreach_statement_t *stat)
{
- unsigned loop_start, loop_end;
+ statement_ctx_t loop_ctx = {1};
+ unsigned loop_start;
HRESULT hres;
hres = compile_expression(ctx, stat->group_expr);
@@ -661,14 +662,14 @@ static HRESULT compile_foreach_statement(compile_ctx_t *ctx, foreach_statement_t
return E_OUTOFMEMORY;
loop_start = ctx->instr_cnt;
- if(!(loop_end = alloc_label(ctx)))
+ if(!(loop_ctx.for_end_label = alloc_label(ctx)))
return E_OUTOFMEMORY;
- hres = push_instr_uint_bstr(ctx, OP_enumnext, loop_end, stat->identifier);
+ hres = push_instr_uint_bstr(ctx, OP_enumnext, loop_ctx.for_end_label, stat->identifier);
if(FAILED(hres))
return hres;
- hres = compile_statement(ctx, NULL, stat->body);
+ hres = compile_statement(ctx, &loop_ctx, stat->body);
if(FAILED(hres))
return hres;
@@ -676,7 +677,7 @@ static HRESULT compile_foreach_statement(compile_ctx_t *ctx, foreach_statement_t
if(FAILED(hres))
return hres;
- label_set_addr(ctx, loop_end);
+ label_set_addr(ctx, loop_ctx.for_end_label);
return S_OK;
}
diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs
index c03fa8f..9389462 100644
--- a/dlls/vbscript/tests/lang.vbs
+++ b/dlls/vbscript/tests/lang.vbs
@@ -431,6 +431,15 @@ next
Call ok(y = 3, "y = " & y)
Call ok(getVT(x) = "VT_EMPTY*", "getVT(x) = " & getVT(x))
+Call collectionObj.reset()
+y = false
+for each x in collectionObj
+ if x = 2 then exit for
+ y = 1
+next
+Call ok(y = 1, "y = " & y)
+Call ok(x = 2, "x = " & x)
+
if false then
Sub testsub
x = true
More information about the wine-cvs
mailing list