From e77298f4b1d4709f7ad71259fe9c8cdb4e4bb994 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 18 Dec 2016 20:04:40 +0200 Subject: [PATCH] Give the class a list of ivars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Which is redundant with the type’s names, so let’s see --- lib/register/boot.rb | 3 ++- lib/typed/parfait/class.rb | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/register/boot.rb b/lib/register/boot.rb index a8f9135e..25fa62ab 100644 --- a/lib/register/boot.rb +++ b/lib/register/boot.rb @@ -76,6 +76,7 @@ module Register @types[name].object_class = cl @types[name].instance_methods = object_with_type Parfait::List cl.instance_methods = object_with_type Parfait::List + cl.instance_names = object_with_type Parfait::List #puts "instance_methods is #{cl.instance_methods.class}" cl.name = name classes[name] = cl @@ -127,7 +128,7 @@ module Register :Frame => {:next_frame => :Frame, :indexed_length => :Integer}, :Type => {:object_class => :Class, :instance_methods => :List , :indexed_length => :Integer} , :Class => {:instance_methods => :List, :instance_type => :Type, :name => :Word, - :super_class_name => :Word}, + :super_class_name => :Word , :instance_names => :List }, :Dictionary => {:keys => :List , :values => :List } , :TypedMethod => {:name => :Word, :source => :Object, :instructions => :Object, :binary => :Object, :arguments => :Type , :for_type => :Type, :locals => :Type } , diff --git a/lib/typed/parfait/class.rb b/lib/typed/parfait/class.rb index 5215854b..e67a0669 100644 --- a/lib/typed/parfait/class.rb +++ b/lib/typed/parfait/class.rb @@ -16,7 +16,7 @@ module Parfait class Class < Object include Behaviour - attributes [:instance_type , :name , :super_class_name] + attributes [:instance_type , :name , :super_class_name , :instance_names] def initialize name , superclass super() @@ -26,13 +26,18 @@ module Parfait # as an instance. The relation is from an object through the Type to it's class # TODO the object type should copy the stuff from superclass self.instance_type = Type.new(self) + self.instance_names = List.new() end def allocate_object #space, and ruby allocate end + def set_instance_names( names ) + self.instance_names = names + end def add_instance_name name + self.instance_names << name self.instance_type.push name end