lib/furnace/ssa/instruction_syntax.rb in furnace-0.4.0.beta.1 vs lib/furnace/ssa/instruction_syntax.rb in furnace-0.4.0.beta.2

- old
+ new

@@ -1,24 +1,23 @@ module Furnace class SSA::InstructionSyntax def initialize(klass) @klass = klass - @operands = {} + @operands = [] @splat = nil end def evaluate yield self codegen end - def operand(name, type=nil) + def operand(name) check_for_splat - type = type.to_type unless type.nil? - @operands[name.to_sym] = type + @operands << name.to_sym end def splat(name) check_for_splat @@ -35,22 +34,26 @@ def codegen operands, splat = @operands, @splat @klass.class_eval do - operands.each_with_index do |(operand, type), index| + operands.each_with_index do |operand, index| define_method(operand) do @operands[index] end define_method(:"#{operand}=") do |value| value = value.to_value + return if @operands[index] == value + @operands[index].remove_use self if @operands[index] @operands[index] = value value.add_use self if value + SSA.instrument(self) + value end end if splat @@ -80,30 +83,11 @@ update_use_lists do @operands = values end - verify! - values end - - define_method(:verify!) do |ignore_nil_types=true| - return if @operands.nil? - - operands.each_with_index do |(operand, type), index| - next if type.nil? - - value = send operand - next if ignore_nil_types && value.type.nil? - - if value.type.nil? || !value.type.subtype_of?(type) - raise TypeError, "Wrong type for operand ##{index + 1} `#{operand}': #{SSA.inspect_type type} is expected, #{SSA.inspect_type value.type} is present" - end - end - - nil - end end end end -end \ No newline at end of file +end