minors
This commit is contained in:
parent
69781fb505
commit
4f2f56fff8
@ -39,7 +39,7 @@ module Register
|
|||||||
@machine.objects.each do |objekt|
|
@machine.objects.each do |objekt|
|
||||||
next unless objekt.is_a? Parfait::BinaryCode
|
next unless objekt.is_a? Parfait::BinaryCode
|
||||||
objekt.set_position at
|
objekt.set_position at
|
||||||
# puts "CODE #{objekt.name} at #{objekt.position}"
|
#puts "CODE #{objekt.name} at #{objekt.position}"
|
||||||
at += objekt.word_length
|
at += objekt.word_length
|
||||||
end
|
end
|
||||||
# and then everything else
|
# and then everything else
|
||||||
@ -98,7 +98,7 @@ module Register
|
|||||||
next if objekt.is_a? Parfait::BinaryCode
|
next if objekt.is_a? Parfait::BinaryCode
|
||||||
write_any( objekt )
|
write_any( objekt )
|
||||||
end
|
end
|
||||||
puts "Assembled 0x#{stream_position.to_s(16)}/#{stream_position.to_s(16)} bytes"
|
puts "Assembled #{stream_position} bytes"
|
||||||
return @stream.string
|
return @stream.string
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -130,9 +130,9 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write_any obj
|
def write_any obj
|
||||||
#puts "Assemble #{obj.class}(#{obj.object_id.to_s(16)}) at stream #{stream_position.to_s(16)} pos:#{obj.position.to_s(16)} , len:#{obj.word_length.to_s(16)}"
|
#puts "Assemble #{obj.class}(#{obj.object_id.to_s(16)}) at stream #{stream_position} pos:#{obj.position.to_s(16)} , len:#{obj.word_length.to_s(16)}"
|
||||||
if stream_position != obj.position
|
if @stream.length != obj.position
|
||||||
raise "Assemble #{obj.class} #{obj.object_id.to_s(16)} at #{stream_position.to_s(16)} not #{obj.position.to_s(16)}"
|
raise "Assemble #{obj.class} #{obj.object_id.to_s(16)} at #{stream_position} not #{obj.position.to_s(16)}"
|
||||||
end
|
end
|
||||||
if obj.is_a?(Parfait::Word) or obj.is_a?(Symbol)
|
if obj.is_a?(Parfait::Word) or obj.is_a?(Symbol)
|
||||||
write_String obj
|
write_String obj
|
||||||
@ -191,15 +191,14 @@ module Register
|
|||||||
str = string.to_string if string.is_a? Parfait::Word
|
str = string.to_string if string.is_a? Parfait::Word
|
||||||
str = string.to_s if string.is_a? Symbol
|
str = string.to_s if string.is_a? Symbol
|
||||||
word = (str.length + 7) / 32 # all object are multiple of 8 words (7 for header)
|
word = (str.length + 7) / 32 # all object are multiple of 8 words (7 for header)
|
||||||
raise "String too long (implement split string!) #{word}" if word > 15
|
|
||||||
# first line is integers, convention is that following lines are the same
|
# first line is integers, convention is that following lines are the same
|
||||||
TYPE_LENGTH.times { word = ((word << TYPE_BITS) + TYPE_INT) }
|
TYPE_LENGTH.times { word = ((word << TYPE_BITS) + TYPE_INT) }
|
||||||
@stream.write_uint32( word )
|
@stream.write_uint32( word )
|
||||||
#puts "String is #{string} at #{string.position.to_s(16)} length #{string.length.to_s(16)}"
|
#puts "String is #{string} at #{string.position.to_s(16)} length #{string.length}"
|
||||||
write_ref_for( string.get_layout ) #ref
|
write_ref_for( string.get_layout ) #ref
|
||||||
@stream.write str
|
@stream.write str
|
||||||
pad_after(str.length)
|
pad_after(str.length)
|
||||||
#puts "String (#{slot.word_length}) stream #{@stream.word_length.to_s(16)}"
|
#puts "String (#{string.length.to_s(16)}) stream #{@stream.length.to_s(16)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_Symbol(sym)
|
def write_Symbol(sym)
|
||||||
@ -221,17 +220,18 @@ module Register
|
|||||||
|
|
||||||
# pad_after is always in bytes and pads (writes 0's) up to the next 8 word boundary
|
# pad_after is always in bytes and pads (writes 0's) up to the next 8 word boundary
|
||||||
def pad_after length
|
def pad_after length
|
||||||
before = stream_position.to_s(16)
|
before = stream_position
|
||||||
pad = padding_for(length)
|
pad = padding_for(length)
|
||||||
pad.times do
|
pad.times do
|
||||||
@stream.write_uint8(0)
|
@stream.write_uint8(0)
|
||||||
end
|
end
|
||||||
after = stream_position.to_s(16)
|
after = stream_position
|
||||||
#puts "padded #{length.to_s(16)} with #{pad.to_s(16)} stream #{before}/#{after}"
|
#puts "padded #{length.to_s(16)} with #{pad.to_s(16)} stream #{before}/#{after}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# return the stream length as hex
|
||||||
def stream_position
|
def stream_position
|
||||||
@stream.length
|
@stream.length.to_s(16)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,13 +12,14 @@ class TestSpace < MiniTest::Test
|
|||||||
def test_machine_space
|
def test_machine_space
|
||||||
assert_equal Parfait::Space , @machine.space.class
|
assert_equal Parfait::Space , @machine.space.class
|
||||||
end
|
end
|
||||||
def test_gloabl_space
|
def test_global_space
|
||||||
assert_equal Parfait::Space , Parfait::Space.object_space.class
|
assert_equal Parfait::Space , Parfait::Space.object_space.class
|
||||||
end
|
end
|
||||||
def test_classes
|
def test_classes
|
||||||
assert_equal 16 , @machine.space.classes.length
|
assert_equal 16 , @machine.space.classes.length
|
||||||
[:Kernel,:Word,:List,:Message,:Frame,:Layout,:Class,:Dictionary,:Method].each do |name|
|
[:Kernel,:Word,:List,:Message,:Frame,:Layout,:Class,:Dictionary,:Method].each do |name|
|
||||||
assert @machine.space.classes[name]
|
assert_equal Parfait::Class , @machine.space.classes[name].class
|
||||||
|
assert_equal Parfait::Layout , @machine.space.classes[name].get_layout.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def test_messages
|
def test_messages
|
||||||
|
@ -33,7 +33,7 @@ HERE
|
|||||||
|
|
||||||
def test_string_put
|
def test_string_put
|
||||||
@string_input = <<HERE
|
@string_input = <<HERE
|
||||||
"Hello".putstring()
|
"Hello again\n".putstring()
|
||||||
HERE
|
HERE
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user