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

ruby-changes:49668

From: shyouhei <ko1@a...>
Date: Fri, 12 Jan 2018 17:45:59 +0900 (JST)
Subject: [ruby-changes:49668] shyouhei:r61787 (trunk): tool/ruby_vm support for pre-2.0 BASERUBY

shyouhei	2018-01-12 17:38:12 +0900 (Fri, 12 Jan 2018)

  New Revision: 61787

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

  Log:
    tool/ruby_vm support for pre-2.0 BASERUBY
    
    This was not requested :) but actually easier than the previous
    so I just did it anyway.

  Modified files:
    trunk/tool/ruby_vm/helpers/c_escape.rb
    trunk/tool/ruby_vm/helpers/dumper.rb
    trunk/tool/ruby_vm/helpers/scanner.rb
    trunk/tool/ruby_vm/loaders/insns_def.rb
    trunk/tool/ruby_vm/models/bare_instructions.rb
    trunk/tool/ruby_vm/models/operands_unifications.rb
Index: tool/ruby_vm/helpers/scanner.rb
===================================================================
--- tool/ruby_vm/helpers/scanner.rb	(revision 61786)
+++ tool/ruby_vm/helpers/scanner.rb	(revision 61787)
@@ -20,7 +20,7 @@ class RubyVM::Scanner https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/helpers/scanner.rb#L20
   attr_reader :__LINE__
 
   def initialize path
-    src       = Pathname.new __dir__
+    src       = Pathname.new(__FILE__).realpath.dirname
     src      += path
     @__LINE__ = 1
     @__FILE__ = src.realpath.to_path
Index: tool/ruby_vm/helpers/dumper.rb
===================================================================
--- tool/ruby_vm/helpers/dumper.rb	(revision 61786)
+++ tool/ruby_vm/helpers/dumper.rb	(revision 61787)
@@ -25,7 +25,7 @@ class RubyVM::Dumper https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/helpers/dumper.rb#L25
   end
 
   def new_erb spec
-    path  = Pathname.new __dir__
+    path  = Pathname.new(__FILE__).realpath.dirname
     path += '../views'
     path += spec
     src   = path.read mode: 'rt:utf-8:utf-8'
@@ -88,8 +88,8 @@ class RubyVM::Dumper https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/helpers/dumper.rb#L88
     @file  = cstr dst.realdirpath.to_path
   end
 
-  def render partial, locals: {}
-    return do_render "_#{partial}.erb", locals
+  def render partial, opts = { :locals => {} }
+    return do_render "_#{partial}.erb", opts[:locals]
   end
 
   def generate template
Index: tool/ruby_vm/helpers/c_escape.rb
===================================================================
--- tool/ruby_vm/helpers/c_escape.rb	(revision 61786)
+++ tool/ruby_vm/helpers/c_escape.rb	(revision 61787)
@@ -118,3 +118,11 @@ module RubyVM::CEscape https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/helpers/c_escape.rb#L118
   }.freeze
   private_constant :RString2CStr
 end
+
+unless defined? ''.b
+  class String
+    def b
+      return dup.force_encoding 'binary'
+    end
+  end
+end
Index: tool/ruby_vm/models/bare_instructions.rb
===================================================================
--- tool/ruby_vm/models/bare_instructions.rb	(revision 61786)
+++ tool/ruby_vm/models/bare_instructions.rb	(revision 61787)
@@ -28,7 +28,7 @@ class RubyVM::BareInstructions https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/models/bare_instructions.rb#L28
     @pops     = typesplit @sig[:pop].reject {|i| i == '...' }
     @rets     = typesplit @sig[:ret].reject {|i| i == '...' }
     @attrs    = opts[:attributes].map {|i|
-      RubyVM::Attribute.new insn: self, **i
+      RubyVM::Attribute.new i.merge(:insn => self)
     }.each_with_object({}) {|a, h|
       h[a.key] = a
     }
@@ -149,8 +149,7 @@ class RubyVM::BareInstructions https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/models/bare_instructions.rb#L149
   end
 
   @instances = RubyVM::InsnsDef.map {|h|
-    hh = h.merge(:template => h)
-    new hh
+    new h.merge(:template => h)
   }
 
   def self.fetch name
Index: tool/ruby_vm/models/operands_unifications.rb
===================================================================
--- tool/ruby_vm/models/operands_unifications.rb	(revision 61786)
+++ tool/ruby_vm/models/operands_unifications.rb	(revision 61787)
@@ -30,7 +30,7 @@ class RubyVM::OperandsUnifications < Rub https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/models/operands_unifications.rb#L30
     json[:name]      = parts[:name]
     @preamble        = parts[:preamble]
     @spec            = parts[:spec]
-    super template: template, **json
+    super json.merge(:template => template)
     parts[:vars].each do |v|
       @variables[v[:name]] ||= v
     end
Index: tool/ruby_vm/loaders/insns_def.rb
===================================================================
--- tool/ruby_vm/loaders/insns_def.rb	(revision 61786)
+++ tool/ruby_vm/loaders/insns_def.rb	(revision 61787)
@@ -42,7 +42,7 @@ grammar = %r' https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/loaders/insns_def.rb#L42
 
 until scanner.eos? do
   next if scanner.scan(/\G#{grammar}\g<ws>+/o)
-  split = -> (v) {
+  split = lambda {|v|
     case v when /\Avoid\z/ then
       []
     else

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

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