Verified Commit b9040086 authored by Vladimir Sedach's avatar Vladimir Sedach
Browse files

Fix dynamic scope multiple value return

parent fd993de3
...@@ -175,7 +175,8 @@ ...@@ -175,7 +175,8 @@
`((and ,_ps_err (eql ',tag `((and ,_ps_err (eql ',tag
(getprop ,_ps_err :__ps_block_tag))) (getprop ,_ps_err :__ps_block_tag)))
(return-from ,tag (return-from ,tag
(getprop ,_ps_err :__ps_value))))) (getprop ,_ps_err :__ps_value)
t))))
`(ps-js:block `(ps-js:block
(ps-js:try (ps-js:try
,body ,body
...@@ -227,7 +228,7 @@ ...@@ -227,7 +228,7 @@
(ps-compile (ps-compile
(if (and (not returning-values?) clear-multiple-values?) (if (and (not returning-values?) clear-multiple-values?)
`(progn `(progn
(setf __PS_MV_REG (list)) (setf __PS_MV_REG '())
(%simple-lexical-return ,@X)) (%simple-lexical-return ,@X))
`(%simple-lexical-return ,@X)))))) `(%simple-lexical-return ,@X))))))
(acond (acond
...@@ -247,7 +248,7 @@ ...@@ -247,7 +248,7 @@
(setf (cdr it) t) (setf (cdr it) t)
(ps-compile (ps-compile
`(progn `(progn
,@(when (and (not returning-values?) clear-multiple-values?) ,@(unless returning-values?
'((setf __PS_MV_REG '()))) '((setf __PS_MV_REG '())))
(throw (create (throw (create
:__ps_block_tag ',tag :__ps_block_tag ',tag
......
...@@ -2709,7 +2709,6 @@ if (foowhat(x)) { ...@@ -2709,7 +2709,6 @@ if (foowhat(x)) {
}); });
} catch (_ps_err5) { } catch (_ps_err5) {
if (_ps_err5 && 'baz' === _ps_err5['__ps_block_tag']) { if (_ps_err5 && 'baz' === _ps_err5['__ps_block_tag']) {
__PS_MV_REG = [];
return _ps_err5['__ps_value']; return _ps_err5['__ps_value'];
} else { } else {
throw _ps_err5; throw _ps_err5;
...@@ -3568,11 +3567,11 @@ while (foo()) { ...@@ -3568,11 +3567,11 @@ while (foo()) {
try { try {
__PS_MV_REG = []; __PS_MV_REG = [];
return (function () { return (function () {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'foo', '__ps_value' : 6 }; throw { '__ps_block_tag' : 'foo', '__ps_value' : 6 };
})(); })();
} catch (_ps_err1) { } catch (_ps_err1) {
if (_ps_err1 && 'foo' === _ps_err1['__ps_block_tag']) { if (_ps_err1 && 'foo' === _ps_err1['__ps_block_tag']) {
__PS_MV_REG = [];
return _ps_err1['__ps_value']; return _ps_err1['__ps_value'];
} else { } else {
throw _ps_err1; throw _ps_err1;
...@@ -3588,11 +3587,11 @@ while (foo()) { ...@@ -3588,11 +3587,11 @@ while (foo()) {
try { try {
__PS_MV_REG = []; __PS_MV_REG = [];
return (function () { return (function () {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'foo', '__ps_value' : null }; throw { '__ps_block_tag' : 'foo', '__ps_value' : null };
})(); })();
} catch (_ps_err1) { } catch (_ps_err1) {
if (_ps_err1 && 'foo' === _ps_err1['__ps_block_tag']) { if (_ps_err1 && 'foo' === _ps_err1['__ps_block_tag']) {
__PS_MV_REG = [];
return _ps_err1['__ps_value']; return _ps_err1['__ps_value'];
} else { } else {
throw _ps_err1; throw _ps_err1;
...@@ -3630,11 +3629,11 @@ while (foo()) { ...@@ -3630,11 +3629,11 @@ while (foo()) {
try { try {
__PS_MV_REG = []; __PS_MV_REG = [];
return (function () { return (function () {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'foo', '__ps_value' : baz ? 6 : 5 }; throw { '__ps_block_tag' : 'foo', '__ps_value' : baz ? 6 : 5 };
})(); })();
} catch (_ps_err1) { } catch (_ps_err1) {
if (_ps_err1 && 'foo' === _ps_err1['__ps_block_tag']) { if (_ps_err1 && 'foo' === _ps_err1['__ps_block_tag']) {
__PS_MV_REG = [];
return _ps_err1['__ps_value']; return _ps_err1['__ps_value'];
} else { } else {
throw _ps_err1; throw _ps_err1;
...@@ -3651,13 +3650,13 @@ while (foo()) { ...@@ -3651,13 +3650,13 @@ while (foo()) {
var foo = (function () { var foo = (function () {
try { try {
(function () { (function () {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'nilBlock', '__ps_value' : 6 }; throw { '__ps_block_tag' : 'nilBlock', '__ps_value' : 6 };
})(); })();
__PS_MV_REG = []; __PS_MV_REG = [];
return 1 + 2; return 1 + 2;
} catch (_ps_err1) { } catch (_ps_err1) {
if (_ps_err1 && 'nilBlock' === _ps_err1['__ps_block_tag']) { if (_ps_err1 && 'nilBlock' === _ps_err1['__ps_block_tag']) {
__PS_MV_REG = [];
return _ps_err1['__ps_value']; return _ps_err1['__ps_value'];
} else { } else {
throw _ps_err1; throw _ps_err1;
...@@ -4375,6 +4374,7 @@ x = 2 + sideEffect() + x + 5;") ...@@ -4375,6 +4374,7 @@ x = 2 + sideEffect() + x + 5;")
try { try {
(function () { (function () {
(function () { (function () {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'X', '__ps_value' : 1 }; throw { '__ps_block_tag' : 'X', '__ps_value' : 1 };
})(); })();
__PS_MV_REG = []; __PS_MV_REG = [];
...@@ -4382,7 +4382,6 @@ x = 2 + sideEffect() + x + 5;") ...@@ -4382,7 +4382,6 @@ x = 2 + sideEffect() + x + 5;")
})(); })();
} catch (_ps_err1) { } catch (_ps_err1) {
if (_ps_err1 && 'X' === _ps_err1['__ps_block_tag']) { if (_ps_err1 && 'X' === _ps_err1['__ps_block_tag']) {
__PS_MV_REG = [];
_ps_err1['__ps_value']; _ps_err1['__ps_value'];
break X; break X;
} else { } else {
...@@ -4403,6 +4402,7 @@ x = 2 + sideEffect() + x + 5;") ...@@ -4403,6 +4402,7 @@ x = 2 + sideEffect() + x + 5;")
"function () { "function () {
try { try {
return function () { return function () {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'X', '__ps_value' : 1 }; throw { '__ps_block_tag' : 'X', '__ps_value' : 1 };
}; };
} catch (_ps_err1) { } catch (_ps_err1) {
...@@ -4451,12 +4451,12 @@ x = 2 + sideEffect() + x + 5;") ...@@ -4451,12 +4451,12 @@ x = 2 + sideEffect() + x + 5;")
nilBlock: { nilBlock: {
try { try {
(function () { (function () {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'nilBlock', '__ps_value' : 6 }; throw { '__ps_block_tag' : 'nilBlock', '__ps_value' : 6 };
})(); })();
1 + 2; 1 + 2;
} catch (_ps_err1) { } catch (_ps_err1) {
if (_ps_err1 && 'nilBlock' === _ps_err1['__ps_block_tag']) { if (_ps_err1 && 'nilBlock' === _ps_err1['__ps_block_tag']) {
__PS_MV_REG = [];
_ps_err1['__ps_value']; _ps_err1['__ps_value'];
break nilBlock; break nilBlock;
} else { } else {
...@@ -4477,6 +4477,7 @@ x = 2 + sideEffect() + x + 5;") ...@@ -4477,6 +4477,7 @@ x = 2 + sideEffect() + x + 5;")
"(function () { "(function () {
bar: { bar: {
try { try {
__PS_MV_REG = [];
throw { '__ps_block_tag' : 'bar', '__ps_value' : 10 }; throw { '__ps_block_tag' : 'bar', '__ps_value' : 10 };
} catch (_ps_err1) { } catch (_ps_err1) {
if (_ps_err1 && 'bar' === _ps_err1['__ps_block_tag']) { if (_ps_err1 && 'bar' === _ps_err1['__ps_block_tag']) {
......
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