-- File [Ivy]<Nelson>Lupine>LupineManagerPrivate.mesa.
-- Last edited by BZM on March 15, 1982  4:54 PM.


DIRECTORY
  CWF USING [WF0],
  Inline USING [LowHalf],
  LupineManager USING [
	ErrorCode, ErrorHandlerProc, ErrorType, Language,
	Options, ParamPassingMethod, String, StringNIL ];


LupineManagerPrivate: DEFINITIONS
  IMPORTS CWF, Inline
  = BEGIN


-- Lupine-wide types and constants.

  String: TYPE = LupineManager.String;
  StringNIL: String = LupineManager.StringNIL;
  AllocString: TYPE = STRING ← NIL;  -- Circumvent String = [100] problem.

  MaxFilenameLength: INTEGER = 100;  -- Including full path (eventually).
  MaxIdentifierLength: INTEGER = 120;  -- Mesa identifiers.


  Options: TYPE = LupineManager.Options;
  Language: TYPE = LupineManager.Language;
  ParamPassingMethod: TYPE = LupineManager.ParamPassingMethod;


  ErrorType: TYPE = LupineManager.ErrorType;
  ErrorCode: TYPE = LupineManager.ErrorCode;
  ErrorHandlerProc: TYPE = LupineManager.ErrorHandlerProc;


-- Code file output routines.

  OpenCodeFile: PROCEDURE [codeModuleName: String];
  StampCodeFile: PROCEDURE [codeModuleName: String];
  CloseCodeFile: PROCEDURE;

  Nest: TYPE = INTEGER[0..LAST[INTEGER]];

  Indent: PROCEDURE [nest: Nest] RETURNS [tabsAndSpaces: String];

  WFS, WriteFormattedStrings: PUBLIC PROCEDURE [
	s01, s02, s03: String←StringNIL ] =
    INLINE BEGIN OPEN CWF;
    IF s01 # StringNIL THEN WF0[s01];   IF s02 # StringNIL THEN WF0[s02];
    IF s03 # StringNIL THEN WF0[s03]; --IF s04 # StringNIL THEN WF0[s04];
    END;

  WFS1, WriteFormattedString: PUBLIC PROCEDURE [s01: String] =
    INLINE BEGIN CWF.WF0[s01]; END;

  WFSL, WriteFormattedStringsLong: PUBLIC PROCEDURE [
	s01, s02, s03, s04, s05, s06, s07, s08, s09, s10,
	s11, s12, s13, s14, s15, s16, s17, s18: String←StringNIL] =
    INLINE BEGIN OPEN CWF;
    IF s01 # StringNIL THEN WF0[s01];  IF s02 # StringNIL THEN WF0[s02];
    IF s03 # StringNIL THEN WF0[s03];  IF s04 # StringNIL THEN WF0[s04];
    IF s05 # StringNIL THEN WF0[s05];  IF s06 # StringNIL THEN WF0[s06];
    IF s07 # StringNIL THEN WF0[s07];  IF s08 # StringNIL THEN WF0[s08];
    IF s09 # StringNIL THEN WF0[s09];  IF s10 # StringNIL THEN WF0[s10];
    IF s11 # StringNIL THEN WF0[s11];  IF s12 # StringNIL THEN WF0[s12];
    IF s13 # StringNIL THEN WF0[s13];  IF s14 # StringNIL THEN WF0[s14];
    IF s15 # StringNIL THEN WF0[s15];  IF s16 # StringNIL THEN WF0[s16];
    IF s17 # StringNIL THEN WF0[s17];  IF s18 # StringNIL THEN WF0[s18];
    END;

  WFL, WriteFormattedLine: PUBLIC PROCEDURE [
	nest: Nest,  s01, s02, s03: String←StringNIL ];

  WFL1, WriteFormattedLine1: PUBLIC PROCEDURE [nest: Nest, s01: String];

  WFLL, WriteFormattedLineLong: PUBLIC PROCEDURE [
	nest: Nest,  s01, s02, s03, s04, s05, s06: String←StringNIL ];


-- Translation-time error handling.

  ExplanationProc: TYPE = PROCEDURE [explanation: String];

  ReportError: PROCEDURE [type: ErrorType, code: ErrorCode, problemText: String];

  GiveExplanation: PROCEDURE [code: ErrorCode, explainer: ExplanationProc];


  Abort: PUBLIC PROC [code: ErrorCode, problemText: String←StringNIL] =
	INLINE {ReportError[abort, code, problemText]};

  Error: PUBLIC PROC [code: ErrorCode, problemText: String←StringNIL] =
	INLINE {ReportError[error, code, problemText]};

  Warning: PUBLIC PROC [code: ErrorCode, problemText: String←StringNIL] =
	INLINE {ReportError[warning, code, problemText]};





-- Random utilities.
	
  ModuleTypes: TYPE = {
	interface, openedInterface,
	control, client, clientBinder, server,
	rpcPublic, rpcPrivate,
	lupineRuntime };
	
  ModuleName: PROCEDURE [module: ModuleTypes] RETURNS [name: String];

  StampTranslationOptions: PROCEDURE [options: Options];

  SHORT: PROCEDURE [long: LONG INTEGER] RETURNS [INTEGER] =
    INLINE {RETURN[
      IF long IN [FIRST[INTEGER]..LAST[INTEGER]]
        THEN Inline.LowHalf[long] ELSE ERROR ]};

  IsNull: PROCEDURE [string: String] RETURNS [--yes:-- BOOLEAN] =
    INLINE {RETURN[ string=StringNIL OR string.length=0 ]};
  

  END.  -- LupineManagerPrivate.