summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-19 18:47:56 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-19 18:47:56 +0000
commitd457fdad2dbcba31eee20f491deae3120db11dec ()
treeb22a65c2882e7408c924bc41f90d7c2c614c2460
parente07663ec1fa3f03031fd6e074446857490767983 (diff)
* eval.c, vm_insnhelper.c: fix cref in instance_eval
and cvar_base search protocol. * bootstraptest/test_knownbug.rb, test_eval.rb: move soleved test and add new tests. * test/ruby/test_eval.rb: fix tests for spec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--bootstraptest/test_eval.rb46
-rw-r--r--bootstraptest/test_knownbug.rb10
-rw-r--r--eval.c2
-rw-r--r--test/ruby/test_eval.rb17
-rw-r--r--vm_insnhelper.c72
6 files changed, 105 insertions, 52 deletions
@@ -1,3 +1,13 @@
Tue May 20 01:43:44 2008 Koichi Sasada <[email protected]>
* bootstraptest/test_knownbug.rb: fix a test.
@@ -236,3 +236,49 @@ assert_equal 'ok', %q{
:ok
end
}
@@ -91,16 +91,6 @@ assert_equal 'ok', %q{
}.call
}, '[ruby-dev:34646]'
-assert_equal 'ok', %q{
- begin
- 0.instance_eval { def m() :m end }
- 1.m
- :ng
- rescue Exception
- :ok
- end
-}, '[ruby-dev:34579]'
-
assert_normal_exit %q{
eval("", method(:proc).call {}.binding)
}
@@ -1933,7 +1933,7 @@ rb_obj_instance_eval(int argc, VALUE *argv, VALUE self)
VALUE klass;
if (SPECIAL_CONST_P(self)) {
- klass = CLASS_OF(self); /* klass = Qnil; */
}
else {
klass = rb_singleton_class(self);
@@ -139,7 +139,7 @@ class TestEval < Test::Unit::TestCase
assert_equal 11, o.instance_eval("11")
assert_equal 12, o.instance_eval("@ivar")
- assert_raise(NameError) {o.instance_eval("@@cvar")}
assert_equal 14, o.instance_eval("$gvar__eval")
assert_equal 15, o.instance_eval("Const")
assert_equal 16, o.instance_eval("7 + 9")
@@ -149,7 +149,7 @@ class TestEval < Test::Unit::TestCase
1.times {
assert_equal 12, o.instance_eval("@ivar")
- assert_raise(NameError) {o.instance_eval("@@cvar")}
assert_equal 14, o.instance_eval("$gvar__eval")
assert_equal 15, o.instance_eval("Const")
}
@@ -169,7 +169,7 @@ class TestEval < Test::Unit::TestCase
assert_equal 11, o.instance_eval { 11 }
assert_equal 12, o.instance_eval { @ivar }
- assert_raise(NameError) {o.instance_eval{ @@cvar }}
assert_equal 14, o.instance_eval { $gvar__eval }
assert_equal 15, o.instance_eval { Const }
assert_equal 16, o.instance_eval { 7 + 9 }
@@ -179,7 +179,7 @@ class TestEval < Test::Unit::TestCase
1.times {
assert_equal 12, o.instance_eval { @ivar }
- assert_raise(NameError) {o.instance_eval{ @@cvar }}
assert_equal 14, o.instance_eval { $gvar__eval }
assert_equal 15, o.instance_eval { Const }
}
@@ -187,8 +187,10 @@ class TestEval < Test::Unit::TestCase
def test_instance_eval_cvar
[Object.new, [], 7, :sym, true, false, nil].each do |obj|
- assert_raise(NameError){obj.instance_eval("@@cvar")}
- assert_raise(NameError){obj.instance_eval{@@cvar}}
end
end
@@ -339,9 +341,10 @@ class TestEval < Test::Unit::TestCase
end
def test_cvar_scope_with_instance_eval
Fixnum.class_eval "@@test_cvar_scope_with_instance_eval = 1" # depends on [ruby-dev:24229]
@@test_cvar_scope_with_instance_eval = 4
- assert_equal(1, 1.instance_eval("@@test_cvar_scope_with_instance_eval"), "[ruby-dev:24223]")
Fixnum.__send__(:remove_class_variable, :@@test_cvar_scope_with_instance_eval)
end
@@ -21,9 +21,10 @@
#endif
static inline rb_control_frame_t *
-vm_push_frame(rb_thread_t *th, rb_iseq_t *iseq, VALUE type,
- VALUE self, VALUE specval, VALUE *pc,
- VALUE *sp, VALUE *lfp, int local_size)
{
VALUE *dfp;
rb_control_frame_t *cfp;
@@ -48,14 +49,14 @@ vm_push_frame(rb_thread_t *th, rb_iseq_t *iseq, VALUE type,
/* setup vm control frame stack */
cfp = th->cfp = th->cfp - 1;
- cfp->pc = pc;
cfp->sp = sp + 1;
cfp->bp = sp + 1;
- cfp->iseq = iseq;
cfp->flag = type;
cfp->self = self;
cfp->lfp = lfp;
- cfp->dfp = dfp;
cfp->proc = 0;
#define COLLECT_PROFILE 0
@@ -72,7 +73,7 @@ vm_push_frame(rb_thread_t *th, rb_iseq_t *iseq, VALUE type,
}
static inline void
-vm_pop_frame(rb_thread_t *th)
{
#if COLLECT_PROFILE
rb_control_frame_t *cfp = th->cfp;
@@ -990,37 +991,32 @@ vm_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq,
klass = cref->nd_clss;
cref = cref->nd_next;
- if (klass == 0) {
- continue;
- }
- if (NIL_P(klass)) {
- if (is_defined) {
- /* TODO: check */
- return 1;
- }
- else {
- klass = CLASS_OF(th->cfp->self);
- return rb_const_get(klass, id);
- }
- }
- search_continue:
- if (RCLASS_IV_TBL(klass) &&
- st_lookup(RCLASS_IV_TBL(klass), id, &val)) {
- if (val == Qundef) {
- rb_autoload_load(klass, id);
- goto search_continue;
- }
- else {
- if (is_defined) {
- return 1;
}
else {
- return val;
}
}
}
}
klass = root_cref->nd_clss;
if (is_defined) {
return rb_const_defined(klass, id);
}
@@ -1042,14 +1038,18 @@ vm_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq,
static inline VALUE
vm_get_cvar_base(NODE *cref)
{
- VALUE klass = Qnil;
- if (cref) {
- klass = cref->nd_clss;
if (!cref->nd_next) {
rb_warn("class variable access from toplevel");
}
}
if (NIL_P(klass)) {
rb_raise(rb_eTypeError, "no class variables available");
}
@@ -1064,6 +1064,10 @@ vm_define_method(rb_thread_t *th, VALUE obj,
VALUE klass = cref->nd_clss;
int noex = cref->nd_visi;
if (is_singleton) {
if (FIXNUM_P(obj) || SYMBOL_P(obj)) {
rb_raise(rb_eTypeError,