Permalink
Browse files

a new implementation for storing active blocks in the VM which fixes …

…lots of bugs

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/experimental@1562 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent b50e8c9 commit f357c64126c7b4b51eaa4378eba8f40a45421ad6 @lrz lrz committed May 11, 2009
Showing with 297 additions and 148 deletions.
  1. +14 −10 object.c
  2. +2 −13 proc.c
  3. +194 −107 roxor.cpp
  4. +2 −4 roxor.h
  5. +71 −2 test_vm/block.rb
  6. +14 −12 vm_eval.c
View
@@ -1699,11 +1699,15 @@ rb_class_new_instance0(int argc, VALUE *argv, VALUE klass)
}
//init_obj = rb_obj_call_init(obj, argc, argv);
+
+ rb_vm_block_t *block = rb_vm_current_block();
if (argc == 0) {
- init_obj = rb_vm_call_with_cache(initializeCache, obj, selInitialize, argc, argv);
+ init_obj = rb_vm_call_with_cache2(initializeCache, block, obj,
+ CLASS_OF(obj), selInitialize, argc, argv);
}
else {
- init_obj = rb_vm_call_with_cache(initialize2Cache, obj, selInitialize2, argc, argv);
+ init_obj = rb_vm_call_with_cache2(initialize2Cache, block, obj,
+ CLASS_OF(obj), selInitialize2, argc, argv);
}
if (init_obj != Qnil) {
@@ -2190,15 +2194,15 @@ convert_type(VALUE val, const char *tname, const char *method, int raise)
// m = rb_intern(method);
// if (!rb_obj_respond_to(val, m, Qtrue)) {
- SEL sel = sel_registerName(method);
- if (!rb_vm_respond_to(val, sel, true)) {
- if (raise) {
+ SEL sel = sel_registerName(method);
+ if (!rb_vm_respond_to(val, sel, true)) {
+ if (raise) {
rb_raise(rb_eTypeError, "can't convert %s into %s",
- NIL_P(val) ? "nil" :
- val == Qtrue ? "true" :
- val == Qfalse ? "false" :
- rb_obj_classname(val),
- tname);
+ NIL_P(val) ? "nil" :
+ val == Qtrue ? "true" :
+ val == Qfalse ? "false" :
+ rb_obj_classname(val),
+ tname);
}
else {
return Qnil;
View
15 proc.c
@@ -295,18 +295,7 @@ bind_eval(VALUE bindval, SEL sel, int argc, VALUE *argv)
static VALUE
proc_new(VALUE klass, int is_lambda)
{
- rb_vm_block_t *block = rb_vm_current_block();
- if (block == NULL) {
- /* If the current block is NULL, let's check if there is a previous
- * block. This is to conform to some dark Ruby behaviors, such as:
- *
- * def foo; Proc.new; end; foo { p 42 }.call
- *
- * def foo(x=Proc.new); x.call; end; foo { p 42 }
- */
- block = rb_vm_previous_block();
- }
-
+ rb_vm_block_t *block = rb_vm_first_block();
if (block == NULL) {
rb_raise(rb_eArgError,
"tried to create Proc object without a block");
@@ -1079,7 +1068,7 @@ rb_method_call(VALUE method, SEL sel, int argc, VALUE *argv)
}
}
- VALUE result = rb_vm_call_with_cache2(data->cache, data->recv,
+ VALUE result = rb_vm_call_with_cache2(data->cache, NULL, data->recv,
data->oclass, data->sel, argc, argv);
if (safe >= 0) {
Oops, something went wrong.

0 comments on commit f357c64

Please sign in to comment.