[ivy]<Satterthwaite>Modula>M2G.mesa!3

FILE: M2G.mesa
Modula-2 Code-Generator Part 1
Last Edited by: Gutknecht, September 18, 1985 0:20:44 am PDT
Satterthwaite December 11, 1985 9:42:41 am PST
DIRECTORY
M2D: TYPE USING [SET, ObjPtr, HeaderPtr, ModulePtr, ProcPtr, PDPtr, ParPtr, StrPtr, ConstValue],
M2S: TYPE USING [Symbol],
M2I: TYPE USING [Relation];
M2G: CEDAR DEFINITIONS = BEGIN
ItemMode: TYPE = { typMd, procMd, codMd, varMd, conMd, linxMd, sinxMd, ladrMd, sadrMd, opnMd, regMd, stkMd, jmpMd };
ItemPtr: TYPE = REF Item;
Item: TYPE = RECORD
[ mode: ItemMode ← stkMd,
contxt: M2D.PDPtr ←NIL,
obj: M2D.ObjPtr ← NIL,
typ: M2D.StrPtr ← NIL,
val: M2D.ConstValue ← [Int [0]],
lev: CARDINAL ← 0,
off: CARDINAL ← 0,
opr: CARDINAL ← 0,
opt, opt2: [0..1] ← 0,
reg, reg2: CARDINAL ← 0,
expRegs: M2D.SET ← ALL [FALSE],
rel: M2I.Relation ← false,
Fjmp, Tjmp: CARDINAL ← 0 ];
statements
NofCases: CARDINAL = 128;
LabelRange: TYPE = RECORD [ low, high: LONG INTEGER, label: CARDINAL ];
LabelTabPtr: TYPE = REF LabelTable;
LabelTable: TYPE = ARRAY [0..NofCases) OF LabelRange;
GenItem: PROC [x: ItemPtr, y: M2D.ObjPtr, Scope: M2D.HeaderPtr];
-- Scope for fields in WITH stmts --
GenIndex: PROC [x, y: ItemPtr];
GenField: PROC [x: ItemPtr, f: M2D.ObjPtr];
GenDeRef: PROC [x: ItemPtr];
GenSingSet: PROC [x, e: ItemPtr];
GenSet: PROC [x, e1, e2: ItemPtr];
PrepAss: PUBLIC PROC [x: ItemPtr];
PrepCall: PROC [x: ItemPtr] RETURNS [fpar: M2D.ParPtr];
GenAssign: PUBLIC PROC [x, y: ItemPtr];
GenParam: PROC [ap: ItemPtr, f: M2D.ParPtr];
GenCall: PROC [x: ItemPtr];
GenEnterM: PROC [mod: M2D.ModulePtr];
GenInitM: PROC [mod: M2D.ModulePtr, modno: CARDINAL] RETURNS [loc: CARDINAL];
GenEnterP: PROC [proc: M2D.ProcPtr] RETURNS [loc1, loc2: CARDINAL];
GenInitP: PROC [proc: M2D.ProcPtr] RETURNS [loc1, loc2, cell: CARDINAL];
GenReturn: PROC [x: ItemPtr, ancestor: M2D.ObjPtr, loc: CARDINAL] RETURNS [Loc: CARDINAL];
GenTrap: PROC [n: CARDINAL];
GenCase1: PROC [x: ItemPtr] RETURNS [L0: CARDINAL];
GenCase2: PROC [l3: CARDINAL] RETURNS [L2: CARDINAL];
GenCase3: PROC [L0, L1, L2, n: CARDINAL, tab: LabelTabPtr];
GenFor1: PROC [v, e1: ItemPtr];
GenFor2: PROC [v, e2: ItemPtr];
GenFor3: PROC [v, e2, e3: ItemPtr] RETURNS [L0, L1: CARDINAL];
GenFor4: PROC [v, e3: ItemPtr, L0, L1: CARDINAL];
GenWith: PUBLIC PROC [v, x: ItemPtr];
expressions
rngchk: BOOLEAN;
LoadAdr: PROC [x: ItemPtr];
LoadAdrStk: PROC [x: ItemPtr];
Load: PROC [x: ItemPtr];
LoadStk: PROC [x: ItemPtr];
GenFJ: PROC [loc: CARDINAL] RETURNS [Loc: CARDINAL];
GenCFJ: PROC [x: ItemPtr] RETURNS [loc: CARDINAL];
GenBJ: PROC [loc: CARDINAL];
GenCBJ: PROC [x: ItemPtr, loc: CARDINAL];
GenIn: PROC [x, y: ItemPtr];
GenNeg: PROC [x: ItemPtr];
GenNot: PROC [x: ItemPtr];
GenAnd: PROC [x: ItemPtr];
GenOr: PROC [x: ItemPtr];
GenOp: PROC [op: M2S.Symbol, x, y: ItemPtr];
GenStParam: PROC [p, x: ItemPtr, fctno, parno: CARDINAL];
GenStFct: PROC [p: ItemPtr, fctno, parno: CARDINAL];
END.