CDIOCommands.mesa
Last Edited by: Jacobi, February 8, 1984 9:41 am
DIRECTORY
CD,
CDExtras,
CDIO,
CDIOExtras,
CDOps USING [AddAnObject],
CDSequencer,
CDViewer USING [CreateViewer],
Commander USING [CommandProc, Register],
CommandTool,
FileNames,
Rope USING [ROPE],
TerminalIO;
CDIOCommands: CEDAR PROGRAM
IMPORTS CDExtras, CDIO, CDIOExtras, CDOps, CDSequencer, CDViewer, Commander, CommandTool, FileNames, TerminalIO =
BEGIN
SetDesignsWorkingDirectoryFromCurrent: PROC [design: CD.Design] =
--sets the working directory of the design using the working directory of the process
BEGIN
CDIOExtras.SetDesignsWorkingDirectory[design, FileNames.CurrentWorkingDirectory[]];
END;
IncludeCommand: PROC [comm: CDSequencer.Command] =
BEGIN
Forward: PROC [a: ATOM] = INLINE {
CDSequencer.ExecuteCommand[comm: comm, as: a, queue: dontQueue];
};
yes: BOOL;
TerminalIO.WriteRope["include the directory of an input design\n"];
TerminalIO.WriteRope[" (but usually people want to import other designs)\n"];
yes ← TerminalIO.UserSaysYes[
label: "you really want to include?",
text: "you really want to include? "
];
TerminalIO.WriteRope[IF yes THEN " yes\n" ELSE " no, import\n"];
Forward[IF yes THEN $ReallyIncludeADesign ELSE $Import]
END;
ReallyIncludeCommand: PROC [comm: CDSequencer.Command] =
BEGIN
Check: PROC [design: CD.Design] RETURNS [ok: BOOL] =
BEGIN
ok ← design.technology=comm.design.technology;
IF NOT ok THEN {
TerminalIO.WriteRope["Technology missmatch: includee is "];
TerminalIO.WriteRope[design.technology.name];
TerminalIO.WriteRope["\n"];
}
END;
done: BOOLFALSE;
design: CD.Design;
ob: CD.ObPtr;
pos: CD.DesignPosition;
TerminalIO.WriteRope["really include the directory of an input design\n"];
design ← CDIO.ReadDesign[NIL, Check];
IF design#NIL THEN {
[ob, pos] ← CDExtras.MergeIn[design: comm.design, from: design];
IF ob#NIL THEN {
CDOps.AddAnObject[comm.design, ob, pos];
done ← TRUE;
};
};
IF done THEN TerminalIO.WriteRope["include done\n"]
ELSE TerminalIO.WriteRope["include not done\n"];
END;
ReadCommand: Commander.CommandProc =
BEGIN
ENABLE {
TerminalIO.UserAbort => GOTO UserAbrt;
};
design: CD.Design;
list: LIST OF Rope.ROPE;
length: NAT;
name: Rope.ROPE;
[list, length] ← CommandTool.ParseToList[cmd];
IF length=0 THEN name←NIL
ELSE IF length=1 THEN name←list.first
ELSE {
result←$Failure;
msg←"unknown arguments";
TerminalIO.WriteRope["read command failed\n"];
RETURN
};
design ← CDIO.ReadDesign[name];
IF design#NIL THEN {
[] ← CDViewer.CreateViewer[design];
SetDesignsWorkingDirectoryFromCurrent[design];
TerminalIO.WriteRope["read done\n"];
}
ELSE TerminalIO.WriteRope["read not done\n"];
EXITS
UserAbrt => {TerminalIO.WriteRope["read aborted\n"]};
END;
WriteCommand: PROC [comm: CDSequencer.Command] =
BEGIN
done: BOOL;
TerminalIO.WriteRope["output file\n"];
done ← CDIO.WriteDesign[design: comm.design, to: NIL];
TerminalIO.WriteRope[IF done THEN "write done\n" ELSE "write not done\n"];
END;
-- Module Initialization
Commander.Register[
key: "CDRead",
proc: ReadCommand,
doc: "Read a Chipndale file"
];
CDSequencer.ImplementCommand[$ReallyIncludeADesign, ReallyIncludeCommand,, doQueue];
CDSequencer.ImplementCommand[$IncludeADesign, IncludeCommand,, doQueue];
CDSequencer.ImplementCommand[$OutputDesign, WriteCommand,, doQueue];
END.