1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1998-03-13 09:04:32 +00:00
parent 107ead2b96
commit 056f219eca
8 changed files with 38 additions and 24 deletions

View file

@ -1,3 +1,10 @@
Fri Mar 13 13:49:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* object.c (mod_clone): need to dups constants and instance
variables.
* eval.c (rb_eval): forgot to initialize body for NODE_DEFS.
Thu Mar 12 15:33:57 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_01.

1
env.h
View file

@ -12,6 +12,7 @@
#define ENV_H
extern struct FRAME {
VALUE self;
int argc;
VALUE *argv;
ID last_func;

8
eval.c
View file

@ -1879,8 +1879,9 @@ rb_eval(self, node)
}
PUSH_ITER(the_iter->iter?ITER_PRE:ITER_NOT);
result = rb_call(RCLASS(the_frame->last_class)->super, self,
the_frame->last_func, argc, argv, 3);
result = rb_call(RCLASS(the_frame->last_class)->super,
the_frame->self, the_frame->last_func,
argc, argv, 3);
POP_ITER();
}
break;
@ -2234,7 +2235,7 @@ rb_eval(self, node)
if (node->nd_defn) {
VALUE recv = rb_eval(self, node->nd_recv);
VALUE klass;
NODE *body;
NODE *body = 0;
if (FIXNUM_P(recv)) {
TypeError("Can't define method \"%s\" for Fixnum",
@ -3169,6 +3170,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
PUSH_FRAME();
the_frame->last_func = id;
the_frame->last_class = nosuper?0:klass;
the_frame->self = recv;
the_frame->argc = argc;
the_frame->argv = argv;

6
gc.c
View file

@ -1016,6 +1016,10 @@ id2ref(obj, id)
INT ptr = NUM2INT(id);
if (FIXNUM_P(ptr)) return (VALUE)ptr;
if (ptr == TRUE) return TRUE;
if (ptr == FALSE) return FALSE;
if (ptr == Qnil) return Qnil;
if (!looks_pointerp(ptr)) {
IndexError("0x%x is not the id value", ptr);
}
@ -1045,7 +1049,7 @@ Init_GC()
rb_define_module_function(mObSpace, "remove_finalizer", rm_final, 1);
rb_define_module_function(mObSpace, "finalizers", finals, 0);
rb_define_module_function(mObSpace, "call_finalizer", call_final, 1);
rb_define_module_function(mObSpace, "id2ref", id2ref, 1);
rb_define_module_function(mObSpace, "_id2ref", id2ref, 1);
rb_global_variable(&finalizers);
finalizers = ary_new();

4
io.c
View file

@ -369,7 +369,7 @@ io_gets_method(argc, argv, io)
VALUE rs;
if (argc == 0) {
return io_gets(io);
rs = RS;
}
else {
rb_scan_args(argc, argv, "1", &rs);
@ -394,7 +394,6 @@ io_gets_method(argc, argv, io)
rsptr = 0;
rslen = 0;
}
newline = rslen ? rsptr[rslen - 1] : 0777;
GetOpenFile(io, fptr);
io_readable(fptr);
@ -413,6 +412,7 @@ io_gets_method(argc, argv, io)
} while (c != EOF);
}
newline = rslen ? rsptr[rslen - 1] : 0777;
{
char buf[8192];
char *bp, *bpe = buf + sizeof buf - 3;

View file

@ -31,26 +31,27 @@ class WeakRef<Delegator
def initialize(orig)
super
@id = orig.id
@__id = orig.id
ObjectSpace.call_finalizer orig
ID_MAP[@id] = self.id
ID_REV_MAP[self.id] = @id
ObjectSpace.call_finalizer self
ID_MAP[@__id] = self.id
ID_REV_MAP[self.id] = @__id
end
def __getobj__
unless ID_MAP[@id]
unless ID_MAP[@__id]
$@ = caller(1)
$! = RefError.new("Illegal Reference - probably recycled")
raise
end
ObjectSpace.id2ref(@id)
ObjectSpace._id2ref(@__id)
# ObjectSpace.each_object do |obj|
# return obj if obj.id == @id
# return obj if obj.id == @__id
# end
end
def weakref_alive?
if ID_MAP[@id]
if ID_MAP[@__id]
true
else
false
@ -62,9 +63,11 @@ class WeakRef<Delegator
end
end
foo = Object.new
p foo.hash
foo = WeakRef.new(foo)
p foo.hash
ObjectSpace.garbage_collect
p foo.hash
if __FILE__ == $0
foo = Object.new
p foo.hash
foo = WeakRef.new(foo)
p foo.hash
ObjectSpace.garbage_collect
p foo.hash
end

View file

@ -386,6 +386,7 @@ mod_clone(module)
clone->super = RCLASS(module)->super;
clone->iv_tbl = 0;
clone->m_tbl = 0; /* avoid GC crashing */
clone->iv_tbl = st_copy(RCLASS(module)->iv_tbl);
clone->m_tbl = st_copy(RCLASS(module)->m_tbl);
return (VALUE)clone;

View file

@ -21,11 +21,7 @@ static VALUE
range_check(args)
VALUE *args;
{
VALUE v = rb_funcall(args[0], rb_intern("<="), 1, args[1]);
if (!RTEST(v)) {
Fail(""); /* no ascending values */
}
rb_funcall(args[0], rb_intern("<=>"), 1, args[1]);
return Qnil;
}