Jacek Caban : jscript: Simplify pop_to_stat implementation.
Alexandre Julliard
julliard at winehq.org
Mon May 1 16:38:05 CDT 2017
Module: wine
Branch: master
Commit: b7bb16673c75ef3e5f49493aa9deeb0255f822bd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b7bb16673c75ef3e5f49493aa9deeb0255f822bd
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon May 1 18:29:53 2017 +0200
jscript: Simplify pop_to_stat implementation.
We no longer need to do stack pops before return expression evaluation.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/compile.c | 24 +++++++++---------------
dlls/jscript/tests/lang.js | 11 +++++++++++
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c
index fe3e043..3770767 100644
--- a/dlls/jscript/compile.c
+++ b/dlls/jscript/compile.c
@@ -1383,22 +1383,20 @@ static HRESULT compile_forin_statement(compiler_ctx_t *ctx, forin_statement_t *s
return S_OK;
}
-static HRESULT pop_to_stat(compiler_ctx_t *ctx, BOOL var_stack, BOOL scope_stack, statement_ctx_t *stat_ctx)
+static HRESULT pop_to_stat(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx)
{
unsigned stack_pop = 0;
statement_ctx_t *iter;
for(iter = ctx->stat_ctx; iter != stat_ctx; iter = iter->next) {
- if(scope_stack) {
- if(iter->using_scope && !push_instr(ctx, OP_pop_scope))
- return E_OUTOFMEMORY;
- if(iter->using_except && !push_instr(ctx, OP_pop_except))
- return E_OUTOFMEMORY;
- }
+ if(iter->using_scope && !push_instr(ctx, OP_pop_scope))
+ return E_OUTOFMEMORY;
+ if(iter->using_except && !push_instr(ctx, OP_pop_except))
+ return E_OUTOFMEMORY;
stack_pop += iter->stack_use;
}
- if(var_stack && stack_pop) {
+ if(stack_pop) {
HRESULT hres;
hres = push_instr_uint(ctx, OP_pop, stack_pop);
@@ -1455,7 +1453,7 @@ static HRESULT compile_continue_statement(compiler_ctx_t *ctx, branch_statement_
}
}
- hres = pop_to_stat(ctx, TRUE, TRUE, pop_ctx);
+ hres = pop_to_stat(ctx, pop_ctx);
if(FAILED(hres))
return hres;
@@ -1492,7 +1490,7 @@ static HRESULT compile_break_statement(compiler_ctx_t *ctx, branch_statement_t *
}
}
- hres = pop_to_stat(ctx, TRUE, TRUE, pop_ctx->next);
+ hres = pop_to_stat(ctx, pop_ctx->next);
if(FAILED(hres))
return hres;
@@ -1509,10 +1507,6 @@ static HRESULT compile_return_statement(compiler_ctx_t *ctx, expression_statemen
return JS_E_MISPLACED_RETURN;
}
- hres = pop_to_stat(ctx, TRUE, FALSE, NULL);
- if(FAILED(hres))
- return hres;
-
if(stat->expr) {
hres = compile_expression(ctx, stat->expr, TRUE);
if(FAILED(hres))
@@ -1521,7 +1515,7 @@ static HRESULT compile_return_statement(compiler_ctx_t *ctx, expression_statemen
return E_OUTOFMEMORY;
}
- hres = pop_to_stat(ctx, FALSE, TRUE, NULL);
+ hres = pop_to_stat(ctx, NULL);
if(FAILED(hres))
return hres;
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index c179265..01d41d5 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -264,6 +264,8 @@ ok(tmp === 3, "tmp = " + tmp);
eval("testRes(); testRes()");
tmp = eval("3; if(false) {4;} else {};;;")
ok(tmp === 3, "tmp = " + tmp);
+tmp = eval("try { 1; } finally { 2; }")
+ok(tmp === 2, "tmp = " + tmp);
testNoRes();
testRes() && testRes();
@@ -1597,6 +1599,15 @@ tmp = (function() {
})();
ok(tmp, "tmp = " + tmp);
+tmp = (function() {
+ for(var iter in [1,2,3,4]) {
+ var ret = false;
+ with({ret: true})
+ return ret;
+ }
+})();
+ok(tmp, "tmp = " + tmp);
+
(function() {
ok(typeof(func) === "function", "typeof(func) = " + typeof(func));
with(new Object()) {
More information about the wine-cvs
mailing list