Skip to content

Commit

Permalink
Showing 4 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ public static BuildCompoundArrayInstr decode(IRReaderDecoder d) {
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRubyObject v1 = (IRubyObject)getAppendingArg().retrieve(context, self, currScope, currDynScope, temp);
IRubyObject v2 = (IRubyObject)getAppendedArg().retrieve(context, self, currScope, currDynScope, temp);
return isArgsPush ? Helpers.argsPush((RubyArray) v1, v2) : Helpers.argsCat(v1, v2);
return isArgsPush ? Helpers.argsPush(context, (RubyArray) v1, v2) : Helpers.argsCat(context, v1, v2);
}

@Override
5 changes: 3 additions & 2 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -703,13 +703,14 @@ public void BUndefInstr(BUndefInstr bundefinstr) {

@Override
public void BuildCompoundArrayInstr(BuildCompoundArrayInstr instr) {
jvmMethod().loadContext();
visit(instr.getAppendingArg());
if (instr.isArgsPush()) jvmAdapter().checkcast("org/jruby/RubyArray");
visit(instr.getAppendedArg());
if (instr.isArgsPush()) {
jvmMethod().invokeHelper("argsPush", RubyArray.class, RubyArray.class, IRubyObject.class);
jvmMethod().invokeHelper("argsPush", RubyArray.class, ThreadContext.class, RubyArray.class, IRubyObject.class);
} else {
jvmMethod().invokeHelper("argsCat", RubyArray.class, IRubyObject.class, IRubyObject.class);
jvmMethod().invokeHelper("argsCat", RubyArray.class, ThreadContext.class, IRubyObject.class, IRubyObject.class);
}
jvmStoreLocal(instr.getResult());
}
21 changes: 15 additions & 6 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import org.jruby.internal.runtime.methods.*;
import org.jruby.ir.IRScopeType;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.javasupport.JavaClass;
import org.jruby.javasupport.JavaUtil;
import org.jruby.lexer.yacc.ISourcePosition;
@@ -2287,16 +2288,24 @@ public static void updateScopeWithCaptures(ThreadContext context, int[] scopeOff
}
}

public static RubyArray argsPush(RubyArray first, IRubyObject second) {
public static RubyArray argsPush(ThreadContext context, RubyArray first, IRubyObject second) {
return ((RubyArray)first.dup()).append(second);
}

public static RubyArray argsCat(IRubyObject first, IRubyObject second) {
Ruby runtime = first.getRuntime();
IRubyObject secondArgs;
secondArgs = Helpers.splatValue19(second);
@Deprecated
public static RubyArray argsPush(RubyArray first, IRubyObject second) {
return argsPush(first.getRuntime().getCurrentContext(), first, second);
}

return ((RubyArray) Helpers.ensureRubyArray(runtime, first).dup()).concat(secondArgs);
public static RubyArray argsCat(ThreadContext context, IRubyObject first, IRubyObject second) {
IRubyObject secondArgs = IRRuntimeHelpers.irSplat(context, second);

return ((RubyArray) Helpers.ensureRubyArray(context.runtime, first).dup()).concat(secondArgs);
}

@Deprecated
public static RubyArray argsCat(IRubyObject first, IRubyObject second) {
return argsCat(first.getRuntime().getCurrentContext(), first, second);
}

/** Use an ArgsNode (used for blocks) to generate ArgumentDescriptors */
7 changes: 0 additions & 7 deletions spec/tags/ruby/language/variables_tags.txt

This file was deleted.

0 comments on commit c5e6f78

Please sign in to comment.