Revision: 1116 http://trac.macosforge.org/projects/ruby/changeset/1116 Author: lsansonetti@apple.com Date: 2009-03-23 17:05:14 -0700 (Mon, 23 Mar 2009) Log Message: ----------- fixed singleton class definition, when passing a non-Array object as a splat argument inside an Array definition make sure to call #to_a if possible, fixed compilation under a given class/outer Modified Paths: -------------- MacRuby/branches/experimental/roxor.cpp MacRuby/branches/experimental/vm_eval.c Modified: MacRuby/branches/experimental/roxor.cpp =================================================================== --- MacRuby/branches/experimental/roxor.cpp 2009-03-23 22:23:56 UTC (rev 1115) +++ MacRuby/branches/experimental/roxor.cpp 2009-03-24 00:05:14 UTC (rev 1116) @@ -392,7 +392,7 @@ public: static RoxorVM *current; - Class current_opened_class; + Class current_class; VALUE current_top_object; VALUE current_exception; VALUE loaded_features; @@ -2791,7 +2791,7 @@ Value *classVal; if (nd_type(node) == NODE_SCLASS) { - classVal = compile_singleton_class(compile_current_class()); + classVal = compile_singleton_class(compile_node(node->nd_recv)); } else { assert(node->nd_cpath->nd_mid > 0); @@ -4012,8 +4012,8 @@ void rb_vm_set_const(VALUE outer, ID id, VALUE obj) { - if (outer == 0) { - outer = (VALUE)GET_VM()->current_opened_class; + if (GET_VM()->current_class != NULL) { + outer = (VALUE)GET_VM()->current_class; } rb_const_set(outer, id, obj); GET_VM()->const_defined(id); @@ -4045,8 +4045,8 @@ { assert(path > 0); - if (outer == 0) { - outer = (VALUE)GET_VM()->current_opened_class; + if (GET_VM()->current_class != NULL) { + outer = (VALUE)GET_VM()->current_class; } VALUE klass; @@ -4124,7 +4124,13 @@ rb_ary_concat(ary, obj); } else { - rb_ary_push(ary, obj); + VALUE ary2 = rb_check_convert_type(obj, T_ARRAY, "Array", "to_a"); + if (!NIL_P(ary2)) { + rb_ary_concat(ary, ary2); + } + else { + rb_ary_push(ary, obj); + } } return ary; } @@ -4256,8 +4262,8 @@ void rb_vm_prepare_method(Class klass, SEL sel, Function *func, NODE *node) { - if (klass == NULL) { - klass = GET_VM()->current_opened_class; + if (GET_VM()->current_class != NULL) { + klass = GET_VM()->current_class; } IMP imp = GET_VM()->compile(func); @@ -5297,13 +5303,14 @@ GET_VM()->current_block = NULL; VALUE old_self = b->self; b->self = self; + //Class old_class = GET_VM()->current_class; + //GET_VM()->current_class = (Class)klass; - // TODO set klass as the default outer! - VALUE retval = rb_vm_block_eval0(b, argc, argv); b->self = old_self; GET_VM()->current_block = b; + //GET_VM()->current_class = old_class; return retval; } @@ -5637,13 +5644,19 @@ VALUE rb_vm_run_under(VALUE klass, VALUE self, const char *fname, NODE *node) { - // TODO honor klass + assert(klass != 0); + assert(self != 0); + VALUE old_top_object = GET_VM()->current_top_object; GET_VM()->current_top_object = self; + Class old_class = GET_VM()->current_class; + GET_VM()->current_class = (Class)klass; + VALUE val = rb_vm_run(fname, node); GET_VM()->current_top_object = old_top_object; + GET_VM()->current_class = old_class; return val; } @@ -5756,7 +5769,7 @@ { rb_cTopLevel = rb_define_class("TopLevel", rb_cObject); - GET_VM()->current_opened_class = (Class)rb_cObject; + GET_VM()->current_class = NULL; VALUE top_self = rb_obj_alloc(rb_cTopLevel); rb_objc_retain((void *)top_self); Modified: MacRuby/branches/experimental/vm_eval.c =================================================================== --- MacRuby/branches/experimental/vm_eval.c 2009-03-23 22:23:56 UTC (rev 1115) +++ MacRuby/branches/experimental/vm_eval.c 2009-03-24 00:05:14 UTC (rev 1116) @@ -318,6 +318,9 @@ if (node == NULL) { rb_raise(rb_eSyntaxError, "compile error"); } + if (klass == 0) { + klass = rb_cObject; + } return rb_vm_run_under(klass, self, file, node); } @@ -498,7 +501,7 @@ VALUE klass; if (SPECIAL_CONST_P(self)) { - klass = Qnil; + klass = 0; } else { klass = rb_singleton_class(self);
participants (1)
-
source_changes@macosforge.org