summaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-08 07:03:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-03-08 07:03:09 +0000
commit973dca035ec861c3cbea0faf5e40ccfbcd84bb17 (patch)
treed7fbdd608eb0698296838406ea964328994e342c /object.c
parent003d0aecc30a939f0712d9f85e2c150e8ccb78da (diff)
downloadruby-973dca035ec861c3cbea0faf5e40ccfbcd84bb17.tar.gz
ruby-973dca035ec861c3cbea0faf5e40ccfbcd84bb17.tar.xz
ruby-973dca035ec861c3cbea0faf5e40ccfbcd84bb17.zip
* eval.c (cvar_cbase): utility function to find innermost non
singleton cbase. * eval.c (is_defined): adopt new cvar behavior. * eval.c (rb_eval): ditto. * eval.c (assign): ditto. * class.c (rb_mod_clone): should not call rb_obj_clone(), since Module does not provide "allocate". * class.c (rb_singleton_class): should crate new singleton class if obj is a class or module and attached object is different, which means metaclass of singleton class is sought. * time.c (time_s_alloc): now follows allocation framework. * eval.c (rb_eval): should initialize outer class variables from methods in singleton class definitions. * eval.c (assign): ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/object.c b/object.c
index bf2207536..a954d8ad8 100644
--- a/object.c
+++ b/object.c
@@ -97,7 +97,7 @@ rb_obj_clone(obj)
if (rb_special_const_p(obj)) {
rb_raise(rb_eTypeError, "can't clone %s", rb_class2name(CLASS_OF(obj)));
}
- clone = rb_obj_alloc(RBASIC(obj)->klass);
+ clone = rb_obj_alloc(rb_class_real(RBASIC(obj)->klass));
CLONESETUP(clone,obj);
if (TYPE(clone) == T_OBJECT && ROBJECT(obj)->iv_tbl) {
ROBJECT(clone)->iv_tbl = st_copy(ROBJECT(obj)->iv_tbl);
@@ -658,7 +658,12 @@ VALUE
rb_obj_alloc(klass)
VALUE klass;
{
- VALUE obj = rb_funcall(klass, alloc, 0, 0);
+ VALUE obj;
+
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't create instance of virtual class");
+ }
+ obj = rb_funcall(klass, alloc, 0, 0);
if (rb_obj_class(obj) != rb_class_real(klass)) {
rb_raise(rb_eTypeError, "wrong instance allocation");
@@ -684,9 +689,6 @@ rb_class_new_instance(argc, argv, klass)
{
VALUE obj;
- if (FL_TEST(klass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "can't create instance of virtual class");
- }
obj = rb_obj_alloc(klass);
rb_obj_call_init(obj, argc, argv);