Class: orgorg::jrubyorg::jruby::runtime::ThreadContext

Inherits:
Object
  • Object
show all
Defined in:
lib/binding_of_caller/jruby_interpreted.rb

Instance Method Summary collapse

Instance Method Details

#binding_of_caller(index) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/binding_of_caller/jruby_interpreted.rb', line 99

def binding_of_caller(index)
  unless JRuby.runtime.instance_config.compile_mode == CompileMode::OFF
    raise RuntimeError, "caller binding only supported in interpreter"
  end

  index += 1 # always omit this frame

  return nil if index > frameIndex

  frame = frameStack[frameIndex - index]

  return binding_of_caller(index - 1) if index > scopeIndex

  scope = scopeStack[scopeIndex - index]
  element = backtrace[backtraceIndex - index]

  binding = Binding.new(frame, scope.static_scope.module, scope, element.clone)

  BindingOfCaller::JRubyBindingHolder.new(binding)
end