diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-28 17:57:34 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-28 17:57:34 +0000 |
commit | a2ec8666cf8fbb579fa48c73bd114908dbbc4a85 (patch) | |
tree | e0c5418d9cea6530b490ea64bd9d8077ef34ad85 /compile.c | |
parent | f0483c494fe092a35ba2022702c554eac68efddf (diff) | |
download | ruby-a2ec8666cf8fbb579fa48c73bd114908dbbc4a85.tar.gz |
* compile.c (NODE_CLASS, NODE_MODULE), insns.def (defineclass): raise
an exception when "class Foo::Bar" is evaluated and Foo::Bar is
private. To implement this, define_type of "defineclass" is added
so that the instruction can distinguish whether the class definition
is scoped (class Foo::Bar) or not (class Bar).
* test/ruby/test_class.rb (test_redefine_private_class),
test/ruby/test_module.rb
(test_define_module_under_private_constant): add tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -4680,10 +4680,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) node->nd_body, rb_sprintf("<class:%s>", rb_id2name(node->nd_cpath->nd_mid)), ISEQ_TYPE_CLASS, nd_line(node)); - compile_cpath(ret, iseq, node->nd_cpath); + VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath); COMPILE(ret, "super", node->nd_super); ADD_INSN3(ret, nd_line(node), defineclass, - ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(0)); + ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(noscope ? 3 : 0)); if (poped) { ADD_INSN(ret, nd_line(node), pop); @@ -4696,10 +4696,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) rb_sprintf("<module:%s>", rb_id2name(node->nd_cpath->nd_mid)), ISEQ_TYPE_CLASS, nd_line(node)); - compile_cpath(ret, iseq, node->nd_cpath); + VALUE noscope = compile_cpath(ret, iseq, node->nd_cpath); ADD_INSN (ret, nd_line(node), putnil); /* dummy */ ADD_INSN3(ret, nd_line(node), defineclass, - ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(2)); + ID2SYM(node->nd_cpath->nd_mid), iseqval, INT2FIX(noscope ? 5 : 2)); if (poped) { ADD_INSN(ret, nd_line(node), pop); } |