diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index 73a7d52f..dcbdcca7 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -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 diff --git a/lib/soml/compiler/function_definition.rb b/lib/soml/compiler/function_definition.rb index 1015ce4a..6f2ecabd 100644 --- a/lib/soml/compiler/function_definition.rb +++ b/lib/soml/compiler/function_definition.rb @@ -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}" diff --git a/test/compiler/expressions/compiler_helper.rb b/test/compiler/expressions/compiler_helper.rb index 2d4df114..71cf073d 100644 --- a/test/compiler/expressions/compiler_helper.rb +++ b/test/compiler/expressions/compiler_helper.rb @@ -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 diff --git a/test/compiler/statements/helper.rb b/test/compiler/statements/helper.rb index 4e6eb121..bc3bfa17 100644 --- a/test/compiler/statements/helper.rb +++ b/test/compiler/statements/helper.rb @@ -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