move assembly from visitor into objects, part one

This commit is contained in:
Torsten Ruger
2014-09-16 16:06:56 +03:00
parent 914d8af8c6
commit 45977ecc01
9 changed files with 121 additions and 148 deletions

View File

@ -1,5 +1,6 @@
require_relative "boot_class"
require "builtin/object"
require "parfait/hash"
module Virtual
# The BootSpace contains all objects for a program. In functional terms it is a program, but in oo
@ -17,7 +18,7 @@ module Virtual
# with a XXXMachine in it that derives from Virtual::RegisterMachine
def initialize machine = nil
super()
@classes = {}
@classes = Parfait::Hash.new
@main = Virtual::CompiledMethod.new("main" , [] )
#global objects (data)
@objects = []
@ -28,7 +29,7 @@ module Virtual
def run_passes
@passes.each do |pass|
all = main.blocks
@classes.each_value do |c|
@classes.values.each do |c|
c.instance_methods.each {|f| all += f.blocks }
end
all.each do |block|
@ -90,6 +91,11 @@ module Virtual
end
end
@@SPACE = { :names => [:classes,:objects] , :types => [Virtual::Reference,Virtual::Reference]}
def layout
@@SPACE
end
# Objects are data and get assembled after functions
def add_object o
return if @objects.include? o