summaryrefslogtreecommitdiff
path: root/ext/ripper/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-28 05:26:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-28 05:26:16 +0000
commitf8ecb823a0705eda22f845abea38fc065ecc3ab9 (patch)
tree718c18dc0680dd8e013de7b9e1e7c611be583236 /ext/ripper/lib
parentb08bfaf672d9f5d0da9ae0b293a692ecc0404710 (diff)
ripper/core.rb: dispatch alias
* ext/ripper/lib/ripper/core.rb: alias same methods instead of eval for each events. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/ripper/lib')
-rw-r--r--ext/ripper/lib/ripper/core.rb21
1 files changed, 11 insertions, 10 deletions
diff --git a/ext/ripper/lib/ripper/core.rb b/ext/ripper/lib/ripper/core.rb
index 637a72f..de8042f 100644
--- a/ext/ripper/lib/ripper/core.rb
+++ b/ext/ripper/lib/ripper/core.rb
@@ -29,16 +29,21 @@ class Ripper
private
+ def _dispatch_0() nil end
+ def _dispatch_1(a) a end
+ def _dispatch_2(a, b) a end
+ def _dispatch_3(a, b, c) a end
+ def _dispatch_4(a, b, c, d) a end
+ def _dispatch_5(a, b, c, d, e) a end
+ def _dispatch_6(a, b, c, d, e, f) a end
+ def _dispatch_7(a, b, c, d, e, f, g) a end
+
#
# Parser Events
#
PARSER_EVENT_TABLE.each do |id, arity|
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{id}(#{ ('a'..'z').to_a[0, arity].join(', ') })
- #{arity == 0 ? 'nil' : 'a'}
- end
- End
+ alias_method "on_#{id}", "_dispatch_#{arity}"
end
# This method is called when weak warning is produced by the parser.
@@ -60,11 +65,7 @@ class Ripper
#
SCANNER_EVENTS.each do |id|
- module_eval(<<-End, __FILE__, __LINE__ + 1)
- def on_#{id}(token)
- token
- end
- End
+ alias_method "on_#{id}", :_dispatch_1
end
end