last fixes from source change
This commit is contained in:
parent
5d3aace459
commit
e4201143b3
@ -28,7 +28,7 @@ module Register
|
|||||||
@machine.objects.each do |id , objekt|
|
@machine.objects.each do |id , objekt|
|
||||||
next unless objekt.is_a? Parfait::Method
|
next unless objekt.is_a? Parfait::Method
|
||||||
# should be fill_to_length (with zeros)
|
# 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
|
end
|
||||||
#need the initial jump at 0 and then functions
|
#need the initial jump at 0 and then functions
|
||||||
@machine.init.set_position(at)
|
@machine.init.set_position(at)
|
||||||
@ -47,7 +47,7 @@ module Register
|
|||||||
# have to tell the code that will be assembled where it is to
|
# have to tell the code that will be assembled where it is to
|
||||||
# get the jumps/calls right
|
# get the jumps/calls right
|
||||||
if objekt.is_a? Parfait::Method
|
if objekt.is_a? Parfait::Method
|
||||||
objekt.source.set_position( objekt.binary.position )
|
objekt.set_position( objekt.binary.position )
|
||||||
end
|
end
|
||||||
next if objekt.is_a? Parfait::BinaryCode
|
next if objekt.is_a? Parfait::BinaryCode
|
||||||
objekt.position = at
|
objekt.position = at
|
||||||
@ -115,8 +115,8 @@ module Register
|
|||||||
index = 1
|
index = 1
|
||||||
stream.rewind
|
stream.rewind
|
||||||
#puts "Assembled #{method.name} with length #{stream.length}"
|
#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 #{method.binary.length} != #{method.total_byte_length}" if method.binary.get_length != method.total_byte_length
|
||||||
raise "length error #{stream.length} != #{method.source.total_byte_length}" if method.source.total_byte_length != stream.length
|
raise "length error #{stream.length} != #{method.total_byte_length}" if method.total_byte_length != stream.length
|
||||||
stream.each_byte do |b|
|
stream.each_byte do |b|
|
||||||
method.binary.set(index , b )
|
method.binary.set(index , b )
|
||||||
index = index + 1
|
index = index + 1
|
||||||
|
@ -28,9 +28,9 @@ module Soml
|
|||||||
if(@method)
|
if(@method)
|
||||||
#puts "Warning, redefining method #{name}" unless name == :main
|
#puts "Warning, redefining method #{name}" unless name == :main
|
||||||
#TODO check args / type compatibility
|
#TODO check args / type compatibility
|
||||||
@method.source.init @method
|
init_method
|
||||||
else
|
else
|
||||||
@method = Register::MethodSource.create_method_for(@clazz, name , args )
|
create_method_for(@clazz, name , args ).init_method
|
||||||
@clazz.add_instance_method @method
|
@clazz.add_instance_method @method
|
||||||
end
|
end
|
||||||
#puts "compile method #{@method.name}"
|
#puts "compile method #{@method.name}"
|
||||||
|
@ -5,6 +5,7 @@ Soml::Compiler.class_eval do
|
|||||||
def set_main main
|
def set_main main
|
||||||
@clazz = Register.machine.space.get_class_by_name :Object
|
@clazz = Register.machine.space.get_class_by_name :Object
|
||||||
@method = main
|
@method = main
|
||||||
|
@current = main.instructions.next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ module Statements
|
|||||||
machine = Register.machine
|
machine = Register.machine
|
||||||
machine.boot unless machine.booted
|
machine.boot unless machine.booted
|
||||||
machine.parse_and_compile @string_input
|
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 @expect , "No output given"
|
||||||
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
|
#assert_equal @expect.length , produced.instructions.length , "instructions length #{produced.instructions.to_ac}"
|
||||||
compare_instructions produced.method.instructions , @expect
|
compare_instructions produced , @expect
|
||||||
produced.method.instructions
|
produced
|
||||||
end
|
end
|
||||||
|
|
||||||
def compare_instructions instruction , expect
|
def compare_instructions instruction , expect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user