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 "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" , :path => "../salama-object-file"
|
||||
gem "salama-arm" , :github => "salama/salama-arm"
|
||||
#gem "salama-arm" , :path => "../salama-arm"
|
||||
|
||||
gem "codeclimate-test-reporter", require: nil
|
||||
|
||||
|
@ -32,7 +32,7 @@ module Elf
|
||||
# add_symbol "main@#{b.name}" , b.position
|
||||
# end
|
||||
# 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 )
|
||||
label = "#{slot.sof_reference_name}"
|
||||
else
|
||||
|
@ -25,7 +25,7 @@ module Register
|
||||
# want to have the methods first in the executable
|
||||
# so first we determine the code length for the methods and set the
|
||||
# binary code (array) to right length
|
||||
@machine.objects.each do |objekt|
|
||||
@machine.objects.each do |id , objekt|
|
||||
next unless objekt.is_a? Parfait::Method
|
||||
# should be fill_to_length (with zeros)
|
||||
objekt.code.set_length(objekt.source.byte_length , 0)
|
||||
@ -36,14 +36,14 @@ module Register
|
||||
at += 8 # thats the padding
|
||||
|
||||
# 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
|
||||
objekt.set_position at
|
||||
#puts "CODE #{objekt.name} at #{objekt.position}"
|
||||
at += objekt.word_length
|
||||
end
|
||||
# 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
|
||||
# get the jumps/calls right
|
||||
if objekt.is_a? Parfait::Method
|
||||
@ -69,14 +69,14 @@ module Register
|
||||
# case we try again. Once.
|
||||
def try_write
|
||||
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
|
||||
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)}"
|
||||
objekt.position
|
||||
end
|
||||
# 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
|
||||
assemble_binary_method(objekt)
|
||||
end
|
||||
@ -89,12 +89,12 @@ module Register
|
||||
end
|
||||
|
||||
# then write the methods to file
|
||||
@machine.objects.each do |objekt|
|
||||
@machine.objects.each do |id, objekt|
|
||||
next unless objekt.is_a? Parfait::BinaryCode
|
||||
write_any( objekt )
|
||||
end
|
||||
# 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
|
||||
write_any( objekt )
|
||||
end
|
||||
@ -159,7 +159,7 @@ module Register
|
||||
# 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
|
||||
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}"
|
||||
end
|
||||
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,
|
||||
# so we can't code the above in ruby
|
||||
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
|
||||
me = get_function.receiver
|
||||
var_name = get_function.args.first
|
||||
@ -39,7 +39,7 @@ module Register
|
||||
end
|
||||
|
||||
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
|
||||
receiver set_function
|
||||
me = set_function.receiver
|
||||
|
@ -93,6 +93,7 @@ module Virtual
|
||||
# Objects are data and get assembled after functions
|
||||
def add_object o
|
||||
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
|
||||
true
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ class Symbol
|
||||
end
|
||||
def get_layout
|
||||
l = Virtual.machine.space.classes[:Word].object_layout
|
||||
puts "LL #{l.class}"
|
||||
#puts "LL #{l.class}"
|
||||
l
|
||||
end
|
||||
def word_length
|
||||
@ -42,7 +42,7 @@ class Symbol
|
||||
pos = cache_positions[self]
|
||||
if pos == nil
|
||||
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}"
|
||||
end
|
||||
pos
|
||||
@ -168,7 +168,7 @@ module Parfait
|
||||
# name comes in as a ruby @var name
|
||||
def instance_variable_get name
|
||||
var = get_instance_variable name.to_s[1 .. -1].to_sym
|
||||
puts "getting #{name} #{var}"
|
||||
#puts "getting #{name} #{var}"
|
||||
var
|
||||
end
|
||||
end
|
||||
|
@ -12,17 +12,17 @@ module Virtual
|
||||
return unless Virtual.machine.add_object object
|
||||
#puts "adding #{object.class}"
|
||||
return unless object.respond_to? :has_layout?
|
||||
unless object.has_layout?
|
||||
object.init_layout
|
||||
end
|
||||
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
|
||||
layout = object.get_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|
|
||||
inst = object.instance_variable_get "@#{name}".to_sym
|
||||
inst = object.get_instance_variable name
|
||||
keep inst
|
||||
end
|
||||
if object.is_a? Parfait::List
|
||||
|
@ -3,7 +3,7 @@ require_relative "type"
|
||||
module Positioned
|
||||
def position
|
||||
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]}"
|
||||
end
|
||||
@position
|
||||
|
@ -30,7 +30,7 @@ HERE
|
||||
check
|
||||
end
|
||||
|
||||
def ttest_string_put
|
||||
def test_string_put
|
||||
@string_input = <<HERE
|
||||
"Hello again\n".putstring()
|
||||
HERE
|
||||
|
@ -3,7 +3,7 @@ require_relative "test_foo"
|
||||
require_relative "test_if"
|
||||
require_relative "test_functions"
|
||||
require_relative "test_string_class"
|
||||
#require_relative "test_hello"
|
||||
require_relative "test_hello"
|
||||
#require_relative "test_putint"
|
||||
require_relative "test_recursive_fibo"
|
||||
require_relative "test_while_fibo"
|
||||
|
@ -7,11 +7,7 @@ class TestHello < MiniTest::Test
|
||||
@string_input = <<HERE
|
||||
"Hello Raisa, I am salama".putstring()
|
||||
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]
|
||||
@output = "Hello Raisa, I am salama "
|
||||
@target = [:Object , :putstring]
|
||||
parse
|
||||
write "hello"
|
||||
@expect = []
|
||||
check
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user