1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2006-02-11 16:13:47 +00:00
parent d9e9972d31
commit 02de06ef1a
4 changed files with 34 additions and 18 deletions

View file

@ -1,3 +1,13 @@
Sat Feb 11 02:04:11 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (eval): no need to push ruby_class. [ruby-dev:28176]
Sat Feb 11 01:57:44 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <ocean@m2.ccsnet.ne.jp> Tue Feb 7 23:03:24 2006 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/zlib/zlib.c: should not access ruby objects in finalizer. * ext/zlib/zlib.c: should not access ruby objects in finalizer.

34
eval.c
View file

@ -1856,13 +1856,12 @@ ev_const_defined(cref, id, self)
while (cbase && cbase->nd_next) { while (cbase && cbase->nd_next) {
struct RClass *klass = RCLASS(cbase->nd_clss); struct RClass *klass = RCLASS(cbase->nd_clss);
if (!NIL_P(klass)) { if (NIL_P(klass)) return rb_const_defined(CLASS_OF(self), id);
if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) { if (klass->iv_tbl && st_lookup(klass->iv_tbl, id, &result)) {
if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) { if (result == Qundef && NIL_P(rb_autoload_p((VALUE)klass, id))) {
return Qfalse; return Qfalse;
}
return Qtrue;
} }
return Qtrue;
} }
cbase = cbase->nd_next; cbase = cbase->nd_next;
} }
@ -1881,15 +1880,14 @@ ev_const_get(cref, id, self)
while (cbase && cbase->nd_next) { while (cbase && cbase->nd_next) {
VALUE klass = cbase->nd_clss; VALUE klass = cbase->nd_clss;
if (!NIL_P(klass)) { if (NIL_P(klass)) return rb_const_get(CLASS_OF(self), id);
while (RCLASS(klass)->iv_tbl && while (RCLASS(klass)->iv_tbl &&
st_lookup(RCLASS(klass)->iv_tbl, id, &result)) { st_lookup(RCLASS(klass)->iv_tbl, id, &result)) {
if (result == Qundef) { if (result == Qundef) {
if (!RTEST(rb_autoload_load(klass, id))) break; if (!RTEST(rb_autoload_load(klass, id))) break;
continue; continue;
}
return result;
} }
return result;
} }
cbase = cbase->nd_next; cbase = cbase->nd_next;
} }
@ -6343,7 +6341,6 @@ eval(self, src, scope, file, line)
file = ruby_sourcefile; file = ruby_sourcefile;
line = ruby_sourceline; line = ruby_sourceline;
} }
PUSH_CLASS(ruby_cbase);
ruby_in_eval++; ruby_in_eval++;
if (TYPE(ruby_class) == T_ICLASS) { if (TYPE(ruby_class) == T_ICLASS) {
ruby_class = RBASIC(ruby_class)->klass; ruby_class = RBASIC(ruby_class)->klass;
@ -6364,7 +6361,6 @@ eval(self, src, scope, file, line)
result = eval_node(self, node); result = eval_node(self, node);
} }
POP_TAG(); POP_TAG();
POP_CLASS();
ruby_in_eval--; ruby_in_eval--;
if (!NIL_P(scope)) { if (!NIL_P(scope)) {
int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE; int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE;
@ -7958,6 +7954,9 @@ rb_f_autoload(obj, sym, file)
VALUE sym; VALUE sym;
VALUE file; 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); return rb_mod_autoload(ruby_cbase, sym, file);
} }
@ -7978,6 +7977,9 @@ rb_f_autoload_p(obj, sym)
VALUE sym; VALUE sym;
{ {
/* use ruby_cbase as same as rb_f_autoload. */ /* use ruby_cbase as same as rb_f_autoload. */
if (NIL_P(ruby_cbase)) {
return Qfalse;
}
return rb_mod_autoload_p(ruby_cbase, sym); return rb_mod_autoload_p(ruby_cbase, sym);
} }

View file

@ -16,7 +16,7 @@ class DRbService
@@ruby += " -d" if $DEBUG @@ruby += " -d" if $DEBUG
def self.add_service_command(nm) def self.add_service_command(nm)
dir = File.dirname(File.expand_path(__FILE__)) dir = File.dirname(File.expand_path(__FILE__))
DRb::ExtServManager.command[nm] = "#{@@ruby} #{dir}/#{nm}" DRb::ExtServManager.command[nm] = "#{@@ruby} -d #{dir}/#{nm}"
end end
%w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb).each do |nm| %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb).each do |nm|

View file

@ -4,8 +4,12 @@ module EnvUtil
return ruby return ruby
end end
ruby = "ruby" ruby = "ruby"
rubyexe = ruby+".exe"
3.times do 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) return File.expand_path(ruby)
end end
ruby = File.join("..", ruby) ruby = File.join("..", ruby)