[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

[lang] Boot Section

A S8 system starts execution loading a Boot Section, after the loading, an image file will be loaded instantiating the system startup contents.
The Boot Section use to be a file hand-written to instantiate core machinery of the S8 System.

Do I need to implement a Boot file?

The Boot section can be implemented as a source file in native language, as a way to get a correct implementation in short time.

Uploaded Image: idea.gifWe also have the Eden Framework that implements a model of BootSector for all native languages. Subclasses of BootSector implements boot contents for execution environments.

Contents of the Boot Section

  1. Initial comment with description of the file and license terms
  2. Definition of minimal variables e.g.
    1. Definition for nil
    2. definition of SystemDictionary (if required)
  3. instantiation of "smalltalk" instance
  4. startUp expression
    1. it is something like sending message #startup to smalltalk instance

The SystemDictionary

SystemDictionary implements a minimal set of required functions to:

Starting the system

The implementation of startup implement the S8 system core, un the following stages (tracked in #state)

Creating core classes

The core classes are created in sequence, calling function mapClassName implemented by smalltalk (SystemDictionary instance).
Example definition from s8/startboot.lua
smalltalk.mapClassName (self, className, category, fn, superclass)

Injecting image contents

An image is a list of classes and methods that will be loaded onto the running system.

Adding classes
The classes are loaded calling function AddClass implemented by smalltalk (SystemDictionary instance).
After an AddClass call can follow an expression to set comment of the class.
In case of adding a class that already exists in the system, the shape of the definition is checked performing mutations required to host the new definition in the system.
An expression to set class side instance variables can also be included here.
Example definition from s8/startboot.lua
addClass (self, className, superclass, iVarNames, category)
smalltalk:addClass("Object",nil,smalltalk:newArray({}),"Kernel")
smalltalk:addClass("Smalltalk",smalltalk.Object,smalltalk:newArray({}),"Kernel")
smalltalk:addClass("Behavior",smalltalk.Object,smalltalk:newArray({}),"Kernel")
smalltalk:addClass("Class",smalltalk.Behavior,smalltalk:newArray({}),"Kernel")
...
smalltalk.EventManager["$comment"]= "\r\n\tEvent system, properties and change/update/release mechanism.\r\n\tWe hook $properties and $handlers internal properties to manage properties and events at Object level.\r\n\tEventManager instances implement events handler as pure instance variable.\r\n"
smalltalk.EventManager["$klass"]["$iVarNames"]=smalltalk:newArray({"eventsTriggered"})

Adding methods
After the list of classes, a list of methods are expected.
All the methods of the system are defined calling the function bind implemented by smalltalk (SystemDictionary instance).
Example definition from s8/startboot.lua
smalltalk.bind (self, klass, stSelector, jsSelector, jsFunction, category, stSource, nativeSource)
smalltalk:bind(smalltalk.Object["$klass"],"eventsTriggered",0
,(...lua encoded function...)
,"events","eventsTriggered\r\n\t\" Return ... \"\r\n\r\n\t^self...","(function(self)\r\n...end)")