summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--class.c9
-rw-r--r--eval.c10
-rw-r--r--lib/finalize.rb12
-rw-r--r--lib/set.rb2
-rw-r--r--lib/tracer.rb8
-rw-r--r--lib/uri/generic.rb2
-rw-r--r--node.h6
-rw-r--r--parse.y8
9 files changed, 48 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index d8631061b9..22306063c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,14 @@ Thu Nov 7 09:51:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (blk_orphan): a block created in a different thread is
orphan. [ruby-dev:17471]
+Wed Nov 6 16:57:06 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * class.c (rb_define_method): do not set NOEX_CFUNC if klass is
+ really a module, whose methods must be safe for reciever's type.
+
+ * eval.c (rb_eval): nosuper should not be inherited unless the
+ overwritten method is an undef placeholder.
+
Tue Nov 5 00:46:04 2002 Akinori MUSHA <knu@iDaemons.org>
* ext/extmk.rb: Properly pass the given target to
@@ -16,6 +24,11 @@ Mon Nov 4 20:03:53 2002 NAKAMURA Usaku <usa@ruby-lang.org>
* instruby.rb, lib/mkmf.rb: use CONFIG["ENABLE_SHARED"] instead of
checking whether CONFIG["configure-args"] includes "--enable-shared".
+Mon Nov 4 16:49:14 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (primary): allow 'when'-less case statement; persuaded
+ by Sean Chittenden.
+
Mon Nov 4 06:28:09 2002 Akinori MUSHA <knu@iDaemons.org>
* Makefile.in, ext/extmk.rb, bcc32/Makefile.sub,
diff --git a/class.c b/class.c
index edd17e1250..e680dc7a67 100644
--- a/class.c
+++ b/class.c
@@ -684,10 +684,13 @@ rb_define_method(klass, name, func, argc)
int argc;
{
ID id = rb_intern(name);
+ int ex = NOEX_PUBLIC;
- rb_add_method(klass, id, NEW_CFUNC(func, argc),
- ((name[0] == 'i' && id == rb_intern("initialize"))?
- NOEX_PRIVATE:NOEX_PUBLIC)|NOEX_CFUNC);
+
+ if (BUILTIN_TYPE(klass) == T_CLASS) {
+ ex |= NOEX_CFUNC;
+ }
+ rb_add_method(klass, id, NEW_CFUNC(func, argc), ex);
}
void
diff --git a/eval.c b/eval.c
index 6a7254587e..75f70b8a81 100644
--- a/eval.c
+++ b/eval.c
@@ -384,7 +384,7 @@ rb_disable_super(klass, name)
print_undef(klass, mid);
}
if (origin == klass) {
- body->nd_noex |= NOEX_UNDEF;
+ body->nd_noex |= NOEX_NOSUPER;
}
else {
rb_add_method(klass, mid, 0, NOEX_UNDEF);
@@ -408,7 +408,7 @@ rb_enable_super(klass, name)
remove_method(klass, mid);
}
else {
- body->nd_noex &= ~NOEX_UNDEF;
+ body->nd_noex &= ~NOEX_NOSUPER;
}
}
@@ -3204,8 +3204,8 @@ rb_eval(self, n)
else {
noex = NOEX_PUBLIC;
}
- if (body && origin == ruby_class && body->nd_noex & NOEX_UNDEF) {
- noex |= NOEX_UNDEF;
+ if (body && origin == ruby_class && body->nd_body == 0) {
+ noex |= NOEX_NOSUPER;
}
defn = copy_node_scope(node->nd_defn, ruby_cref);
@@ -4807,7 +4807,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
}
}
- return rb_call0(klass, recv, mid, id, argc, argv, body, noex & NOEX_UNDEF);
+ return rb_call0(klass, recv, mid, id, argc, argv, body, noex & NOEX_NOSUPER);
}
VALUE
diff --git a/lib/finalize.rb b/lib/finalize.rb
index 7d86d94212..ed1ccc830f 100644
--- a/lib/finalize.rb
+++ b/lib/finalize.rb
@@ -52,17 +52,17 @@ module Finalizer
ObjectSpace.call_finalizer(obj)
method = method.intern unless method.kind_of?(Integer)
assoc = [dependant, method].concat(opt)
- if dep = @dependency[obj.id]
+ if dep = @dependency[obj.object_id]
dep.push assoc
else
- @dependency[obj.id] = [assoc]
+ @dependency[obj.object_id] = [assoc]
end
end
alias add add_dependency
# delete dependency R_method(obj, dependant)
def delete_dependency(id, dependant, method = :finalize)
- id = id.id unless id.kind_of?(Integer)
+ id = id.object_id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
for assoc in @dependency[id]
assoc.delete_if do
@@ -76,7 +76,7 @@ module Finalizer
# delete dependency R_*(obj, dependant)
def delete_all_dependency(id, dependant)
- id = id.id unless id.kind_of?(Integer)
+ id = id.object_id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
for assoc in @dependency[id]
assoc.delete_if do
@@ -104,7 +104,7 @@ module Finalizer
# finalize the depandant connected by dependency R_method(obj, dependtant)
def finalize_dependency(id, dependant, method = :finalize)
- id = id.id unless id.kind_of?(Integer)
+ id = id.object_id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
for assocs in @dependency[id]
assocs.delete_if do
@@ -119,7 +119,7 @@ module Finalizer
# finalize all dependants connected by dependency R_*(obj, dependtant)
def finalize_all_dependency(id, dependant)
- id = id.id unless id.kind_of?(Integer)
+ id = id.object_id unless id.kind_of?(Integer)
method = method.intern unless method.kind_of?(Integer)
for assoc in @dependency[id]
assoc.delete_if do
diff --git a/lib/set.rb b/lib/set.rb
index 945bdd7c98..ec4037a172 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -265,7 +265,7 @@ class Set
def flatten_merge(set, seen = Set.new)
set.each { |e|
if e.is_a?(Set)
- if seen.include?(e_id = e.id)
+ if seen.include?(e_id = e.object_id)
raise ArgumentError, "tried to flatten recursive Set"
end
diff --git a/lib/tracer.rb b/lib/tracer.rb
index 70be58da5a..f522a9178d 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -39,9 +39,9 @@ class Tracer
def initialize
@threads = Hash.new
if defined? Thread.main
- @threads[Thread.main.id] = 0
+ @threads[Thread.main.object_id] = 0
else
- @threads[Thread.current.id] = 0
+ @threads[Thread.current.object_id] = 0
end
@get_line_procs = {}
@@ -105,10 +105,10 @@ class Tracer
end
def get_thread_no
- if no = @threads[Thread.current.id]
+ if no = @threads[Thread.current.object_id]
no
else
- @threads[Thread.current.id] = @threads.size
+ @threads[Thread.current.object_id] = @threads.size
end
end
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 73f80c946c..b819dd12b3 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -1130,7 +1130,7 @@ Object
=begin
=end
def inspect
- sprintf("#<%s:0x%x URL:%s>", self.class.to_s, self.id, self.to_s)
+ sprintf("#<%s:0x%x URL:%s>", self.class.to_s, self.object_id, self.to_s)
end
=begin
diff --git a/node.h b/node.h
index ec27c86012..691a4cd8c1 100644
--- a/node.h
+++ b/node.h
@@ -334,12 +334,14 @@ typedef struct RNode {
#define NEW_BMETHOD(b) rb_node_newnode(NODE_BMETHOD,0,0,b)
#define NOEX_PUBLIC 0
-#define NOEX_UNDEF 1
-#define NOEX_CFUNC 1
+#define NOEX_NOSUPER 1
#define NOEX_PRIVATE 2
#define NOEX_PROTECTED 4
#define NOEX_MASK 6
+#define NOEX_UNDEF NOEX_NOSUPER
+#define NOEX_CFUNC NOEX_NOSUPER
+
NODE *rb_compile_cstr _((const char*, const char*, int, int));
NODE *rb_compile_string _((const char*, VALUE, int));
NODE *rb_compile_file _((const char*, VALUE, int));
diff --git a/parse.y b/parse.y
index 8a6a3fee77..4ff369953a 100644
--- a/parse.y
+++ b/parse.y
@@ -485,6 +485,10 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
$$ = 0;
}
}
+ | expr kRESCUE_MOD expr
+ {
+ $$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
+ }
| primary_value '[' aref_args ']' tOP_ASGN command_call
{
NODE *args;
@@ -1417,6 +1421,10 @@ primary : literal
{
$$ = $3;
}
+ | kCASE opt_terms kELSE compstmt kEND
+ {
+ $$ = $4;
+ }
| kFOR block_var kIN {COND_PUSH(1);} expr_value do {COND_POP();}
compstmt
kEND