summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-05 10:04:56 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-07-05 10:04:56 +0000
commit0bb4c2b3db16c7e1c23877f1f1efc216c601f3d0 (patch)
treed9045d9e1835d881258b638ceb4552c887f720c8 /compile.c
parenta74dbca6863a41bd948961944d1c6b19e01070c7 (diff)
* compile.c (iseq_compile_each): add break catch point.
* insns.def (throw): support correct "break" and "return". this commit achieve that "make test" passes all tests. * vm.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/compile.c b/compile.c
index 3e237e7f37..6ac0e61f0e 100644
--- a/compile.c
+++ b/compile.c
@@ -2839,38 +2839,41 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
case NODE_ITER:
case NODE_FOR:{
- VALUE prevblock = iseq->compile_data->current_block;
- LABEL *retry_label = NEW_LABEL(nd_line(node));
- LABEL *retry_end_l = NEW_LABEL(nd_line(node));
- ID mid = 0;
+ VALUE prevblock = iseq->compile_data->current_block;
+ LABEL *retry_label = NEW_LABEL(nd_line(node));
+ LABEL *retry_end_l = NEW_LABEL(nd_line(node));
+ ID mid = 0;
- ADD_LABEL(ret, retry_label);
- if (nd_type(node) == NODE_FOR) {
- COMPILE(ret, "iter caller (for)", node->nd_iter);
+ ADD_LABEL(ret, retry_label);
+ if (nd_type(node) == NODE_FOR) {
+ COMPILE(ret, "iter caller (for)", node->nd_iter);
- iseq->compile_data->current_block =
+ iseq->compile_data->current_block =
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK);
- mid = idEach;
- ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0),
- iseq->compile_data->current_block, INT2FIX(0));
- if (poped) {
- ADD_INSN(ret, nd_line(node), pop);
- }
- }
- else {
- iseq->compile_data->current_block =
+ mid = idEach;
+ ADD_SEND_R(ret, nd_line(node), ID2SYM(idEach), INT2FIX(0),
+ iseq->compile_data->current_block, INT2FIX(0));
+ }
+ else {
+ iseq->compile_data->current_block =
NEW_CHILD_ISEQVAL(node->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK);
- COMPILE_(ret, "iter caller", node->nd_iter, poped);
- }
- ADD_LABEL(ret, retry_end_l);
- iseq->compile_data->current_block = prevblock;
+ COMPILE(ret, "iter caller", node->nd_iter);
+ }
+ ADD_LABEL(ret, retry_end_l);
- ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0,
- retry_label);
- break;
+ if (poped) {
+ ADD_INSN(ret, nd_line(node), pop);
+ }
+
+ iseq->compile_data->current_block = prevblock;
+
+ ADD_CATCH_ENTRY(CATCH_TYPE_RETRY, retry_label, retry_end_l, 0, retry_label);
+ ADD_CATCH_ENTRY(CATCH_TYPE_BREAK, retry_label, retry_end_l, 0, retry_end_l);
+
+ break;
}
case NODE_BREAK:{
unsigned long level = 0;