Skip to content
Permalink
Browse files
[Truffle] Return with block spec passes.
  • Loading branch information
chrisseaton committed Oct 2, 2014
1 parent 39c9ca5 commit 5073469fc70598879a7d3242e2466a87c62ce3c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
@@ -1838,7 +1838,7 @@ public InjectNode(InjectNode prev) {
}

@Specialization(guards = "isObject")
public Object inject(VirtualFrame frame, RubyArray array, Object initial, RubyProc block) {
public Object injectObject(VirtualFrame frame, RubyArray array, Object initial, RubyProc block) {
int count = 0;

final Object[] store = (Object[]) array.getStore();
@@ -1862,6 +1862,25 @@ public Object inject(VirtualFrame frame, RubyArray array, Object initial, RubyPr
return accumulator;
}

@Specialization
public Object inject(VirtualFrame frame, RubyArray array, Object initial, RubyProc block) {
notDesignedForCompilation();

final Object[] store = array.slowToArray();

if (store.length < 2) {
throw new UnsupportedOperationException();
}

Object accumulator = initial;

for (int n = 0; n < array.getSize(); n++) {
accumulator = yield(frame, block, accumulator, store[n]);
}

return accumulator;
}

@Specialization
public Object inject(VirtualFrame frame, RubyArray array, RubySymbol symbol, UndefinedPlaceholder unused) {
notDesignedForCompilation();
@@ -1,3 +1,2 @@
fails:The return keyword invoked with a method call without parentheses with a block returns the value returned from the method call
fails:The return keyword in a Thread raises a LocalJumpError if used to exit a thread
fails:The return keyword within define_method stops at the method when the return is used directly

0 comments on commit 5073469

Please sign in to comment.