getting the symbols to work
This commit is contained in:
@ -64,12 +64,6 @@ module Virtual
|
||||
end
|
||||
end
|
||||
|
||||
# double check that all objects dependents are really in the space too (debugging)
|
||||
def double_check
|
||||
@objects.each do |o|
|
||||
check o
|
||||
end
|
||||
end
|
||||
# Objects are data and get assembled after functions
|
||||
def add_object o
|
||||
return false if @objects.include?(o)
|
||||
@ -77,21 +71,6 @@ module Virtual
|
||||
true
|
||||
end
|
||||
|
||||
# private
|
||||
def check object , recurse = true
|
||||
raise "No good #{object.class}" unless @objects.include? object
|
||||
puts "#{object.class}"
|
||||
puts "#{object}" if object.class == Parfait::Word
|
||||
check object.get_layout
|
||||
return unless recurse
|
||||
object.get_layout.each do |name|
|
||||
check name , false
|
||||
inst = object.instance_variable_get "@#{name}".to_sym
|
||||
check inst , false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Passes may be added to by anyone who wants
|
||||
# This is intentionally quite flexible, though one sometimes has to watch the order of them
|
||||
# most ordering is achieved by ordering the requires and using add_pass
|
||||
@ -112,10 +91,10 @@ module Virtual
|
||||
end
|
||||
|
||||
def self.boot
|
||||
instance = self.instance
|
||||
me = self.instance
|
||||
# boot is a verb here. this is a somewhat tricky process which is in it's own file, boot.rb
|
||||
instance.boot_parfait!
|
||||
instance
|
||||
me.boot_parfait!
|
||||
me
|
||||
end
|
||||
def self.instance
|
||||
@instance ||= Machine.new
|
||||
|
@ -73,6 +73,35 @@ class Symbol
|
||||
def get_layout
|
||||
Virtual::Machine.instance.class_mappings[:Word].object_layout
|
||||
end
|
||||
def mem_length
|
||||
to_s.length
|
||||
end
|
||||
# not the prettiest addition to the game, but it wasn't me who decided symbols are frozen in 2.x
|
||||
def cache_positions
|
||||
unless defined?(@@symbol_positions)
|
||||
@@symbol_positions = {}
|
||||
end
|
||||
@@symbol_positions
|
||||
end
|
||||
def position
|
||||
pos = cache_positions[self]
|
||||
if pos == nil
|
||||
str = "position accessed but not set, "
|
||||
str += "Machine has object=#{Virtual::Machine.instance.objects.include?(self)} "
|
||||
raise str + " for Symbol:#{self}"
|
||||
end
|
||||
pos
|
||||
end
|
||||
def set_position pos
|
||||
# resetting of position used to be error, but since relink and dynamic instruction size it is ok.
|
||||
# in measures (of 32)
|
||||
old = cache_positions[self]
|
||||
if old != nil and ((old - pos).abs > 32)
|
||||
raise "position set again #{pos}!=#{old} for #{self}"
|
||||
end
|
||||
cache_positions[self] = pos
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module Parfait
|
||||
|
@ -14,9 +14,12 @@ module Virtual
|
||||
unless object.has_layout?
|
||||
object.init_layout
|
||||
end
|
||||
if( object.is_a? Parfait::Method)
|
||||
object.info.constants.each{|c| keep(c) }
|
||||
end
|
||||
layout = object.get_layout
|
||||
#puts "Layout #{layout.get_object_class.name} #{Machine.instance.objects.include?(layout)}"
|
||||
keep layout
|
||||
#puts "Layout #{layout.get_object_class.name} #{Machine.instance.objects.include?(layout)}"
|
||||
layout.each do |name|
|
||||
inst = object.instance_variable_get "@#{name}".to_sym
|
||||
keep inst
|
||||
|
@ -21,9 +21,9 @@ module Virtual
|
||||
def run block
|
||||
block.codes.dup.each do |code|
|
||||
if code.is_a?(NewFrame)
|
||||
kind = "next_frame"
|
||||
kind = :next_frame
|
||||
elsif code.is_a?(NewMessage)
|
||||
kind = "next_message"
|
||||
kind = :next_message
|
||||
else
|
||||
next
|
||||
end
|
||||
|
@ -22,13 +22,13 @@ module Virtual
|
||||
puts "function was already removed #{ function.name}"
|
||||
return
|
||||
end
|
||||
#puts "stayer #{function.name}"
|
||||
@gonners.delete function
|
||||
function.info.blocks.each do |block|
|
||||
block.codes.each do |code|
|
||||
if code.is_a? Virtual::MessageSend
|
||||
str_name = code.name.to_s
|
||||
@gonners.each do |stay|
|
||||
remove stay if(stay.name == str_name)
|
||||
remove stay if(stay.name == code.name)
|
||||
end
|
||||
end
|
||||
remove code.method if code.is_a? Virtual::MethodCall
|
||||
|
Reference in New Issue
Block a user