better inspect
This commit is contained in:
parent
18935366fe
commit
26c6db17b1
@ -157,6 +157,17 @@ module Parfait
|
|||||||
padded_words( get_layout().get_length() + get_length() )
|
padded_words( get_layout().get_length() + get_length() )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inspect
|
||||||
|
ret = ""
|
||||||
|
index = 1
|
||||||
|
while index <= self.get_length
|
||||||
|
item = get(index)
|
||||||
|
ret += item.inspect
|
||||||
|
ret += "," unless index == self.get_length
|
||||||
|
index = index + 1
|
||||||
|
end
|
||||||
|
ret
|
||||||
|
end
|
||||||
#many basic List functions can not be defined in ruby, such as
|
#many basic List functions can not be defined in ruby, such as
|
||||||
# get/set/length/add/delete
|
# get/set/length/add/delete
|
||||||
# so they must be defined as Methods in Builtin::Kernel
|
# so they must be defined as Methods in Builtin::Kernel
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
module Parfait
|
module Parfait
|
||||||
class Variable < Object
|
class Variable < Object
|
||||||
|
|
||||||
def initialize type , name , value = nil
|
def initialize type , name , value = nil
|
||||||
@type , @name , @value = type , name , value
|
raise "not type #{type}" unless type == :ref or type == :int
|
||||||
@value = 0 if @type == :int and value == nil
|
self.type , self.name , self.value = type , name , value
|
||||||
|
self.value = 0 if self.type == :int and value == nil
|
||||||
|
raise "must give name for variable" unless name
|
||||||
end
|
end
|
||||||
attributes [:type , :name, :value]
|
attributes [:type , :name, :value]
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
"Variable(#{self.type} ,#{self.name})"
|
||||||
|
end
|
||||||
|
def inspect
|
||||||
|
to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user