minors
This commit is contained in:
parent
7216300452
commit
8ab9a417aa
@ -26,5 +26,7 @@
|
||||
|
||||
module Parfait
|
||||
class Frame < Object
|
||||
attribute :next_frame
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 }
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user