diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-12 08:38:11 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-12 08:38:11 +0000 |
commit | 8a72c77c7920d129818b7b83bb4fa669cd7e3f7d (patch) | |
tree | e88e17811fdb1059cc3a63199c297582780c8497 /tool/ruby_vm/models | |
parent | 069e9ff52cbb01fe2c5821a9b6a8077ab59c26c7 (diff) | |
download | ruby-8a72c77c7920d129818b7b83bb4fa669cd7e3f7d.tar.gz |
tool/ruby_vm support for pre-2.1 BASERUBY
as requested by devs, support for BASERUBY prior to 2.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/ruby_vm/models')
-rw-r--r-- | tool/ruby_vm/models/attribute.rb | 10 | ||||
-rw-r--r-- | tool/ruby_vm/models/bare_instructions.rb | 19 | ||||
-rw-r--r-- | tool/ruby_vm/models/c_expr.rb | 8 | ||||
-rw-r--r-- | tool/ruby_vm/models/instructions_unifications.rb | 10 | ||||
-rw-r--r-- | tool/ruby_vm/models/operands_unifications.rb | 10 | ||||
-rw-r--r-- | tool/ruby_vm/models/trace_instructions.rb | 4 |
6 files changed, 32 insertions, 29 deletions
diff --git a/tool/ruby_vm/models/attribute.rb b/tool/ruby_vm/models/attribute.rb index 0b6d6e09b2..f6d95bd67c 100644 --- a/tool/ruby_vm/models/attribute.rb +++ b/tool/ruby_vm/models/attribute.rb @@ -16,11 +16,11 @@ class RubyVM::Attribute include RubyVM::CEscape attr_reader :insn, :key, :type, :expr - def initialize insn:, name:, type:, location:, expr: - @insn = insn - @key = name - @expr = RubyVM::CExpr.new location: location, expr: expr - @type = type + def initialize opts = {} + @insn = opts[:insn] + @key = opts[:name] + @expr = RubyVM::CExpr.new location: opts[:location], expr: opts[:expr] + @type = opts[:type] end def name diff --git a/tool/ruby_vm/models/bare_instructions.rb b/tool/ruby_vm/models/bare_instructions.rb index c3a96b8f08..a9cb4db953 100644 --- a/tool/ruby_vm/models/bare_instructions.rb +++ b/tool/ruby_vm/models/bare_instructions.rb @@ -18,16 +18,16 @@ require_relative 'attribute' class RubyVM::BareInstructions attr_reader :template, :name, :opes, :pops, :rets, :decls, :expr - def initialize template:, name:, location:, signature:, attributes:, expr: - @template = template - @name = name - @loc = location - @sig = signature - @expr = RubyVM::CExpr.new expr + def initialize opts = {} + @template = opts[:template] + @name = opts[:name] + @loc = opts[:location] + @sig = opts[:signature] + @expr = RubyVM::CExpr.new opts[:expr] @opes = typesplit @sig[:ope] @pops = typesplit @sig[:pop].reject {|i| i == '...' } @rets = typesplit @sig[:ret].reject {|i| i == '...' } - @attrs = attributes.map {|i| + @attrs = opts[:attributes].map {|i| RubyVM::Attribute.new insn: self, **i }.each_with_object({}) {|a, h| h[a.key] = a @@ -148,7 +148,10 @@ class RubyVM::BareInstructions end end - @instances = RubyVM::InsnsDef.map {|h| new template: h, **h } + @instances = RubyVM::InsnsDef.map {|h| + hh = h.merge(:template => h) + new hh + } def self.fetch name @instances.find do |insn| diff --git a/tool/ruby_vm/models/c_expr.rb b/tool/ruby_vm/models/c_expr.rb index b19dd8bb48..923651a26b 100644 --- a/tool/ruby_vm/models/c_expr.rb +++ b/tool/ruby_vm/models/c_expr.rb @@ -17,10 +17,10 @@ class RubyVM::CExpr attr_reader :__FILE__, :__LINE__, :expr - def initialize location:, expr: - @__FILE__ = location[0] - @__LINE__ = location[1] - @expr = expr + def initialize opts = {} + @__FILE__ = opts[:location][0] + @__LINE__ = opts[:location][1] + @expr = opts[:expr] end # blank, in sense of C program. diff --git a/tool/ruby_vm/models/instructions_unifications.rb b/tool/ruby_vm/models/instructions_unifications.rb index 346cebd709..aa8cef1bd5 100644 --- a/tool/ruby_vm/models/instructions_unifications.rb +++ b/tool/ruby_vm/models/instructions_unifications.rb @@ -19,10 +19,10 @@ class RubyVM::InstructionsUnifications attr_reader :name - def initialize location:, signature: - @location = location - @name = namegen signature - @series = signature.map do |i| + def initialize opts = {} + @location = opts[:location] + @name = namegen opts[:signature] + @series = opts[:signature].map do |i| RubyVM::BareInstructions.fetch i # Misshit is fatal end end @@ -34,7 +34,7 @@ class RubyVM::InstructionsUnifications end @instances = RubyVM::OptInsnUnifDef.map do |h| - new(**h) + new h end def self.to_a diff --git a/tool/ruby_vm/models/operands_unifications.rb b/tool/ruby_vm/models/operands_unifications.rb index c0ae0ece45..2a34ea0f62 100644 --- a/tool/ruby_vm/models/operands_unifications.rb +++ b/tool/ruby_vm/models/operands_unifications.rb @@ -19,13 +19,13 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions attr_reader :preamble, :original, :spec - def initialize location:, signature: - name = signature[0] + def initialize opts = {} + name = opts[:signature][0] @original = RubyVM::BareInstructions.fetch name template = @original.template - parts = compose location, signature, template[:signature] + parts = compose opts[:location], opts[:signature], template[:signature] json = template.dup - json[:location] = location + json[:location] = opts[:location] json[:signature] = parts[:signature] json[:name] = parts[:name] @preamble = parts[:preamble] @@ -122,7 +122,7 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions end @instances = RubyVM::OptOperandDef.map do |h| - new(**h) + new h end def self.to_a diff --git a/tool/ruby_vm/models/trace_instructions.rb b/tool/ruby_vm/models/trace_instructions.rb index a99a933ac7..fc904a11b5 100644 --- a/tool/ruby_vm/models/trace_instructions.rb +++ b/tool/ruby_vm/models/trace_instructions.rb @@ -18,7 +18,7 @@ class RubyVM::TraceInstructions attr_reader :name - def initialize orig: + def initialize orig @orig = orig @name = as_tr_cpp "trace @ #{@orig.name}" end @@ -61,7 +61,7 @@ class RubyVM::TraceInstructions private - @instances = RubyVM::Instructions.map {|i| new orig: i } + @instances = RubyVM::Instructions.map {|i| new i } def self.to_a @instances |