fix docs for rename

This commit is contained in:
Torsten Ruger
2016-02-25 12:03:11 -08:00
parent d32b51c67b
commit 278d71b56c
15 changed files with 80 additions and 81 deletions

View File

@ -132,7 +132,7 @@ module Register
obj.position
end
# write type and type of the instance, and the variables that are passed
# write type of the instance, and the variables that are passed
# variables ar values, ie int or refs. For refs the object needs to save the object first
def write_object( object )
log.debug "Write object #{object.class} #{object.inspect}"

View File

@ -11,8 +11,8 @@ module Register
# And so we have a chicken and egg problem. At the end of the boot function we want to have a
# working Space object
# But that has instance variables (List and Dictionary) and off course a class.
# Or more precisely in salama, a Layout, that points to a class.
# So we need a Layout, but that has Layout and Class too. hmmm
# Or more precisely in salama, a Type, that points to a class.
# So we need a Type, but that has Type and Class too. hmmm
#
# The way out is to build empty shell objects and stuff the neccessary data into them
# (not use the normal initialize way)
@ -86,7 +86,7 @@ module Register
end
end
# helper to create a Layout, name is the parfait name, ie :Type
# helper to create a Type, name is the parfait name, ie :Type
def type_for( name , ivars )
l = Parfait::Type.allocate.fake_init
l.add_instance_variable :type , :Type

View File

@ -1,17 +1,19 @@
# Class is mainly a list of methods with a name (for now)
# The memory type of object is seperated into Layout
# A class describes the capabilities of a group of objects, ie what data it has
# and functions it responds to.
#
# So it is essential that the class (the object defining the class)
# Class is mainly a list of methods with a name. (Note that methods may have many functions)
# The memory layout of an object is determined by the Type (see there).
# The class carries the "current" type, ie the type an object would be if you created an instance
# of the class. Note that this changes over time and so many types share the same class.
# It is essential that the class (the object defining the class)
# can carry methods. It does so as instance variables.
# In fact this property is implemented in the Layout, as methods
# In fact this property is implemented in the Type, as methods
# may be added to any object at run-time
# An Object carries the data for the instance variables it has
# The Layout lists the names of the instance variables
# The Type lists the names of the instance variables
# The class keeps a list of instance methods, these have a name and code
module Parfait
@ -24,7 +26,7 @@ module Parfait
self.name = name
self.super_class_name = superclass
# the type for this class (class = object of type Class) carries the class
# as an instance. The relation is from an object through the Layout to it's class
# 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.object_type = Type.new(self)
end

View File

@ -8,13 +8,16 @@
# A Message (see details there) is created by the caller and control is transferred
# A Frame is created by the receiver
# PS: it turns out that both messages and frames are created at compile, not run-time, and
# just constantly reused. Each message has a frame object ready and ist also linked
# just constantly reused. Each message has a frame object ready and is also linked
# to the next message.
# The better way to say above is that a message is *used* by the caller, and a frame by the callee.
# Also at runtime Messages and Frames remain completely "normal" objects. Ie have types and so on.
# Also at runtime Messages and Frames remain completely "normal" objects.
# Ie they have have type and instances and so on.*
# Which resolves the dichotomy of objects on the stack or heap. Sama sama.
#
# *Alas the type for each call instance is unique.
#
module Parfait
class Frame < Object
attribute :next_frame

View File

@ -4,12 +4,12 @@ require_relative "indexed"
# For a programmer this may be a little strange as this new start goes with trying to break old
# bad habits. A List would be an array in some languages, but list is a better name, closer to
# common language.
# Another habit is to start a list from 0. This is "just" programmers lazyness, as it goes
# Another bad habit is to start a list from 0. This is "just" programmers lazyness, as it goes
# with the standard c implementation. But it bends the mind, and in oo we aim not to.
# If you have a list of three items, you they will be first, second and third, ie 1,2,3
# If you have a list of three items, they will be first, second and third, ie 1,2,3
#
# For the implementation we use Objects memory which is index addressable
# But, objects are also lists where indexes start with 1, except 1 is taken for the Layout
# But, objects are also lists where indexes start with 1, except 1 is taken for the Type
# so all incoming/outgoing indexes have to be shifted one up/down
module Parfait

View File

