minor fixes

This commit is contained in:
Torsten Ruger 2015-05-31 14:44:26 +03:00
parent db5c958d2e
commit 7a5cf03d73
8 changed files with 13 additions and 10 deletions

View File

@ -2,6 +2,7 @@ require "parfait/value"
require "parfait/integer" require "parfait/integer"
require "parfait/object" require "parfait/object"
require "parfait/module" require "parfait/module"
require "parfait/meta_class"
require "parfait/class" require "parfait/class"
require "parfait/list" require "parfait/list"
require "parfait/word" require "parfait/word"

View File

@ -14,6 +14,8 @@ module Parfait
super(0) super(0)
@name = name @name = name
end end
attr_reader :name
# this is a sof check if there are instance variables or "structure" # this is a sof check if there are instance variables or "structure"
# have to override false, as word answers true # have to override false, as word answers true
def is_value? def is_value?

View File

@ -1,4 +1,4 @@
module Virtual module Parfait
# TODO : rethink - possibly needs to be a module to be mixed into Object # TODO : rethink - possibly needs to be a module to be mixed into Object
# #

View File

@ -26,8 +26,8 @@ module Parfait
@name = name @name = name
@code = BinaryCode.new_object name @code = BinaryCode.new_object name
@arg_names = arg_names @arg_names = arg_names
@locals = [] @locals = List.new
@tmps = [] @tmps = List.new
end end
attr_reader :name , :arg_names , :for_class , :code attr_reader :name , :arg_names , :for_class , :code

View File

@ -19,7 +19,7 @@ module Parfait
@instance_methods = List.new_object @instance_methods = List.new_object
@name = name @name = name
@super_class = superclass @super_class = superclass
@meta_class = Virtual::MetaClass.new(self) @meta_class = MetaClass.new(self)
end end
def name def name
@ -71,7 +71,7 @@ module Parfait
# get the method and if not found, try superclasses. raise error if not found # get the method and if not found, try superclasses. raise error if not found
def resolve_method m_name def resolve_method m_name
raise "uups #{m_name}.#{m_name.class}" unless m_name.is_a? Word raise "uups #{m_name}.#{m_name.class}" unless m_name.is_a?(Word) or m_name.is_a?(String)
method = get_instance_method(m_name) method = get_instance_method(m_name)
return method if method return method if method
if( @super_class ) if( @super_class )

View File

@ -27,7 +27,7 @@ module FakeMem
#TODO, this is copied from module Positioned, maybe avoid duplication ? #TODO, this is copied from module Positioned, maybe avoid duplication ?
def position def position
if @position == nil if @position == nil
raise "position accessed but not set at #{mem_length} for #{self.inspect[0...1000]}" raise "position not set for #{self.class} at #{mem_length} for #{self.inspect[0...1000]}"
end end
@position @position
end end

View File

@ -10,12 +10,12 @@ module Virtual
def keep object def keep object
return if object.nil? return if object.nil?
return unless Machine.instance.add_object object return unless Machine.instance.add_object object
# puts "adding #{object.class}" #puts "adding #{object.class}"
unless object.has_layout? unless object.has_layout?
object.init_layout object.init_layout
end end
layout = object.get_layout layout = object.get_layout
puts "Layout #{layout.get_object_class.name} #{Machine.instance.objects.include?(layout)}" #puts "Layout #{layout.get_object_class.name} #{Machine.instance.objects.include?(layout)}"
keep layout keep layout
layout.each do |name| layout.each do |name|
inst = object.instance_variable_get "@#{name}".to_sym inst = object.instance_variable_get "@#{name}".to_sym

View File

@ -24,7 +24,7 @@ module Virtual
elsif( me.is_a? Parfait::Object ) elsif( me.is_a? Parfait::Object )
# get the function from my class. easy peasy # get the function from my class. easy peasy
puts "Me is #{me.class}" puts "Me is #{me.class}"
method = me.get_class.get_instance_method(Virtual.new_word code.name) method = me.get_class.get_instance_method(code.name)
raise "Method not implemented #{me.class}.#{code.name}" unless method raise "Method not implemented #{me.class}.#{code.name}" unless method
new_codes << MethodCall.new( method ) new_codes << MethodCall.new( method )
else else
@ -39,7 +39,7 @@ module Virtual
if ref.type.is_a?(Reference) and ref.type.of_class if ref.type.is_a?(Reference) and ref.type.of_class
#find method and call #find method and call
clazz = ref.type.of_class clazz = ref.type.of_class
method = clazz.resolve_method Virtual.new_word(code.name) method = clazz.resolve_method code.name
raise "No method found #{code.name}" unless method raise "No method found #{code.name}" unless method
new_codes << MethodCall.new( method ) new_codes << MethodCall.new( method )
else else