* eval.c (rb_clear_cache_by_class): check both klass and origin.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-07-17 08:58:16 +00:00
parent 9a27cf9499
commit 8cee72d5c6
5 changed files with 38 additions and 33 deletions

View File

@ -1,3 +1,7 @@
Thu Jul 17 17:57:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_clear_cache_by_class): check both klass and origin.
Thu Jul 17 13:46:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Thu Jul 17 13:46:25 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ruby_init): set ruby_running to true after * eval.c (ruby_init): set ruby_running to true after

41
eval.c
View File

@ -256,7 +256,7 @@ rb_clear_cache_by_class(klass)
if (!ruby_running) return; if (!ruby_running) return;
ent = cache; end = ent + CACHE_SIZE; ent = cache; end = ent + CACHE_SIZE;
while (ent < end) { while (ent < end) {
if (ent->origin == klass) { if (ent->klass == klass || ent->origin == klass) {
ent->mid = 0; ent->mid = 0;
} }
ent++; ent++;
@ -365,6 +365,7 @@ rb_get_method_body(klassp, idp, noexp)
if (ruby_running) { if (ruby_running) {
/* store in cache */ /* store in cache */
if (BUILTIN_TYPE(origin) == T_ICLASS) origin = RBASIC(origin)->klass;
ent = cache + EXPR1(klass, id); ent = cache + EXPR1(klass, id);
ent->klass = klass; ent->klass = klass;
ent->noex = body->nd_noex; ent->noex = body->nd_noex;
@ -949,6 +950,8 @@ static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
#define YIELD_PROC_CALL 1 #define YIELD_PROC_CALL 1
#define YIELD_PUBLIC_DEF 2 #define YIELD_PUBLIC_DEF 2
#define YIELD_FUNC_AVALUE 1
#define YIELD_FUNC_SVALUE 2
static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int)); static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int));
static VALUE module_setup _((VALUE,NODE*)); static VALUE module_setup _((VALUE,NODE*));
@ -4121,7 +4124,18 @@ rb_yield_0(val, self, klass, flags, avalue)
result = Qnil; result = Qnil;
} }
else if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) { else if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
if (avalue) val = avalue_to_svalue(val); if (node->nd_state == YIELD_FUNC_AVALUE) {
if (!avalue) {
val = svalue_to_avalue(val);
}
}
else {
if (avalue) {
val = avalue_to_svalue(val);
}
if (val == Qundef && node->nd_state != YIELD_FUNC_SVALUE)
val = Qnil;
}
result = (*node->nd_cfnc)(val, node->nd_tval, self); result = (*node->nd_cfnc)(val, node->nd_tval, self);
} }
else { else {
@ -7557,24 +7571,17 @@ struct proc_funcall_data {
VALUE val; VALUE val;
}; };
static VALUE
proc_funcall(args, data)
VALUE args;
struct proc_funcall_data *data;
{
return (*data->func)(svalue_to_avalue(args), data->val);
}
VALUE VALUE
rb_proc_new(func, val) rb_proc_new(func, val)
VALUE (*func)(ANYARGS); /* VALUE yieldarg[, VALUE procarg] */ VALUE (*func)(ANYARGS); /* VALUE yieldarg[, VALUE procarg] */
VALUE val; VALUE val;
{ {
struct proc_funcall_data data; struct BLOCK *data;
VALUE proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
data.func = func; Data_Get_Struct(proc, struct BLOCK, data);
data.val = val; data->body->nd_state = YIELD_FUNC_AVALUE;
return rb_iterate((VALUE(*)_((VALUE)))mproc, 0, proc_funcall, (VALUE)&data); return proc;
} }
static VALUE static VALUE
@ -10061,12 +10068,12 @@ catch_i(tag)
} }
VALUE VALUE
rb_catch(tag, proc, data) rb_catch(tag, func, data)
const char *tag; const char *tag;
VALUE (*proc)(); VALUE (*func)();
VALUE data; VALUE data;
{ {
return rb_iterate((VALUE(*)_((VALUE)))catch_i, rb_intern(tag), proc, data); return rb_iterate((VALUE(*)_((VALUE)))catch_i, rb_intern(tag), func, data);
} }
static VALUE static VALUE

1
gc.c
View File

@ -1109,7 +1109,6 @@ obj_free(obj)
} }
break; break;
case T_ICLASS: case T_ICLASS:
rb_clear_cache_by_class((VALUE)obj);
/* iClass shares table with the module */ /* iClass shares table with the module */
break; break;

View File

@ -411,19 +411,18 @@ end
class Fixnum class Fixnum
unless defined? 1.power!
alias power! ** alias power! **
p [__FILE__, defined? 1.power!]
end
# Redefined to handle a Complex argument. # Redefined to handle a Complex argument.
def ** (other) def ** (other)
if self < 0 if self < 0
Complex.new!(self, 0) ** other Complex.new!(self, 0) ** other
else else
if defined? Rational if defined? self.rpower
if other >= 0 self.rpower(other)
self.power!(other)
else
Rational.new!(self,1)**other
end
else else
self.power!(other) self.power!(other)
end end
@ -597,7 +596,6 @@ module Math
end end
# Documentation comments: # Documentation comments:
# - source: original (researched from pickaxe) # - source: original (researched from pickaxe)
# - a couple of fixme's # - a couple of fixme's

View File

@ -329,10 +329,6 @@ class Integer
end end
class Fixnum class Fixnum
unless defined? Complex
alias power! **;
end
undef quo undef quo
def quo(other) def quo(other)
Rational.new!(self,1) / other Rational.new!(self,1) / other
@ -347,7 +343,8 @@ class Fixnum
end end
end end
unless defined? Complex unless defined? 1.power!
alias power! **
alias ** rpower alias ** rpower
end end
end end