implements inspect for copy paste into tests

This commit is contained in:
Torsten Ruger
2014-05-10 12:54:10 +03:00
parent 051b0ea7dc
commit 20128627c7
5 changed files with 43 additions and 15 deletions

View File

@ -7,11 +7,14 @@ module Ast
def initialize val
@value = val
end
def inspect
self.class.name + ".new(" + value.to_s+ ")"
end
def compile context
Vm::Signed.new value
end
def == other
compare other , [:value]
def attributes
[:value]
end
end
@ -20,8 +23,11 @@ module Ast
def initialize name
@name = name
end
def == other
compare other , [:name]
def inspect
self.class.name + ".new(" + name + ")"
end
def attributes
[:name]
end
end
@ -30,14 +36,17 @@ module Ast
def initialize str
@string = str
end
def inspectt
"#{string}"
end
def compile context
value = Vm::StringLiteral.new(string)
context.program.add_object value
value
end
def == other
compare other , [:string]
def attributes
[:string]
end
end