* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@16290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3e8e963837
commit
a823fc5d8b
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Mon May 5 11:13:50 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Mon May 5 02:10:23 2008 Tanaka Akira <akr@fsij.org>
|
Mon May 5 02:10:23 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* gc.c (set_heaps_increment): fix memory allocation strategy by
|
* gc.c (set_heaps_increment): fix memory allocation strategy by
|
||||||
|
15
compile.c
15
compile.c
@ -2283,14 +2283,17 @@ compile_colon2(rb_iseq_t *iseq, NODE * node,
|
|||||||
static int
|
static int
|
||||||
compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
|
compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
|
||||||
{
|
{
|
||||||
if (cpath->nd_head) {
|
if (nd_type(cpath) == NODE_COLON3) {
|
||||||
|
/* toplevel class ::Foo */
|
||||||
|
ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject);
|
||||||
|
}
|
||||||
|
else if (cpath->nd_head) {
|
||||||
|
/* Bar::Foo */
|
||||||
COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
|
COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
|
||||||
}
|
}
|
||||||
else if (nd_type(cpath) == NODE_COLON2) {
|
|
||||||
COMPILE(ret, "cpath (NODE_COLON2)", cpath->nd_head);
|
|
||||||
}
|
|
||||||
else {
|
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;
|
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) {
|
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,
|
ADD_INSN1(ret, nd_line(node), setconstant,
|
||||||
ID2SYM(node->nd_vid));
|
ID2SYM(node->nd_vid));
|
||||||
}
|
}
|
||||||
|
25
insns.def
25
insns.def
@ -240,24 +240,14 @@ setconstant
|
|||||||
(VALUE val, VALUE klass)
|
(VALUE val, VALUE klass)
|
||||||
()
|
()
|
||||||
{
|
{
|
||||||
if (klass == Qnil) {
|
if (klass == Qundef) {
|
||||||
klass = vm_get_cbase(th);
|
klass = vm_get_cbase(th);
|
||||||
}
|
if (NIL_P(klass)) {
|
||||||
if (NIL_P(klass)) {
|
rb_raise(rb_eTypeError, "no class/module to define constant");
|
||||||
rb_raise(rb_eTypeError, "no class/module to define constant");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch (TYPE(klass)) {
|
|
||||||
case T_CLASS:
|
|
||||||
case T_MODULE:
|
|
||||||
break;
|
|
||||||
default: {
|
|
||||||
volatile VALUE tmp = rb_obj_as_string(klass);
|
|
||||||
rb_raise(rb_eTypeError, "%s is not a class/module",
|
|
||||||
RSTRING_PTR(tmp));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vm_check_if_namespace(klass);
|
||||||
rb_const_set(klass, id, val);
|
rb_const_set(klass, id, val);
|
||||||
INC_VM_STATE_VERSION();
|
INC_VM_STATE_VERSION();
|
||||||
}
|
}
|
||||||
@ -939,8 +929,11 @@ defineclass
|
|||||||
super = rb_cObject;
|
super = rb_cObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cbase == Qnil) {
|
if (cbase == Qundef) {
|
||||||
cbase = vm_get_cbase(th);
|
cbase = vm_get_cbase(th);
|
||||||
|
if (NIL_P(klass)) {
|
||||||
|
rb_raise(rb_eTypeError, "no class/module to define constant");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vm_check_if_namespace(cbase);
|
vm_check_if_namespace(cbase);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#define RUBY_VERSION "1.9.0"
|
#define RUBY_VERSION "1.9.0"
|
||||||
#define RUBY_RELEASE_DATE "2008-05-02"
|
#define RUBY_RELEASE_DATE "2008-05-05"
|
||||||
#define RUBY_VERSION_CODE 190
|
#define RUBY_VERSION_CODE 190
|
||||||
#define RUBY_RELEASE_CODE 20080502
|
#define RUBY_RELEASE_CODE 20080505
|
||||||
#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 2008
|
#define RUBY_RELEASE_YEAR 2008
|
||||||
#define RUBY_RELEASE_MONTH 5
|
#define RUBY_RELEASE_MONTH 5
|
||||||
#define RUBY_RELEASE_DAY 2
|
#define RUBY_RELEASE_DAY 5
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
@ -985,7 +985,7 @@ vm_check_if_namespace(VALUE klass)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rb_raise(rb_eTypeError, "%s is not a class/module",
|
rb_raise(rb_eTypeError, "%s is not a class/module",
|
||||||
RSTRING_PTR(rb_obj_as_string(klass)));
|
RSTRING_PTR(rb_inspect(klass)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user