summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-20 07:11:44 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-20 07:11:44 +0000
commitf289fddace1c84075e6794e24a3d46aee6b35d69 (patch)
treed84ee3ea9c21646d38e396bb875c4bcc591a81f4 /eval.c
parent65ba3eba645a61ae9995f9f1e88cab6150c858a7 (diff)
* 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
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/eval.c b/eval.c
index be8b3d3..de1d9b9 100644
--- a/eval.c
+++ b/eval.c
@@ -2131,7 +2131,7 @@ is_defined(self, node, buf)
switch (TYPE(val)) {
case T_CLASS:
case T_MODULE:
- if (rb_const_defined_at(val, node->nd_mid))
+ if (rb_const_defined_from(val, node->nd_mid))
return "constant";
break;
default:
@@ -2774,14 +2774,14 @@ rb_eval(self, n)
break;
case NODE_YIELD:
- if (node->nd_stts) {
+ if (node->nd_head) {
result = rb_eval(self, node->nd_head);
}
else {
result = Qundef; /* no arg */
}
SET_CURRENT_SOURCE();
- result = rb_yield_0(result, 0, 0, Qfalse, Qfalse);
+ result = rb_yield_0(result, 0, 0, Qfalse, node->nd_state);
break;
case NODE_RESCUE:
@@ -3235,15 +3235,22 @@ rb_eval(self, n)
VALUE klass;
klass = rb_eval(self, node->nd_head);
- switch (TYPE(klass)) {
- case T_CLASS:
- case T_MODULE:
- result = rb_const_get(klass, node->nd_mid);
- break;
- default:
+ if (rb_is_const_id(node->nd_mid)) {
+ switch (TYPE(klass)) {
+ case T_CLASS:
+ case T_MODULE:
+ result = rb_const_get_from(klass, node->nd_mid);
+ break;
+ default:
+ rb_raise(rb_eTypeError, "%s is not a class/module",
+ RSTRING(rb_obj_as_string(klass))->ptr);
+ break;
+ }
+ }
+ else {
result = rb_funcall(klass, node->nd_mid, 0, 0);
- break;
}
+ break;
}
break;
@@ -3506,7 +3513,7 @@ rb_eval(self, n)
cbase = class_prefix(self, node->nd_cpath);
cname = node->nd_cpath->nd_mid;
if (rb_const_defined_at(cbase, cname)) {
- klass = rb_const_get(cbase, cname);
+ klass = rb_const_get_at(cbase, cname);
if (TYPE(klass) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class",
rb_id2name(cname));
@@ -3549,7 +3556,7 @@ rb_eval(self, n)
cbase = class_prefix(self, node->nd_cpath);
cname = node->nd_cpath->nd_mid;
if (rb_const_defined_at(cbase, cname)) {
- module = rb_const_get(cbase, cname);
+ module = rb_const_get_at(cbase, cname);
if (TYPE(module) != T_MODULE) {
rb_raise(rb_eTypeError, "%s is not a module",
rb_id2name(cname));
@@ -4014,6 +4021,7 @@ rb_yield_0(val, self, klass, pcall, avalue)
volatile VALUE old_wrapper;
struct BLOCK * volatile block;
struct SCOPE * volatile old_scope;
+ int old_vmode;
struct FRAME frame;
NODE *cnode = ruby_current_node;
int state;
@@ -4035,6 +4043,8 @@ rb_yield_0(val, self, klass, pcall, avalue)
ruby_wrapper = block->wrapper;
old_scope = ruby_scope;
ruby_scope = block->scope;
+ old_vmode = scope_vmode;
+ scope_vmode = block->vmode;
ruby_block = block->prev;
if (block->flags & BLOCK_D_SCOPE) {
/* put place holder for dynamic (in-block) local variables */
@@ -4154,6 +4164,7 @@ rb_yield_0(val, self, klass, pcall, avalue)
if (ruby_scope->flags & SCOPE_DONT_RECYCLE)
scope_dup(old_scope);
ruby_scope = old_scope;
+ scope_vmode = old_vmode;
ruby_current_node = cnode;
if (state) {
if (!block->tag) {
@@ -8117,7 +8128,6 @@ rb_thread_save_context(th)
th->wrapper = ruby_wrapper;
th->cref = ruby_cref;
th->dyna_vars = ruby_dyna_vars;
- FL_SET(ruby_dyna_vars, DVAR_DONT_RECYCLE);
th->block = ruby_block;
th->flags &= THREAD_FLAGS_MASK;
th->flags |= (rb_trap_immediate<<8) | scope_vmode;