2015-09-27 14:30:41 +03:00
|
|
|
module Parfait
|
|
|
|
class Variable < Object
|
2015-09-27 16:06:11 +03:00
|
|
|
|
2015-09-27 14:30:41 +03:00
|
|
|
def initialize type , name , value = nil
|
2015-10-14 16:16:03 +03:00
|
|
|
raise "not type #{type}" unless Virtual.machine.space.get_class_by_name(type)
|
2015-09-27 16:06:11 +03:00
|
|
|
self.type , self.name , self.value = type , name , value
|
2015-10-15 09:32:47 +03:00
|
|
|
self.value = 0 if self.type == :Integer and value == nil
|
2015-09-27 16:06:11 +03:00
|
|
|
raise "must give name for variable" unless name
|
2015-09-27 14:30:41 +03:00
|
|
|
end
|
|
|
|
attributes [:type , :name, :value]
|
2015-09-27 16:06:11 +03:00
|
|
|
|
|
|
|
def to_s
|
|
|
|
"Variable(#{self.type} ,#{self.name})"
|
|
|
|
end
|
|
|
|
def inspect
|
|
|
|
to_s
|
|
|
|
end
|
2015-09-27 14:30:41 +03:00
|
|
|
end
|
|
|
|
end
|