C2CAccess.mesa
Copyright Ó 1990, 1991, 1993 by Xerox Corporation. All rights reserved.
Christian Jacobi, October 4, 1990 10:59:22 am PDT
Christian Jacobi, January 25, 1993 7:13 pm PST
This definition exports an entrypoint into C2C. It is the external view of C2C's access.
It does not depend on C2C internal features, so it wont need recompilation on internal C2C improvements. However, it lays bare an elaborate dependency on options; it will be recompiled whenever those need change. We do NOT really try to minimize recompilations of C2C's inner parts however.
It assumes that there is a separate module (or two) which plugs into mimosa and calls C2C. The internal part of C2C therefore does not need to know how it is plugged into Mimosa. However, of course the inner of C2C has to know the definitions for IntCode anyway.
C2C is non re-entrant. This has been decided so after long thought for the benefit of being able to use global variables.
If C2C is used on multiple targets, target specific behaviour has to be brought in with the binder.
While the author really believes in re-entrancy and dynamic specification of targets, C2C is much too heavily used to make all users pay for the rarely used flexibility.
DIRECTORY
CardTab, IntCodeDefs, IO, Rope;
C2CAccess: CEDAR DEFINITIONS =
BEGIN
InputParameters: TYPE = RECORD [
This type describes the input parameters of C2C. It is a type of its own so it can be copied and made available internally with a single statement and won't need further maintenance on chances
--
moduleName: Rope.ROPE,
--Used to generate start up sequence
versionStamp: Rope.ROPE,
--Used for obvious reasons
fileName: Rope.ROPE ¬ NIL,
--File is not accessed by C2C but name is documented in C file
commentLines: LIST OF Rope.ROPE ¬ NIL,
--Will be included into the C code as comments
--Lines do not need to have the form of comments
root: IntCodeDefs.Node,
--Root of the code graph
--C2C may do irreversible changes to the node tree
names: CardTab.Ref,
--Lookup for names for named variables
labels: CardTab.Ref,
--Lookup for names for procedures
outputStream: IO.STREAM,
--Stream for the generated C code.
--C2C will not close the stream.
lineNumberStream: IO.STREAM,
--Stream for the generated line number information.
--C2C will not close the stream.
reportStream: IO.STREAM ¬ NIL,
--Stream for rare progress messages (The little dots).
--C2C will not close the stream.
getErrorStream: PROC [] RETURNS [IO.STREAM],
--Output stream requested on demand only, as normally there are no errors.
--Procedure called only once, even if multiple errors are written.
--Caller is adviced to not really use the generated C code when an error stream has been requested.
--C2C will not close the stream.
namesStream: IO.STREAM ¬ NIL,
--Option for input of external definition for names; normally NIL
supportReferenceCounting: BOOL ¬ FALSE,
--Option whether runtime calls for reference counting ought to be made
extraShortAndUgly: BOOL ¬ FALSE,
--Option to save bytes in C file...
generateSourceMacros: BOOL ¬ TRUE,
generateDBXStyleSourceMacros: BOOL ¬ FALSE,
generateLineNumberStream: BOOL ¬ FALSE,
supportInlineFloatingPoint: BOOL ¬ FALSE,
--Option whether floatingpoint ought to be generated inline
lineTerminationChar: CHAR ¬ '\n,
--Typically one of lf or cr...
destroyRoot: BOOL ¬ TRUE,
--Whether the root node tree ought to be destroyed to help the garbage collector
debuggingCode: BOOL ¬ FALSE,
--If debuggingCode is TRUE, more debugging info is included into the generated code
debuggingMode: BOOL ¬ TRUE
--If not in debugging mode, C2C tries to catch errors and make nice messages
];
params: --PRIVATE-- C2CAccess.InputParameters;
A copy of the parameters of CallC2C when C2C was called.
Private for the inside of C2C; clients, please don't touch.
Valid only within C2CAccess's re-entry lock.
CallC2C: PROC [parameters: InputParameters] RETURNS [ok: BOOL, synopsis: Rope.ROPE];
This is the way C2C can be invoked.
Caller is responsible for guarante that there is a SINGLE process calling into C2C; he is supposed to do so by using CallC2C only from an inner proc of ExcludeReentry.
ExcludeReEntry: PROC [inner: PROC[]];
This procedure must be used to make sure C2C is only called in a non reentrant way. May raise ImSorryC2CIsNotReEntrant.
ImSorryC2CIsNotReEntrant: ERROR;
Design rationale. A separate procedure ExcludeReEntry is used, so Mimosa does have the option where to exclude reentrancy at its own disgression.
END.