<> <> <> <> DIRECTORY CD, CDExtras, CDIO, CDOps USING [AddAnObject], CDSequencer, CDViewer USING [CreateViewer], Commander USING [CommandProc, Register], CommandTool, Rope USING [ROPE], TerminalIO; CDIOCommands: CEDAR PROGRAM IMPORTS CDExtras, CDIO, CDOps, CDSequencer, CDViewer, Commander, CommandTool, TerminalIO = BEGIN IncludeCommand: PROC [comm: CDSequencer.Command] = BEGIN Forward: PROC [a: ATOM] = INLINE { CDSequencer.ExecuteCommand[comm: comm, command: 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: BOOL _ FALSE; 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]; 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 design file" ]; CDSequencer.ImplementCommand[$ReallyIncludeADesign, ReallyIncludeCommand,, doQueue]; CDSequencer.ImplementCommand[$IncludeADesign, IncludeCommand,, doQueue]; CDSequencer.ImplementCommand[$OutputDesign, WriteCommand,, doQueue]; END.