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
|
end
|
||||||
case object
|
case object
|
||||||
when Symbol
|
when Symbol
|
||||||
raise "Must convert symbol to word:#{object}" unless( index == 2 )
|
if(index == 0)
|
||||||
value = object.to_s.length
|
value = object.get_type
|
||||||
|
elsif(index==1)
|
||||||
|
value = object.to_s.length
|
||||||
|
else
|
||||||
|
raise "Must convert symbol to word:#{object}:#{index}"
|
||||||
|
end
|
||||||
when nil
|
when nil
|
||||||
raise "error #{@instruction} retrieves nil"
|
raise "error #{@instruction} retrieves nil"
|
||||||
else
|
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
|
def whole_input
|
||||||
<<-eos
|
<<-eos
|
||||||
class Space
|
class Class
|
||||||
def times
|
def get_name
|
||||||
n = 5
|
@name
|
||||||
i = 0
|
|
||||||
while( i < 5 )
|
|
||||||
yield
|
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
return 1
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
class Type
|
||||||
|
def get_name
|
||||||
|
@object_class.get_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class Space
|
||||||
def main(arg)
|
def main(arg)
|
||||||
times{
|
@type.get_name.putstring
|
||||||
"1".putstring
|
|
||||||
}
|
|
||||||
return 4
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
eos
|
eos
|
||||||
@ -43,8 +41,8 @@ module Mains
|
|||||||
def test_chain
|
def test_chain
|
||||||
run_all
|
run_all
|
||||||
assert_equal ::Integer , get_return.class , " "
|
assert_equal ::Integer , get_return.class , " "
|
||||||
assert_equal 4 , get_return , " "
|
#assert_equal 4 , get_return , " "
|
||||||
assert_equal "11111" , @interpreter.stdout
|
assert_equal "hi" , @interpreter.stdout
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_type
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user