The TOM Runtime Library is the library that enables TOM programs to run. It contains the data structures needed for every method invocation; it performs object allocation, garbage collection, etc.
In C, all functionality of TOM and the TOM runtime can be obtained by including <tom/util.h>. This will also include the header generated by the resolver for the tom unit.
From the start of a TOM program, the following sequence of actions takes place:
If the program was not statically resolved, build the method dispatch tables and other runtime structures needed but not built by the resolver. When run, this installs what the GNU Objective-C runtime very nicely calls the `premature' dispatch table for each object. Upon invocation of a method through said table, the actual dispatch table will be built and put in place.
Collect the arguments to the program, excluding C's argv[0] into tom.Runtime.all_arguments, using tom.ByteString objects . Set the tom.Runtime.program_name and tom.Runtime.long_program_name from argv[0].
Initialize the in, out, and err streams of tom.stdio.
Invoke the load imps, i.e. every class method with a signature matching void load Array arguments, with the arguments collected from the command line. A load imp is allowed to recognize options and remove them from the arguments. It is customary for such options to start with a colon (`:') instead of a dash (`-').
Store the array of remaining arguments in tom.Runtime.arguments.
Invoke the following method of the class tom.Runtime:
int start (All, selector) (object, sel) arguments Array arguments; |
where the sel is the selector for the main method to be invoked, which normally is int main Array arguments. The object is the receiver of this message, normally a class object.
When the previous method invocation returns, all open streams are flushed and the value it returned it used as the exit code.
[Streams are not yet flushed.]