mirror of
https://github.com/ruby/ruby.git
synced 2025-08-16 05:59:00 +02:00
* parse.y (new_yield): distinguish "yield 1,2" and "yield [1,2]".
[ruby-dev:20360] * eval.c (rb_eval): support new_yield() change. * variable.c (rb_const_get_0): warn for Foo::BAR when BAR is a toplevel constant (i.e. a constant defined under Object). [ruby-list:36935] * parse.y (no_blockarg): separate no block argument check and ret_args argument processing. * range.c (rb_range_beg_len): out_of_range check after adjusting end point. [ruby-dev:20370] * parse.y (call_args): the first argument to arg_cancat() should be NODE_LIST. [ruby-core:01151] * eval.c (rb_eval): should dispatch based on ID type. * eval.c (rb_yield_0): should restore scope_vmode during yield. [ruby-dev:20361] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
65ba3eba64
commit
f289fddace
10 changed files with 151 additions and 40 deletions
46
variable.c
46
variable.c
|
@ -1284,10 +1284,11 @@ rb_const_get_at(klass, id)
|
|||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_const_get(klass, id)
|
||||
static VALUE
|
||||
rb_const_get_0(klass, id, exclude)
|
||||
VALUE klass;
|
||||
ID id;
|
||||
int exclude;
|
||||
{
|
||||
VALUE value, tmp;
|
||||
int mod_retry = 0;
|
||||
|
@ -1295,6 +1296,10 @@ rb_const_get(klass, id)
|
|||
tmp = klass;
|
||||
retry:
|
||||
while (tmp) {
|
||||
if (exclude && tmp == rb_cObject && klass != rb_cObject) {
|
||||
rb_warn("toplevel constant %s referenced by %s::%s",
|
||||
rb_id2name(id), rb_class2name(klass), rb_id2name(id));
|
||||
}
|
||||
while (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
|
||||
if (value == Qundef) {
|
||||
rb_autoload_load(tmp, id);
|
||||
|
@ -1315,6 +1320,22 @@ rb_const_get(klass, id)
|
|||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_const_get_from(klass, id)
|
||||
VALUE klass;
|
||||
ID id;
|
||||
{
|
||||
return rb_const_get_0(klass, id, Qtrue);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_const_get(klass, id)
|
||||
VALUE klass;
|
||||
ID id;
|
||||
{
|
||||
return rb_const_get_0(klass, id, Qfalse);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_mod_remove_const(mod, name)
|
||||
VALUE mod, name;
|
||||
|
@ -1439,6 +1460,27 @@ rb_const_defined_at(klass, id)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
int
|
||||
rb_const_defined_from(klass, id)
|
||||
VALUE klass;
|
||||
ID id;
|
||||
{
|
||||
VALUE tmp = klass, value;
|
||||
|
||||
while (tmp) {
|
||||
if (tmp == rb_cObject && klass != rb_cObject) {
|
||||
break;
|
||||
}
|
||||
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl, id, &value)) {
|
||||
if (value == Qundef && NIL_P(autoload_file(klass, id)))
|
||||
return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
tmp = RCLASS(tmp)->super;
|
||||
}
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
int
|
||||
rb_const_defined(klass, id)
|
||||
VALUE klass;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue