(****************************************
*                                       *
*     MODULA-2 Multi-Pass Compiler      *
*     ****************************      *
*                                       *
*       VAX/VMS Implementation          *
*                                       *
*                                       *
*     MVCXRef:                          *
*                                       * 
*     Cross Reference Table             *
*     Management                        *
*                                       * 
*     Version 3.1 of  1-FEB-1983        *
*                                       *
*                                       *
*                                       *
*     Based on PDP11 Implementation:    *
*     Version M22 of 26.02.81           *
*                                       *
*     Institut fuer Informatik          *
*     ETH-Zuerich                       *
*     CH-8092 Zuerich                   *
*                                       *
****************************************)

(****************************************
* Updates: see implementation module    *
****************************************)

DEFINITION MODULE MVCXRef; (* VAX: H. Eckhardt *)

FROM MVCompiler IMPORT Spellix, Idclass, Idptr, Varkind, Structform, XRefptr;

EXPORT QUALIFIED
        Nameptr, StLabel, XTabEntry,
        EnableXRef, DisableXRef,
        EnterXRef, GetEntry,
        OpenTable,
        EoTab;


TYPE
  Nameptr =     POINTER TO Namerecs;
  Namerecs =    RECORD
                  name : Spellix;
                  next : Nameptr;
                END;
  StLabel =     RECORD
                  CASE named : BOOLEAN OF
                    TRUE :  typename : Spellix |
                    FALSE : typeform : Structform;
                  END;
                END;
  XTabEntry =   RECORD
                  ident :       Spellix;
                  class :       Idclass;
                  kind :        Varkind; (* for variables only                 *)
                  struct :      StLabel;
                  elstruct :    StLabel; (* element type (sets/arrays/records) *)
                  scopes :      Nameptr; (* identifier scopes, possibly NIL    *)
                  external :    BOOLEAN;
                  exported :    BOOLEAN;
                  refList :     XRefptr;
                END;


PROCEDURE EnableXRef;

PROCEDURE DisableXRef;
        (* Enable and disable entering of line numbers.
         * Initially disabled !
         *)


PROCEDURE EnterXRef     ( idptr :  Idptr;
                          line :   CARDINAL;
                          marked : BOOLEAN );
        (* Enters line no. into the (ordered) list;
         * entries may be 'marked'.
         * Calls ignored on
         *               idptr = NIL and
         *               idptr^.name < sysmodp^.name
         *)


PROCEDURE GetEntry      ( VAR entry : XTabEntry );
        (* Returns next entry of current scope
         * A reference to line 0 is removed from refList.
         * Error : if EoTab = TRUE before calling then entry is undefined.
         *)

PROCEDURE OpenTable;
        (* Initializes table.
         *)

PROCEDURE EoTab (): BOOLEAN;
        (* TRUE when last entry of current table has been read
         * or no initial OpenTable has been done.
         *)

END MVCXRef. 
