summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 12:37:16 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 12:37:16 +0000
commit633df8de16203da72dff1a010740fdf92f9f7f5c (patch)
tree7f9889ab265a4dbf85c36ca259da1fb51a6db600 /compile.c
parent904b278f94d9d18fef50adce79aec0756496a773 (diff)
* compile.c (iseq_compile_each): fix stack consistency error
(break is compiled to throw instead of jump insn). these problems are reported by Yusuke ENDOH <mame AT tsg.ne.jp> * bootstraptest/test_knownbug.rb, test_syntax.rb: move fixed test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 1960a3fa99..1e26d45419 100644
--- a/compile.c
+++ b/compile.c
@@ -2924,12 +2924,26 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
if (iseq->compile_data->redo_label != 0) {
/* while/until */
+#if 0
add_ensure_iseq(ret, iseq);
COMPILE_(ret, "break val (while/until)", node->nd_stts,
iseq->compile_data->loopval_popped);
ADD_INSNL(ret, nd_line(node), jump,
iseq->compile_data->end_label);
- ADD_INSN(ret, nd_line(node), pop);
+
+ if (poped) {
+ ADD_INSN(ret, nd_line(node), pop);
+ }
+#else
+ level = 0x8000 | 0x4000;
+ COMPILE(ret, "break val (while/until)", node->nd_stts);
+ ADD_INSN1(ret, nd_line(node), throw,
+ INT2FIX(level | 0x02) /* TAG_BREAK */ );
+
+ if (poped) {
+ ADD_INSN(ret, nd_line(node), pop);
+ }
+#endif
}
else if (iseq->type == ISEQ_TYPE_BLOCK) {
break_by_insn:
@@ -3089,6 +3103,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN(ret, nd_line(node), putnil);
ADD_INSN1(ret, nd_line(node), throw,
INT2FIX(0x04) /* TAG_RETRY */ );
+
+ if (poped) {
+ ADD_INSN(ret, nd_line(node), pop);
+ }
}
else {
COMPILE_ERROR((ERROR_ARGS "Invalid retry"));