move boot* classes to boot directory

This commit is contained in:
Torsten Ruger 2014-06-13 23:51:53 +03:00
parent a7551ea8b6
commit 12a92e4db0
9 changed files with 23 additions and 23 deletions

View File

@ -1,9 +1,9 @@
require_relative "meta_class"
module Vm
module Boot
# class is mainly a list of functions with a name (for now)
# layout of object is seperated into Layout
class BootClass < ObjectConstant
class BootClass < Vm::ObjectConstant
def initialize name , context , super_class = :Object
super()
@context = context
@ -16,7 +16,7 @@ module Vm
attr_reader :name , :functions , :meta_class , :context
def add_function function
raise "not a function #{function}" unless function.is_a? Function
raise "not a function #{function}" unless function.is_a? Vm::Function
raise "syserr " unless function.name.is_a? Symbol
@functions << function
end

View File

@ -1,12 +1,12 @@
require_relative "context"
require_relative "boot_class"
require_relative "call_site"
require "vm/context"
require "boot/boot_class"
require "vm/call_site"
require "arm/arm_machine"
require "core/kernel"
require "boot/object"
require "boot/string"
module Vm
module Boot
# The BootSpace is contains all objects for a program. In functional terms it is a program, but on oo
# it is a collection of objects, some of which are data, some classes, some functions
@ -18,7 +18,7 @@ module Vm
# throwing in a context for unspecified use (well one is to pass the programm/globals around)
class BootSpace < Code
class BootSpace < Vm::Code
# Initialize with a string for cpu. Naming conventions are: for Machine XXX there exists a module XXX
# with a XXXMachine in it that derives from Vm::RegisterMachine
@ -27,19 +27,19 @@ module Vm
machine = RbConfig::CONFIG["host_cpu"] unless machine
machine = "intel" if machine == "x86_64"
machine = machine.capitalize
RegisterMachine.instance = eval("#{machine}::#{machine}Machine").new
Vm::RegisterMachine.instance = eval("#{machine}::#{machine}Machine").new
@classes = {}
@context = Context.new(self)
@context = Vm::Context.new(self)
@context.current_class = get_or_create_class :Object
@main = Function.new("main")
@main = Vm::Function.new("main")
@context.function = @main
#global objects (data)
@objects = []
@entry = RegisterMachine.instance.main_start @context
@entry = Vm::RegisterMachine.instance.main_start @context
#main gets executed between entry and exit
@exit = RegisterMachine.instance.main_exit @context
@exit = Vm::RegisterMachine.instance.main_exit @context
boot_classes
@passes = [ MoveMoveReduction.new , LogicMoveReduction.new, NoopReduction.new, SaveLocals.new ]
@passes = [ Vm::MoveMoveReduction.new , Vm::LogicMoveReduction.new, Vm::NoopReduction.new, Vm::SaveLocals.new ]
end
attr_reader :context , :main , :classes , :entry , :exit
@ -81,7 +81,7 @@ module Vm
# Objects are data and get assembled after functions
def add_object o
return if @objects.include? o
raise "must be derived from Code #{o.inspect}" unless o.is_a? Code
raise "must be derived from Code #{o.inspect}" unless o.is_a? Vm::Code
@objects << o # TODO check type , no basic values allowed (must be wrapped)
end

View File

@ -1,4 +1,4 @@
module Vm
module Boot
# class that acts like a class, but is really the object
# described in the ruby language book as the eigenclass, what you get with
@ -8,7 +8,7 @@ module Vm
# PS: can't say i fancy the << self syntax and am considerernig adding a keyword for it, like meta
# In effect it is a very similar construct to def self.function(...)
# So one could write def meta.function(...) and thus define on the meta-class
class MetaClass < ObjectConstant
class MetaClass < Vm::ObjectConstant
# no name, nor nothing. as this is just the object really
def initialize(object)

View File

@ -9,7 +9,7 @@ require "vm/code"
require "vm/values"
require "vm/block"
require "vm/function"
require "vm/boot_class"
require "vm/boot_space"
require "boot/boot_class"
require "boot/boot_space"
require "stream_reader"
require "core/kernel"

View File

@ -17,7 +17,7 @@ module Vm
if value.is_a?(IntegerConstant) or value.is_a?(ObjectConstant)
function.receiver.load into , value
else
raise "meta #{name} " if value.is_a? MetaClass
raise "meta #{name} " if value.is_a? Boot::MetaClass
function.receiver.move( into, value ) if value.register_symbol != function.receiver.register_symbol
end
raise "function call '#{name}' has #{args.length} arguments, but function has #{function.args.length}" if args.length != function.args.length

View File

@ -161,7 +161,7 @@ module Vm
elsif right.is_a? StringConstant
block.add( self , right , nil) #move the address, by "adding" to pc, ie pc relative
block.mov( Integer.new(self.used_register.next_reg_use) , right.length ) #and the length HACK TODO
elsif right.is_a?(BootClass) or right.is_a?(MetaClass)
elsif right.is_a?(Boot::BootClass) or right.is_a?(Boot::MetaClass)
block.add( self , right , nil) #move the address, by "adding" to pc, ie pc relative
else
raise "unknown #{right.inspect}"

View File

@ -13,7 +13,7 @@ require 'parslet/convenience'
module Fragments
# need a code generator, for arm
def setup
@object_space = Vm::BootSpace.new "Arm"
@object_space = Boot::BootSpace.new "Arm"
end
def parse

View File

@ -85,7 +85,7 @@ HERE
expr = part.compile( @object_space.context )
else
expr = part.compile( @object_space.context )
raise "should be function definition for now, not #{part.inspect}#{expr.inspect}" unless expr.is_a? Vm::BootClass
raise "should be function definition for now, not #{part.inspect}#{expr.inspect}" unless expr.is_a? Boot::BootClass
end
end
end