some more safety tests

This commit is contained in:
Torsten Ruger 2018-04-05 12:22:40 +03:00
parent ee0a1ca823
commit 5bb3ad03cc
5 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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