* insns.def, compile.c: fix to allow dsym for alias/undef.

[ruby-dev:32355]
* bootstraptest/test_method.rb: add tests for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-11-27 01:02:30 +00:00
parent 724de18989
commit 329484693a
5 changed files with 63 additions and 39 deletions

View File

@ -1,3 +1,10 @@
Tue Nov 27 09:57:42 2007 Koichi Sasada <ko1@atdot.net>
* insns.def, compile.c: fix to allow dsym for alias/undef.
[ruby-dev:32355]
* bootstraptest/test_method.rb: add tests for above.
Mon Nov 26 23:18:46 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> Mon Nov 26 23:18:46 2007 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
* lib/drb/extserv.rb (initialize, stop_service): synchronize with * lib/drb/extserv.rb (initialize, stop_service): synchronize with

View File

@ -230,6 +230,28 @@ assert_equal '1', %q( class A; def a() end end # [yarv-dev:999]
end end
begin B.new.b; rescue NoMethodError; 1 end ) begin B.new.b; rescue NoMethodError; 1 end )
assert_equal '3', %q{
def m1
1
end
alias m2 m1
alias :"#{'m3'}" m1
m1 + m2 + m3
}, '[ruby-dev:32308]'
assert_equal '1', %q{
def foobar
end
undef :"foo#{:bar}"
1
}, '[ruby-dev:32308]'
assert_equal '1', %q{
def foobar
1
end
alias :"bar#{:baz}" :"foo#{:bar}"
barbaz
}, '[ruby-dev:32308]'
# private # private
assert_equal '1', %q( class C assert_equal '1', %q( class C
def m() mm() end def m() mm() end

View File

@ -4066,35 +4066,30 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
VALUE s1, s2; VALUE s1, s2;
enum node_type t; enum node_type t;
if (((t = nd_type(node->u1.node)) != NODE_LIT && t != NODE_DSYM) || COMPILE(ret, "alias arg1", node->u1.node);
((t = nd_type(node->u2.node)) != NODE_LIT && t != NODE_DSYM)) { COMPILE(ret, "alias arg2", node->u2.node);
rb_compile_bug(ERROR_ARGS "alias args must be NODE_LIT or NODE_DSYM");
} ADD_INSN1(ret, nd_line(node), alias, Qfalse);
s1 = node->u1.node->nd_lit;
s2 = node->u2.node->nd_lit;
ADD_INSN3(ret, nd_line(node), alias, Qfalse, ID2SYM(rb_to_id(s1)),
ID2SYM(rb_to_id(s2)));
if (!poped) { if (!poped) {
ADD_INSN(ret, nd_line(node), putnil); ADD_INSN(ret, nd_line(node), putnil);
} }
break; break;
} }
case NODE_VALIAS:{ case NODE_VALIAS:{
ADD_INSN3(ret, nd_line(node), alias, Qtrue, ID2SYM(node->u1.id), ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u1.id));
ID2SYM(node->u2.id)); ADD_INSN1(ret, nd_line(node), putobject, ID2SYM(node->u2.id));
ADD_INSN1(ret, nd_line(node), alias, Qtrue);
if (!poped) { if (!poped) {
ADD_INSN(ret, nd_line(node), putnil); ADD_INSN(ret, nd_line(node), putnil);
} }
break; break;
} }
case NODE_UNDEF:{ case NODE_UNDEF:{
enum node_type t = nd_type(node->u2.node); COMPILE(ret, "undef arg", node->u2.node);
if (t != NODE_LIT && t != NODE_DSYM) { ADD_INSN(ret, nd_line(node), undef);
rb_compile_bug(ERROR_ARGS "undef args must be NODE_LIT");
}
ADD_INSN1(ret, nd_line(node), undef,
ID2SYM(rb_to_id(node->u2.node->nd_lit)));
if (!poped) { if (!poped) {
ADD_INSN(ret, nd_line(node), putnil); ADD_INSN(ret, nd_line(node), putnil);
} }

View File

@ -751,18 +751,18 @@ definemethod
*/ */
DEFINE_INSN DEFINE_INSN
alias alias
(VALUE v_p, ID id1, ID id2) (VALUE v_p)
() (VALUE sym1, VALUE sym2)
() ()
{ {
VALUE klass; VALUE klass;
if (v_p == Qtrue) { if (v_p == Qtrue) {
rb_alias_variable(id1, id2); rb_alias_variable(ID2SYM(sym1), SYM2ID(sym2));
} }
else { else {
klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss; klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
rb_alias(klass, id1, id2); rb_alias(klass, SYM2ID(sym1), SYM2ID(sym2));
} }
} }
@ -773,12 +773,12 @@ alias
*/ */
DEFINE_INSN DEFINE_INSN
undef undef
(ID id)
() ()
(VALUE sym)
() ()
{ {
VALUE klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss; VALUE klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
rb_undef(klass, id); rb_undef(klass, SYM2ID(sym));
INC_VM_STATE_VERSION(); INC_VM_STATE_VERSION();
} }

View File

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0" #define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2007-11-26" #define RUBY_RELEASE_DATE "2007-11-27"
#define RUBY_VERSION_CODE 190 #define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20071126 #define RUBY_RELEASE_CODE 20071127
#define RUBY_PATCHLEVEL 0 #define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0 #define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2007 #define RUBY_RELEASE_YEAR 2007
#define RUBY_RELEASE_MONTH 11 #define RUBY_RELEASE_MONTH 11
#define RUBY_RELEASE_DAY 26 #define RUBY_RELEASE_DAY 27
#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];