move machine to module level
makes for shorter, more concise, access also remove one more bug possibility (reinitiation)
This commit is contained in:
@ -39,6 +39,7 @@ module Virtual
|
||||
@parser = Parser::Salama.new
|
||||
@passes = [ "Virtual::SendImplementation" ]
|
||||
@objects = []
|
||||
@booted = false
|
||||
end
|
||||
attr_reader :passes , :space , :class_mappings , :init , :objects
|
||||
|
||||
@ -91,20 +92,17 @@ module Virtual
|
||||
end
|
||||
|
||||
def self.boot
|
||||
me = self.instance
|
||||
me = Virtual.machine
|
||||
# boot is a verb here. this is a somewhat tricky process which is in it's own file, boot.rb
|
||||
raise "already booted" if @booted
|
||||
me.boot_parfait!
|
||||
me
|
||||
end
|
||||
def self.instance
|
||||
@instance ||= Machine.new
|
||||
end
|
||||
|
||||
# for testing, make sure no old artefacts hang around
|
||||
#maybe should be moved to test dir
|
||||
def self.reboot
|
||||
@instance = nil
|
||||
self.boot
|
||||
raise "redo"
|
||||
end
|
||||
def compile_main bytes
|
||||
syntax = @parser.parse_with_debug(bytes)
|
||||
@ -112,6 +110,13 @@ module Virtual
|
||||
Compiler.compile( parts , @space.get_main )
|
||||
end
|
||||
end
|
||||
|
||||
def self.machine
|
||||
unless defined?(@machine)
|
||||
@machine = Machine.new
|
||||
end
|
||||
@machine
|
||||
end
|
||||
end
|
||||
|
||||
require_relative "boot"
|
||||
|
Reference in New Issue
Block a user