Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.language;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameInstanceVisitor;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.collections.Memo;
import org.jruby.truffle.core.module.ModuleOperations;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.backtrace.Activation;
import org.jruby.truffle.language.backtrace.Backtrace;
import org.jruby.truffle.language.backtrace.BacktraceFormatter;
import org.jruby.truffle.language.backtrace.InternalRootNode;
import org.jruby.truffle.language.exceptions.DisablingBacktracesNode;
import org.jruby.truffle.language.methods.InternalMethod;
import org.jruby.truffle.language.methods.SharedMethodInfo;
import java.util.ArrayList;
public class CallStackManager {
private final RubyContext context;
public CallStackManager(RubyContext context) {
this.context = context;
}
private static final Object STOP_ITERATING = new Object();
public FrameInstance getCallerFrameIgnoringSend() {
return getCallerFrameIgnoringSend(0);
}
@TruffleBoundary
public FrameInstance getCallerFrameIgnoringSend(int skip) {
// Try first using getCallerFrame() as it's the common case
if (skip == 0) {
FrameInstance callerFrame = Truffle.getRuntime().getCallerFrame();
if (callerFrame == null) {
return null;
}
InternalMethod method = getMethod(callerFrame);
if (method == null) { // Not a Ruby frame
return null;
} else if (!context.getCoreLibrary().isSend(method)) {
return callerFrame;
}
}
// Need to iterate further
final Object frame = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor