Skip to content

Commit

Permalink
Implement IR splat like MRI splat.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Jul 14, 2015
1 parent 08d8234 commit 76be367
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 10 additions & 2 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -1325,8 +1325,16 @@ public static RubyRegexp newLiteralRegexp(ThreadContext context, ByteList source
}

@JIT
public static RubyArray irSplat(ThreadContext context, IRubyObject maybeAry) {
return Helpers.splatValue19(maybeAry);
public static RubyArray irSplat(ThreadContext context, IRubyObject ary) {
Ruby runtime = context.runtime;
IRubyObject tmp = TypeConverter.convertToTypeWithCheck19(ary, runtime.getArray(), "to_a");
if (tmp.isNil()) {
tmp = runtime.newArray(ary);
}
else if (true /**RTEST(flag)**/) { // this logic is only used for bare splat, and MRI dups
tmp = ((RubyArray)tmp).aryDup();
}
return (RubyArray)tmp;
}

public static IRubyObject irToAry(ThreadContext context, IRubyObject value) {
Expand Down
8 changes: 0 additions & 8 deletions spec/tags/ruby/language/variables_tags.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
fails:Basic multiple assignment with a splatted single RHS value does not call #to_ary on an object
fails:Basic multiple assignment with a splatted single RHS value calls #to_a even if it's private

fails:Multiple assignment with a single RHS value does not call #to_ary if #respond_to? returns false
fails:Multiple assignment with a single RHS value assigns an Array when the RHS is an Array subclass
fails:Multiple assignment with a single splatted RHS value calls #to_a to convert nil to an empty Array
fails:Multiple assignment with a single splatted RHS value does not call #to_a if #respond_to? returns false
fails:Multiple assignment with a single splatted RHS value does not call #to_ary to convert an Object RHS with a single splat LHS
fails:Multiple assignment with a single splatted RHS value does not call #to_ary to convert an Object RHS with a single LHS
fails:Multiple assignment with a single splatted RHS value does not call #to_ary to convert an Object splat RHS when assigned to a simple MLHS
fails:Multiple assignment with a single splatted RHS value does not call #to_ary to convert an Object RHS with a MLHS
fails:Multiple assignment with a MRHS value does not call #to_ary to convert a splatted Object as part of a MRHS with a splat MRHS
fails:Multiple assignment with a MRHS value calls #to_ary to convert a splatted Object when the position receiving the value is a multiple assignment
fails:Multiple assignment with a MRHS value does not call #to_ary to convert a splatted Object when the position receiving the value is a simple variable
fails:Multiple assignment with a MRHS value does not call #to_ary to convert a splatted Object when the position receiving the value is a rest variable

0 comments on commit 76be367

Please sign in to comment.