fix that silly mistake that made the percentage plummet
mostly due to the fact that object is a hash now, not array. Took a while though
This commit is contained in:
parent
2d0424a370
commit
e3577d18af
2
Gemfile
2
Gemfile
@ -5,9 +5,11 @@ gem "salama" , :path => "."
|
|||||||
gem "rake"
|
gem "rake"
|
||||||
|
|
||||||
gem "salama-reader" , :github => "salama/salama-reader"
|
gem "salama-reader" , :github => "salama/salama-reader"
|
||||||
|
#gem "salama-reader" , :path => "../salama-reader"
|
||||||
gem "salama-object-file" , :github => "salama/salama-object-file"
|
gem "salama-object-file" , :github => "salama/salama-object-file"
|
||||||
#gem "salama-object-file" , :path => "../salama-object-file"
|
#gem "salama-object-file" , :path => "../salama-object-file"
|
||||||
gem "salama-arm" , :github => "salama/salama-arm"
|
gem "salama-arm" , :github => "salama/salama-arm"
|
||||||
|
#gem "salama-arm" , :path => "../salama-arm"
|
||||||
|
|
||||||
gem "codeclimate-test-reporter", require: nil
|
gem "codeclimate-test-reporter", require: nil
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ module Elf
|
|||||||
# add_symbol "main@#{b.name}" , b.position
|
# add_symbol "main@#{b.name}" , b.position
|
||||||
# end
|
# end
|
||||||
# add_symbol "#register@#{@object_machine.space.init.name}" , @object_machine.space.init.position
|
# add_symbol "#register@#{@object_machine.space.init.name}" , @object_machine.space.init.position
|
||||||
@object_machine.objects.each do |slot|
|
@object_machine.objects.each do |id,slot|
|
||||||
if( slot.respond_to? :sof_reference_name )
|
if( slot.respond_to? :sof_reference_name )
|
||||||
label = "#{slot.sof_reference_name}"
|
label = "#{slot.sof_reference_name}"
|
||||||
else
|
else
|
||||||
|
@ -25,7 +25,7 @@ module Register
|
|||||||
# want to have the methods first in the executable
|
# want to have the methods first in the executable
|
||||||
# so first we determine the code length for the methods and set the
|
# so first we determine the code length for the methods and set the
|
||||||
# binary code (array) to right length
|
# binary code (array) to right length
|
||||||
@machine.objects.each do |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.code.set_length(objekt.source.byte_length , 0)
|
objekt.code.set_length(objekt.source.byte_length , 0)
|
||||||
@ -36,14 +36,14 @@ module Register
|
|||||||
at += 8 # thats the padding
|
at += 8 # thats the padding
|
||||||
|
|
||||||
# then we make sure we really get the binary codes first
|
# then we make sure we really get the binary codes first
|
||||||
@machine.objects.each do |objekt|
|
@machine.objects.each do |id , objekt|
|
||||||
next unless objekt.is_a? Parfait::BinaryCode
|
next unless objekt.is_a? Parfait::BinaryCode
|
||||||
objekt.set_position at
|
objekt.set_position at
|
||||||
#puts "CODE #{objekt.name} at #{objekt.position}"
|
#puts "CODE #{objekt.name} at #{objekt.position}"
|
||||||
at += objekt.word_length
|
at += objekt.word_length
|
||||||
end
|
end
|
||||||
# and then everything else
|
# and then everything else
|
||||||
@machine.objects.each do | objekt|
|
@machine.objects.each do | id , objekt|
|
||||||
# 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
|
||||||
@ -69,14 +69,14 @@ module Register
|
|||||||
# case we try again. Once.
|
# case we try again. Once.
|
||||||
def try_write
|
def try_write
|
||||||
assemble
|
assemble
|
||||||
all = @machine.objects.sort{|a,b| a.position <=> b.position}
|
all = @machine.objects.values.sort{|a,b| a.position <=> b.position}
|
||||||
# debugging loop accesses all positions to force an error if it's not set
|
# debugging loop accesses all positions to force an error if it's not set
|
||||||
all.each do |objekt|
|
all.each do |objekt|
|
||||||
#puts "Linked #{objekt.class}(#{objekt.object_id.to_s(16)}) at #{objekt.position.to_s(16)} / #{objekt.word_length.to_s(16)}"
|
#puts "Linked #{objekt.class}(#{objekt.object_id.to_s(16)}) at #{objekt.position.to_s(16)} / #{objekt.word_length.to_s(16)}"
|
||||||
objekt.position
|
objekt.position
|
||||||
end
|
end
|
||||||
# first we need to create the binary code for the methods
|
# first we need to create the binary code for the methods
|
||||||
@machine.objects.each do |objekt|
|
@machine.objects.each do |id , objekt|
|
||||||
next unless objekt.is_a? Parfait::Method
|
next unless objekt.is_a? Parfait::Method
|
||||||
assemble_binary_method(objekt)
|
assemble_binary_method(objekt)
|
||||||
end
|
end
|
||||||
@ -89,12 +89,12 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
# then write the methods to file
|
# then write the methods to file
|
||||||
@machine.objects.each do |objekt|
|
@machine.objects.each do |id, objekt|
|
||||||
next unless objekt.is_a? Parfait::BinaryCode
|
next unless objekt.is_a? Parfait::BinaryCode
|
||||||
write_any( objekt )
|
write_any( objekt )
|
||||||
end
|
end
|
||||||
# and then the rest of the object machine
|
# and then the rest of the object machine
|
||||||
@machine.objects.each do | objekt|
|
@machine.objects.each do | id, objekt|
|
||||||
next if objekt.is_a? Parfait::BinaryCode
|
next if objekt.is_a? Parfait::BinaryCode
|
||||||
write_any( objekt )
|
write_any( objekt )
|
||||||
end
|
end
|
||||||
@ -159,7 +159,7 @@ module Register
|
|||||||
# write type and layout of the instance, and the variables that are passed
|
# write type and layout of the instance, and the variables that are passed
|
||||||
# variables ar values, ie int or refs. For refs the object needs to save the object first
|
# variables ar values, ie int or refs. For refs the object needs to save the object first
|
||||||
def write_object( object )
|
def write_object( object )
|
||||||
unless @machine.objects.include? object
|
unless @machine.objects.has_key? object.object_id
|
||||||
raise "Object(#{object.object_id}) not linked #{object.inspect}"
|
raise "Object(#{object.object_id}) not linked #{object.inspect}"
|
||||||
end
|
end
|
||||||
layout = object.get_layout
|
layout = object.get_layout
|
||||||
|
@ -18,7 +18,7 @@ module Register
|
|||||||
# The at_index is just "below" the api, something we need but don't want to expose,
|
# The at_index is just "below" the api, something we need but don't want to expose,
|
||||||
# so we can't code the above in ruby
|
# so we can't code the above in ruby
|
||||||
def _get_instance_variable context , name = Virtual::Integer
|
def _get_instance_variable context , name = Virtual::Integer
|
||||||
get_function = Virtual::MethodSource.create_method(:Object,:_get_instance_variable , [ Virtual::Reference ] )
|
get_function = Virtual::MethodSource.create_method(:Object,:_get_instance_variable , [ ] )
|
||||||
return get_function
|
return get_function
|
||||||
me = get_function.receiver
|
me = get_function.receiver
|
||||||
var_name = get_function.args.first
|
var_name = get_function.args.first
|
||||||
@ -39,7 +39,7 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def _set_instance_variable(context , name = Virtual::Integer , value = Virtual::Integer )
|
def _set_instance_variable(context , name = Virtual::Integer , value = Virtual::Integer )
|
||||||
set_function = Virtual::MethodSource.create_method(:Object,:_set_instance_variable ,[Virtual::Reference ,Virtual::Reference] )
|
set_function = Virtual::MethodSource.create_method(:Object,:_set_instance_variable ,[] )
|
||||||
return set_function
|
return set_function
|
||||||
receiver set_function
|
receiver set_function
|
||||||
me = set_function.receiver
|
me = set_function.receiver
|
||||||
|
@ -93,6 +93,7 @@ module Virtual
|
|||||||
# Objects are data and get assembled after functions
|
# Objects are data and get assembled after functions
|
||||||
def add_object o
|
def add_object o
|
||||||
return false if @objects[o.object_id]
|
return false if @objects[o.object_id]
|
||||||
|
raise "adding non parfait #{o.class}" unless o.is_a? Parfait::Object or o.is_a? Symbol
|
||||||
@objects[o.object_id] = o
|
@objects[o.object_id] = o
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ class Symbol
|
|||||||
end
|
end
|
||||||
def get_layout
|
def get_layout
|
||||||
l = Virtual.machine.space.classes[:Word].object_layout
|
l = Virtual.machine.space.classes[:Word].object_layout
|
||||||
puts "LL #{l.class}"
|
#puts "LL #{l.class}"
|
||||||
l
|
l
|
||||||
end
|
end
|
||||||
def word_length
|
def word_length
|
||||||
@ -42,7 +42,7 @@ class Symbol
|
|||||||
pos = cache_positions[self]
|
pos = cache_positions[self]
|
||||||
if pos == nil
|
if pos == nil
|
||||||
str = "position accessed but not set, "
|
str = "position accessed but not set, "
|
||||||
str += "Machine has object=#{Virtual.machine.objects.include?(self)} "
|
str += "Machine has object=#{Virtual.machine.objects.has_key?(self.object_id)} "
|
||||||
raise str + " for Symbol:#{self}"
|
raise str + " for Symbol:#{self}"
|
||||||
end
|
end
|
||||||
pos
|
pos
|
||||||
@ -168,7 +168,7 @@ module Parfait
|
|||||||
# name comes in as a ruby @var name
|
# name comes in as a ruby @var name
|
||||||
def instance_variable_get name
|
def instance_variable_get name
|
||||||
var = get_instance_variable name.to_s[1 .. -1].to_sym
|
var = get_instance_variable name.to_s[1 .. -1].to_sym
|
||||||
puts "getting #{name} #{var}"
|
#puts "getting #{name} #{var}"
|
||||||
var
|
var
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,17 +12,17 @@ module Virtual
|
|||||||
return unless Virtual.machine.add_object object
|
return unless Virtual.machine.add_object object
|
||||||
#puts "adding #{object.class}"
|
#puts "adding #{object.class}"
|
||||||
return unless object.respond_to? :has_layout?
|
return unless object.respond_to? :has_layout?
|
||||||
unless object.has_layout?
|
|
||||||
object.init_layout
|
|
||||||
end
|
|
||||||
if( object.is_a? Parfait::Method)
|
if( object.is_a? Parfait::Method)
|
||||||
object.source.constants.each{|c| keep(c) }
|
object.source.constants.each{|c|
|
||||||
|
puts "keeping constant #{c.class}"
|
||||||
|
keep(c)
|
||||||
|
}
|
||||||
end
|
end
|
||||||
layout = object.get_layout
|
layout = object.get_layout
|
||||||
keep layout
|
keep layout
|
||||||
#puts "Layout #{layout.object_class.name} #{Machine.instance.objects.include?(layout)}"
|
#puts "Layout #{layout.object_class.name} #{Machine.instance.objects.has_key?(layout.object_id)}"
|
||||||
layout.object_instance_names.each do |name|
|
layout.object_instance_names.each do |name|
|
||||||
inst = object.instance_variable_get "@#{name}".to_sym
|
inst = object.get_instance_variable name
|
||||||
keep inst
|
keep inst
|
||||||
end
|
end
|
||||||
if object.is_a? Parfait::List
|
if object.is_a? Parfait::List
|
||||||
|
@ -3,7 +3,7 @@ require_relative "type"
|
|||||||
module Positioned
|
module Positioned
|
||||||
def position
|
def position
|
||||||
if @position.nil?
|
if @position.nil?
|
||||||
str = "IN machine #{Virtual.machine.objects.include?(self)}, at #{self.object_id.to_s(16)}\n"
|
str = "IN machine #{Virtual.machine.objects.has_key?(self.object_id)}, at #{self.object_id.to_s(16)}\n"
|
||||||
raise str + "position not set for #{self.class} len #{word_length} for #{self.inspect[0...100]}"
|
raise str + "position not set for #{self.class} len #{word_length} for #{self.inspect[0...100]}"
|
||||||
end
|
end
|
||||||
@position
|
@position
|
||||||
|
@ -30,7 +30,7 @@ HERE
|
|||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def ttest_string_put
|
def test_string_put
|
||||||
@string_input = <<HERE
|
@string_input = <<HERE
|
||||||
"Hello again\n".putstring()
|
"Hello again\n".putstring()
|
||||||
HERE
|
HERE
|
||||||
|
@ -3,7 +3,7 @@ require_relative "test_foo"
|
|||||||
require_relative "test_if"
|
require_relative "test_if"
|
||||||
require_relative "test_functions"
|
require_relative "test_functions"
|
||||||
require_relative "test_string_class"
|
require_relative "test_string_class"
|
||||||
#require_relative "test_hello"
|
require_relative "test_hello"
|
||||||
#require_relative "test_putint"
|
#require_relative "test_putint"
|
||||||
require_relative "test_recursive_fibo"
|
require_relative "test_recursive_fibo"
|
||||||
require_relative "test_while_fibo"
|
require_relative "test_while_fibo"
|
||||||
|
@ -7,11 +7,7 @@ class TestHello < MiniTest::Test
|
|||||||
@string_input = <<HERE
|
@string_input = <<HERE
|
||||||
"Hello Raisa, I am salama".putstring()
|
"Hello Raisa, I am salama".putstring()
|
||||||
HERE
|
HERE
|
||||||
@should = [0x0,0x40,0x2d,0xe9,0x1,0x0,0xa0,0xe3,0x2,0x10,0xa0,0xe1,0x3,0x20,0xa0,0xe1,0x4,0x70,0xa0,0xe3,0x0,0x0,0x0,0xef,0x0,0x80,0xbd,0xe8]
|
@expect = []
|
||||||
@output = "Hello Raisa, I am salama "
|
check
|
||||||
@target = [:Object , :putstring]
|
|
||||||
parse
|
|
||||||
write "hello"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user