whitespace and code style
This commit is contained in:
parent
db798d1a4a
commit
83b6628f1a
@ -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
|
||||
|
@ -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)}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user