@ -1,17 +1,19 @@
# to be precise, this should be an ObjectReference, as the Reference is a Value
# but we don't want to make that distinction all the time , so we don't.
# From a programmers perspective an object has hash like data (with instance variables as keys)
# and functions to work on that data.
# Only the object may access it's data directly.
# that does lead to the fact that we have Reference functions on the Object though
# From an implementation perspective it is a chunk of memory with an type as the first
# word.
# Objects are arranged or layed out (in memory) according to their Layout
# every object has a Layout. Layout objects are immutalbe and may be resued for a group/class
# Objects are arranged or layed out (in memory) according to their Type
# every object has a Type. Type objects are immutalbe and may be reused for a group/class
# off objects.
# The Layout of an object may change, but then a new Layout is created
# The Layout also defines the class of the object
# The Layout is **always** the first entry (index 1) in an object, but the type word is index 0
# The Type of an object may change, but then a new Type is created
# The Type also defines the class of the object
# The Type is **always** the first entry (index 1) in an object
module Parfait
LAYOUT_INDEX = 1
TYPE_INDEX = 1
class Object < Value
@ -68,7 +70,7 @@ module Parfait
# This is the crux of the object system. The class of an object is stored in the objects
# memory (as opposed to an integer that has no memory and so always has the same class)
#
# In Salama we store the class in the Layout, and so the Layout is the only fixed
# In Salama we store the class in the Type, and so the Type is the only fixed
# data that every object carries.
def get_class()
l = get_type()
@ -80,16 +82,16 @@ module Parfait
def set_type(type)
# puts "Type was set for #{self.class}"
raise "Nil type" unless type
set_internal_word(LAYOUT_INDEX , type)
set_internal_word(TYPE_INDEX , type)
end
# so we can keep the raise in get_type
def has_type?
! get_internal_word(LAYOUT_INDEX).nil?
! get_internal_word(TYPE_INDEX).nil?
end
def get_type()
l = get_internal_word(LAYOUT_INDEX)
l = get_internal_word(TYPE_INDEX)
#puts "get type for #{self.class} returns #{l.class}"
raise "No type #{self.object_id.to_s(16)}:#{self.class} " unless l
return l

View File

@ -1,26 +1,29 @@
# An Object is really a hash like structure. It is dynamic and
# you want to store values by name (instance variable names).
#
# One could (like mri), store the names in each object, but that is wasteful
# One could (like mri), store the names in each object, but that is wasteful in both time and space.
# Instead we store only the values, and access them by index.
# The Layout allows the mapping of names to index.
# The Type allows the mapping of names to index.
# The Layout of an object describes the memory type of the object
# The Layout is a simple list of the names of instance variables.
# The Type of an object describes the memory layout of the object. In a c analogy, it is the
# information defined in a struct.
# The Type is a list of the names of instance variables, and their value types (int etc).
#
# As every object has a Layout to describe it, the name "type" is the
# first name in the list for every Layout.
# Every object has a Type to describe it, so it's *first* instance variable is **always**
# "type". This means the name "type" is the first name in the list
# for every Type instance.
# But as we want every Object to have a class, the Layout carries that class.
# But, as we want every Object to have a class, the Type carries that class.
# So the type of type has an entry "object_class"
# But Objects must also be able to carry methods themselves (ruby calls singleton_methods)
# and those too are stored in the Layout (both type and class include behaviour)
# and those too are stored in the Type (both type and class include behaviour)
# In other words, the Layout is a list of names that describe
# In other words, the Type is a list of names and value types that describe
# the values stored in an actual object.
# The object is an List of values of length n and
# the Layout is an List of names of length n , plus class reference and methods reference
# the Type is an List of names and value tpyes of length n ,
# plus class reference and methods reference
# Together they turn the object into a hash like structure
module Parfait

View File

@ -1,39 +1,15 @@
# this is not a "normal" ruby file, ie it is not required by salama
# instead it is parsed by salama to define part of the program that runs
# Values are _not_ objects. Specifically they have the following properties not found in objects:
# - they are immutable
# - equality implies identity == is ===
# - they have type, not class
# To make them useful in an oo system, we assign a class to each basic type
# To make them useful in an oo system, we assign a class to each value type
# This makes them look more like objects, but they are not.
# Value is an abstract class that unifies the "has a type" concept
# Types are not "objectified", but are represented as integer constants
# Types are not "objectified", but are represented as symbol constants
module Parfait
class Value
# to make the machine work, the constants need
# - to start at 0
# - be unique
# - be smaller enough to fit into the 2-4 bits available
INTEGER_VALUE = 0
OBJECT_VALUE = 1
# the type is what identifies the value
def get_type()
raise "abstract clalled on #{self}"
end
# Get class works on the type. The value's type is stored by the machine.
# So this function is not overriden in derived classes, because it is used
# to espablish what class a value has! (it's that "fake" oo i mentioned)
# def get_class()
# type = self.get_type()
# return Integer if( type == INTEGER_VALUE )
# raise "invalid type"
# end
end
end

View File

@ -8,7 +8,7 @@ module Parfait
# Words are constant, maybe like js strings, ruby symbols
# Words are short, but may have spaces
# Words are objects, that means they carry Layout as index 0
# Words are objects, that means they carry Type as index 0
# So all indexes are offset by one in the implementation
# Object length is measured in non-type cells though

View File

@ -4,7 +4,7 @@ module Soml
def on_field_access statement
receiver_ast , field_ast = *statement
receiver = process(receiver_ast)
clazz = Register.machine.space.get_class_by_name receiver.type
field_name = field_ast.first_from(:name)