* 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.

* parse.y (primary): allow 'when'-less case statement; persuaded
  by Sean Chittenden.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-11-07 19:18:16 +00:00
Родитель 8e3721dfa8
Коммит 54fdacb125
9 изменённых файлов: 48 добавлений и 22 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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

10
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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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

6
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));

Просмотреть файл

@ -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