some more safety tests
This commit is contained in:
parent
ee0a1ca823
commit
5bb3ad03cc
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user