DIRECTORY CD, CDExtras, CDIO, CDOps, CDDirectory, CDPanel, CDSequencer, CDValue, CDViewer USING [CreateViewer], Commander USING [CommandProc, Register], CommandTool, Rope, TerminalIO; CDIOCommands: CEDAR PROGRAM IMPORTS CDDirectory, CD, CDExtras, CDIO, CDOps, CDPanel, CDSequencer, CDValue, CDViewer, Commander, CommandTool, Rope, 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; MergeIn: PROC [design: CD.Design, from: CD.Design, name: Rope.ROPE_NIL] RETURNS [ob: CD.Object_NIL, pos: CD.Position] = BEGIN SkipAt: PROC [n: Rope.ROPE] RETURNS [Rope.ROPE] = BEGIN RETURN [Rope.Substr[base: n, len: Rope.SkipTo[s: n, skip: "@"]]] END; IncludeOneEntry: CDDirectory.EachEntryAction = BEGIN IF NOT CDDirectory.Remove[design: from, name: name, expectObject: ob] THEN ERROR; [] _ CDDirectory.Include[design: design, object: ob, alternateName: SkipAt[name]] END; IF design=from THEN RETURN; IF design.technology#from.technology THEN RETURN WITH ERROR CD.Error[callingError, "MergIn design has different technology"]; [ob, pos] _ CDExtras.Cellize[from, name]; IF ob#NIL THEN { [] _ CDDirectory.Enumerate[design: from, action: IncludeOneEntry]; CDOps.ResetDesign[from]; } ELSE ob _ NIL 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.Object; pos: CD.Position; TerminalIO.WriteRope["really include the directory of an input design\n"]; design _ CDIO.ReadDesign[NIL, Check]; IF design#NIL THEN { [ob, pos] _ 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"; RETURN }; IF Rope.Length[name]>1 AND Rope.Fetch[name, 0] = '- THEN { tech: CD.Technology _ CDExtras.GetTechnology[Rope.Substr[name, 1, Rope.Length[name]]]; IF tech=NIL THEN {result _ $Failure; msg _ "technology not loaded"; RETURN}; design _ CDOps.CreateDesign[tech]; } ELSE design _ CDIO.ReadDesign[name]; IF design#NIL THEN { [] _ CDViewer.CreateViewer[design]; TerminalIO.WriteRope["done\n"]; } ELSE TerminalIO.WriteRope["read not done\n"]; EXITS UserAbrt => {result _ $Failure; msg _ "aborted"}; END; WriteCommand: PROC [comm: CDSequencer.Command] = BEGIN done: BOOL; to: REF_NIL; TerminalIO.WriteRope["write design to a file\n"]; IF comm.a=$SaveDesign THEN to _ CDValue.Fetch[comm.design, $CDxFromFile]; done _ CDIO.WriteDesign[design: comm.design, to: to]; IF done THEN TerminalIO.WriteRope["done\n"] ELSE { WITH to SELECT FROM r: Rope.ROPE => TerminalIO.WriteRope[Rope.Cat["write to ", r, " "]]; ENDCASE => NULL; TerminalIO.WriteRope["not done\n"]; } END; Commander.Register[ key: "CDRead", proc: ReadCommand, doc: "Read a ChipNDale design file" ]; Commander.Register[ key: "CDOpen", proc: ReadCommand, doc: "Open a ChipNDale design: CDOpen {file|-technology}" ]; CDSequencer.ImplementCommand[$ReallyIncludeADesign, ReallyIncludeCommand,, doQueue]; CDSequencer.ImplementCommand[$IncludeADesign, IncludeCommand,, doQueue]; CDSequencer.ImplementCommand[$OutputDesign, WriteCommand,, doQueue]; CDSequencer.ImplementCommand[$SaveDesign, WriteCommand,, doQueue]; CDPanel.DefineButton[tech: NIL, name: "save", command: $SaveDesign, topLine: TRUE]; END.  CDIOCommands.mesa Copyright (C) 1984, Xerox Corporation. All rights reserved. Last Edited by: Jacobi, February 8, 1984 9:41 am Last Edited by: Jacobi, July 1, 1985 11:36:27 am PDT --DANGEROUS PROC --"from" is transfered to an object, and is included (transitive) to "design"'s directory --"from" then may be resetted (preserving the rule: any object is in at most one directory) --the caller is assumed to have the locks of both designs --if "from" is pushed in, it's merged copy will be popped out, either by flushing, --replacing or creating new cells --"name" replaces "from"'s design name for the new created object, but it is a hint only --"pos": if "ob" is included at position "pos" in an empty design we would get "from" again --the "from"'s object's may change name to avoid conflicts with "design"'s directory --ob gets nil if "from" is empty --technologies must be compatible --skip everything after and inclusive first "@" --[name: Rope.ROPE, ob: CD.Object] RETURNS [quit: BOOL_FALSE]-- -- Module Initialization ΚW– "cedar" style˜™J™