зеркало из https://github.com/github/ruby.git
* parse.y (stmt): NODE_NOT elimitation for if/unless/while/until node.
* parse.y (primary): ditto. * eval.c (rb_eval): reduce recursive rb_eval() call by using sort of continuation passing style. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e29b4b4862
Коммит
dadb16d894
11
ChangeLog
11
ChangeLog
|
@ -1,8 +1,19 @@
|
||||||
|
Thu Jan 9 15:12:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (stmt): NODE_NOT elimitation for if/unless/while/until node.
|
||||||
|
|
||||||
|
* parse.y (primary): ditto.
|
||||||
|
|
||||||
Thu Jan 9 13:26:18 2003 Akinori MUSHA <knu@iDaemons.org>
|
Thu Jan 9 13:26:18 2003 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* st.h, st.c: Back out the introduction of st_*_func_t. Some
|
* st.h, st.c: Back out the introduction of st_*_func_t. Some
|
||||||
compilers complain about function type mismatch.
|
compilers complain about function type mismatch.
|
||||||
|
|
||||||
|
Thu Jan 9 02:10:44 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_eval): reduce recursive rb_eval() call by using sort
|
||||||
|
of continuation passing style.
|
||||||
|
|
||||||
Wed Jan 08 17:10:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
|
Wed Jan 08 17:10:32 2003 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* ext/Win32API/lib/win32/registry.rb: added. [new]
|
* ext/Win32API/lib/win32/registry.rb: added. [new]
|
||||||
|
|
15
eval.c
15
eval.c
|
@ -2209,6 +2209,7 @@ rb_eval(self, n)
|
||||||
VALUE self;
|
VALUE self;
|
||||||
NODE *n;
|
NODE *n;
|
||||||
{
|
{
|
||||||
|
NODE * volatile contnode = 0;
|
||||||
NODE * volatile node = n;
|
NODE * volatile node = n;
|
||||||
int state;
|
int state;
|
||||||
volatile VALUE result = Qnil;
|
volatile VALUE result = Qnil;
|
||||||
|
@ -2224,10 +2225,10 @@ rb_eval(self, n)
|
||||||
ruby_current_node = node;
|
ruby_current_node = node;
|
||||||
switch (nd_type(node)) {
|
switch (nd_type(node)) {
|
||||||
case NODE_BLOCK:
|
case NODE_BLOCK:
|
||||||
while (node->nd_next) {
|
if (contnode) {
|
||||||
rb_eval(self, node->nd_head);
|
rb_bug("nested NODE_BLOCK");
|
||||||
node = node->nd_next;
|
|
||||||
}
|
}
|
||||||
|
contnode = node->nd_next;
|
||||||
node = node->nd_head;
|
node = node->nd_head;
|
||||||
goto again;
|
goto again;
|
||||||
|
|
||||||
|
@ -3391,7 +3392,6 @@ rb_eval(self, n)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_NEWLINE:
|
case NODE_NEWLINE:
|
||||||
ruby_sourceline = node->nd_nth;
|
|
||||||
if (trace_func) {
|
if (trace_func) {
|
||||||
call_trace_func("line", node, self,
|
call_trace_func("line", node, self,
|
||||||
ruby_frame->last_func,
|
ruby_frame->last_func,
|
||||||
|
@ -3405,6 +3405,11 @@ rb_eval(self, n)
|
||||||
}
|
}
|
||||||
finish:
|
finish:
|
||||||
CHECK_INTS;
|
CHECK_INTS;
|
||||||
|
if (contnode) {
|
||||||
|
node = contnode;
|
||||||
|
contnode = 0;
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4304,7 +4309,7 @@ rb_with_disable_interrupt(proc, data)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static inline void
|
||||||
stack_check()
|
stack_check()
|
||||||
{
|
{
|
||||||
static int overflowing = 0;
|
static int overflowing = 0;
|
||||||
|
|
38
parse.y
38
parse.y
|
@ -407,11 +407,21 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
||||||
{
|
{
|
||||||
$$ = NEW_IF(cond($3), $1, 0);
|
$$ = NEW_IF(cond($3), $1, 0);
|
||||||
fixpos($$, $3);
|
fixpos($$, $3);
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
$$->nd_else = $$->nd_body;
|
||||||
|
$$->nd_body = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| stmt kUNLESS_MOD expr_value
|
| stmt kUNLESS_MOD expr_value
|
||||||
{
|
{
|
||||||
$$ = NEW_UNLESS(cond($3), $1, 0);
|
$$ = NEW_UNLESS(cond($3), $1, 0);
|
||||||
fixpos($$, $3);
|
fixpos($$, $3);
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
$$->nd_body = $$->nd_else;
|
||||||
|
$$->nd_else = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| stmt kWHILE_MOD expr_value
|
| stmt kWHILE_MOD expr_value
|
||||||
{
|
{
|
||||||
|
@ -421,6 +431,10 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
||||||
else {
|
else {
|
||||||
$$ = NEW_WHILE(cond($3), $1, 1);
|
$$ = NEW_WHILE(cond($3), $1, 1);
|
||||||
}
|
}
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
nd_set_type($$, NODE_UNTIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| stmt kUNTIL_MOD expr_value
|
| stmt kUNTIL_MOD expr_value
|
||||||
{
|
{
|
||||||
|
@ -430,6 +444,10 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
||||||
else {
|
else {
|
||||||
$$ = NEW_UNTIL(cond($3), $1, 1);
|
$$ = NEW_UNTIL(cond($3), $1, 1);
|
||||||
}
|
}
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
nd_set_type($$, NODE_WHILE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| klBEGIN
|
| klBEGIN
|
||||||
{
|
{
|
||||||
|
@ -1440,6 +1458,12 @@ primary : literal
|
||||||
{
|
{
|
||||||
$$ = NEW_IF(cond($2), $4, $5);
|
$$ = NEW_IF(cond($2), $4, $5);
|
||||||
fixpos($$, $2);
|
fixpos($$, $2);
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
NODE *tmp = $$->nd_body;
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
$$->nd_body = $$->nd_else;
|
||||||
|
$$->nd_else = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| kUNLESS expr_value then
|
| kUNLESS expr_value then
|
||||||
compstmt
|
compstmt
|
||||||
|
@ -1448,6 +1472,12 @@ primary : literal
|
||||||
{
|
{
|
||||||
$$ = NEW_UNLESS(cond($2), $4, $5);
|
$$ = NEW_UNLESS(cond($2), $4, $5);
|
||||||
fixpos($$, $2);
|
fixpos($$, $2);
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
NODE *tmp = $$->nd_body;
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
$$->nd_body = $$->nd_else;
|
||||||
|
$$->nd_else = tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| kWHILE {COND_PUSH(1);} expr_value do {COND_POP();}
|
| kWHILE {COND_PUSH(1);} expr_value do {COND_POP();}
|
||||||
compstmt
|
compstmt
|
||||||
|
@ -1455,6 +1485,10 @@ primary : literal
|
||||||
{
|
{
|
||||||
$$ = NEW_WHILE(cond($3), $6, 1);
|
$$ = NEW_WHILE(cond($3), $6, 1);
|
||||||
fixpos($$, $3);
|
fixpos($$, $3);
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
nd_set_type($$, NODE_UNTIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| kUNTIL {COND_PUSH(1);} expr_value do {COND_POP();}
|
| kUNTIL {COND_PUSH(1);} expr_value do {COND_POP();}
|
||||||
compstmt
|
compstmt
|
||||||
|
@ -1462,6 +1496,10 @@ primary : literal
|
||||||
{
|
{
|
||||||
$$ = NEW_UNTIL(cond($3), $6, 1);
|
$$ = NEW_UNTIL(cond($3), $6, 1);
|
||||||
fixpos($$, $3);
|
fixpos($$, $3);
|
||||||
|
if (nd_type($$->nd_cond) == NODE_NOT) {
|
||||||
|
$$->nd_cond = $$->nd_cond->nd_body;
|
||||||
|
nd_set_type($$, NODE_WHILE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| kCASE expr_value opt_terms
|
| kCASE expr_value opt_terms
|
||||||
case_body
|
case_body
|
||||||
|
|
Загрузка…
Ссылка в новой задаче