public abstract class RubyCallStack {
public static RubyMethod getCurrentMethod() {
CompilerAsserts.neverPartOfCompilation();
MethodLike method;
final FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();
method = getMethod(currentFrame);
if (method instanceof RubyMethod) {
return (RubyMethod) method;
}
return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<RubyMethod>() {
@Override
public RubyMethod visitFrame(FrameInstance frameInstance) {
final MethodLike maybeMethod = getMethod(frameInstance);
if (maybeMethod instanceof RubyMethod) {
return (RubyMethod) maybeMethod;
} else {
return null;