DIRECTORY
  TreesDefs USING [NodeType, TreeNode],
  Storage USING [Free, FreeString, Node];

TreesImpl: PROGRAM IMPORTS Storage EXPORTS TreesDefs = {
  
  MakeNode: PUBLIC PROCEDURE [left, right: LONG POINTER TO TreesDefs.TreeNode,
  	string: LONG STRING, nodeType: TreesDefs.NodeType]
	RETURNS [newNode: LONG POINTER TO TreesDefs.TreeNode] = {
	
    newNode		← Storage.Node[nwords: SIZE[TreesDefs.TreeNode]];
    newNode.left	← left;
    newNode.right	← right;
    newNode.lastInList	← NIL;
    newNode.string	← string;
    newNode.nodeType	← nodeType;
    newNode.char	← FALSE;
    newNode.short	← FALSE;
    newNode.int		← FALSE;
    newNode.long	← FALSE;
    newNode.unsigned	← FALSE;
    newNode.float	← FALSE;
    newNode.double	← FALSE;
    newNode.structure	← FALSE;
    newNode.union	← FALSE;
    newNode.enumeration	← FALSE;
    newNode.class	← noClass;
    newNode.declaratorType ← unknown;
    newNode.operationType ← unknown;
    newNode.dataType ← none;
    newNode.typeString ← NIL;
    newNode.baseDataType ← none;
    newNode.pointerCount ← 0; };

  FreeTree: PUBLIC PROCEDURE [node: LONG POINTER TO TreesDefs.TreeNode] = {
  
    IF node = NIL THEN RETURN;
    FreeTree[node.left];
    FreeTree[node.right];
    IF node.string # NIL THEN Storage.FreeString[node.string];
    Storage.Free[node]; };

  }.