FILE: M2D.mesa
Modula-2 Datastructure
Last Edited by: Gutknecht, September 18, 1985 0:14:02 am PDT
Satterthwaite December 12, 1985 10:31:00 am PST
M2D: CEDAR DEFINITIONS =
BEGIN
WordSize: CARDINAL = 32;
SET: TYPE = PACKED ARRAY [0..WordSize) OF BOOL;
nilval: CARDINAL = 177777B;
MaxCodeLength: CARDINAL = 8;
ObjPtr: TYPE = REF Object;
HeaderPtr: TYPE = REF Object.Header;
ConstPtr: TYPE = REF Object.Const;
TypPtr: TYPE = REF Object.Typ;
VarPtr: TYPE = REF Object.Var;
FieldPtr: TYPE = REF Object.Field;
ProcPtr: TYPE = REF Object.Proc;
ModulePtr: TYPE = REF Object.Module;
LinkagePtr: TYPE = REF Object.Linkage;
BDPtr: TYPE = REF BDesc;
PDPtr: TYPE = REF BDesc.Block;
CDPtr: TYPE = REF BDesc.Code;
StrPtr: TYPE = REF Structure;
EnumPtr: TYPE = REF Structure.Enum;
RangePtr: TYPE = REF Structure.Range;
PointerPtr: TYPE = REF Structure.Pointer;
SetPtr: TYPE = REF Structure.Set;
ArrayPtr: TYPE = REF Structure.Array;
RecordPtr: TYPE = REF Structure.Record;
ProcTypPtr: TYPE = REF Structure.ProcTyp;
OpaquePtr: TYPE = REF Structure.Opaque;
ParPtr: TYPE = REF Parameter;
ImpPtr: TYPE = REF ImportItem;
ExpPtr: TYPE = REF ExportItem;
ObjClass: TYPE = { Header, Const, Typ, Var, Field, Proc, Module, Linkage };
StrForm: TYPE = { Undef, Bool, Char, Card, Int, Double, Real, LongReal, String, Enum, Range, Pointer, Set, Array, Record, ProcTyp, Opaque };
ConstValue: TYPE = RECORD
[ SELECT OVERLAID StrForm FROM
Bool => [ B: BOOL ],
Char => [ Ch: CHAR ],
Int => [ I: LONG INTEGER ],
Card, Enum => [ C: LONG INTEGER ],
Set => [ S: SET ],
Double => [ D: LONG INTEGER ],
Real => [ R: REAL ],
LongReal => [ X: REAL ],
String => [ D0, D1, D2, D3: CARDINAL ]
ENDCASE ];
Object: TYPE = RECORD
[ name: CARDINAL ← 0,
typ: StrPtr ← NIL,
next: ObjPtr ← NIL,
ext: SELECT class: ObjClass FROM
Header =>
[ kind: ObjClass ← $Proc, -- Proc, Module or Typ
last: ObjPtr ← NIL,
base: ObjPtr ← NIL,
firstImp: ImpPtr ← NIL,
cell: CARDINAL ← 0 ], -- record base addr
Const =>
[ conval: ConstValue ],
Typ =>
[ mod: ModulePtr ← NIL ],
Var =>
[ mod: CARDINAL ← 0,
lev: CARDINAL ← 0,
cell: CARDINAL ← 0,
varpar: BOOLFALSE ],
Field =>
[ offset: CARDINAL ← 0 ],
Proc =>
[ bd: BDPtr ← NIL,
firstParam: ParPtr ← NIL],
Module =>
[ mod: CARDINAL ← 0,
key: LONG CARDINAL ← 0,
prio: CARDINAL ← 0,
pc: CARDINAL ← 0 ,
pAnc: PDPtr ← NIL, -- proc ancestor --
firstExp: ExpPtr ← NIL,
firstObj: ObjPtr ← NIL ],
Linkage =>
[ baseref: CARDINAL ← 0 ],
ENDCASE];
BodyForm: TYPE = { Block, Code };
BDesc: TYPE = RECORD
[ SELECT form: BodyForm FROM
Block =>
[ mod: CARDINAL ← 0,
num: CARDINAL ← 0,
pc: CARDINAL ← 0,
lev: CARDINAL ← 0,
firstLocal: ObjPtr ← NIL,
pAnc: PDPtr ← NIL,
mAnc: ModulePtr ← NIL,
LNK: CARDINAL ← 0, -- LNK=SL, LNK+1=FRX
cell: CARDINAL ← 0,
adr: CARDINAL ← 0,
needsBUP: BOOLFALSE,
impRegs: SETALL [FALSE]],
Code =>
[ num: CARDINAL ← 0,
length: CARDINAL ← 0,
cod: ARRAY [0..MaxCodeLength) OF [0..255] ]
ENDCASE
];
Structure: TYPE = RECORD
[ strobj: TypPtr ← NIL, --type naming structure
size: CARDINAL ← 0,
ref: CARDINAL ← 0,
ext: SELECT form: StrForm FROM
Undef, Bool, Char, Int, Card, Double, Real, LongReal, String =>
[],
Enum =>
[ NofConst: CARDINAL ← 0 ],
Range =>
[ BaseTyp: StrPtr ← NIL,
min: INTEGER ← 0,
max: INTEGER ← 0,
BndAdr: INTEGER ← 0 ],
Pointer =>
[ BaseTyp: StrPtr ← NIL,
BaseId: CARDINAL ← 0 -- to handle forward refs -- ],
Set =>
[ BaseTyp: StrPtr ← NIL ],
Array =>
[ ElemTyp: StrPtr ← NIL,
IndexTyp: StrPtr ← NIL,
dyn: BOOLFALSE ],
Record =>
[ firstFld: ObjPtr ← NIL ],
ProcTyp =>
[ firstPar: ParPtr ← NIL,
resTyp: StrPtr ← NIL ],
Opaque =>
[],
ENDCASE ← Undef[]
];
Parameter: TYPE = RECORD [ typ: StrPtr, varpar: BOOL, next: ParPtr ];
ImportItem: TYPE = RECORD [ name: CARDINAL, item: ObjPtr, next: ImpPtr ];
ExportItem: TYPE = RECORD [ name: CARDINAL, item: ObjPtr, next: ExpPtr ];
mainmod, sysmod: VAR ModulePtr;
undftyp, booltyp, chartyp, inttyp, cardtyp, bitstyp, dbltyp, realtyp, lrltyp,
proctyp, stringtyp, notyp, addrtyp, wordtyp: VAR StrPtr;
UNION: PROC [r, s: SET] RETURNS [R: SET];
INTERSECTION: PROC [r, s: SET] RETURNS [R: SET];
SETDIFF: PROC [r, s: SET] RETURNS [R: SET];
SYMMDIFF: PROC [r, s: SET] RETURNS [R: SET];
SUBSET: PROC [r, s: SET] RETURNS [B: BOOL];
InitData: PROC
END.