From 02de06ef1a9df0fd3e76328d402b1a62bb5cece8 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 11 Feb 2006 16:13:47 +0000 Subject: * eval.c (eval): no need to push ruby_class. [ruby-dev:28176] * eval.c (rb_f_autoload): check if ruby_cbase is nil (during instance_eval for objects cannot have singleton classes, e.g. fixnums and symbols). [ruby-dev:28178] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ eval.c | 34 ++++++++++++++++++---------------- test/drb/drbtest.rb | 2 +- test/ruby/envutil.rb | 6 +++++- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8aad07731e..a854ae4754 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sat Feb 11 02:04:11 2006 Yukihiro Matsumoto + + * eval.c (eval): no need to push ruby_class. [ruby-dev:28176] + +Sat Feb 11 01:57:44 2006 Yukihiro Matsumoto + + * eval.c (rb_f_autoload): check if ruby_cbase is nil (during + instance_eval for objects cannot have singleton classes, + e.g. fixnums and symbols). [ruby-dev:28178] + Tue Feb 7 23:03:24 2006 Hirokazu Yamamoto * ext/zlib/zlib.c: should not access ruby objects in finalizer. diff --git a/eval.c b/eval.c index 6f47130ac4..87cf6127b1 100644 --- a/eval.c +++ b/eval.c @@ -1856,13 +1856,12 @@ ev_const_defined(cref, id, self) while (cbase && cbase->nd_next) { struct RClass *klass = RCLASS(cbase->nd_clss); - if (!NIL_P(klass)) { - if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { - if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) { - return Qfalse; - } - return Qtrue; + if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id); + if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { + if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) { + return Qfalse; } + return Qtrue; } cbase = cbase->nd_next; } @@ -1881,15 +1880,14 @@ ev_const_get(cref, id, self) while (cbase && cbase->nd_next) { VALUE klass = cbase->nd_clss; - if (!NIL_P(klass)) { - while (RCLASS(klass)->iv_tbl && - st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { - if (result == Qundef) { - if (!RTEST(rb_autoload_load(klass, id))) break; - continue; - } - return result; + if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id); + while (RCLASS(klass)->iv_tbl && + st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { + if (result == Qundef) { + if (!RTEST(rb_autoload_load(klass, id))) break; + continue; } + return result; } cbase = cbase->nd_next; } @@ -6343,7 +6341,6 @@ eval(self, src, scope, file, line) file = ruby_sourcefile; line = ruby_sourceline; } - PUSH_CLASS(ruby_cbase); ruby_in_eval++; if (TYPE(ruby_class) == T_ICLASS) { ruby_class = RBASIC(ruby_class)->klass; @@ -6364,7 +6361,6 @@ eval(self, src, scope, file, line) result = eval_node(self, node); } POP_TAG(); - POP_CLASS(); ruby_in_eval--; if (!NIL_P(scope)) { int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE; @@ -7958,6 +7954,9 @@ rb_f_autoload(obj, sym, file) VALUE sym; VALUE file; { + if (NIL_P(ruby_cbase)) { + rb_raise(rb_eTypeError, "no class/module for autoload target"); + } return rb_mod_autoload(ruby_cbase, sym, file); } @@ -7978,6 +7977,9 @@ rb_f_autoload_p(obj, sym) VALUE sym; { /* use ruby_cbase as same as rb_f_autoload. */ + if (NIL_P(ruby_cbase)) { + return Qfalse; + } return rb_mod_autoload_p(ruby_cbase, sym); } diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb index 30aafb5788..6f05de70c1 100644 --- a/test/drb/drbtest.rb +++ b/test/drb/drbtest.rb @@ -16,7 +16,7 @@ class DRbService @@ruby += " -d" if $DEBUG def self.add_service_command(nm) dir = File.dirname(File.expand_path(__FILE__)) - DRb::ExtServManager.command[nm] = "#{@@ruby} #{dir}/#{nm}" + DRb::ExtServManager.command[nm] = "#{@@ruby} -d #{dir}/#{nm}" end %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb).each do |nm| diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index cd9ad3c858..c481326288 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -4,8 +4,12 @@ module EnvUtil return ruby end ruby = "ruby" + rubyexe = ruby+".exe" 3.times do - if File.exist? ruby or File.exist? ruby+".exe" + if File.exist? ruby and File.executable? ruby and !File.directory? ruby + return File.expand_path(ruby) + end + if File.exist? rubyexe and File.executable? rubyexe return File.expand_path(ruby) end ruby = File.join("..", ruby) -- cgit v1.2.3