-- file TreeOps.Mesa
-- last modified by Satterthwaite, 30-Apr-82 15:23:44

DIRECTORY
  Alloc: TYPE USING [Handle],
  Literals: TYPE USING [LTIndex, STIndex],
  Symbols: TYPE USING [HTIndex, ISEIndex],
  Tree: TYPE;

TreeOps: DEFINITIONS = {

 -- tree construction interface

  Initialize: PROC [Alloc.Handle, UNCOUNTED ZONE];
  Reset, Finalize: PROC;

  PushTree: PROC [v: Tree.Link];
  PopTree: PROC RETURNS [Tree.Link];

  InsertTree: PROC [Tree.Link, CARDINAL];
  ExtractTree: PROC [CARDINAL] RETURNS [Tree.Link];

  MakeNode: PROC [name: Tree.NodeName, count: INTEGER] RETURNS [Tree.Link];
  MakeList: PROC [size: INTEGER] RETURNS [Tree.Link];

  PushNode: PROC [name: Tree.NodeName, count: INTEGER];
  PushList, PushProperList: PROC [size: INTEGER];
  PushHash: PROC [hti: Symbols.HTIndex];
  PushSe: PROC [sei: Symbols.ISEIndex];
  PushLit: PROC [lti: Literals.LTIndex];
  PushStringLit: PROC [sti: Literals.STIndex];

  SetInfo: PROC [info: UNSPECIFIED];
  SetAttr: PROC [attr: Tree.AttrId, value: BOOLEAN];

 -- tree deallocation

  FreeNode: PROC [node: Tree.Index];
  FreeTree: PROC [t: Tree.Link] RETURNS [Tree.Link];

 -- tree attributes

  GetHash: PROC [t: Tree.Link] RETURNS [Symbols.HTIndex];
  GetNode: PROC [t: Tree.Link] RETURNS [Tree.Index];
  GetSe: PROC [t: Tree.Link] RETURNS [Symbols.ISEIndex];
  NthSon: PROC [t: Tree.Link, n: CARDINAL] RETURNS [Tree.Link];
  OpName: PROC [t: Tree.Link] RETURNS [Tree.NodeName];
  Shared: PROC [t: Tree.Link] RETURNS [BOOLEAN];
  SetShared: PROC [t: Tree.Link, shared: BOOLEAN];

 -- tree manipulation

  ScanSons: PROC [root: Tree.Link, action: Tree.Scan];
  UpdateLeaves: PROC [root: Tree.Link, map: Tree.Map] RETURNS [v: Tree.Link];

 -- list testing

  ListLength: PROC [t: Tree.Link] RETURNS [CARDINAL];
  ListHead: PROC [t: Tree.Link] RETURNS [Tree.Link];
  ListTail: PROC [t: Tree.Link] RETURNS [Tree.Link];

 -- list manipulation

  ScanList: PROC [root: Tree.Link, action: Tree.Scan];
  SearchList: PROC [root: Tree.Link, test: Tree.Test];
  ReverseScanList: PROC [root: Tree.Link, action: Tree.Scan];
  UpdateList: PROC [root: Tree.Link, map: Tree.Map] RETURNS [Tree.Link];
  ReverseUpdateList: PROC [root: Tree.Link, map: Tree.Map] RETURNS [Tree.Link];


 -- cross-table tree copying

  CopyTree: PROC [root: Tree.Id, map: Tree.Map] RETURNS [v: Tree.Link];
  IdentityMap: Tree.Map;
  NodeSize: PROC [baseP: Tree.Finger, node: Tree.Index] RETURNS [CARDINAL];

  }.