DEFINITION MODULE m2cd;
(*$ LargeVars:=FALSE NameChk:=FALSE LongAlign:=TRUE *)
(* 02.04.88/cn *)
(* 30.9.90/bp neue VarModes, nue Procs Init und Exit *)

FROM SYSTEM IMPORT ADDRESS;

TYPE
  ObjPtr;
  StrPtr;
  StrForm=(
    Undef,Bool,Char,UInt,Enum,Range,FFP,Real,LReal,UReal,BPointer,Pointer,Set,
    ProcTyp,Opaque,String,Array,Record,
    Prc,Mod                     (*<- Debugger only*)
  );
  VarModes=(normVar, absVar, regVar, farVar, extVar, smallExtVar,
		normIniVar, farIniVar);
  VarModeSet=SET OF VarModes;

  Item = RECORD
    obj: ObjPtr;
    str: StrPtr;
    dbase:ADDRESS;  (* Starting address of object *)
    CASE :StrForm OF
    | Mod:   ibase:ADDRESS;   (* base of iniVars *)
    | Array: ahigh: LONGINT;  (* high index in case of dyn arrays *)
    | Range: srsize:LONGINT;  (* size in case of a subrange basetype *)
    END;
  END;

  (*
   * Because Item is mostly a private type, ItemInfo provides the
   * informations needed to client modules.
   *
   * nameSpelling: The name of the object.
   * typeSpelling: The name of the object's type if any.
   * adr: The address where this object can be found.
   * ind: Is true if this is a VAR parameter.
   * size: The object's size.
   * mode: Tells wheter the variable is a normal, absolute or register variable.
   *)
  ItemInfo=RECORD
    nameSpelling, typeSpelling: ARRAY [0..127] OF CHAR;
    adr: LONGINT;
    size: LONGINT;
    ind: BOOLEAN;
    sign: BOOLEAN;
    mode: VarModes;
    CASE form: StrForm OF
    | Enum: nofConst: LONGINT;
    | Range: min, max: LONGINT;
    | Array: dyn: BOOLEAN;
    ELSE (* no info needed *)
    END;
  END;

CONST
  illSourcePos=-1;

VAR
  srcPos:LONGINT;

PROCEDURE InitM2CD; (* nur von m2d aufrufen *)
PROCEDURE ExitM2CD; (* nur von m2d aufrufen, Objekte behalten *)
PROCEDURE ForgetM2CD; (* alles vergessen *)
PROCEDURE GetModuleItem(modNo: INTEGER; VAR mod: Item);
PROCEDURE GetProcedureItem(mod: Item; pc: INTEGER; VAR proc: Item);
(* Finds the procedure in the given module to which the pc belongs. *)

PROCEDURE GetItemInfo(item: Item; VAR info: ItemInfo);
(* Copy the relevant information in item into info *)
PROCEDURE GetBrotherItem(VAR item: Item; n: LONGINT);
PROCEDURE GetSonItem(VAR item: Item; n: LONGINT);
PROCEDURE EmptyItem(item: Item): BOOLEAN;
PROCEDURE NumberOfSons(item: Item): LONGINT;

PROCEDURE FindType(VAR i: Item; VAR tName: ARRAY OF CHAR);
PROCEDURE ChangeType(i: Item; newS: StrPtr); (* jr *)

PROCEDURE OpenSource(modNo: INTEGER; mod: BOOLEAN);
PROCEDURE SourceLength(): LONGINT;
PROCEDURE ReadSourceChar(VAR ch: CHAR);
PROCEDURE FindLine(pos: LONGINT): INTEGER;
PROCEDURE GotoLine(line: INTEGER);
PROCEDURE GetErrPosition(modNo, pc: INTEGER; VAR errStart, errStop: LONGINT);

END m2cd.
