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)
|
return set_type(value) if( index == 1)
|
||||||
raise "not type #{@type.class}" unless @type.is_a?(Type)
|
raise "not type #{@type.class}" unless @type.is_a?(Type)
|
||||||
name = @type.name_at(index)
|
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)
|
instance_variable_set("@#{name}".to_sym, value)
|
||||||
value
|
value
|
||||||
end
|
end
|
||||||
|
@ -7,6 +7,7 @@ module Risc
|
|||||||
def initialize( source , register )
|
def initialize( source , register )
|
||||||
super(source)
|
super(source)
|
||||||
@register = register
|
@register = register
|
||||||
|
raise "Not register #{register}" unless RiscValue.look_like_reg(register)
|
||||||
end
|
end
|
||||||
attr_reader :register
|
attr_reader :register
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ module Risc
|
|||||||
@register = register
|
@register = register
|
||||||
@constant = constant
|
@constant = constant
|
||||||
raise "Not Constant #{constant}" if constant.is_a?(Mom::SlotDefinition)
|
raise "Not Constant #{constant}" if constant.is_a?(Mom::SlotDefinition)
|
||||||
|
raise "Not register #{register}" unless RiscValue.look_like_reg(register)
|
||||||
end
|
end
|
||||||
attr_accessor :register , :constant
|
attr_accessor :register , :constant
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ module Risc
|
|||||||
@register = register
|
@register = register
|
||||||
@constant = constant
|
@constant = constant
|
||||||
raise "Not Integer #{constant}" unless constant.is_a?(Integer)
|
raise "Not Integer #{constant}" unless constant.is_a?(Integer)
|
||||||
|
raise "Not register #{register}" unless RiscValue.look_like_reg(register)
|
||||||
end
|
end
|
||||||
attr_accessor :register , :constant
|
attr_accessor :register , :constant
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ module Risc
|
|||||||
raise "unsuported operator :#{operator}:" unless [:+, :-, :>>, :<<, :*, :&, :|, :==].include?(operator)
|
raise "unsuported operator :#{operator}:" unless [:+, :-, :>>, :<<, :*, :&, :|, :==].include?(operator)
|
||||||
@left = left
|
@left = left
|
||||||
@right = right
|
@right = right
|
||||||
|
raise "Not register #{left}" unless RiscValue.look_like_reg(left)
|
||||||
|
raise "Not register #{right}" unless RiscValue.look_like_reg(right)
|
||||||
end
|
end
|
||||||
attr_reader :operator, :left , :right
|
attr_reader :operator, :left , :right
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user