1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

forwardable/impl.rb

* lib/forwardable/impl.rb (_valid_method?, _compile_method):
  extract to separate implementation specific part.
  [ruby-core:78138] [Bug #12938]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-11-20 02:12:48 +00:00
parent fb8628ecda
commit 2283d14cc9
4 changed files with 50 additions and 15 deletions

View file

@ -0,0 +1,19 @@
# :stopdoc:
module Forwardable
FILTER_EXCEPTION = ""
def self._valid_method?(method)
iseq = RubyVM::InstructionSequence.compile("().#{method}", nil, nil, 0, false)
rescue SyntaxError => e
false
else
iseq.to_a.dig(-1, 1, 1, :mid) == method.to_sym
end
def self._compile_method(src, file, line)
RubyVM::InstructionSequence.compile(src, file, file, line,
trace_instruction: false,
tailcall_optimization: true)
.eval
end
end