Commit f8deed7c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Fixed function return crossing for loop.

parent 8de35a45
......@@ -946,6 +946,25 @@ static HRESULT compile_exitfor_statement(compile_ctx_t *ctx)
return push_instr_addr(ctx, OP_jmp, iter->for_end_label);
}
static HRESULT exit_label(compile_ctx_t *ctx, unsigned jmp_label)
{
statement_ctx_t *iter;
unsigned pop_cnt = 0;
for(iter = ctx->stat_ctx; iter; iter = iter->next)
pop_cnt += iter->stack_use;
if(pop_cnt) {
HRESULT hres;
hres = push_instr_uint(ctx, OP_pop, pop_cnt);
if(FAILED(hres))
return hres;
}
return push_instr_addr(ctx, OP_jmp, jmp_label);
}
static HRESULT compile_exitsub_statement(compile_ctx_t *ctx)
{
if(!ctx->sub_end_label) {
......@@ -953,7 +972,7 @@ static HRESULT compile_exitsub_statement(compile_ctx_t *ctx)
return E_FAIL;
}
return push_instr_addr(ctx, OP_jmp, ctx->sub_end_label);
return exit_label(ctx, ctx->sub_end_label);
}
static HRESULT compile_exitfunc_statement(compile_ctx_t *ctx)
......@@ -963,7 +982,7 @@ static HRESULT compile_exitfunc_statement(compile_ctx_t *ctx)
return E_FAIL;
}
return push_instr_addr(ctx, OP_jmp, ctx->func_end_label);
return exit_label(ctx, ctx->func_end_label);
}
static HRESULT compile_exitprop_statement(compile_ctx_t *ctx)
......@@ -973,7 +992,7 @@ static HRESULT compile_exitprop_statement(compile_ctx_t *ctx)
return E_FAIL;
}
return push_instr_addr(ctx, OP_jmp, ctx->prop_end_label);
return exit_label(ctx, ctx->prop_end_label);
}
static HRESULT compile_onerror_statement(compile_ctx_t *ctx, onerror_statement_t *stat)
......
......@@ -489,6 +489,13 @@ End Sub
Call TestSubExit(true)
Sub TestSubExit2
for x = 1 to 100
Exit Sub
next
End Sub
Call TestSubExit2
TestSubMultiArgs 1, 2, 3, 4, 5
Call TestSubMultiArgs(1, 2, 3, 4, 5)
......@@ -584,6 +591,17 @@ End Function
Call TestFuncExit(true)
Function TestFuncExit2(ByRef a)
For x = 1 to 100
For y = 1 to 100
Exit Function
Next
Next
Call ok(false, "Exit Function not called?")
End Function
Call TestFuncExit2(true)
Sub SubParseTest
End Sub : x = false
Call SubParseTest
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment