last fixes from source change

This commit is contained in:
Torsten Ruger 2015-10-28 21:40:48 +02:00
parent 5d3aace459
commit e4201143b3
4 changed files with 10 additions and 9 deletions

View File

@ -28,7 +28,7 @@ module Register
@machine.objects.each do |id , objekt|
next unless objekt.is_a? Parfait::Method
# should be fill_to_length (with zeros)
objekt.binary.set_length(objekt.source.total_byte_length )
objekt.binary.set_length(objekt.total_byte_length )
end
#need the initial jump at 0 and then functions
@machine.init.set_position(at)
@ -47,7 +47,7 @@ module Register
# have to tell the code that will be assembled where it is to
# get the jumps/calls right
if objekt.is_a? Parfait::Method
objekt.source.set_position( objekt.binary.position )
objekt.set_position( objekt.binary.position )
end
next if objekt.is_a? Parfait::BinaryCode
objekt.position = at
@ -115,8 +115,8 @@ module Register
index = 1
stream.rewind
#puts "Assembled #{method.name} with length #{stream.length}"
raise "length error #{method.binary.length} != #{method.source.total_byte_length}" if method.binary.get_length != method.source.total_byte_length
raise "length error #{stream.length} != #{method.source.total_byte_length}" if method.source.total_byte_length != stream.length
raise "length error #{method.binary.length} != #{method.total_byte_length}" if method.binary.get_length != method.total_byte_length
raise "length error #{stream.length} != #{method.total_byte_length}" if method.total_byte_length != stream.length
stream.each_byte do |b|
method.binary.set(index , b )
index = index + 1

View File

@ -28,9 +28,9 @@ module Soml
if(@method)
#puts "Warning, redefining method #{name}" unless name == :main
#TODO check args / type compatibility
@method.source.init @method
init_method
else
@method = Register::MethodSource.create_method_for(@clazz, name , args )
create_method_for(@clazz, name , args ).init_method
@clazz.add_instance_method @method
end
#puts "compile method #{@method.name}"

View File

@ -5,6 +5,7 @@ Soml::Compiler.class_eval do
def set_main main
@clazz = Register.machine.space.get_class_by_name :Object
@method = main
@current = main.instructions.next
end
end

View File

@ -7,11 +7,11 @@ module Statements
machine = Register.machine
machine.boot unless machine.booted
machine.parse_and_compile @string_input
produced = Register.machine.space.get_main.source
produced = Register.machine.space.get_main.instructions
assert @expect , "No output given"
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
compare_instructions produced.method.instructions , @expect
produced.method.instructions
compare_instructions produced , @expect
produced
end
def compare_instructions instruction , expect