diff options
Diffstat (limited to 'ext/rubyvm/lib')
-rw-r--r-- | ext/rubyvm/lib/forwardable/impl.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/rubyvm/lib/forwardable/impl.rb b/ext/rubyvm/lib/forwardable/impl.rb new file mode 100644 index 0000000000..ddf732156a --- /dev/null +++ b/ext/rubyvm/lib/forwardable/impl.rb @@ -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 |