1717// Further down the line, it could get converted to calls that implement splat semantics
1818public class Splat extends Operand implements DepthCloneable {
1919 final private Operand array ;
20- final public boolean unsplatArgs ;
2120
22- public Splat (Operand array , boolean unsplatArgs ) {
21+ public Splat (Operand array ) {
2322 super (OperandType .SPLAT );
2423 this .array = array ;
25- this .unsplatArgs = unsplatArgs ;
26- }
27-
28- public Splat (Operand array ) {
29- this (array , false );
3024 }
3125
3226 @ Override
3327 public String toString () {
34- return ( unsplatArgs ? "*(unsplat)" : "*" ) + array ;
28+ return "*(unsplat)" + array ;
3529 }
3630
3731 @ Override
@@ -46,7 +40,7 @@ public Operand getArray() {
4640 @ Override
4741 public Operand getSimplifiedOperand (Map <Operand , Operand > valueMap , boolean force ) {
4842 Operand newArray = array .getSimplifiedOperand (valueMap , force );
49- return (newArray == array ) ? this : new Splat (newArray , unsplatArgs );
43+ return (newArray == array ) ? this : new Splat (newArray );
5044 }
5145
5246 /** Append the list of variables used in this operand to the input list */
@@ -57,19 +51,31 @@ public void addUsedVariables(List<Variable> l) {
5751
5852 /** When fixing up splats in nested closure we need to tweak the operand if it is a LocalVariable */
5953 public Operand cloneForDepth (int n ) {
60- return array instanceof LocalVariable ? new Splat (((LocalVariable ) array ).cloneForDepth (n ), unsplatArgs ) : this ;
54+ return array instanceof LocalVariable ? new Splat (((LocalVariable ) array ).cloneForDepth (n )) : this ;
6155 }
6256
6357 @ Override
6458 public Operand cloneForInlining (CloneInfo ii ) {
65- return hasKnownValue () ? this : new Splat (array .cloneForInlining (ii ), unsplatArgs );
59+ return hasKnownValue () ? this : new Splat (array .cloneForInlining (ii ));
6660 }
6761
6862 @ Override
6963 public Object retrieve (ThreadContext context , IRubyObject self , StaticScope currScope , DynamicScope currDynScope , Object [] temp ) {
70- IRubyObject arrayVal = (IRubyObject ) array .retrieve (context , self , currScope , currDynScope , temp );
71- // SSS FIXME: Some way to specialize this code?
72- return IRRuntimeHelpers .irSplat (context , arrayVal );
64+ // Splat is now only used in call arg lists where it is guaranteed that
65+ // the splat-arg is an array.
66+ //
67+ // It is:
68+ // - either a result of a args-cat/args-push (which generate an array),
69+ // - or a result of a BuildSplatInstr (which also generates an array),
70+ // - or a rest-arg that has been received (which also generates an array)
71+ // and is being passed via zsuper.
72+ //
73+ // In addition, since this only shows up in call args, the array itself is
74+ // never modified. The array elements are extracted out and inserted into
75+ // a java array. So, a dup is not required either.
76+ //
77+ // So, besides retrieving the array, nothing more to be done here!
78+ return (IRubyObject ) array .retrieve (context , self , currScope , currDynScope , temp );
7379 }
7480
7581 @ Override
0 commit comments