Parfait, a minimal runtime
RubyX uses the these following classes at compile time to build the base of an object oriented system.In RubyX every object really is an object and data is hidden to the language level.
Objects have a Type and constant size. See memory for more on memory layout and management.
Types
- every object has a type as it's first variable
- types are immutable
- an object's type may change at run-time
- a type describes a class at a certain time
If we would be talking about a language, this would be like Javascript, or previously Self. Basically rubyx's types would be (immutable) prototypes in a prototype based language.
It may be easiest to understand types by how they are used. When rubyx parses a class,
it creates a Sol::ClassExpression, which in turn creates a Parfait::Class. This class carries
the Sol methods, basically the language code for the methods.
At this point a type, representing the object layout as known at the time, is created.
Parfait::SolMethod are compiled to binary (Parfait::Callable) according to the type information
and stored in the type.
If the class changes at run-time, ie variables are added or removed, a new type object is
created (with the updated layout) and the same ruby code is compiled to new Parfait::Methods.
Method, Message and Frame
The TypedMethod class describes a callable method. It carries a name, argument and local variable type and several descriptions of the code:
- The risc instructions
- Cpu level instructions
- Binary code
When TypedMethods are invoked, A message object (instance of Message class) is populated. The data in the Message holds the receiver, return addresses, arguments and a frame. Frames are also created at compile time and just reused at runtime. Calling describes more detail about the calling convention, while method resolution described how the methods are found, mainly at run-time.
Memory
The single instance of Space holds a list of all Types and all Classes, which in turn hold the methods. The space also holds messages and will hold memory management objects like pages.
Pages are currently not implemented but will be used to realise the aproach described in the page about memory management.
Util
There are off course several utility classes necessary just to implement the type and class system.
- Words represent short immutable text and other word processing (buffers, text) is still tbd.
- Lists (aka Array) are number indexed containers
- Dictionaries (aka Hash) are mappings from words to objects.
- DataObjects are just objects that hold data. Data can not be accessed at the language level, only through methods that are programmed at the risc level.
- Integers, which are DataObjects that hold data interpreted as an integer