// look for mangling markers for compiled Ruby in method name
int index = element.getMethodName().indexOf("$RUBY$");
if (index >= 0) {
String unmangledMethod = element.getMethodName().substring(index + 6);
RubyString str = RubyString.newString(runtime, element.getFileName() + ":" + element.getLineNumber() + ":in `" + unmangledMethod + "'");
traceArray.append(str);
// if it's not a rescue or ensure, there's a frame associated, so decrement
if (!(element.getMethodName().contains("__rescue__") || element.getMethodName().contains("__ensure__"))) {
rubyFrameIndex--;
}
continue;
}
// look for __file__ method name for compiled roots
if (element.getMethodName().equals("__file__")) {
RubyString str = RubyString.newString(runtime, element.getFileName() + ":" + element.getLineNumber() + ": `<toplevel>'");
traceArray.append(str);
rubyFrameIndex--;
continue;
}
// look for mangling markers for bound, unframed methods in class name
index = element.getClassName().indexOf("$RUBYINVOKER$");
if (index >= 0) {
// unframed invokers have no Ruby frames, so pull from class name
// but use current frame as file and line
String unmangledMethod = element.getClassName().substring(index + 13);
Frame current = context.frameStack[rubyFrameIndex];
RubyString str = RubyString.newString(runtime, current.getFile() + ":" + (current.getLine() + 1) + ":in `" + unmangledMethod + "'");
traceArray.append(str);
continue;
}
// look for mangling markers for bound, framed methods in class name
index = element.getClassName().indexOf("$RUBYFRAMEDINVOKER$");
if (index >= 0) {
// framed invokers will have Ruby frames associated with them
addBackTraceElement(traceArray, backtraceFrames[rubyFrameIndex], backtraceFrames[rubyFrameIndex - 1], FrameType.METHOD);
rubyFrameIndex--;
continue;
}
// try to mine out a Ruby frame using our list of interpreter entry-point markers
String classMethod = element.getClassName() + "." + element.getMethodName();
FrameType frameType = INTERPRETED_FRAMES.get(classMethod);
if (frameType != null) {
// Frame matches one of our markers for "interpreted" calls
if (rubyFrameIndex == 0) {
addBackTraceElement(traceArray, backtraceFrames[rubyFrameIndex], backtraceFrames[rubyFrameIndex], frameType);
} else {
addBackTraceElement(traceArray, backtraceFrames[rubyFrameIndex], backtraceFrames[rubyFrameIndex - 1], frameType);
rubyFrameIndex--;
}
continue;
} else {
// Frame is extraneous runtime information, skip it unless debug
if (debug) {
RubyString str = RubyString.newString(runtime, createRubyBacktraceString(element));
traceArray.append(str);
}
continue;
}
}