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 "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
|
||||
gem "codeclimate-test-reporter" , require: false
|
||||
|
@ -104,4 +104,4 @@ DEPENDENCIES
|
||||
thor (= 0.19.1)
|
||||
|
||||
BUNDLED WITH
|
||||
1.15.4
|
||||
1.16.1
|
||||
|
@ -24,12 +24,12 @@ module Elf
|
||||
|
||||
# for debug add labels for labels
|
||||
Parfait.object_space.each_type do |type|
|
||||
type.each_method do |f|
|
||||
f.cpu_instructions.each do |label|
|
||||
type.each_method do |meth|
|
||||
meth.cpu_instructions.each do |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
|
||||
f.binary.each do |code|
|
||||
meth.binary.each do |code|
|
||||
label = "BinaryCode@#{Risc::Position.get(code).method.name}"
|
||||
add_symbol label , Risc::Position.get(code).at
|
||||
end
|
||||
@ -38,8 +38,8 @@ module Elf
|
||||
|
||||
@machine.objects.each do |id,slot|
|
||||
next if slot.is_a?(Parfait::BinaryCode)
|
||||
if( slot.respond_to? :sof_reference_name )
|
||||
label = "#{slot.sof_reference_name}"
|
||||
if( slot.respond_to? :rxf_reference_name )
|
||||
label = "#{slot.rxf_reference_name}"
|
||||
else
|
||||
label = "#{slot.class.name}::#{Risc::Position.get(slot)}"
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ module Parfait
|
||||
super()
|
||||
extend_to(total_size)
|
||||
#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
|
||||
def extend_to(total_size)
|
||||
if total_size > self.data_length
|
||||
@ -37,13 +37,13 @@ module Parfait
|
||||
end
|
||||
|
||||
def each_word
|
||||
index = 1
|
||||
while( index <= data_length)
|
||||
index = 0
|
||||
while( index < data_length)
|
||||
yield get_word(index)
|
||||
index += 1
|
||||
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
|
||||
13
|
||||
end
|
||||
@ -51,8 +51,8 @@ module Parfait
|
||||
4*data_length
|
||||
end
|
||||
def set_word(index , word)
|
||||
raise "invalid index #{index}" if index < 1
|
||||
if index > data_length + 1
|
||||
raise "invalid index #{index}" if index < 0
|
||||
if index > data_length
|
||||
#raise "invalid index #{index}" unless @next
|
||||
extend_to( index )
|
||||
@next.set_word( index - data_length , word)
|
||||
@ -60,7 +60,7 @@ module Parfait
|
||||
set_internal_word(index + 2 , word)
|
||||
end
|
||||
def get_word(index)
|
||||
raise "invalid index #{index}" if index < 1
|
||||
raise "invalid index #{index}" if index < 0
|
||||
if index > data_length + 1
|
||||
raise "invalid index #{index}" unless @next
|
||||
return @next.get_word( index - data_length)
|
||||
|
@ -266,7 +266,7 @@ module Parfait
|
||||
array = []
|
||||
index = 0
|
||||
while( index < self.get_length)
|
||||
array[index - 1] = get(index)
|
||||
array[index] = get(index)
|
||||
index = index + 1
|
||||
end
|
||||
array
|
||||
|
@ -40,7 +40,7 @@ module Risc
|
||||
#
|
||||
# The way out is to build empty shell objects and stuff the neccessary data into them
|
||||
# (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 :-))
|
||||
|
||||
# There are some helpers below, but the roadmap is something like:
|
||||
@ -60,7 +60,7 @@ module Risc
|
||||
Parfait.set_object_space( space )
|
||||
|
||||
#puts Sof.write(space)
|
||||
boot_functions( space )
|
||||
#boot_functions( space )
|
||||
end
|
||||
|
||||
# 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
|
||||
type_names.each do |name , vars|
|
||||
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
|
||||
classes
|
||||
end
|
||||
|
@ -45,8 +45,8 @@ module Risc
|
||||
|
||||
def self.message(object , depth)
|
||||
msg = "adding #{depth}#{' ' * depth}:"
|
||||
if( object.respond_to?(:sof_reference_name))
|
||||
msg + object.sof_reference_name.to_s
|
||||
if( object.respond_to?(:rxf_reference_name))
|
||||
msg + object.rxf_reference_name.to_s
|
||||
else
|
||||
msg + object.class.name
|
||||
end
|
||||
|
@ -22,7 +22,7 @@ module Risc
|
||||
class_source "#{@name} (next: #{self.next.class.name.split("::").last})"
|
||||
end
|
||||
|
||||
def sof_reference_name
|
||||
def rxf_reference_name
|
||||
@name
|
||||
end
|
||||
|
||||
|
@ -24,8 +24,8 @@ module Risc
|
||||
when String , Symbol
|
||||
@constant.to_s
|
||||
else
|
||||
if( @constant.respond_to? :sof_reference_name )
|
||||
constant.sof_reference_name
|
||||
if( @constant.respond_to? :rxf_reference_name )
|
||||
constant.rxf_reference_name
|
||||
else
|
||||
constant.class.name.to_s
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ module Risc
|
||||
@register = register
|
||||
@array = array
|
||||
@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 register #{register}" unless RiscValue.look_like_reg(register)
|
||||
raise "Not register #{array}" unless RiscValue.look_like_reg(array)
|
||||
|
@ -24,7 +24,7 @@ module Risc
|
||||
end
|
||||
def init(at)
|
||||
diff = at - Position.get(@binary).at
|
||||
if( diff % 60 == 13*4)
|
||||
if( diff % 60 == 12*4)
|
||||
@binary.extend_one unless @binary.next
|
||||
@binary = @binary.next
|
||||
raise "end of line " unless @binary
|
||||
|
@ -52,7 +52,7 @@ module Risc
|
||||
RiscValue.new( sym , type, value)
|
||||
end
|
||||
|
||||
def sof_reference_name
|
||||
def rxf_reference_name
|
||||
@symbol
|
||||
end
|
||||
|
||||
|
@ -16,8 +16,6 @@ module Risc
|
||||
include Logging
|
||||
log_level :info
|
||||
|
||||
MARKER = 0xBAD4C0DE
|
||||
|
||||
def initialize(machine)
|
||||
@machine = machine
|
||||
end
|
||||
@ -134,7 +132,6 @@ module Risc
|
||||
end
|
||||
|
||||
def write_object_variables(object)
|
||||
@stream.write_signed_int_32( MARKER )
|
||||
written = 0 # compensate for the "secret" marker
|
||||
object.get_instance_variables.each do |var|
|
||||
inst = object.get_instance_variable(var)
|
||||
@ -147,7 +144,6 @@ module Risc
|
||||
end
|
||||
|
||||
def write_data4( code )
|
||||
@stream.write_signed_int_32( MARKER )
|
||||
write_ref_for( code.get_type )
|
||||
log.debug "Data4 witten stream 0x#{@stream.length.to_s(16)}"
|
||||
end
|
||||
@ -160,7 +156,6 @@ module Risc
|
||||
end
|
||||
|
||||
def write_BinaryCode( code )
|
||||
@stream.write_signed_int_32( MARKER )
|
||||
write_ref_for( code.get_type )
|
||||
write_ref_for( code.next )
|
||||
code.each_word do |word|
|
||||
@ -180,7 +175,6 @@ module Risc
|
||||
end
|
||||
|
||||
def write_checked_string(string, str)
|
||||
@stream.write_signed_int_32( MARKER )
|
||||
write_ref_for( string.get_type ) #ref
|
||||
@stream.write_signed_int_32( str.length ) #int
|
||||
@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
|
||||
def pad_after( length )
|
||||
before = stream_position
|
||||
pad = Padding.padding_for(length) - 4 # four is for the MARKER we write
|
||||
pad = Padding.padding_for(length)
|
||||
pad.times do
|
||||
@stream.write_unsigned_int_8(0)
|
||||
end
|
||||
|
@ -25,7 +25,7 @@ module Risc
|
||||
def test_load_args_from_message
|
||||
produced = produce_body
|
||||
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
|
||||
|
@ -21,12 +21,12 @@ module Risc
|
||||
def test_frame_load
|
||||
produced = produce_body
|
||||
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
|
||||
def test_value_load
|
||||
produced = produce_body
|
||||
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
|
||||
|
@ -21,12 +21,12 @@ module Risc
|
||||
def test_frame_load
|
||||
produced = produce_body
|
||||
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
|
||||
def test_value_load
|
||||
produced = produce_body
|
||||
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
|
||||
|
@ -53,7 +53,7 @@ module Parfait
|
||||
end
|
||||
def test_nilled
|
||||
assert_equal 0 , @code.get_word(1)
|
||||
assert_equal 0 , @code.get_word(14)
|
||||
assert_equal 0 , @code.get_word(13)
|
||||
end
|
||||
def test_get_set_self
|
||||
@code.set_word(10,1)
|
||||
@ -86,11 +86,11 @@ module Parfait
|
||||
assert_equal 13 , len
|
||||
end
|
||||
def test_each_set
|
||||
(1..13).each{|i| @code.set_word(i,i)}
|
||||
(0..12).each{|i| @code.set_word(i,i)}
|
||||
all = []
|
||||
@code.each_word{ |w| all << w}
|
||||
assert_equal 1 , all.first
|
||||
assert_equal 13 , all.last
|
||||
assert_equal 0 , all.first
|
||||
assert_equal 12 , all.last
|
||||
end
|
||||
def test_set_word
|
||||
assert_equal 1 , @code.set_word(1 , 1)
|
||||
|
@ -180,5 +180,10 @@ module Parfait
|
||||
end
|
||||
assert_equal 2 , counter
|
||||
end
|
||||
def test_to_a
|
||||
arr = @list.to_a
|
||||
assert_equal Array , arr.class
|
||||
assert_equal 3 , arr.length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user