removing passes (before arm)
collector becomes a function minimizer unused
This commit is contained in:
parent
fa4949fc80
commit
15b570f5cf
@ -74,6 +74,7 @@ module Interpreter
|
||||
def tick
|
||||
return unless @instruction
|
||||
@clock += 1
|
||||
#puts @instruction
|
||||
name = @instruction.class.name.split("::").last
|
||||
fetch = send "execute_#{name}"
|
||||
return unless fetch
|
||||
|
@ -6,11 +6,7 @@ require "virtual/padding"
|
||||
require "virtual/parfait_adapter"
|
||||
|
||||
require "phisol/compiler"
|
||||
require "virtual/instruction"
|
||||
require "virtual/method_source"
|
||||
# the passes _are_ order dependant
|
||||
require "virtual/passes/minimizer"
|
||||
require "virtual/passes/collector"
|
||||
|
||||
|
||||
class Fixnum
|
||||
|
@ -1,10 +1,10 @@
|
||||
module Virtual
|
||||
|
||||
# collect anything that is in the space but and reachable from init
|
||||
class Collector
|
||||
def run
|
||||
module Collector
|
||||
def collect
|
||||
# init= Parfait::Space.object_space.get_class_by_name("Kernel").get_instance_method "__init__"
|
||||
Virtual.machine.objects.clear
|
||||
self.objects.clear
|
||||
keep Parfait::Space.object_space , 0
|
||||
end
|
||||
|
||||
@ -12,7 +12,7 @@ module Virtual
|
||||
return if object.nil?
|
||||
#puts "adding #{' ' * depth}:#{object.class}"
|
||||
#puts "ADD #{object.first.class}, #{object.last.class}" if object.is_a? Array
|
||||
return unless Virtual.machine.add_object object
|
||||
return unless self.add_object object
|
||||
return unless object.respond_to? :has_layout?
|
||||
if( object.is_a? Parfait::Method)
|
||||
object.source.constants.each{|c|
|
@ -1,5 +1,5 @@
|
||||
require 'parslet/convenience'
|
||||
|
||||
require_relative "collector"
|
||||
module Virtual
|
||||
# The Virtual Machine is a object based virtual machine in which ruby is implemented.
|
||||
#
|
||||
@ -35,12 +35,11 @@ module Virtual
|
||||
# The "machine" is not part of the run-time (Parfait)
|
||||
|
||||
class Machine
|
||||
|
||||
FIRST_PASS = "Register::CallImplementation"
|
||||
include Collector
|
||||
|
||||
def initialize
|
||||
@parser = Parser::Salama.new
|
||||
@passes = [ FIRST_PASS ]
|
||||
@passes = [ ]
|
||||
@objects = {}
|
||||
@booted = false
|
||||
end
|
||||
@ -51,8 +50,6 @@ module Virtual
|
||||
# runs housekeeping Minimizer and Collector
|
||||
# Has to be called before run_after
|
||||
def run_before stop_at
|
||||
Minimizer.new.run
|
||||
Collector.new.run
|
||||
@blocks = [@init]
|
||||
@space.classes.values.each do |c|
|
||||
c.instance_methods.each do |f|
|
||||
@ -85,8 +82,9 @@ module Virtual
|
||||
# as before, run all passes that are registered
|
||||
# (but now finer control with before/after versions)
|
||||
def run_passes
|
||||
run_before FIRST_PASS
|
||||
run_after FIRST_PASS
|
||||
return if @passes.empty?
|
||||
run_before @passes.first
|
||||
run_after @passes.first
|
||||
end
|
||||
|
||||
# Objects are data and get assembled after functions
|
||||
|
@ -25,7 +25,7 @@ module Virtual
|
||||
@gonners.delete function
|
||||
function.source.blocks.each do |block|
|
||||
block.codes.each do |code|
|
||||
keep code.method if code.is_a? Virtual::MethodCall
|
||||
keep code.method if code.is_a? Register::FunctionCall
|
||||
end
|
||||
end
|
||||
end
|
@ -9,6 +9,7 @@ class HelloTest < MiniTest::Test
|
||||
statements = machine.parse_and_compile @string_input
|
||||
output_at = "Register::CallImplementation"
|
||||
#{}"Register::CallImplementation"
|
||||
machine.collect
|
||||
machine.run_before output_at
|
||||
#puts Sof.write(machine.space)
|
||||
machine.run_after output_at
|
||||
|
@ -5,7 +5,7 @@ class AddTest < MiniTest::Test
|
||||
include Ticker
|
||||
|
||||
def setup
|
||||
Virtual.machine.boot
|
||||
machine = Virtual.machine.boot
|
||||
code = s(:class, :Object,
|
||||
s(:derives, nil),
|
||||
s(:statements,
|
||||
@ -19,7 +19,7 @@ class AddTest < MiniTest::Test
|
||||
s(:int, 7)))))))
|
||||
|
||||
Phisol::Compiler.compile( code )
|
||||
Virtual.machine.run_before "Register::CallImplementation"
|
||||
machine.collect
|
||||
@interpreter = Interpreter::Interpreter.new
|
||||
@interpreter.start Virtual.machine.init
|
||||
end
|
||||
|
@ -48,15 +48,14 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
Virtual.machine.boot
|
||||
machine = Virtual.machine.boot
|
||||
syntax = Parser::Salama.new.parse_with_debug(@string_input)
|
||||
parts = Parser::Transform.new.apply(syntax)
|
||||
#puts parts.inspect
|
||||
Phisol::Compiler.compile( parts )
|
||||
|
||||
machine.collect
|
||||
# statements = Virtual.machine.boot.parse_and_compile @string_input
|
||||
# Phisol::Compiler.compile( statements , Virtual.machine.space.get_main )
|
||||
Virtual.machine.run_before "Register::CallImplementation"
|
||||
@interpreter = Interpreter::Interpreter.new
|
||||
@interpreter.start Virtual.machine.init
|
||||
#show_ticks # get output of what is
|
||||
|
@ -4,7 +4,7 @@ class TestPuts < MiniTest::Test
|
||||
include AST::Sexp
|
||||
include Ticker
|
||||
def setup
|
||||
Virtual.machine.boot
|
||||
machine = Virtual.machine.boot
|
||||
code = s(:class, :Object,
|
||||
s(:derives, nil),
|
||||
s(:statements,
|
||||
@ -19,7 +19,7 @@ class TestPuts < MiniTest::Test
|
||||
s(:string, "Hello again")))))))
|
||||
|
||||
Phisol::Compiler.compile( code )
|
||||
Virtual.machine.run_before "Register::CallImplementation"
|
||||
machine.collect
|
||||
@interpreter = Interpreter::Interpreter.new
|
||||
@interpreter.start Virtual.machine.init
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user