whitespace and code style
This commit is contained in:
parent
db798d1a4a
commit
83b6628f1a
@ -32,11 +32,12 @@ module Register
|
|||||||
def asseble_code_from( at )
|
def asseble_code_from( at )
|
||||||
@machine.objects.each do |id , objekt|
|
@machine.objects.each do |id , objekt|
|
||||||
next unless objekt.is_a? Parfait::TypedMethod
|
next unless objekt.is_a? Parfait::TypedMethod
|
||||||
|
log.debug "CODE1 #{objekt.name}"
|
||||||
binary = objekt.binary
|
binary = objekt.binary
|
||||||
binary.set_position( at )
|
binary.set_position( at )
|
||||||
objekt.instructions.set_position( at + 12 )# BinaryCode header
|
objekt.instructions.set_position( at + 12 )# BinaryCode header
|
||||||
len = objekt.instructions.total_byte_length
|
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)
|
binary.set_length(len , 0)
|
||||||
at += binary.padded_length
|
at += binary.padded_length
|
||||||
end
|
end
|
||||||
|
@ -5,14 +5,14 @@ module Register
|
|||||||
def collect_space
|
def collect_space
|
||||||
@objects.clear
|
@objects.clear
|
||||||
keep Parfait.object_space , 0
|
keep Parfait.object_space , 0
|
||||||
constants.each {|o| keep(o,0)}
|
constants.each {|obj| keep(obj,0)}
|
||||||
end
|
end
|
||||||
|
|
||||||
def keep object , depth
|
def keep object , depth
|
||||||
return if object.nil?
|
return if object.nil?
|
||||||
#puts "adding #{' ' * depth}:#{object.class}"
|
#puts "adding #{' ' * depth}:#{object.class}"
|
||||||
#puts "ADD #{object.first.class}, #{object.last.class}" if object.is_a? Array
|
#puts "ADD #{object.inspect}, #{object.hash}" if object.is_a? Parfait::Type
|
||||||
return unless self.add_object object
|
return unless add_object( object )
|
||||||
# probably should make labels or even instructions derive from Parfait::Object, but . .
|
# probably should make labels or even instructions derive from Parfait::Object, but . .
|
||||||
if object.is_a? Register::Label
|
if object.is_a? Register::Label
|
||||||
object.each_label { |l| self.add_object(l)}
|
object.each_label { |l| self.add_object(l)}
|
||||||
|
@ -51,7 +51,7 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Objects are data and get assembled after functions
|
# Objects are data and get assembled after functions
|
||||||
def add_object objekt
|
def add_object( objekt )
|
||||||
return false if @objects[objekt.object_id]
|
return false if @objects[objekt.object_id]
|
||||||
return true if objekt.is_a? Fixnum
|
return true if objekt.is_a? Fixnum
|
||||||
unless objekt.is_a?( Parfait::Object) or objekt.is_a?( Symbol) or objekt.is_a?( Register::Label)
|
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 "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 "Args must be Hash #{args}" unless args.is_a?(Hash)
|
||||||
raise "create_method #{method_name}.#{method_name.class}" unless method_name.is_a? Symbol
|
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 , args)
|
||||||
@method = type.create_method( method_name , arguments)
|
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ module Parfait
|
|||||||
# Word from string
|
# Word from string
|
||||||
def self.new_word( string )
|
def self.new_word( string )
|
||||||
string = string.to_s if string.is_a? Symbol
|
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 |
|
string.codepoints.each_with_index do |code , index |
|
||||||
word.set_char(index + 1 , code)
|
word.set_char(index + 1 , code)
|
||||||
end
|
end
|
||||||
|
@ -3,7 +3,8 @@ require_relative "../helper"
|
|||||||
class TestEmptyWord < MiniTest::Test
|
class TestEmptyWord < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@word = ::Parfait::Word.new(0)
|
Register.machine.boot
|
||||||
|
@word = Parfait::Word.new(0)
|
||||||
end
|
end
|
||||||
def test_word_create
|
def test_word_create
|
||||||
assert @word.empty?
|
assert @word.empty?
|
||||||
@ -28,8 +29,8 @@ end
|
|||||||
class TestWord < MiniTest::Test
|
class TestWord < MiniTest::Test
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Register.machine.boot unless Register.machine.booted
|
Register.machine.boot
|
||||||
@word = ::Parfait::Word.new(5)
|
@word = Parfait::Word.new(5)
|
||||||
end
|
end
|
||||||
def test_len
|
def test_len
|
||||||
assert_equal 5 , @word.length
|
assert_equal 5 , @word.length
|
||||||
|
Loading…
x
Reference in New Issue
Block a user