-- NodeNameTable.Mesa
-- written by Paxton.  December 1980
-- last written by Paxton.  March 18, 1981  3:04 PM

DIRECTORY
TextNode,
TextRope;

NodeNameTable: DEFINITIONS =
BEGIN OPEN nodeI:TextNode, ropeI:TextRope;

NameTable: TYPE = REF NameTableBody;
NameTableBody: TYPE; -- exported by NodeNameTableImpl

CreateNameTable: PROC RETURNS [NameTable];
-- creates an empty name table.

FindNameTable: PROC [n: nodeI.Ref] RETURNS [NameTable];
-- find the name table for node n.
-- look for nametable prop on n or ancestor.

AddNames: PROC [n: nodeI.Ref, table: NameTable];
-- looks for names among immediate children of node n.
-- add them to name table.

RemoveNames: PROC [n: nodeI.Ref, table: NameTable];
-- looks for names among immediate children of node n.
-- remove them from name table.

AddName: PROC [name: ropeI.Rope, n: nodeI.Ref, table: NameTable];
-- add name for n to table

RemoveName: PROC [name: ropeI.Rope, n: nodeI.Ref, table: NameTable];
-- remove name for n from table.

LookupName: PROC [
  name: ropeI.Rope, table: NameTable, prev: nodeI.Ref ← NIL]
  RETURNS [nodeI.Ref];
-- returns a node that has the given name.
-- let prev be NIL for first call.
-- if prev # NIL, will return next node with that name.
-- returns NIL when no more nodes with the name.
-- or when prev # NIL is not on list.

END.