[前][次][番号順一覧][スレッド一覧]

ruby-changes:40697

From: nobu <ko1@a...>
Date: Sat, 28 Nov 2015 15:56:29 +0900 (JST)
Subject: [ruby-changes:40697] nobu:r52776 (trunk): ripper/lexer.rb: dispatch alias

nobu	2015-11-28 15:56:23 +0900 (Sat, 28 Nov 2015)

  New Revision: 52776

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52776

  Log:
    ripper/lexer.rb: dispatch alias
    
    * ext/ripper/lib/ripper/lexer.rb: alias same methods instead of
      eval for each events.

  Modified files:
    trunk/ext/ripper/lib/ripper/lexer.rb
Index: ext/ripper/lib/ripper/lexer.rb
===================================================================
--- ext/ripper/lib/ripper/lexer.rb	(revision 52775)
+++ ext/ripper/lib/ripper/lexer.rb	(revision 52776)
@@ -60,12 +60,12 @@ class Ripper https://github.com/ruby/ruby/blob/trunk/ext/ripper/lib/ripper/lexer.rb#L60
 
     private
 
+    def _push_token(tok)
+      @buf.push [[lineno(), column()], __callee__, tok]
+    end
+
     SCANNER_EVENTS.each do |event|
-      module_eval(<<-End, __FILE__+'/module_eval', __LINE__ + 1)
-        def on_#{event}(tok)
-          @buf.push [[lineno(), column()], :on_#{event}, tok]
-        end
-      End
+      alias_method "on_#{event}", :_push_token
     end
   end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]