summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--eval.c41
-rw-r--r--gc.c1
-rw-r--r--lib/complex.rb16
-rw-r--r--lib/rational.rb9
5 files changed, 38 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index b2de89b..e8a7d82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* eval.c (ruby_init): set ruby_running to true after
diff --git a/eval.c b/eval.c
index 1225349..7068bb2 100644
--- a/eval.c
+++ b/eval.c
@@ -256,7 +256,7 @@ rb_clear_cache_by_class(klass)
if (!ruby_running) return;
ent = cache; end = ent + CACHE_SIZE;
while (ent < end) {
- if (ent->origin == klass) {
+ if (ent->klass == klass || ent->origin == klass) {
ent->mid = 0;
}
ent++;
@@ -365,6 +365,7 @@ rb_get_method_body(klassp, idp, noexp)
if (ruby_running) {
/* store in cache */
+ if (BUILTIN_TYPE(origin) == T_ICLASS) origin = RBASIC(origin)->klass;
ent = cache + EXPR1(klass, id);
ent->klass = klass;
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_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 module_setup _((VALUE,NODE*));
@@ -4121,7 +4124,18 @@ rb_yield_0(val, self, klass, flags, avalue)
result = Qnil;
}
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);
}
else {
@@ -7557,24 +7571,17 @@ struct proc_funcall_data {
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
rb_proc_new(func, val)
VALUE (*func)(ANYARGS); /* VALUE yieldarg[, VALUE procarg] */
VALUE val;
{
- struct proc_funcall_data data;
+ struct BLOCK *data;
+ VALUE proc = rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
- data.func = func;
- data.val = val;
- return rb_iterate((VALUE(*)_((VALUE)))mproc, 0, proc_funcall, (VALUE)&data);
+ Data_Get_Struct(proc, struct BLOCK, data);
+ data->body->nd_state = YIELD_FUNC_AVALUE;
+ return proc;
}
static VALUE
@@ -10061,12 +10068,12 @@ catch_i(tag)
}
VALUE
-rb_catch(tag, proc, data)
+rb_catch(tag, func, data)
const char *tag;
- VALUE (*proc)();
+ VALUE (*func)();
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
diff --git a/gc.c b/gc.c
index b6ceff8..b1afbb1 100644
--- a/gc.c
+++ b/gc.c
@@ -1109,7 +1109,6 @@ obj_free(obj)
}
break;
case T_ICLASS:
- rb_clear_cache_by_class((VALUE)obj);
/* iClass shares table with the module */
break;
diff --git a/lib/complex.rb b/lib/complex.rb
index 6b3e42f..53d0f5e 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -411,19 +411,18 @@ end
class Fixnum
- alias power! **
-
+ unless defined? 1.power!
+ alias power! **
+ p [__FILE__, defined? 1.power!]
+ end
+
# Redefined to handle a Complex argument.
def ** (other)
if self < 0
Complex.new!(self, 0) ** other
else
- if defined? Rational
- if other >= 0
- self.power!(other)
- else
- Rational.new!(self,1)**other
- end
+ if defined? self.rpower
+ self.rpower(other)
else
self.power!(other)
end
@@ -597,7 +596,6 @@ module Math
end
-
# Documentation comments:
# - source: original (researched from pickaxe)
# - a couple of fixme's
diff --git a/lib/rational.rb b/lib/rational.rb
index e0a3642..38af7b8 100644
--- a/lib/rational.rb
+++ b/lib/rational.rb
@@ -329,10 +329,6 @@ class Integer
end
class Fixnum
- unless defined? Complex
- alias power! **;
- end
-
undef quo
def quo(other)
Rational.new!(self,1) / other
@@ -346,8 +342,9 @@ class Fixnum
Rational.new!(self,1)**other
end
end
-
- unless defined? Complex
+
+ unless defined? 1.power!
+ alias power! **
alias ** rpower
end
end