2015-09-27 13:30:41 +02:00
|
|
|
module Parfait
|
|
|
|
class Variable < Object
|
2015-09-27 15:06:11 +02:00
|
|
|
|
2015-09-27 13:30:41 +02:00
|
|
|
def initialize type , name , value = nil
|
2015-11-08 12:39:13 +01:00
|
|
|
raise "not type #{type}(#{type.class})" unless Register.machine.space.get_class_by_name(type)
|
2016-02-25 20:41:03 +01:00
|
|
|
self.value_type , self.name , self.value = type , name , value
|
|
|
|
self.value = 0 if self.value_type == :Integer and value == nil
|
2015-09-27 15:06:11 +02:00
|
|
|
raise "must give name for variable" unless name
|
2015-09-27 13:30:41 +02:00
|
|
|
end
|
2016-02-25 20:41:03 +01:00
|
|
|
attributes [:value_type , :name, :value]
|
2015-09-27 15:06:11 +02:00
|
|
|
|
|
|
|
def to_s
|
2016-02-25 20:41:03 +01:00
|
|
|
"Variable(#{self.value_type} ,#{self.name})"
|
2015-09-27 15:06:11 +02:00
|
|
|
end
|
|
|
|
def inspect
|
|
|
|
to_s
|
|
|
|
end
|
2015-09-27 13:30:41 +02:00
|
|
|
end
|
|
|
|
end
|