aboutsummaryrefslogtreecommitdiffstats
path: root/tool/ruby_vm/models
diff options
context:
space:
mode:
Diffstat (limited to 'tool/ruby_vm/models')
-rwxr-xr-xtool/ruby_vm/models/bare_instructions.rb8
-rw-r--r--tool/ruby_vm/models/operands_unifications.rb9
2 files changed, 15 insertions, 2 deletions
diff --git a/tool/ruby_vm/models/bare_instructions.rb b/tool/ruby_vm/models/bare_instructions.rb
index 302c375589..e0fac5ff91 100755
--- a/tool/ruby_vm/models/bare_instructions.rb
+++ b/tool/ruby_vm/models/bare_instructions.rb
@@ -131,6 +131,14 @@ class RubyVM::BareInstructions
sprintf "#<%s %s@%s:%d>", self.class.name, @name, @loc[0], @loc[1]
end
+ def has_ope? var
+ return @opes.any? {|i| i[:name] == var[:name] }
+ end
+
+ def has_pop? var
+ return @pops.any? {|i| i[:name] == var[:name] }
+ end
+
private
def generate_attribute t, k, v
diff --git a/tool/ruby_vm/models/operands_unifications.rb b/tool/ruby_vm/models/operands_unifications.rb
index 1bc1a2a153..ee4e3a695d 100644
--- a/tool/ruby_vm/models/operands_unifications.rb
+++ b/tool/ruby_vm/models/operands_unifications.rb
@@ -31,7 +31,8 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
@preamble = parts[:preamble]
@spec = parts[:spec]
super json.merge(:template => template)
- parts[:vars].each do |v|
+ @konsts = parts[:vars]
+ @konsts.each do |v|
@variables[v[:name]] ||= v
end
end
@@ -63,6 +64,10 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
end
end
+ def has_ope? var
+ super or @konsts.any? {|i| i[:name] == var[:name] }
+ end
+
private
def namegen signature
@@ -101,7 +106,7 @@ class RubyVM::OperandsUnifications < RubyVM::BareInstructions
vars << k
src << {
location: location,
- expr: " #{k[:name]} = #{j};"
+ expr: " const #{k[:decl]} = #{j};"
}
end
end