mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (cvar_cbase): utility function to find innermost non
singleton cbase. * eval.c (is_defined): adopt new cvar behavior. * eval.c (rb_eval): ditto. * eval.c (assign): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cffe9928c4
commit
3e29ea9a7d
9 changed files with 70 additions and 55 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Fri Mar 8 02:21:32 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (cvar_cbase): utility function to find innermost non
|
||||
singleton cbase.
|
||||
|
||||
* eval.c (is_defined): adopt new cvar behavior.
|
||||
|
||||
* eval.c (rb_eval): ditto.
|
||||
|
||||
* eval.c (assign): ditto.
|
||||
|
||||
Thu Mar 7 20:08:25 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* gc.c (rb_source_filename): added. holds unique strings for file
|
||||
|
@ -42,6 +53,17 @@ Mon Mar 4 13:23:16 2002 Akinori MUSHA <knu@iDaemons.org>
|
|||
--with-xx-{include,lib} is ignored when --with-xx-dir is
|
||||
specified.
|
||||
|
||||
Mon Mar 4 00:09:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_eval): should initialize outer class variables from
|
||||
methods in singleton class definitions.
|
||||
|
||||
* eval.c (assign): ditto.
|
||||
|
||||
Sun Mar 3 15:02:23 2002 akira yamada <akira@arika.org>
|
||||
|
||||
* marshal.c (r_object): should call "call", not "yield".
|
||||
|
||||
Fri Mar 1 23:08:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* stable version 1.6.7 released.
|
||||
|
|
51
eval.c
51
eval.c
|
@ -1460,6 +1460,20 @@ ev_const_get(cref, id, self)
|
|||
return rb_const_get(cref->nd_clss, id);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
cvar_cbase()
|
||||
{
|
||||
NODE *cref = RNODE(ruby_frame->cbase);
|
||||
|
||||
while (cref && cref->nd_next && FL_TEST(cref->nd_clss, FL_SINGLETON)) {
|
||||
cref = cref->nd_next;
|
||||
if (!cref->nd_next) {
|
||||
rb_warn("class variable access from toplevel singleton method");
|
||||
}
|
||||
}
|
||||
return cref->nd_clss;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_mod_nesting()
|
||||
{
|
||||
|
@ -1837,19 +1851,7 @@ is_defined(self, node, buf)
|
|||
break;
|
||||
|
||||
case NODE_CVAR:
|
||||
if (NIL_P(ruby_cbase)) {
|
||||
if (rb_cvar_defined(CLASS_OF(self), node->nd_vid)) {
|
||||
return "class variable";
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
||||
if (rb_cvar_defined(ruby_cbase, node->nd_vid)) {
|
||||
return "class variable";
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (rb_cvar_defined(rb_iv_get(ruby_cbase, "__attached__"), node->nd_vid)) {
|
||||
if (rb_cvar_defined(cvar_cbase(), node->nd_vid)) {
|
||||
return "class variable";
|
||||
}
|
||||
break;
|
||||
|
@ -2724,15 +2726,12 @@ rb_eval(self, n)
|
|||
rb_raise(rb_eTypeError, "no class/module to define class variable");
|
||||
}
|
||||
result = rb_eval(self, node->nd_value);
|
||||
if (ruby_verbose && FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
||||
rb_warn("declaring singleton class variable");
|
||||
}
|
||||
rb_cvar_declare(ruby_cbase, node->nd_vid, result);
|
||||
rb_cvar_declare(cvar_cbase(), node->nd_vid, result);
|
||||
break;
|
||||
|
||||
case NODE_CVASGN:
|
||||
result = rb_eval(self, node->nd_value);
|
||||
rb_cvar_set(ruby_cbase, node->nd_vid, result);
|
||||
rb_cvar_set(cvar_cbase(), node->nd_vid, result);
|
||||
break;
|
||||
|
||||
case NODE_LVAR:
|
||||
|
@ -2759,15 +2758,7 @@ rb_eval(self, n)
|
|||
break;
|
||||
|
||||
case NODE_CVAR:
|
||||
if (NIL_P(ruby_cbase)) {
|
||||
result = rb_cvar_get(CLASS_OF(self), node->nd_vid);
|
||||
break;
|
||||
}
|
||||
if (!FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
||||
result = rb_cvar_get(ruby_cbase, node->nd_vid);
|
||||
break;
|
||||
}
|
||||
result = rb_cvar_get(rb_iv_get(ruby_cbase, "__attached__"), node->nd_vid);
|
||||
result = rb_cvar_get(cvar_cbase(), node->nd_vid);
|
||||
break;
|
||||
|
||||
case NODE_BLOCK_ARG:
|
||||
|
@ -3014,7 +3005,7 @@ rb_eval(self, n)
|
|||
NODE *body = 0, *defn;
|
||||
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(recv)) {
|
||||
rb_raise(rb_eSecurityError, "Insecure; can't define singleton method");
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't define singleton method");
|
||||
}
|
||||
if (FIXNUM_P(recv) || SYMBOL_P(recv)) {
|
||||
rb_raise(rb_eTypeError,
|
||||
|
@ -3822,11 +3813,11 @@ assign(self, lhs, val, check)
|
|||
if (ruby_verbose && FL_TEST(ruby_cbase, FL_SINGLETON)) {
|
||||
rb_warn("declaring singleton class variable");
|
||||
}
|
||||
rb_cvar_declare(ruby_cbase, lhs->nd_vid, val);
|
||||
rb_cvar_declare(cvar_cbase(), lhs->nd_vid, val);
|
||||
break;
|
||||
|
||||
case NODE_CVASGN:
|
||||
rb_cvar_set(ruby_cbase, lhs->nd_vid, val);
|
||||
rb_cvar_set(cvar_cbase(), lhs->nd_vid, val);
|
||||
break;
|
||||
|
||||
case NODE_MASGN:
|
||||
|
|
|
@ -450,11 +450,11 @@ module TkComm
|
|||
end
|
||||
|
||||
def pack(*args)
|
||||
TkPack.configure *args
|
||||
TkPack.configure(*args)
|
||||
end
|
||||
|
||||
def grid(*args)
|
||||
TkGrid.configure *args
|
||||
TkGrid.configure(*args)
|
||||
end
|
||||
|
||||
def update(idle=nil)
|
||||
|
@ -495,18 +495,18 @@ module TkCore
|
|||
myid = _curr_cmd_id
|
||||
cmdid = install_cmd(cmd)
|
||||
tk_call("after",ms,cmdid)
|
||||
return
|
||||
if false #defined? Thread
|
||||
Thread.start do
|
||||
ms = Float(ms)/1000
|
||||
ms = 10 if ms == 0
|
||||
sleep ms/1000
|
||||
cmd.call
|
||||
end
|
||||
else
|
||||
cmdid = install_cmd(cmd)
|
||||
tk_call("after",ms,cmdid)
|
||||
end
|
||||
# return
|
||||
# if false #defined? Thread
|
||||
# Thread.start do
|
||||
# ms = Float(ms)/1000
|
||||
# ms = 10 if ms == 0
|
||||
# sleep ms/1000
|
||||
# cmd.call
|
||||
# end
|
||||
# else
|
||||
# cmdid = install_cmd(cmd)
|
||||
# tk_call("after",ms,cmdid)
|
||||
# end
|
||||
end
|
||||
|
||||
def after_idle(cmd=Proc.new)
|
||||
|
@ -657,10 +657,11 @@ module TkCore
|
|||
end
|
||||
|
||||
def tk_call(*args)
|
||||
print args.join(" "), "\n" if $DEBUG
|
||||
puts args.inspect if $DEBUG
|
||||
args.collect! {|x|ruby2tcl(x)}
|
||||
args.compact!
|
||||
args.flatten!
|
||||
print "=> ", args.join(" ").inspect, "\n" if $DEBUG
|
||||
begin
|
||||
res = INTERP._invoke(*args)
|
||||
rescue NameError
|
||||
|
@ -676,7 +677,7 @@ module TkCore
|
|||
if INTERP._return_value() != 0
|
||||
fail RuntimeError, res, error_at
|
||||
end
|
||||
print "==> ", res, "\n" if $DEBUG
|
||||
print "==> ", res.inspect, "\n" if $DEBUG
|
||||
return res
|
||||
end
|
||||
end
|
||||
|
@ -836,8 +837,8 @@ module Tk
|
|||
if bar
|
||||
@xscrollbar = bar
|
||||
@xscrollbar.orient 'horizontal'
|
||||
self.xscrollcommand {|arg| @xscrollbar.set *arg}
|
||||
@xscrollbar.command {|arg| self.xview *arg}
|
||||
self.xscrollcommand {|arg| @xscrollbar.set(*arg)}
|
||||
@xscrollbar.command {|arg| self.xview(*arg)}
|
||||
end
|
||||
@xscrollbar
|
||||
end
|
||||
|
@ -845,8 +846,8 @@ module Tk
|
|||
if bar
|
||||
@yscrollbar = bar
|
||||
@yscrollbar.orient 'vertical'
|
||||
self.yscrollcommand {|arg| @yscrollbar.set *arg}
|
||||
@yscrollbar.command {|arg| self.yview *arg}
|
||||
self.yscrollcommand {|arg| @yscrollbar.set(*arg)}
|
||||
@yscrollbar.command {|arg| self.yview(*arg)}
|
||||
end
|
||||
@yscrollbar
|
||||
end
|
||||
|
|
|
@ -776,7 +776,7 @@ class TkFont
|
|||
|
||||
def call_font_configure(path, *args)
|
||||
args += hash_kv(args.pop.update(@fontslot))
|
||||
tk_call *args
|
||||
tk_call(*args)
|
||||
Tk_FontUseTBL[path] = self
|
||||
self
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ class TkText<TkTextWin
|
|||
def self.new(*args, &block)
|
||||
obj = super(*args){}
|
||||
obj.init_instance_variable
|
||||
obj.instance_eval &block if defined? yield
|
||||
obj.instance_eval(&block) if defined? yield
|
||||
obj
|
||||
end
|
||||
|
||||
|
|
2
hash.c
2
hash.c
|
@ -96,7 +96,7 @@ rb_any_hash(a)
|
|||
DEFER_INTS;
|
||||
hval = rb_funcall(a, hash, 0);
|
||||
if (!FIXNUM_P(hval)) {
|
||||
hval = rb_funcall(hval, '%', 1, INT2FIX(65439));
|
||||
hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
|
||||
}
|
||||
ENABLE_INTS;
|
||||
return (int)FIX2LONG(hval);
|
||||
|
|
|
@ -1047,7 +1047,7 @@ r_object(arg)
|
|||
break;
|
||||
}
|
||||
if (arg->proc) {
|
||||
rb_funcall(arg->proc, rb_intern("yield"), 1, v);
|
||||
rb_funcall(arg->proc, rb_intern("call"), 1, v);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
1
parse.y
1
parse.y
|
@ -2845,6 +2845,7 @@ yylex()
|
|||
case EXPR_BEG:
|
||||
case EXPR_FNAME:
|
||||
case EXPR_DOT:
|
||||
case EXPR_CLASS:
|
||||
goto retry;
|
||||
default:
|
||||
break;
|
||||
|
|
2
signal.c
2
signal.c
|
@ -521,7 +521,7 @@ trap(arg)
|
|||
s += 3;
|
||||
sig = signm2signo(s);
|
||||
if (sig == 0 && strcmp(s, "EXIT") != 0)
|
||||
rb_raise(rb_eArgError, "invalid signal SIG%s", s);
|
||||
rb_raise(rb_eArgError, "unsupported signal SIG%s", s);
|
||||
}
|
||||
|
||||
if (sig < 0 || sig > NSIG) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue