summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-06 11:29:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-06 11:29:20 +0000
commitfb81dcb863e6a796b113212f6b3e6086b11bffb8 (patch)
tree9bb659c9aa4b041bd69142e4f8b2ec910abf04ca /parse.y
parentbad7546f15573e06208651a39b9c41ff921c25a2 (diff)
* eval.c (error_print): needs to be exception proof.
* eval.c (error_handle, rb_longjmp): bails out when exception reentered. (ruby-bugs-ja:PR#487), [ruby-core:01119], [ruby-core:01122] * eval.c (Init_Proc): pre-allocates critical error objects. * parse.y (cmd_brace_block, do_block, brace_block): initialize block variables at the beginning of the block. [ruby-talk:72521] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y32
1 files changed, 24 insertions, 8 deletions
diff --git a/parse.y b/parse.y
index c5f5d8c..55b5a5f 100644
--- a/parse.y
+++ b/parse.y
@@ -165,6 +165,7 @@ static ID internal_id();
static struct RVarmap *dyna_push();
static void dyna_pop();
static int dyna_in_block();
+static NODE *dyna_init();
static void top_local_init();
static void top_local_setup();
@@ -645,11 +646,11 @@ cmd_brace_block : tLBRACE_ARG
$<vars>$ = dyna_push();
$<num>1 = ruby_sourceline;
}
- opt_block_var
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
compstmt
'}'
{
- $$ = NEW_ITER($3, 0, $4);
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
nd_set_line($$, $<num>1);
dyna_pop($<vars>2);
}
@@ -1714,11 +1715,11 @@ do_block : kDO_BLOCK
$<vars>$ = dyna_push();
$<num>1 = ruby_sourceline;
}
- opt_block_var
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
compstmt
kEND
{
- $$ = NEW_ITER($3, 0, $4);
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
nd_set_line($$, $<num>1);
dyna_pop($<vars>2);
}
@@ -1777,10 +1778,10 @@ brace_block : '{'
$<vars>$ = dyna_push();
$<num>1 = ruby_sourceline;
}
- opt_block_var
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
compstmt '}'
{
- $$ = NEW_ITER($3, 0, $4);
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
nd_set_line($$, $<num>1);
dyna_pop($<vars>2);
}
@@ -1789,10 +1790,10 @@ brace_block : '{'
$<vars>$ = dyna_push();
$<num>1 = ruby_sourceline;
}
- opt_block_var
+ opt_block_var {$<vars>$ = ruby_dyna_vars;}
compstmt kEND
{
- $$ = NEW_ITER($3, 0, $4);
+ $$ = NEW_ITER($3, 0, dyna_init($5, $<vars>4));
nd_set_line($$, $<num>1);
dyna_pop($<vars>2);
}
@@ -5656,6 +5657,21 @@ dyna_in_block()
return (lvtbl->dlev > 0);
}
+static NODE *
+dyna_init(node, pre)
+ NODE *node;
+ struct RVarmap *pre;
+{
+ struct RVarmap *post = ruby_dyna_vars;
+ NODE *var;
+
+ if (!node || !post || pre == post) return node;
+ for (var = 0; post != pre && post->id; post = post->next) {
+ var = NEW_DASGN_CURR(post->id, var);
+ }
+ return block_append(var, node);
+}
+
int
ruby_parser_stack_on_heap()
{