-- file ProtoTreeOps.mesa
-- last modified by Satterthwaite, January 10, 1983 9:32 am

DIRECTORY
  Alloc: TYPE USING [Handle],
  Literals: TYPE USING [LitIndex],
  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.LitIndex];

  SetAttr: PROC [attr: Tree.AttrId, value: BOOL];
  SetInfo: PROC [info: Tree.Info];

 -- 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];

  GetAttr: PROC [t: Tree.Link, attr: Tree.AttrId] RETURNS [BOOL];
  PutAttr: PROC [t: Tree.Link, attr: Tree.AttrId, value: BOOL];

  GetInfo: PROC [t: Tree.Link] RETURNS [Tree.Info];
  PutInfo: PROC [t: Tree.Link, value: Tree.Info];

  Shared: PROC [t: Tree.Link] RETURNS [BOOL];
  MarkShared: PROC [t: Tree.Link, shared: BOOL];

 -- 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];

  }.