diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index 00f649f3..e92e6f75 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -42,7 +42,8 @@ module Parfait return set_type(value) if( index == 1) raise "not type #{@type.class}" unless @type.is_a?(Type) name = @type.name_at(index) - raise "object type has no name at index #{index} " unless name + #return value unless name + raise "object type (#{type}) has no name at index #{index} " unless name instance_variable_set("@#{name}".to_sym, value) value end diff --git a/lib/risc/instructions/function_return.rb b/lib/risc/instructions/function_return.rb index 642a0651..ebcc9dc8 100644 --- a/lib/risc/instructions/function_return.rb +++ b/lib/risc/instructions/function_return.rb @@ -7,6 +7,7 @@ module Risc def initialize( source , register ) super(source) @register = register + raise "Not register #{register}" unless RiscValue.look_like_reg(register) end attr_reader :register diff --git a/lib/risc/instructions/load_constant.rb b/lib/risc/instructions/load_constant.rb index 07fd6d72..33e35621 100644 --- a/lib/risc/instructions/load_constant.rb +++ b/lib/risc/instructions/load_constant.rb @@ -10,6 +10,7 @@ module Risc @register = register @constant = constant raise "Not Constant #{constant}" if constant.is_a?(Mom::SlotDefinition) + raise "Not register #{register}" unless RiscValue.look_like_reg(register) end attr_accessor :register , :constant diff --git a/lib/risc/instructions/load_data.rb b/lib/risc/instructions/load_data.rb index 19dc3bf6..3b57f581 100644 --- a/lib/risc/instructions/load_data.rb +++ b/lib/risc/instructions/load_data.rb @@ -13,6 +13,7 @@ module Risc @register = register @constant = constant raise "Not Integer #{constant}" unless constant.is_a?(Integer) + raise "Not register #{register}" unless RiscValue.look_like_reg(register) end attr_accessor :register , :constant diff --git a/lib/risc/instructions/operator_instruction.rb b/lib/risc/instructions/operator_instruction.rb index 4b3e8d56..3f0850c2 100644 --- a/lib/risc/instructions/operator_instruction.rb +++ b/lib/risc/instructions/operator_instruction.rb @@ -14,6 +14,8 @@ module Risc raise "unsuported operator :#{operator}:" unless [:+, :-, :>>, :<<, :*, :&, :|, :==].include?(operator) @left = left @right = right + raise "Not register #{left}" unless RiscValue.look_like_reg(left) + raise "Not register #{right}" unless RiscValue.look_like_reg(right) end attr_reader :operator, :left , :right