summaryrefslogtreecommitdiff
path: root/tool/ruby_vm
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-12 08:38:12 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-12 08:38:12 +0000
commitfbacf5faade7207dd4d2a25235bf0af5f04a7ce7 (patch)
tree4522e92604be44190102e2c7fac527494f343a23 /tool/ruby_vm
parent8a72c77c7920d129818b7b83bb4fa669cd7e3f7d (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/ruby_vm')
-rw-r--r--tool/ruby_vm/helpers/c_escape.rb8
-rw-r--r--tool/ruby_vm/helpers/dumper.rb6
-rw-r--r--tool/ruby_vm/helpers/scanner.rb2
-rw-r--r--tool/ruby_vm/loaders/insns_def.rb2
-rw-r--r--tool/ruby_vm/models/bare_instructions.rb5
-rw-r--r--tool/ruby_vm/models/operands_unifications.rb2
6 files changed, 16 insertions, 9 deletions
diff --git a/tool/ruby_vm/helpers/c_escape.rb b/tool/ruby_vm/helpers/c_escape.rb
index 088df1562e..2f73b8889f 100644
--- a/tool/ruby_vm/helpers/c_escape.rb
+++ b/tool/ruby_vm/helpers/c_escape.rb
@@ -118,3 +118,11 @@ module RubyVM::CEscape
}.freeze
private_constant :RString2CStr
end
+
+unless defined? ''.b
+ class String
+ def b
+ return dup.force_encoding 'binary'
+ end
+ end
+end
diff --git a/tool/ruby_vm/helpers/dumper.rb b/tool/ruby_vm/helpers/dumper.rb
index 3ba7310f56..2d6bb269f6 100644
--- a/tool/ruby_vm/helpers/dumper.rb
+++ b/tool/ruby_vm/helpers/dumper.rb
@@ -25,7 +25,7 @@ class RubyVM::Dumper
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
@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
diff --git a/tool/ruby_vm/helpers/scanner.rb b/tool/ruby_vm/helpers/scanner.rb
index 5ae1363480..8f7531abda 100644
--- a/tool/ruby_vm/helpers/scanner.rb
+++ b/tool/ruby_vm/helpers/scanner.rb
@@ -20,7 +20,7 @@ class RubyVM::Scanner
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
diff --git a/tool/ruby_vm/loaders/insns_def.rb b/tool/ruby_vm/loaders/insns_def.rb
index 987e29640a..f83cc77fa1 100644
--- a/tool/ruby_vm/loaders/insns_def.rb
+++ b/tool/ruby_vm/loaders/insns_def.rb
@@ -42,7 +42,7 @@ grammar = %r'
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
diff --git a/tool/ruby_vm/models/bare_instructions.rb b/tool/ruby_vm/models/bare_instructions.rb
index a9cb4db953..16d5782e2f 100644
--- a/tool/ruby_vm/models/bare_instructions.rb
+++ b/tool/ruby_vm/models/bare_instructions.rb
@@ -28,7 +28,7 @@ class RubyVM::BareInstructions
@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
end
@instances = RubyVM::InsnsDef.map {|h|
- hh = h.merge(:template => h)
- new hh
+ new h.merge(:template => h)
}
def self.fetch name
diff --git a/tool/ruby_vm/models/operands_unifications.rb b/tool/ruby_vm/models/operands_unifications.rb
index 2a34ea0f62..184bb7d79c 100644
--- a/tool/ruby_vm/models/operands_unifications.rb
+++ b/tool/ruby_vm/models/operands_unifications.rb
@@ -30,7 +30,7 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
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