diff --git a/lib/parfait/frame.rb b/lib/parfait/frame.rb index aada088f..489e6b0b 100644 --- a/lib/parfait/frame.rb +++ b/lib/parfait/frame.rb @@ -26,5 +26,7 @@ module Parfait class Frame < Object + attribute :next_frame + end end diff --git a/lib/parfait/module.rb b/lib/parfait/module.rb index f74d9405..ca038317 100644 --- a/lib/parfait/module.rb +++ b/lib/parfait/module.rb @@ -56,7 +56,7 @@ module Parfait raise "uups #{method_name}.#{method_name.class}" unless method_name.is_a?(Symbol) clazz = object_layout().object_class() raise "??? #{method_name}" unless clazz - puts "Self: #{self.class} clazz: #{clazz.name}" + #puts "Self: #{self.class} clazz: #{clazz.name}" Method.new( clazz , method_name , arg_names ) end diff --git a/lib/virtual/block.rb b/lib/virtual/block.rb index 2287b2cd..b22e01bc 100644 --- a/lib/virtual/block.rb +++ b/lib/virtual/block.rb @@ -46,6 +46,7 @@ module Virtual # returns if this is a block that ends in a call (and thus needs local variable handling) def call_block? + raise "called" return false unless codes.last.is_a?(CallInstruction) return false unless codes.last.opcode == :call codes.dup.reverse.find{ |c| c.is_a? StackInstruction } diff --git a/lib/virtual/compiler/module_expression.rb b/lib/virtual/compiler/module_expression.rb index ff7decfd..c9781ac9 100644 --- a/lib/virtual/compiler/module_expression.rb +++ b/lib/virtual/compiler/module_expression.rb @@ -7,7 +7,7 @@ module Virtual def self.compile_class expression , method clazz = Parfait::Space.object_space.get_class_by_name! expression.name - puts "Compiling class #{clazz.name.inspect}" + #puts "Compiling class #{clazz.name.inspect}" expression_value = nil expression.expressions.each do |expr| # check if it's a function definition and add diff --git a/lib/virtual/passes/collector.rb b/lib/virtual/passes/collector.rb index 0036aa2a..435b3fe0 100644 --- a/lib/virtual/passes/collector.rb +++ b/lib/virtual/passes/collector.rb @@ -4,30 +4,31 @@ module Virtual class Collector def run # init= Parfait::Space.object_space.get_class_by_name("Kernel").get_instance_method "__init__" - keep Parfait::Space.object_space + Virtual.machine.objects.clear + keep Parfait::Space.object_space , 0 end - def keep object + def keep object , depth 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 - #puts "adding #{object.class}" return unless object.respond_to? :has_layout? if( object.is_a? Parfait::Method) object.source.constants.each{|c| - puts "keeping constant #{c.class}" - keep(c) + #puts "keeping constant #{c.class}:#{c.object_id}" + keep(c , depth + 1) } end layout = object.get_layout - keep layout - #puts "Layout #{layout.object_class.name} #{Machine.instance.objects.has_key?(layout.object_id)}" + keep(layout , depth + 1) layout.object_instance_names.each do |name| inst = object.get_instance_variable name - keep inst + keep(inst , depth + 1) end if object.is_a? Parfait::List object.each do |item| - keep item + keep(item , depth + 1) end end end diff --git a/lib/virtual/passes/minimizer.rb b/lib/virtual/passes/minimizer.rb index 83d8cdb2..40a1e0e4 100644 --- a/lib/virtual/passes/minimizer.rb +++ b/lib/virtual/passes/minimizer.rb @@ -11,8 +11,7 @@ module Virtual @gonners << f end end - init = Parfait::Space.object_space.get_class_by_name(:Kernel).get_instance_method :__init__ - remove init + remove Virtual.machine.space.get_init dump_remaining end diff --git a/test/parfait/test_space.rb b/test/parfait/test_space.rb index a58e12f9..55604415 100644 --- a/test/parfait/test_space.rb +++ b/test/parfait/test_space.rb @@ -3,8 +3,7 @@ require_relative "../helper" class TestSpace < MiniTest::Test def setup - @machine = Virtual.machine - @machine.boot + @machine = Virtual.machine.boot end def classes [:Kernel,:Word,:List,:Message,:Frame,:Layout,:Class,:Dictionary,:Method] @@ -46,7 +45,7 @@ class TestSpace < MiniTest::Test classes.each do |name| cl = @machine.space.classes[name] cl.method_names.each do |mname| - puts "Mehtod #{mname}" + #puts "Mehtod #{mname}" method = cl.get_instance_method(mname) assert_equal mname , method.name assert_equal name , method.for_class.name