split the pass runs to debug
This commit is contained in:
parent
54c71fa216
commit
1baece99c7
@ -43,28 +43,47 @@ module Virtual
|
|||||||
end
|
end
|
||||||
attr_reader :passes , :space , :class_mappings , :init , :objects
|
attr_reader :passes , :space , :class_mappings , :init , :objects
|
||||||
|
|
||||||
def run_passes
|
# run all passes before the pass given
|
||||||
@init = Block.new("init",nil)
|
# also collect the block to run the passes on and
|
||||||
@init.add_code Register::RegisterMain.new( self.space.get_main )
|
# runs housekeeping Minimizer and Collector
|
||||||
|
# Has to be called before run_after
|
||||||
|
def run_before stop_at
|
||||||
Minimizer.new.run
|
Minimizer.new.run
|
||||||
Collector.new.run
|
Collector.new.run
|
||||||
@passes.each do |pass_class|
|
@blocks = [@init]
|
||||||
blocks = [@init]
|
|
||||||
@space.classes.values.each do |c|
|
@space.classes.values.each do |c|
|
||||||
c.instance_methods.each do |f|
|
c.instance_methods.each do |f|
|
||||||
nb = f.info.blocks
|
nb = f.info.blocks
|
||||||
blocks += nb
|
@blocks += nb
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#puts "running #{pass_class}"
|
@passes.each do |pass_class|
|
||||||
blocks.each do |block|
|
puts "running #{pass_class}"
|
||||||
raise "nil block " unless block
|
run_blocks_for pass_class
|
||||||
pass = eval pass_class
|
return if stop_at == pass_class
|
||||||
raise "no such pass-class as #{pass_class}" unless pass
|
|
||||||
pass.new.run(block)
|
|
||||||
end
|
end
|
||||||
#puts @space.get_main if pass_class == "Virtual::SendImplementation"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# run all passes after the pass given
|
||||||
|
# run_before MUST be called first.
|
||||||
|
# the two are meant as a poor mans breakoint
|
||||||
|
def run_after start_at
|
||||||
|
run = false
|
||||||
|
@passes.each do |pass_class|
|
||||||
|
if run
|
||||||
|
puts "running #{pass_class}"
|
||||||
|
run_blocks_for pass_class
|
||||||
|
else
|
||||||
|
run = true if start_at == pass_class
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# as before, run all passes that are registered
|
||||||
|
# (but now finer control with before/after versions)
|
||||||
|
def run_passes
|
||||||
|
run_before "Virtual::SendImplementation"
|
||||||
|
run_after "Virtual::SendImplementation"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Objects are data and get assembled after functions
|
# Objects are data and get assembled after functions
|
||||||
@ -97,10 +116,17 @@ module Virtual
|
|||||||
me = Virtual.machine
|
me = Virtual.machine
|
||||||
# boot is a verb here. this is a somewhat tricky process which is in it's own file, boot.rb
|
# 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
|
raise "already booted" if @booted
|
||||||
me.boot_parfait!
|
me.boot
|
||||||
me
|
me
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def boot
|
||||||
|
boot_parfait!
|
||||||
|
@init = Block.new("init",nil)
|
||||||
|
@init.add_code Register::RegisterMain.new( self.space.get_main )
|
||||||
|
@booted = true
|
||||||
|
end
|
||||||
|
|
||||||
# for testing, make sure no old artefacts hang around
|
# for testing, make sure no old artefacts hang around
|
||||||
#maybe should be moved to test dir
|
#maybe should be moved to test dir
|
||||||
def self.reboot
|
def self.reboot
|
||||||
@ -111,14 +137,27 @@ module Virtual
|
|||||||
parts = Parser::Transform.new.apply(syntax)
|
parts = Parser::Transform.new.apply(syntax)
|
||||||
Compiler.compile( parts , @space.get_main )
|
Compiler.compile( parts , @space.get_main )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def run_blocks_for pass_class
|
||||||
|
pass = eval pass_class
|
||||||
|
raise "no such pass-class as #{pass_class}" unless pass
|
||||||
|
@blocks.each do |block|
|
||||||
|
raise "nil block " unless block
|
||||||
|
pass.new.run(block)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# Module function to retrieve singleton
|
||||||
def self.machine
|
def self.machine
|
||||||
unless defined?(@machine)
|
unless defined?(@machine)
|
||||||
@machine = Machine.new
|
@machine = Machine.new
|
||||||
end
|
end
|
||||||
@machine
|
@machine
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require_relative "boot"
|
require_relative "boot"
|
||||||
|
@ -6,8 +6,10 @@ class HelloTest < MiniTest::Test
|
|||||||
def check
|
def check
|
||||||
machine = Virtual::Machine.boot
|
machine = Virtual::Machine.boot
|
||||||
expressions = machine.compile_main @string_input
|
expressions = machine.compile_main @string_input
|
||||||
|
machine.run_before "Register::CallImplementation"
|
||||||
puts Sof::Writer.write(machine.space)
|
puts Sof::Writer.write(machine.space)
|
||||||
machine.run_passes
|
machine.run_after "Register::CallImplementation"
|
||||||
|
|
||||||
|
|
||||||
writer = Elf::ObjectWriter.new(machine)
|
writer = Elf::ObjectWriter.new(machine)
|
||||||
writer.save "hello.o"
|
writer.save "hello.o"
|
||||||
|
Loading…
Reference in New Issue
Block a user