summaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-05 02:27:29 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-05 02:27:29 +0000
commitc0c9fbc34b4847af337c4e539f21d55e0d46432a (patch)
treeb0702f4e904be214d914e51ad4a763a5ba3bf13b /compile.c
parent678c95f27849f5c36a60a95338d7d4998df8c0b0 (diff)
downloadruby-c0c9fbc34b4847af337c4e539f21d55e0d46432a.tar.gz
ruby-c0c9fbc34b4847af337c4e539f21d55e0d46432a.tar.xz
ruby-c0c9fbc34b4847af337c4e539f21d55e0d46432a.zip
* compile.c (compile_cpath): use Qundef to denote cbase lookup.
* insns.def (defineclass): Qudef is passed for cbase. * insns.def (setconstant): ditto. * vm_insnhelper.c (vm_check_if_namespace): use rb_inspect() instead of rb_obj_as_string() for better description. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/compile.c b/compile.c
index c4cbf837e..a5604fa9a 100644
--- a/compile.c
+++ b/compile.c
@@ -2283,14 +2283,17 @@ compile_colon2(rb_iseq_t *iseq, NODE * node,
static int
compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
{
- if (cpath->nd_head) {
- COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
+ if (nd_type(cpath) == NODE_COLON3) {
+ /* toplevel class ::Foo */
+ ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject);
}
- else if (nd_type(cpath) == NODE_COLON2) {
- COMPILE(ret, "cpath (NODE_COLON2)", cpath->nd_head);
+ else if (cpath->nd_head) {
+ /* Bar::Foo */
+ COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
}
else {
- ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject);
+ /* class at cbase Foo */
+ ADD_INSN1(ret, nd_line(cpath), putobject, Qundef);
}
return COMPILE_OK;
}
@@ -3432,7 +3435,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
if (node->nd_vid) {
- ADD_INSN(ret, nd_line(node), putnil);
+ ADD_INSN1(ret, nd_line(node), putobject, Qundef);
ADD_INSN1(ret, nd_line(node), setconstant,
ID2SYM(node->nd_vid));
}