fixed layouts

also moved objects to machine, from space
space has a list of objects, but implicit,
not as an explicit array
This commit is contained in:
Torsten Ruger
2015-05-31 13:02:29 +03:00
parent aaa206fbca
commit 03bdc16810
8 changed files with 69 additions and 75 deletions

View File

@ -38,8 +38,9 @@ module Virtual
def initialize
@parser = Parser::Salama.new
@passes = [ "Virtual::SendImplementation" ]
@objects = []
end
attr_reader :passes , :space , :class_mappings , :init
attr_reader :passes , :space , :class_mappings , :init , :objects
def run_passes
Minimizer.new.run
@ -62,6 +63,34 @@ 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)
@objects.push o
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