summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-26 13:33:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-26 13:33:14 +0000
commit89eb20764ea4d3b780eee12488e7c3ff6fb9ba9f (patch)
treee7a4ebf6d948a323be51af989ef19b3707dbc424
parentb56b457e45aefe2cc20bf85158fb8e886368072c (diff)
* eval.c (rb_eval), gc.c (gc_mark_children), node.h (NEW_ALIAS,
NEW_VALIAS), parse.y (fitem): allow dynamic symbols to NODE_UNDEF and NODE_ALIAS. backported from trunk. fixed: [ruby-dev:28105] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--eval.c7
-rw-r--r--gc.c6
-rw-r--r--node.h7
-rw-r--r--parse.y13
5 files changed, 27 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e51946..50f6f61 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Dec 26 22:32:47 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * eval.c (rb_eval), gc.c (gc_mark_children), node.h (NEW_ALIAS,
+ NEW_VALIAS), parse.y (fitem): allow dynamic symbols to
+ NODE_UNDEF and NODE_ALIAS.
+ backported from trunk. fixed: [ruby-dev:28105]
+
Mon Dec 26 08:50:36 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ev_const_get): fixed a bug in constant reference during
@@ -25,7 +32,7 @@ Wed Dec 21 16:53:06 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
Wed Dec 21 14:53:26 2005 Tanaka Akira <akr@m17n.org>
- * lib/pathname.rb (test_kernel_open): use File.identical?.
+ * lib/pathname.rb (test_kernel_open): use File.identical?.
[ruby-talk:171804]
Tue Dec 20 22:41:17 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
diff --git a/eval.c b/eval.c
index 719860a..40599b5 100644
--- a/eval.c
+++ b/eval.c
@@ -3889,7 +3889,7 @@ rb_eval(self, n)
if (NIL_P(ruby_class)) {
rb_raise(rb_eTypeError, "no class to undef method");
}
- rb_undef(ruby_class, node->nd_mid);
+ rb_undef(ruby_class, rb_to_id(rb_eval(self, node->u2.node)));
result = Qnil;
break;
@@ -3897,12 +3897,13 @@ rb_eval(self, n)
if (NIL_P(ruby_class)) {
rb_raise(rb_eTypeError, "no class to make alias");
}
- rb_alias(ruby_class, node->nd_new, node->nd_old);
+ rb_alias(ruby_class, rb_to_id(rb_eval(self, node->u1.node)),
+ rb_to_id(rb_eval(self, node->u2.node)));
result = Qnil;
break;
case NODE_VALIAS:
- rb_alias_variable(node->nd_new, node->nd_old);
+ rb_alias_variable(node->u1.id, node->u2.id);
result = Qnil;
break;
diff --git a/gc.c b/gc.c
index c172a08..7c8324c 100644
--- a/gc.c
+++ b/gc.c
@@ -814,6 +814,8 @@ gc_mark_children(ptr, lev)
case NODE_OP_ASGN_OR:
case NODE_OP_ASGN_AND:
case NODE_MODULE:
+ case NODE_ALIAS:
+ case NODE_VALIAS:
gc_mark((VALUE)obj->as.node.u1.node, lev);
/* fall through */
case NODE_METHOD: /* 2 */
@@ -828,6 +830,7 @@ gc_mark_children(ptr, lev)
case NODE_COLON3:
case NODE_OPT_N:
case NODE_EVSTR:
+ case NODE_UNDEF:
ptr = (VALUE)obj->as.node.u2.node;
goto again;
@@ -867,11 +870,8 @@ gc_mark_children(ptr, lev)
case NODE_CVAR:
case NODE_NTH_REF:
case NODE_BACK_REF:
- case NODE_ALIAS:
- case NODE_VALIAS:
case NODE_REDO:
case NODE_RETRY:
- case NODE_UNDEF:
case NODE_SELF:
case NODE_NIL:
case NODE_TRUE:
diff --git a/node.h b/node.h
index fe5b5f5..a70ebff 100644
--- a/node.h
+++ b/node.h
@@ -209,9 +209,6 @@ typedef struct RNode {
#define nd_noex u1.id
#define nd_defn u3.node
-#define nd_old u1.id
-#define nd_new u2.id
-
#define nd_cfnc u1.cfunc
#define nd_argc u2.argc
@@ -311,8 +308,8 @@ typedef struct RNode {
#define NEW_SVALUE(a) NEW_NODE(NODE_SVALUE,a,0,0)
#define NEW_BLOCK_ARG(v) NEW_NODE(NODE_BLOCK_ARG,v,0,local_cnt(v))
#define NEW_BLOCK_PASS(b) NEW_NODE(NODE_BLOCK_PASS,0,b,0)
-#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,o,n,0)
-#define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,o,n,0)
+#define NEW_ALIAS(n,o) NEW_NODE(NODE_ALIAS,n,o,0)
+#define NEW_VALIAS(n,o) NEW_NODE(NODE_VALIAS,n,o,0)
#define NEW_UNDEF(i) NEW_NODE(NODE_UNDEF,0,i,0)
#define NEW_CLASS(n,b,s) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(b),(s))
#define NEW_SCLASS(r,b) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(b),0)
diff --git a/parse.y b/parse.y
index 2fc0fcc..0fc91b0 100644
--- a/parse.y
+++ b/parse.y
@@ -277,9 +277,9 @@ static void top_local_setup();
%type <node> mrhs superclass block_call block_command
%type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg
%type <node> assoc_list assocs assoc undef_list backref string_dvar
-%type <node> block_var opt_block_var brace_block cmd_brace_block do_block lhs none
+%type <node> block_var opt_block_var brace_block cmd_brace_block do_block lhs none fitem
%type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
-%type <id> fitem variable sym symbol operation operation2 operation3
+%type <id> fsym variable sym symbol operation operation2 operation3
%type <id> cname fname op f_rest_arg
%type <num> f_norm_arg f_arg
%token tUPLUS /* unary+ */
@@ -916,10 +916,17 @@ fname : tIDENTIFIER
}
;
-fitem : fname
+fsym : fname
| symbol
;
+fitem : fsym
+ {
+ $$ = NEW_LIT(ID2SYM($1));
+ }
+ | dsym
+ ;
+
undef_list : fitem
{
$$ = NEW_UNDEF($1);