Permalink
Browse files

fixed defined class outer inside eval.

  • Loading branch information...
1 parent 6b101bd commit 53184975985743af8d5804fe931ab026cfdae75d @takaokouji takaokouji committed Apr 24, 2011
Showing with 12 additions and 8 deletions.
  1. +3 −0 compiler.cpp
  2. +0 −1 spec/frozen/tags/macruby/core/kernel/eval_tags.txt
  3. +8 −7 vm.cpp
  4. +1 −0 vm.h
View
3 compiler.cpp
@@ -4013,6 +4013,9 @@ RoxorCompiler::compile_node0(NODE *node)
if (nd_type(node) == NODE_MODULE) {
flags |= DEFINE_MODULE;
}
+ if (inside_eval) {
+ flags |= DEFINE_INSIDE_EVAL;
+ }
Value *args[] = {
compile_id(path),
View
1 spec/frozen/tags/macruby/core/kernel/eval_tags.txt
@@ -1,2 +1 @@
-fails:Kernel#eval evaluates such that consts are scoped to the class of the eval
fails:Kernel#eval uses the filename of the binding if none is provided
View
15 vm.cpp
@@ -1458,13 +1458,14 @@ rb_vm_define_class(ID path, VALUE outer, VALUE super, int flags,
assert(path > 0);
rb_vm_check_if_module(outer);
- if (dynamic_class) {
- rb_vm_outer_t *root_outer = outer_stack;
- while (root_outer != NULL && root_outer->pushed_by_eval) {
- root_outer = root_outer->outer;
- }
- if (root_outer != NULL) {
- outer = (VALUE)root_outer->klass;
+ if (dynamic_class || (flags & DEFINE_INSIDE_EVAL)) {
+ rb_vm_outer_t *o =
+ (flags & DEFINE_INSIDE_EVAL) ? rb_vm_get_outer_stack() : outer_stack;
+ while (o != NULL && o->pushed_by_eval) {
+ o = o->outer;
+ }
+ if (o != NULL) {
+ outer = (VALUE)o->klass;
}
}
View
1 vm.h
@@ -715,6 +715,7 @@ typedef VALUE rb_vm_long_arity_bstub_t(IMP imp, id self, SEL sel,
#define DEFINE_MODULE 0x1
#define DEFINE_OUTER 0x2
#define DEFINE_SUB_OUTER 0x4
+#define DEFINE_INSIDE_EVAL 0x8
class RoxorCompiler;
class RoxorJITManager;

0 comments on commit 5318497

Please sign in to comment.