random checkin
still suffering -1 trauma
This commit is contained in:
parent
ab01fa3862
commit
4a88f342d3
3
Gemfile
3
Gemfile
@ -5,7 +5,8 @@ gem "rubyx" , :path => "."
|
|||||||
gem "rake"
|
gem "rake"
|
||||||
gem "rye"
|
gem "rye"
|
||||||
|
|
||||||
gem "rx-file" , :git => "https://github.com/ruby-x/rx-file"
|
gem "rx-file" , git: "https://github.com/ruby-x/rx-file"
|
||||||
|
#gem "rx-file" , path: "../rx-file"
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem "codeclimate-test-reporter" , require: false
|
gem "codeclimate-test-reporter" , require: false
|
||||||
|
@ -104,4 +104,4 @@ DEPENDENCIES
|
|||||||
thor (= 0.19.1)
|
thor (= 0.19.1)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.15.4
|
1.16.1
|
||||||
|
@ -24,12 +24,12 @@ module Elf
|
|||||||
|
|
||||||
# for debug add labels for labels
|
# for debug add labels for labels
|
||||||
Parfait.object_space.each_type do |type|
|
Parfait.object_space.each_type do |type|
|
||||||
type.each_method do |f|
|
type.each_method do |meth|
|
||||||
f.cpu_instructions.each do |label|
|
meth.cpu_instructions.each do |label|
|
||||||
next unless label.is_a?(Risc::Label)
|
next unless label.is_a?(Risc::Label)
|
||||||
add_symbol "#{type.name}@#{f.name}:#{label.name}" , Risc::Position.get(label).at
|
add_symbol "#{type.name}@#{meth.name}:Label=#{label.name}" , Risc::Position.get(label).at
|
||||||
end
|
end
|
||||||
f.binary.each do |code|
|
meth.binary.each do |code|
|
||||||
label = "BinaryCode@#{Risc::Position.get(code).method.name}"
|
label = "BinaryCode@#{Risc::Position.get(code).method.name}"
|
||||||
add_symbol label , Risc::Position.get(code).at
|
add_symbol label , Risc::Position.get(code).at
|
||||||
end
|
end
|
||||||
@ -38,8 +38,8 @@ module Elf
|
|||||||
|
|
||||||
@machine.objects.each do |id,slot|
|
@machine.objects.each do |id,slot|
|
||||||
next if slot.is_a?(Parfait::BinaryCode)
|
next if slot.is_a?(Parfait::BinaryCode)
|
||||||
if( slot.respond_to? :sof_reference_name )
|
if( slot.respond_to? :rxf_reference_name )
|
||||||
label = "#{slot.sof_reference_name}"
|
label = "#{slot.rxf_reference_name}"
|
||||||
else
|
else
|
||||||
label = "#{slot.class.name}::#{Risc::Position.get(slot)}"
|
label = "#{slot.class.name}::#{Risc::Position.get(slot)}"
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ module Parfait
|
|||||||
super()
|
super()
|
||||||
extend_to(total_size)
|
extend_to(total_size)
|
||||||
#puts "Init with #{total_size} for #{object_id}"
|
#puts "Init with #{total_size} for #{object_id}"
|
||||||
(1..(data_length+1)).each{ |index| set_word(index , 0) }
|
(0 ..(data_length)).each{ |index| set_word(index , 0) }
|
||||||
end
|
end
|
||||||
def extend_to(total_size)
|
def extend_to(total_size)
|
||||||
if total_size > self.data_length
|
if total_size > self.data_length
|
||||||
@ -37,13 +37,13 @@ module Parfait
|
|||||||
end
|
end
|
||||||
|
|
||||||
def each_word
|
def each_word
|
||||||
index = 1
|
index = 0
|
||||||
while( index <= data_length)
|
while( index < data_length)
|
||||||
yield get_word(index)
|
yield get_word(index)
|
||||||
index += 1
|
index += 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#16 - 2 -1 , two instance varaibles and one for the jump
|
#16 - 2 -1 , two instance variables and one for the jump
|
||||||
def data_length
|
def data_length
|
||||||
13
|
13
|
||||||
end
|
end
|
||||||
@ -51,8 +51,8 @@ module Parfait
|
|||||||
4*data_length
|
4*data_length
|
||||||
end
|
end
|
||||||
def set_word(index , word)
|
def set_word(index , word)
|
||||||
raise "invalid index #{index}" if index < 1
|
raise "invalid index #{index}" if index < 0
|
||||||
if index > data_length + 1
|
if index > data_length
|
||||||
#raise "invalid index #{index}" unless @next
|
#raise "invalid index #{index}" unless @next
|
||||||
extend_to( index )
|
extend_to( index )
|
||||||
@next.set_word( index - data_length , word)
|
@next.set_word( index - data_length , word)
|
||||||
@ -60,7 +60,7 @@ module Parfait
|
|||||||
set_internal_word(index + 2 , word)
|
set_internal_word(index + 2 , word)
|
||||||
end
|
end
|
||||||
def get_word(index)
|
def get_word(index)
|
||||||
raise "invalid index #{index}" if index < 1
|
raise "invalid index #{index}" if index < 0
|
||||||
if index > data_length + 1
|
if index > data_length + 1
|
||||||
raise "invalid index #{index}" unless @next
|
raise "invalid index #{index}" unless @next
|
||||||
return @next.get_word( index - data_length)
|
return @next.get_word( index - data_length)
|
||||||
|
@ -266,7 +266,7 @@ module Parfait
|
|||||||
array = []
|
array = []
|
||||||
index = 0
|
index = 0
|
||||||
while( index < self.get_length)
|
while( index < self.get_length)
|
||||||
array[index - 1] = get(index)
|
array[index] = get(index)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
end
|
end
|
||||||
array
|
array
|
||||||
|
@ -40,7 +40,7 @@ module Risc
|
|||||||
#
|
#
|
||||||
# The way out is to build empty shell objects and stuff the neccessary data into them
|
# The way out is to build empty shell objects and stuff the neccessary data into them
|
||||||
# (not use the normal initialize way)
|
# (not use the normal initialize way)
|
||||||
# (PPS: The "real" solution is to read a sof graph and not do this by hand
|
# (PPS: The "real" solution is to read a rx-file graph and not do this by hand
|
||||||
# That graph can be programatically built and written (with this to boot that process :-))
|
# That graph can be programatically built and written (with this to boot that process :-))
|
||||||
|
|
||||||
# There are some helpers below, but the roadmap is something like:
|
# There are some helpers below, but the roadmap is something like:
|
||||||
@ -60,7 +60,7 @@ module Risc
|
|||||||
Parfait.set_object_space( space )
|
Parfait.set_object_space( space )
|
||||||
|
|
||||||
#puts Sof.write(space)
|
#puts Sof.write(space)
|
||||||
boot_functions( space )
|
#boot_functions( space )
|
||||||
end
|
end
|
||||||
|
|
||||||
# types is where the snake bites its tail. Every chain ends at a type and then it
|
# types is where the snake bites its tail. Every chain ends at a type and then it
|
||||||
@ -98,7 +98,8 @@ module Risc
|
|||||||
classes = Parfait::Dictionary.new
|
classes = Parfait::Dictionary.new
|
||||||
type_names.each do |name , vars|
|
type_names.each do |name , vars|
|
||||||
super_c = super_class_names[name] || :Object
|
super_c = super_class_names[name] || :Object
|
||||||
classes[name] = Parfait::Class.new(name , super_c , types[name] )
|
clazz = Parfait::Class.new(name , super_c , types[name] )
|
||||||
|
classes[name] = clazz
|
||||||
end
|
end
|
||||||
classes
|
classes
|
||||||
end
|
end
|
||||||
|
@ -45,8 +45,8 @@ module Risc
|
|||||||
|
|
||||||
def self.message(object , depth)
|
def self.message(object , depth)
|
||||||
msg = "adding #{depth}#{' ' * depth}:"
|
msg = "adding #{depth}#{' ' * depth}:"
|
||||||
if( object.respond_to?(:sof_reference_name))
|
if( object.respond_to?(:rxf_reference_name))
|
||||||
msg + object.sof_reference_name.to_s
|
msg + object.rxf_reference_name.to_s
|
||||||
else
|
else
|
||||||
msg + object.class.name
|
msg + object.class.name
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ module Risc
|
|||||||
class_source "#{@name} (next: #{self.next.class.name.split("::").last})"
|
class_source "#{@name} (next: #{self.next.class.name.split("::").last})"
|
||||||
end
|
end
|
||||||
|
|
||||||
def sof_reference_name
|
def rxf_reference_name
|
||||||
@name
|
@name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ module Risc
|
|||||||
when String , Symbol
|
when String , Symbol
|
||||||
@constant.to_s
|
@constant.to_s
|
||||||
else
|
else
|
||||||
if( @constant.respond_to? :sof_reference_name )
|
if( @constant.respond_to? :rxf_reference_name )
|
||||||
constant.sof_reference_name
|
constant.rxf_reference_name
|
||||||
else
|
else
|
||||||
constant.class.name.to_s
|
constant.class.name.to_s
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@ module Risc
|
|||||||
@register = register
|
@register = register
|
||||||
@array = array
|
@array = array
|
||||||
@index = index
|
@index = index
|
||||||
raise "index 0 " if index == 0
|
raise "index 0 " if index < 0
|
||||||
raise "Not integer or reg #{index}" unless index.is_a?(Numeric) or RiscValue.look_like_reg(index)
|
raise "Not integer or reg #{index}" unless index.is_a?(Numeric) or RiscValue.look_like_reg(index)
|
||||||
raise "Not register #{register}" unless RiscValue.look_like_reg(register)
|
raise "Not register #{register}" unless RiscValue.look_like_reg(register)
|
||||||
raise "Not register #{array}" unless RiscValue.look_like_reg(array)
|
raise "Not register #{array}" unless RiscValue.look_like_reg(array)
|
||||||
|
@ -24,7 +24,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
def init(at)
|
def init(at)
|
||||||
diff = at - Position.get(@binary).at
|
diff = at - Position.get(@binary).at
|
||||||
if( diff % 60 == 13*4)
|
if( diff % 60 == 12*4)
|
||||||
@binary.extend_one unless @binary.next
|
@binary.extend_one unless @binary.next
|
||||||
@binary = @binary.next
|
@binary = @binary.next
|
||||||
raise "end of line " unless @binary
|
raise "end of line " unless @binary
|
||||||
|
@ -52,7 +52,7 @@ module Risc
|
|||||||
RiscValue.new( sym , type, value)
|
RiscValue.new( sym , type, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sof_reference_name
|
def rxf_reference_name
|
||||||
@symbol
|
@symbol
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@ module Risc
|
|||||||
include Logging
|
include Logging
|
||||||
log_level :info
|
log_level :info
|
||||||
|
|
||||||
MARKER = 0xBAD4C0DE
|
|
||||||
|
|
||||||
def initialize(machine)
|
def initialize(machine)
|
||||||
@machine = machine
|
@machine = machine
|
||||||
end
|
end
|
||||||
@ -134,7 +132,6 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write_object_variables(object)
|
def write_object_variables(object)
|
||||||
@stream.write_signed_int_32( MARKER )
|
|
||||||
written = 0 # compensate for the "secret" marker
|
written = 0 # compensate for the "secret" marker
|
||||||
object.get_instance_variables.each do |var|
|
object.get_instance_variables.each do |var|
|
||||||
inst = object.get_instance_variable(var)
|
inst = object.get_instance_variable(var)
|
||||||
@ -147,7 +144,6 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write_data4( code )
|
def write_data4( code )
|
||||||
@stream.write_signed_int_32( MARKER )
|
|
||||||
write_ref_for( code.get_type )
|
write_ref_for( code.get_type )
|
||||||
log.debug "Data4 witten stream 0x#{@stream.length.to_s(16)}"
|
log.debug "Data4 witten stream 0x#{@stream.length.to_s(16)}"
|
||||||
end
|
end
|
||||||
@ -160,7 +156,6 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write_BinaryCode( code )
|
def write_BinaryCode( code )
|
||||||
@stream.write_signed_int_32( MARKER )
|
|
||||||
write_ref_for( code.get_type )
|
write_ref_for( code.get_type )
|
||||||
write_ref_for( code.next )
|
write_ref_for( code.next )
|
||||||
code.each_word do |word|
|
code.each_word do |word|
|
||||||
@ -180,7 +175,6 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def write_checked_string(string, str)
|
def write_checked_string(string, str)
|
||||||
@stream.write_signed_int_32( MARKER )
|
|
||||||
write_ref_for( string.get_type ) #ref
|
write_ref_for( string.get_type ) #ref
|
||||||
@stream.write_signed_int_32( str.length ) #int
|
@stream.write_signed_int_32( str.length ) #int
|
||||||
@stream.write str
|
@stream.write str
|
||||||
@ -210,7 +204,7 @@ module Risc
|
|||||||
# pad_after is always in bytes and pads (writes 0's) up to the next 8 word boundary
|
# pad_after is always in bytes and pads (writes 0's) up to the next 8 word boundary
|
||||||
def pad_after( length )
|
def pad_after( length )
|
||||||
before = stream_position
|
before = stream_position
|
||||||
pad = Padding.padding_for(length) - 4 # four is for the MARKER we write
|
pad = Padding.padding_for(length)
|
||||||
pad.times do
|
pad.times do
|
||||||
@stream.write_unsigned_int_8(0)
|
@stream.write_unsigned_int_8(0)
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ module Risc
|
|||||||
def test_load_args_from_message
|
def test_load_args_from_message
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal :r0 , produced.next.array.symbol , produced.next.to_rxf
|
assert_equal :r0 , produced.next.array.symbol , produced.next.to_rxf
|
||||||
assert_equal 9 , produced.next.index , produced.next.to_rxf
|
assert_equal 8 , produced.next.index , produced.next.to_rxf
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -21,12 +21,12 @@ module Risc
|
|||||||
def test_frame_load
|
def test_frame_load
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal :Message , produced.next(1).array.type
|
assert_equal :Message , produced.next(1).array.type
|
||||||
assert_equal 4 , produced.next(1).index # 4 is frame
|
assert_equal 3 , produced.next(1).index # 3 is frame
|
||||||
end
|
end
|
||||||
def test_value_load
|
def test_value_load
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal produced.next(2).register , produced.register
|
assert_equal produced.next(2).register , produced.register
|
||||||
assert_equal 2 , produced.next(2).index #type == 1 , r == 2
|
assert_equal 1 , produced.next(2).index #type == 0 , r == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -21,12 +21,12 @@ module Risc
|
|||||||
def test_frame_load
|
def test_frame_load
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal :Message , produced.next(1).array.type
|
assert_equal :Message , produced.next(1).array.type
|
||||||
assert_equal 4 , produced.next(1).index # 4 is frame
|
assert_equal 3 , produced.next(1).index # 4 is frame
|
||||||
end
|
end
|
||||||
def test_value_load
|
def test_value_load
|
||||||
produced = produce_body
|
produced = produce_body
|
||||||
assert_equal produced.next(2).register , produced.register
|
assert_equal produced.next(2).register , produced.register
|
||||||
assert_equal 2 , produced.next(2).index #type == 1 , r == 2
|
assert_equal 1 , produced.next(2).index #type == 1 , r == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -53,7 +53,7 @@ module Parfait
|
|||||||
end
|
end
|
||||||
def test_nilled
|
def test_nilled
|
||||||
assert_equal 0 , @code.get_word(1)
|
assert_equal 0 , @code.get_word(1)
|
||||||
assert_equal 0 , @code.get_word(14)
|
assert_equal 0 , @code.get_word(13)
|
||||||
end
|
end
|
||||||
def test_get_set_self
|
def test_get_set_self
|
||||||
@code.set_word(10,1)
|
@code.set_word(10,1)
|
||||||
@ -86,11 +86,11 @@ module Parfait
|
|||||||
assert_equal 13 , len
|
assert_equal 13 , len
|
||||||
end
|
end
|
||||||
def test_each_set
|
def test_each_set
|
||||||
(1..13).each{|i| @code.set_word(i,i)}
|
(0..12).each{|i| @code.set_word(i,i)}
|
||||||
all = []
|
all = []
|
||||||
@code.each_word{ |w| all << w}
|
@code.each_word{ |w| all << w}
|
||||||
assert_equal 1 , all.first
|
assert_equal 0 , all.first
|
||||||
assert_equal 13 , all.last
|
assert_equal 12 , all.last
|
||||||
end
|
end
|
||||||
def test_set_word
|
def test_set_word
|
||||||
assert_equal 1 , @code.set_word(1 , 1)
|
assert_equal 1 , @code.set_word(1 , 1)
|
||||||
|
@ -180,5 +180,10 @@ module Parfait
|
|||||||
end
|
end
|
||||||
assert_equal 2 , counter
|
assert_equal 2 , counter
|
||||||
end
|
end
|
||||||
|
def test_to_a
|
||||||
|
arr = @list.to_a
|
||||||
|
assert_equal Array , arr.class
|
||||||
|
assert_equal 3 , arr.length
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user