summaryrefslogtreecommitdiff
path: root/lib/forwardable.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-20 02:12:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-20 02:12:48 +0000
commit2283d14cc9fefa278dfde02bdf8d84ce50cfe16f (patch)
tree30d2cbd4b62f9f61a83a9ef7e622351f630aa44a /lib/forwardable.rb
parentfb8628ecda28227d000f006cc17d4bddbc67f97e (diff)
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
Diffstat (limited to 'lib/forwardable.rb')
-rw-r--r--lib/forwardable.rb21
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index b94c9a3e61..0c04fb3a27 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -110,8 +110,10 @@
# +delegate.rb+.
#
module Forwardable
+ require 'forwardable/impl'
+
# Version of +forwardable.rb+
- FORWARDABLE_VERSION = "1.1.0"
+ FORWARDABLE_VERSION = "1.2.0"
@debug = nil
class << self
@@ -195,14 +197,8 @@ module Forwardable
accessor = "#{accessor}()"
end
- vm = RubyVM::InstructionSequence
method_call = ".__send__(:#{method}, *args, &block)"
- if begin
- iseq = vm.compile("().#{method}", nil, nil, 0, false)
- rescue SyntaxError
- else
- iseq.to_a.dig(-1, 1, 1, :mid) == method.to_sym
- end
+ if _valid_method?(method)
loc, = caller_locations(2,1)
pre = "_ ="
mesg = "#{Module === obj ? obj : obj.class}\##{ali} at #{loc.path}:#{loc.lineno} forwarding to private method "
@@ -217,22 +213,17 @@ module Forwardable
end;
end
- line_no = __LINE__+1; str = "#{<<-"begin;"}\n#{<<-"end;"}"
+ _compile_method("#{<<-"begin;"}\n#{<<-"end;"}", __FILE__, __LINE__+1)
begin;
proc do
def #{ali}(*args, &block)
#{pre}
begin
#{accessor}
- end#{method_call}
+ end#{method_call}#{FILTER_EXCEPTION}
end
end
end;
-
- vm.compile(str, __FILE__, __FILE__, line_no,
- trace_instruction: false,
- tailcall_optimization: true)
- .eval
end
end