File IntPhase2.mesa
March 27, 1981 2:17 PM
Last Edited by: McCreight, February 8, 1985 10:54:07 am PST
DIRECTORY
Basics, IntDefs, IO, IODefs, ParserErrorDefs, IntStorageDefs, IntTransDefs, IntUtilityDefs, OutputDefs;
IntPhase2: CEDAR PROGRAM IMPORTS IO, IODefs, OutputDefs, ParserErrorDefs, IntTransDefs, IntStorageDefs
EXPORTS IntDefs =
BEGIN OPEN IntUtilityDefs, IntStorageDefs;
Instantiate: PUBLIC PROCEDURE [] =
BEGIN
Initial transformation has been set up
cs: IntTransDefs.ContextStack ← IntTransDefs.FreezeContext[];
objectCount: INT ← 0;
pending: LIST OF Object ← LIST[rootSymbol.guts];
IntTransDefs.Push[];
WHILE pending # NIL DO
WHILE pending.first # NIL DO
WITH pending.first.first SELECT FROM
call: Call =>
BEGIN
SELECT TRUE FROM
call.callee.defined AND ~call.callee.expanded =>
BEGIN
IntTransDefs.Push[];
IntTransDefs.ApplyLocal[call.t];
pending.first ← CONS[call.callee, pending.first];
call.callee.expanded ← TRUE;
pending ← CONS[call.callee.guts, pending];
LOOP;
END;
call.callee.expanded =>
ParserErrorDefs.Report[IO.PutFR["Cell %g calls itself, inner call ignored.", IO.int[call.callee.symNumber]], Advisory];
~call.callee.defined =>
ParserErrorDefs.Report[IO.PutFR["Cell %g is undefined, call ignored.", IO.int[call.callee.symNumber]], Advisory];
ENDCASE => ERROR;
END;
symbol: STEntry =>
BEGIN
symbol.expanded ← FALSE; -- returning from symbol call
pending.first ← pending.first.rest; -- remove called symbol and call
END;
box: Box =>
OutputDefs.OutputBox[yes,box.layer,box.length,box.width,
box.center,box.xRot,box.yRot];
box: MBox =>
OutputDefs.OutputBox[yes,box.layer,
(box.bb.right-box.bb.left),(box.bb.top-box.bb.bottom),
[(box.bb.left+box.bb.right)/2,(box.bb.bottom+box.bb.top)/2],
1,0];
flash: Flash =>
OutputDefs.OutputFlash[yes,flash.layer,flash.diameter,flash.center];
poly: Polygon =>
OutputDefs.OutputPolygon[yes,poly.layer,poly.p];
wire: Wire =>
OutputDefs.OutputWire[yes,wire.layer,wire.width,wire.p];
userOb: UserOb =>
OutputDefs.OutputUserObject[yes,userOb.layer,userOb.data];
userCmd: UserCmd =>
OutputDefs.OutputUserCommand[userCmd.command, NARROW[userCmd.data]];
ENDCASE => ERROR;
pending.first ← pending.first.rest;
objectCount ← objectCount+1;
IF objectCount MOD 1000 = 0 THEN
IODefs.PostIt[IO.PutFR["Objects generated to partition files: %g", IO.int[objectCount]]];
ENDLOOP;
IntTransDefs.Pop[];
pending ← pending.rest;
ENDLOOP;
IntTransDefs.SwapContext[cs]; -- recover frozen context
END;
END.