mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
8a72c77c79
commit
fbacf5faad
6 changed files with 16 additions and 9 deletions
|
@ -118,3 +118,11 @@ module RubyVM::CEscape
|
||||||
}.freeze
|
}.freeze
|
||||||
private_constant :RString2CStr
|
private_constant :RString2CStr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
unless defined? ''.b
|
||||||
|
class String
|
||||||
|
def b
|
||||||
|
return dup.force_encoding 'binary'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ class RubyVM::Dumper
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_erb spec
|
def new_erb spec
|
||||||
path = Pathname.new __dir__
|
path = Pathname.new(__FILE__).realpath.dirname
|
||||||
path += '../views'
|
path += '../views'
|
||||||
path += spec
|
path += spec
|
||||||
src = path.read mode: 'rt:utf-8:utf-8'
|
src = path.read mode: 'rt:utf-8:utf-8'
|
||||||
|
@ -88,8 +88,8 @@ class RubyVM::Dumper
|
||||||
@file = cstr dst.realdirpath.to_path
|
@file = cstr dst.realdirpath.to_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def render partial, locals: {}
|
def render partial, opts = { :locals => {} }
|
||||||
return do_render "_#{partial}.erb", locals
|
return do_render "_#{partial}.erb", opts[:locals]
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate template
|
def generate template
|
||||||
|
|
|
@ -20,7 +20,7 @@ class RubyVM::Scanner
|
||||||
attr_reader :__LINE__
|
attr_reader :__LINE__
|
||||||
|
|
||||||
def initialize path
|
def initialize path
|
||||||
src = Pathname.new __dir__
|
src = Pathname.new(__FILE__).realpath.dirname
|
||||||
src += path
|
src += path
|
||||||
@__LINE__ = 1
|
@__LINE__ = 1
|
||||||
@__FILE__ = src.realpath.to_path
|
@__FILE__ = src.realpath.to_path
|
||||||
|
|
|
@ -42,7 +42,7 @@ grammar = %r'
|
||||||
|
|
||||||
until scanner.eos? do
|
until scanner.eos? do
|
||||||
next if scanner.scan(/\G#{grammar}\g<ws>+/o)
|
next if scanner.scan(/\G#{grammar}\g<ws>+/o)
|
||||||
split = -> (v) {
|
split = lambda {|v|
|
||||||
case v when /\Avoid\z/ then
|
case v when /\Avoid\z/ then
|
||||||
[]
|
[]
|
||||||
else
|
else
|
||||||
|
|
|
@ -28,7 +28,7 @@ class RubyVM::BareInstructions
|
||||||
@pops = typesplit @sig[:pop].reject {|i| i == '...' }
|
@pops = typesplit @sig[:pop].reject {|i| i == '...' }
|
||||||
@rets = typesplit @sig[:ret].reject {|i| i == '...' }
|
@rets = typesplit @sig[:ret].reject {|i| i == '...' }
|
||||||
@attrs = opts[:attributes].map {|i|
|
@attrs = opts[:attributes].map {|i|
|
||||||
RubyVM::Attribute.new insn: self, **i
|
RubyVM::Attribute.new i.merge(:insn => self)
|
||||||
}.each_with_object({}) {|a, h|
|
}.each_with_object({}) {|a, h|
|
||||||
h[a.key] = a
|
h[a.key] = a
|
||||||
}
|
}
|
||||||
|
@ -149,8 +149,7 @@ class RubyVM::BareInstructions
|
||||||
end
|
end
|
||||||
|
|
||||||
@instances = RubyVM::InsnsDef.map {|h|
|
@instances = RubyVM::InsnsDef.map {|h|
|
||||||
hh = h.merge(:template => h)
|
new h.merge(:template => h)
|
||||||
new hh
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def self.fetch name
|
def self.fetch name
|
||||||
|
|
|
@ -30,7 +30,7 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
|
||||||
json[:name] = parts[:name]
|
json[:name] = parts[:name]
|
||||||
@preamble = parts[:preamble]
|
@preamble = parts[:preamble]
|
||||||
@spec = parts[:spec]
|
@spec = parts[:spec]
|
||||||
super template: template, **json
|
super json.merge(:template => template)
|
||||||
parts[:vars].each do |v|
|
parts[:vars].each do |v|
|
||||||
@variables[v[:name]] ||= v
|
@variables[v[:name]] ||= v
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue