-- file P4.Mesa
-- last modified by Satterthwaite, January 10, 1980  10:26 AM

DIRECTORY
  ControlDefs: FROM "controldefs" USING [ControlLink, GFTIndex],
  Literals: FROM "literals" USING [LitDescriptor],
  Symbols: FROM "symbols",
  Table: FROM "table" USING [Notifier],
  Tree: FROM "tree" USING [Index, Link, Map, NodeName, Scan];

P4: DEFINITIONS =
  BEGIN
  OPEN Symbols;

  Mark: BOOLEAN = FALSE;

 -- representations (temporary)

  Repr: TYPE = [none..all];
    signed: CARDINAL = 1;
    unsigned: CARDINAL = 2;
    long: CARDINAL = 4;
    other: CARDINAL = 8;

    none: CARDINAL = 0;
    both: CARDINAL = signed+unsigned;
    all: CARDINAL = other+long+both;

 -- register counts

  RegCount: TYPE = [0..256);
  MaxRegs: RegCount = LAST[RegCount];

 -- notifiers

  BCDNotify, DeclNotify, LayoutNotify, StmtNotify: Table.Notifier;
  OpsNotify, ExpANotify, ExpBNotify: Table.Notifier;

 -- exported by Pass4B

  AssignImports: Tree.Scan;
  InitBCD: PROCEDURE;
  FinishBCD: PROCEDURE;
  MakeEPLink: PROCEDURE [ep: CARDINAL, gfi: ControlDefs.GFTIndex] RETURNS [ControlDefs.ControlLink];
  ProcessExports: Tree.Map;
  ProcessImports: Tree.Scan;

 -- exported by Pass4D

  BiasForType: PROCEDURE [CSEIndex] RETURNS [INTEGER];
  ComparableType: PROCEDURE [CSEIndex] RETURNS [BOOLEAN];
  DeclItem: Tree.Scan;
  DeclUpdate: Tree.Map;
  RepForType: PROCEDURE [CSEIndex] RETURNS [Repr];
  TypeExp: PROCEDURE [typeExp: Tree.Link, body: BOOLEAN ← FALSE];
  TypeForTree: PROCEDURE [Tree.Link] RETURNS [SEIndex];
  WordsForType: PROCEDURE [CSEIndex] RETURNS [CARDINAL];

  VarInit: SIGNAL RETURNS [BOOLEAN];

 -- exported by Pass4L

  AssignEntries: PROCEDURE [BTIndex];
  BitsForType: PROCEDURE [SEIndex] RETURNS [CARDINAL];
  CheckBlock: PROCEDURE [BTIndex];
  LayoutArgs: PROCEDURE [RecordSEIndex, CARDINAL, BOOLEAN] RETURNS [CARDINAL];
  LayoutBlock: PROCEDURE [BTIndex, CARDINAL] RETURNS [CARDINAL];
  LayoutFields: PROCEDURE [RecordSEIndex, CARDINAL];
  LayoutGlobals: PROCEDURE [CBTIndex] RETURNS [CARDINAL];
  LayoutInterface: PROCEDURE [CBTIndex] RETURNS [CARDINAL];
  LayoutLocals: PROCEDURE [CBTIndex] RETURNS [CARDINAL];

 -- exported by Pass4S

  Binding: PROCEDURE [
	Tree.Index,
	Tree.NodeName,
	PROCEDURE [Tree.Link, INTEGER] RETURNS [Tree.Link]]
    RETURNS [Tree.Link];
  BodyList: PROCEDURE [BTIndex];
  CaseDriver: PROCEDURE [Tree.Index, Tree.Map, INTEGER] RETURNS [Tree.Link];
  CatchNest: PROCEDURE [Tree.Link];
  Subst: PROCEDURE [Tree.Index] RETURNS [Tree.Link];

 -- exported by Pass4Ops

  RelOp: TYPE = Tree.NodeName [relE .. relLE];

  FoldExpr: PROCEDURE [Tree.Index, Repr] RETURNS [Tree.Link];
  IntervalTest: PROCEDURE [l,r: Tree.Link, rep: Repr] RETURNS [BOOLEAN];
  LiteralRep: PROCEDURE [Tree.Link, Repr] RETURNS [Repr];
  MakeTreeLiteral: PROCEDURE [WORD] RETURNS [Tree.Link];
  RelTest: PROCEDURE [l,r: Tree.Link, op: RelOp, rep: Repr] RETURNS [BOOLEAN];
  TreeLiteralDesc: PROCEDURE [Tree.Link] RETURNS [Literals.LitDescriptor];
  TreeLiteralValue: PROCEDURE [Tree.Link] RETURNS [WORD];
  ZeroP: PROCEDURE [Tree.Link] RETURNS [BOOLEAN];

 -- exported by Pass4Xa

  Covering: TYPE = {none, partial, full};

  AddrOp: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  All: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  Assignment: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  Call: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  Construct: PROCEDURE [node: Tree.Index, nested: BOOLEAN ← FALSE] RETURNS [Tree.Link];
  Cover: PROCEDURE [lType: CSEIndex, lRep: Repr, rType: CSEIndex, rRep: Repr]
    RETURNS [Covering];
  Dollar: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  Index: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  MakeArgRecord: PROCEDURE [RecordSEIndex, Tree.Link] RETURNS [Tree.Link];
  MiscXfer: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  New: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  PadRecord: PROCEDURE [t: Tree.Link, lType: CSEIndex] RETURNS [Tree.Link];
  PushAssignment: PROCEDURE [id, val: Tree.Link, type: CSEIndex];
  Reloc: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  Rhs: PROCEDURE [exp: Tree.Link, lType: CSEIndex, voidOK: BOOLEAN ← FALSE]
    RETURNS [Tree.Link];
  RowConstruct: PROCEDURE [Tree.Index] RETURNS [Tree.Link];
  TargetRep: PROCEDURE [Repr] RETURNS [Repr];
  Union: PROCEDURE [node: Tree.Index, nested: BOOLEAN ← FALSE] RETURNS [Tree.Link];

 -- exported by Pass4Xb

  Pass4XInit: PROCEDURE;

  AdjustBias: PROCEDURE [Tree.Link, INTEGER] RETURNS [Tree.Link];
  ComputeIndexRegs: PROCEDURE [Tree.Index] RETURNS [RegCount];
  ConstantInterval: PROCEDURE [Tree.Index] RETURNS [origin, range: INTEGER];
  Exp: PROCEDURE [Tree.Link, Repr] RETURNS [Tree.Link];
  ForceType: PROCEDURE [Tree.Link, CSEIndex] RETURNS [Tree.Link];
  Interval: PROCEDURE [Tree.Index, INTEGER, Repr] RETURNS [const: BOOLEAN];
  MakeStructuredLiteral: PROCEDURE [val: WORD, type: CSEIndex] RETURNS [Tree.Link];
  NeutralExp: Tree.Map;
  OperandType: PROCEDURE [Tree.Link] RETURNS [CSEIndex];
  NormalizeRange: PROCEDURE [Tree.Link] RETURNS [Tree.Link];
  RegsForType: PROCEDURE [CSEIndex] RETURNS [RegCount];
  RValue: PROCEDURE [exp: Tree.Link, bias: INTEGER, target: Repr] RETURNS [Tree.Link];
  StructuredLiteral: PROCEDURE [Tree.Link] RETURNS [BOOLEAN];
  TreeLiteral: PROCEDURE [Tree.Link] RETURNS [BOOLEAN];
  VBias: PROCEDURE RETURNS [INTEGER];
  VPop: PROCEDURE;
  VPush: PROCEDURE [bias: INTEGER, rep: Repr, nRegs: RegCount];
  VRegs: PROCEDURE RETURNS [RegCount];
  VRep: PROCEDURE RETURNS [Repr];

  EmptyInterval: SIGNAL;

 -- the global frames

  Pass4B, Pass4D, Pass4L, Pass4S, Pass4Ops, Pass4Xa, Pass4Xb: PROGRAM;

  END.