use positions in interpreter

This commit is contained in:
Torsten Ruger 2018-05-20 15:52:13 +03:00
parent c0f10bb42b
commit ef2dc932ad
6 changed files with 11 additions and 6 deletions

View File

@ -48,7 +48,7 @@ module Risc
def set_pc( pos ) def set_pc( pos )
raise "Not int #{pos}" unless pos.is_a? Numeric raise "Not int #{pos}" unless pos.is_a? Numeric
position = Position.at(pos) position = Position.at(pos)
log.debug "Setting Position #{pos}" log.debug "Setting Position #{position}"
if position.is_a?(Position::CodePosition) if position.is_a?(Position::CodePosition)
return set_pc(position.at + 12) return set_pc(position.at + 12)
end end

View File

@ -90,6 +90,7 @@ module Risc
before = at before = at
Position.set(objekt,at) Position.set(objekt,at)
at += objekt.padded_length at += objekt.padded_length
log.debug "PADDED #{objekt.padded_length}"
log.debug "Object #{objekt.class}:#{before.to_s(16)} len: #{(at - before).to_s(16)}" log.debug "Object #{objekt.class}:#{before.to_s(16)} len: #{(at - before).to_s(16)}"
end end
at at

View File

@ -15,6 +15,9 @@ module Risc
# entails to affected objects. # entails to affected objects.
module Position module Position
include Util::Logging
log_level :debug
@positions = {} @positions = {}
def self.positions def self.positions
@ -39,7 +42,7 @@ module Risc
if pos == nil if pos == nil
str = "position accessed but not set, " str = "position accessed but not set, "
str += "0x#{object.object_id.to_s(16)}\n" str += "0x#{object.object_id.to_s(16)}\n"
str += "for #{object.class} byte_length #{object.byte_length if object.respond_to?(:byte_length)} for #{object.inspect[0...130]}" str += "for #{object.class} byte_length #{object.byte_length if object.respond_to?(:byte_length)} for #{object.to_s[0...130]}"
raise str raise str
end end
pos pos
@ -55,7 +58,7 @@ module Risc
def self.set( 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. # resetting of position used to be error, but since relink and dynamic instruction size it is ok.
# in measures (of 32) # in measures (of 32)
#puts "Setting #{pos} for #{self.class}" log.debug "Setting #{pos} for #{object.class}-#{object}" if pos < 3000
old = Position.positions[object] old = Position.positions[object]
if old != nil if old != nil
old.reset_to(pos) old.reset_to(pos)
@ -64,6 +67,7 @@ module Risc
position = for_at( object , pos , extra) position = for_at( object , pos , extra)
self.positions[object] = position self.positions[object] = position
position.init(pos) position.init(pos)
log.debug "Set #{pos} for #{position.class}" if pos < 3000
position position
end end

View File

@ -5,6 +5,7 @@ module Risc
def initialize( at , object) def initialize( at , object)
@at = at @at = at
@object = object
raise "not int #{self}-#{at}" unless @at.is_a?(Integer) raise "not int #{self}-#{at}" unless @at.is_a?(Integer)
end end

View File

@ -458,7 +458,7 @@ module Util
# Default formatter for log messages # Default formatter for log messages
class Formatter class Formatter
def call(severity, time, progname, msg) def call(severity, time, progname, msg)
"#{severity} #{progname} #{time.strftime("%M-%S-%L")} #{progname}::#{msg2str(msg)}\n" "#{severity} #{progname} #{time.strftime("%M-%S-%L")}::#{msg2str(msg)}\n"
end end
private private

View File

@ -10,9 +10,8 @@ module Risc
Risc.machine.boot Risc.machine.boot
do_clean_compile do_clean_compile
Vool::VoolCompiler.ruby_to_binary( @string_input , :interpreter) Vool::VoolCompiler.ruby_to_binary( @string_input , :interpreter)
Collector.collect_space
@interpreter = Interpreter.new @interpreter = Interpreter.new
@interpreter.start Risc.machine.risc_init @interpreter.start_machine
end end
alias :do_setup :setup alias :do_setup :setup