Jacek Caban : jscript: Added throw statement implementation.
Alexandre Julliard
julliard at winehq.org
Wed Sep 17 07:14:46 CDT 2008
Module: wine
Branch: master
Commit: e7903ecfa9aaa07ecf6ad32ffc5a15eb9cf73353
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e7903ecfa9aaa07ecf6ad32ffc5a15eb9cf73353
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Sep 16 20:45:13 2008 +0200
jscript: Added throw statement implementation.
---
dlls/jscript/engine.c | 21 +++++++++++-
dlls/jscript/tests/lang.js | 76 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index f73f3bc..e554dd8 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -722,10 +722,27 @@ HRESULT switch_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t
return E_NOTIMPL;
}
+/* ECMA-262 3rd Edition 12.13 */
HRESULT throw_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
{
- FIXME("\n");
- return E_NOTIMPL;
+ expression_statement_t *stat = (expression_statement_t*)_stat;
+ exprval_t exprval;
+ VARIANT val;
+ HRESULT hres;
+
+ TRACE("\n");
+
+ hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
+ if(FAILED(hres))
+ return hres;
+
+ hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
+ exprval_release(&exprval);
+ if(FAILED(hres))
+ return hres;
+
+ rt->ei.var = val;
+ return DISP_E_EXCEPTION;
}
/* ECMA-262 3rd Edition 12.14 */
diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js
index d55aa17..e4c4a2c 100644
--- a/dlls/jscript/tests/lang.js
+++ b/dlls/jscript/tests/lang.js
@@ -267,4 +267,80 @@ try {
}
ok(state === "finally", "state = " + state + " expected finally");
+var state = "";
+try {
+ ok(state === "", "try: state = " + state);
+ state = "try";
+ throw "except";
+}catch(ex) {
+ ok(state === "try", "catch: state = " + state);
+ ok(ex === "except", "ex is not \"except\"");
+ state = "catch";
+}
+ok(state === "catch", "state = " + state + " expected catch");
+
+var state = "";
+try {
+ ok(state === "", "try: state = " + state);
+ state = "try";
+ throw true;
+}catch(ex) {
+ ok(state === "try", "catch: state = " + state);
+ ok(ex === true, "ex is not true");
+ state = "catch";
+}finally {
+ ok(state === "catch", "funally: state = " + state);
+ state = "finally";
+}
+ok(state === "finally", "state = " + state + " expected finally");
+
+var state = "";
+try {
+ ok(state === "", "try: state = " + state);
+ state = "try";
+ try { throw true; } finally {}
+}catch(ex) {
+ ok(state === "try", "catch: state = " + state);
+ ok(ex === true, "ex is not true");
+ state = "catch";
+}finally {
+ ok(state === "catch", "funally: state = " + state);
+ state = "finally";
+}
+ok(state === "finally", "state = " + state + " expected finally");
+
+var state = "";
+try {
+ ok(state === "", "try: state = " + state);
+ state = "try";
+ try { throw "except"; } catch(ex) { throw true; }
+}catch(ex) {
+ ok(state === "try", "catch: state = " + state);
+ ok(ex === true, "ex is not true");
+ state = "catch";
+}finally {
+ ok(state === "catch", "funally: state = " + state);
+ state = "finally";
+}
+ok(state === "finally", "state = " + state + " expected finally");
+
+function throwFunc(x) {
+ throw x;
+}
+
+var state = "";
+try {
+ ok(state === "", "try: state = " + state);
+ state = "try";
+ throwFunc(true);
+}catch(ex) {
+ ok(state === "try", "catch: state = " + state);
+ ok(ex === true, "ex is not true");
+ state = "catch";
+}finally {
+ ok(state === "catch", "funally: state = " + state);
+ state = "finally";
+}
+ok(state === "finally", "state = " + state + " expected finally");
+
reportSuccess();
More information about the wine-cvs
mailing list