rename Position get/set
This commit is contained in:
@ -46,7 +46,7 @@ module Risc
|
||||
|
||||
# labels have the same position as their next
|
||||
def set_position( position , count = 0 , extra = nil)
|
||||
Position.set_position(self,position , extra)
|
||||
Position.set(self,position , extra)
|
||||
self.next.set_position(position,count,extra) if self.next
|
||||
end
|
||||
|
||||
|
@ -77,7 +77,7 @@ module Risc
|
||||
def position_all
|
||||
translate_arm unless @translated
|
||||
#need the initial jump at 0 and then functions
|
||||
Position.set_position(binary_init,0)
|
||||
Position.set(binary_init,0)
|
||||
cpu_init.set_position( 12 ,0 , binary_init)
|
||||
@code_start = position_objects( binary_init.padded_length )
|
||||
# and then everything code
|
||||
@ -91,7 +91,7 @@ module Risc
|
||||
# want to have the objects first in the executable
|
||||
objects.each do | id , objekt|
|
||||
next if objekt.is_a?( Parfait::BinaryCode) or objekt.is_a?( Risc::Label )
|
||||
Position.set_position(objekt,at)
|
||||
Position.set(objekt,at)
|
||||
before = at
|
||||
at += objekt.padded_length
|
||||
log.debug "Object #{objekt.class}:#{before.to_s(16)} len: #{(at - before).to_s(16)}"
|
||||
@ -114,7 +114,7 @@ module Risc
|
||||
before = at
|
||||
nekst = method.binary
|
||||
while(nekst)
|
||||
Position.set_position(nekst , at , method)
|
||||
Position.set(nekst , at , method)
|
||||
at += nekst.padded_length
|
||||
nekst = nekst.next
|
||||
end
|
||||
|
@ -48,7 +48,11 @@ module Risc
|
||||
@positions
|
||||
end
|
||||
|
||||
def self.position(object)
|
||||
def self.set?(object)
|
||||
self.positions.has_key?(object)
|
||||
end
|
||||
|
||||
def self.get(object)
|
||||
pos = self.positions[object]
|
||||
if pos == nil
|
||||
str = "position accessed but not set, "
|
||||
@ -59,7 +63,7 @@ module Risc
|
||||
pos
|
||||
end
|
||||
|
||||
def self.set_position( object , pos , extra = nil)
|
||||
def self.set( object , pos , extra = nil)
|
||||
# resetting of position used to be error, but since relink and dynamic instruction size it is ok.
|
||||
# in measures (of 32)
|
||||
#puts "Setting #{pos} for #{self.class}"
|
||||
|
@ -41,7 +41,7 @@ module Risc
|
||||
def write_debug
|
||||
@machine.objects.each do |id , objekt|
|
||||
next if objekt.is_a?(Risc::Label)
|
||||
log.debug "Linked #{objekt.class}:0x#{objekt.object_id.to_s(16)} at #{Position.position(objekt)} / 0x#{objekt.padded_length.to_s(16)}"
|
||||
log.debug "Linked #{objekt.class}:0x#{objekt.object_id.to_s(16)} at #{Position.get(objekt)} / 0x#{objekt.padded_length.to_s(16)}"
|
||||
end
|
||||
end
|
||||
|
||||
@ -71,16 +71,16 @@ module Risc
|
||||
# Write any object just logs a bit and passes to write_any_out
|
||||
def write_any( obj )
|
||||
write_any_log( obj , "Write")
|
||||
if @stream.length != Position.position(obj).at
|
||||
raise "Write #{obj.class}:0x#{obj.object_id.to_s(16)} at 0x#{stream_position.to_s(16)} not #{Position.position(obj)}"
|
||||
if @stream.length != Position.get(obj).at
|
||||
raise "Write #{obj.class}:0x#{obj.object_id.to_s(16)} at 0x#{stream_position.to_s(16)} not #{Position.get(obj)}"
|
||||
end
|
||||
write_any_out(obj)
|
||||
write_any_log( obj , "Wrote")
|
||||
Position.position(obj)
|
||||
Position.get(obj)
|
||||
end
|
||||
|
||||
def write_any_log( obj , at)
|
||||
log.debug "#{at} #{obj.class}:0x#{obj.object_id.to_s(16)} at stream #{stream_position} pos:#{Position.position(obj)} , len:0x#{obj.padded_length.to_s(16)}"
|
||||
log.debug "#{at} #{obj.class}:0x#{obj.object_id.to_s(16)} at stream #{stream_position} pos:#{Position.get(obj)} , len:0x#{obj.padded_length.to_s(16)}"
|
||||
end
|
||||
|
||||
# Most objects are the same and get passed to write_object
|
||||
@ -108,14 +108,14 @@ module Risc
|
||||
log.debug "type #{obj_written} , total #{obj_written + indexed_written} (array #{indexed_written})"
|
||||
log.debug "Len = 0x#{object.get_length.to_s(16)} , inst =0x#{object.get_type.instance_length.to_s(16)}" if object.is_a? Parfait::Type
|
||||
pad_after( obj_written + indexed_written )
|
||||
Position.position(object)
|
||||
Position.get(object)
|
||||
end
|
||||
|
||||
def write_object_check(object)
|
||||
log.debug "Write object #{object.class} #{object.inspect[0..100]}"
|
||||
#Only initially created codes are collected. Binary_init and method "tails" not
|
||||
if !@machine.objects.has_key?(object.object_id) and !object.is_a?(Parfait::BinaryCode)
|
||||
log.debug "Object at 0x#{Position.position(object).to_s(16)}:#{object.get_type()}"
|
||||
log.debug "Object at 0x#{Position.get(object).to_s(16)}:#{object.get_type()}"
|
||||
raise "Object(0x#{object.object_id.to_s(16)}) not linked #{object.inspect}"
|
||||
end
|
||||
end
|
||||
@ -178,7 +178,7 @@ module Risc
|
||||
raise "length mismatch #{str.length} != #{string.char_length}" if str.length != string.char_length
|
||||
end
|
||||
str = string.to_s if string.is_a? Symbol
|
||||
log.debug "#{string.class} is #{string} at 0x#{Position.position(string)} length 0x#{string.length.to_s(16)}"
|
||||
log.debug "#{string.class} is #{string} at 0x#{Position.get(string)} length 0x#{string.length.to_s(16)}"
|
||||
write_checked_string(string , str)
|
||||
end
|
||||
|
||||
@ -206,7 +206,7 @@ module Risc
|
||||
when Fixnum
|
||||
@stream.write_signed_int_32(object)
|
||||
else
|
||||
@stream.write_signed_int_32(Position.position(object) + @load_at)
|
||||
@stream.write_signed_int_32(Position.get(object) + @load_at)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user