@Override public void postInvoke(IRubyObject rbValue, long[] arr, ToNativeContext context) { if (rbValue instanceof RubyArray && arr != null) { RubyArray rbArray = (RubyArray) rbValue; Ruby runtime = rbArray.getRuntime(); for (int i = 0; i < arr.length; i++) { rbArray.store(i, Util.newSigned64(runtime, arr[i])); } } }
private static void addBackTraceElement( RubyArray backtrace, RubyStackTraceElement frame, RubyStackTraceElement previousFrame, FrameType frameType) { if (frame != previousFrame && // happens with native exceptions, should not filter those out frame.getMethodName() != null && frame.getMethodName().equals(previousFrame.getMethodName()) && frame.getFileName().equals(previousFrame.getFileName()) && frame.getLineNumber() == previousFrame.getLineNumber()) { return; } StringBuilder buf = new StringBuilder(60); buf.append(frame.getFileName()).append(':').append(frame.getLineNumber()); if (previousFrame.getMethodName() != null) { switch (frameType) { case METHOD: buf.append(":in `"); buf.append(previousFrame.getMethodName()); buf.append('\''); break; case BLOCK: buf.append(":in `"); buf.append("block in " + previousFrame.getMethodName()); buf.append('\''); break; case EVAL: buf.append(":in `"); buf.append("eval in " + previousFrame.getMethodName()); buf.append('\''); break; case CLASS: buf.append(":in `"); buf.append("class in " + previousFrame.getMethodName()); buf.append('\''); break; case ROOT: buf.append(":in `<toplevel>'"); break; } } backtrace.append(backtrace.getRuntime().newString(buf.toString())); }
@Deprecated private static void addBackTraceElement( RubyArray backtrace, RubyStackTraceElement frame, RubyStackTraceElement previousFrame) { addBackTraceElement(backtrace.getRuntime(), backtrace, frame, previousFrame); }