fix interpreter to output symbols
which amazingly lets us get at classnames etc
This commit is contained in:
parent
a99abd7ad0
commit
6811fc4174
@ -158,8 +158,13 @@ module Risc
|
||||
end
|
||||
case object
|
||||
when Symbol
|
||||
raise "Must convert symbol to word:#{object}" unless( index == 2 )
|
||||
value = object.to_s.length
|
||||
if(index == 0)
|
||||
value = object.get_type
|
||||
elsif(index==1)
|
||||
value = object.to_s.length
|
||||
else
|
||||
raise "Must convert symbol to word:#{object}:#{index}"
|
||||
end
|
||||
when nil
|
||||
raise "error #{@instruction} retrieves nil"
|
||||
else
|
||||
|
18
test/mains/source/classname_Space_5.rb
Normal file
18
test/mains/source/classname_Space_5.rb
Normal file
@ -0,0 +1,18 @@
|
||||
class Class
|
||||
def name
|
||||
@name
|
||||
end
|
||||
end
|
||||
class Type
|
||||
def name
|
||||
@object_class.name
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def type
|
||||
@type
|
||||
end
|
||||
def main(arg)
|
||||
type.name.putstring
|
||||
end
|
||||
end
|
@ -16,21 +16,19 @@ module Mains
|
||||
|
||||
def whole_input
|
||||
<<-eos
|
||||
class Space
|
||||
def times
|
||||
n = 5
|
||||
i = 0
|
||||
while( i < 5 )
|
||||
yield
|
||||
i = i + 1
|
||||
end
|
||||
return 1
|
||||
class Class
|
||||
def get_name
|
||||
@name
|
||||
end
|
||||
end
|
||||
class Type
|
||||
def get_name
|
||||
@object_class.get_name
|
||||
end
|
||||
end
|
||||
class Space
|
||||
def main(arg)
|
||||
times{
|
||||
"1".putstring
|
||||
}
|
||||
return 4
|
||||
@type.get_name.putstring
|
||||
end
|
||||
end
|
||||
eos
|
||||
@ -43,8 +41,8 @@ module Mains
|
||||
def test_chain
|
||||
run_all
|
||||
assert_equal ::Integer , get_return.class , " "
|
||||
assert_equal 4 , get_return , " "
|
||||
assert_equal "11111" , @interpreter.stdout
|
||||
#assert_equal 4 , get_return , " "
|
||||
assert_equal "hi" , @interpreter.stdout
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ module Parfait
|
||||
end
|
||||
|
||||
def test_type
|
||||
assert_equal "Parfait::Type" , @object.get_internal_word( 0 ).class.name
|
||||
assert_equal ::Parfait::Type , @object.get_internal_word( 0 ).class
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user