The main module of the stable stub generator starts by
using a M3ToolFrame.Startup
which starts DoRun
, the
main working procedure, as call back (see there).
MODULE\subsection{Procedure DoRun}; IMPORT Process, RTCollector; IMPORT Type, TypeNames, StablegenArgs, StablegenError, GenCode; IMPORT M3CFETool, M3ToolFrame, M3Context; IMPORT M3AST_all; <*NOWARN*> (* this cannot be omitted; it defines the particular revelations for all the AST nodes *) Main
DoRun
reads the run string
parameter to gather the interface where the T
which
shall be made stable is defined (together with tool kit
options. It then starts M3CFETool.CompileInContext()
to produce an abstract syntax tree of that type.
A preprocess run TypeNames.Preprocess()
will assign an
attribute on each node of the AST which is a type
specification. A ``type specification'' is a type that
is not just an identifier. The attribute is the name of
that type.
Finally AstToType.OneStub()
is called to produce the
implementation of the stable subtype.
PROCEDURE\subsection{Startup}DoRun (<*UNUSED*> w: M3ToolFrame.Worker; c: M3Context.T; <*UNUSED*> compileResult: INTEGER): INTEGER RAISES {} = BEGIN TRY VAR object: Type.Qid; reveal, impl, rep: TEXT; BEGIN StablegenArgs.Get(object, reveal, impl, rep); IF M3CFETool.CompileInContext(c) < 0 THEN RAISE StablegenError.E("errors in object declaration"); END; RTCollector.DisableMotion(); (* because of "FRefRefTbl" module *) TypeNames.Preprocess(c); GenCode.Do(c, object, reveal, impl, rep); RTCollector.EnableMotion(); RETURN 0; END EXCEPT StablegenError.E(msg)=> StablegenError.Failure(msg); RETURN 1; END; END DoRun;
<* FATAL ANY *> BEGIN Process.Exit(ABS(M3ToolFrame.Startup( NEW(M3ToolFrame.Worker, work := DoRun), compile := FALSE))); END Main.