diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index cb16eedb..0b6f702f 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -32,11 +32,12 @@ module Register def asseble_code_from( at ) @machine.objects.each do |id , objekt| next unless objekt.is_a? Parfait::TypedMethod + log.debug "CODE1 #{objekt.name}" binary = objekt.binary binary.set_position( at ) objekt.instructions.set_position( at + 12 )# BinaryCode header len = objekt.instructions.total_byte_length - log.debug "CODE #{objekt.name} at #{binary.position} len: #{len}" + log.debug "CODE2 #{objekt.name} at #{binary.position} len: #{len}" binary.set_length(len , 0) at += binary.padded_length end diff --git a/lib/register/collector.rb b/lib/register/collector.rb index 2437c0d5..a0d103d6 100644 --- a/lib/register/collector.rb +++ b/lib/register/collector.rb @@ -5,14 +5,14 @@ module Register def collect_space @objects.clear keep Parfait.object_space , 0 - constants.each {|o| keep(o,0)} + constants.each {|obj| keep(obj,0)} end def keep object , depth return if object.nil? #puts "adding #{' ' * depth}:#{object.class}" - #puts "ADD #{object.first.class}, #{object.last.class}" if object.is_a? Array - return unless self.add_object object + #puts "ADD #{object.inspect}, #{object.hash}" if object.is_a? Parfait::Type + return unless add_object( object ) # probably should make labels or even instructions derive from Parfait::Object, but . . if object.is_a? Register::Label object.each_label { |l| self.add_object(l)} diff --git a/lib/register/machine.rb b/lib/register/machine.rb index b81a97c5..1410fb2f 100644 --- a/lib/register/machine.rb +++ b/lib/register/machine.rb @@ -51,7 +51,7 @@ module Register end # Objects are data and get assembled after functions - def add_object objekt + def add_object( objekt ) return false if @objects[objekt.object_id] return true if objekt.is_a? Fixnum unless objekt.is_a?( Parfait::Object) or objekt.is_a?( Symbol) or objekt.is_a?( Register::Label) diff --git a/lib/typed/method_compiler.rb b/lib/typed/method_compiler.rb index 836db071..37e8db81 100644 --- a/lib/typed/method_compiler.rb +++ b/lib/typed/method_compiler.rb @@ -122,8 +122,7 @@ module Typed raise "create_method #{type.inspect} is not a Type" unless type.is_a? Parfait::Type raise "Args must be Hash #{args}" unless args.is_a?(Hash) raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol - arguments = Parfait::Type.for_hash( type.object_class , args ) - @method = type.create_method( method_name , arguments) + @method = type.create_method( method_name , args) self end diff --git a/lib/typed/parfait/word.rb b/lib/typed/parfait/word.rb index e9705d40..a787224c 100644 --- a/lib/typed/parfait/word.rb +++ b/lib/typed/parfait/word.rb @@ -211,7 +211,7 @@ module Parfait # Word from string def self.new_word( string ) string = string.to_s if string.is_a? Symbol - word = Parfait::Word.new( string.length ) + word = Word.new( string.length ) string.codepoints.each_with_index do |code , index | word.set_char(index + 1 , code) end diff --git a/test/typed/parfait/test_word.rb b/test/typed/parfait/test_word.rb index 034795b7..a375bd2d 100644 --- a/test/typed/parfait/test_word.rb +++ b/test/typed/parfait/test_word.rb @@ -3,7 +3,8 @@ require_relative "../helper" class TestEmptyWord < MiniTest::Test def setup - @word = ::Parfait::Word.new(0) + Register.machine.boot + @word = Parfait::Word.new(0) end def test_word_create assert @word.empty? @@ -28,8 +29,8 @@ end class TestWord < MiniTest::Test def setup - Register.machine.boot unless Register.machine.booted - @word = ::Parfait::Word.new(5) + Register.machine.boot + @word = Parfait::Word.new(5) end def test_len assert_equal 5 , @word.length