DIRECTORY CD, CDCommandOps, CDConditions, CDEnvironment, CDMenus, CDOps, CDOrient, CDSequencer, Rope, TerminalIO; CDConditionsCommands: CEDAR PROGRAM IMPORTS CDCommandOps, CDConditions, CDEnvironment, CDMenus, CDSequencer, CDOps, TerminalIO = BEGIN disabled: BOOL _ TRUE; CheckDisabled: PROC [] = BEGIN IF disabled THEN { TerminalIO.WriteRope["**conditional commands are disabled\n"]; ERROR TerminalIO.UserAbort } END; ChangeCondition: PROC [comm: CDSequencer.Command] = BEGIN fileName, procedureText: Rope.ROPE; ob: CD.Object; first: CD.Instance; multiple: BOOL; TerminalIO.WriteRope["make object conditional\n"]; [first, multiple] _ CDOps.SelectedInstance[comm.design]; IF first=NIL THEN {TerminalIO.WriteRope[" no selected object\n"]; RETURN}; IF multiple THEN { TerminalIO.WriteRope[" multiple selection; not done for now\n"]; RETURN; }; CheckDisabled[]; IF ISTYPE[first.ob.specificRef, CDConditions.CondPtr] THEN { cp: CDConditions.CondPtr _ NARROW[first.ob.specificRef]; ob _ first.ob; TerminalIO.WriteRope[" object already conditional: ["]; TerminalIO.WriteRope[cp.procName]; TerminalIO.WriteRope["] on "]; TerminalIO.WriteRope[cp.fileName]; TerminalIO.WriteRope[" you may change procedure or abort\n"]; } ELSE { ob _ CDConditions.CreateCondition[design: comm.design, ob: first.ob, condition: NIL, data: NIL]; IF ob=NIL THEN { TerminalIO.WriteRope[" not done\n"]; RETURN }; first.ob _ ob; TerminalIO.WriteRope[" object made conditional; now input procedure\n"]; }; fileName _ TerminalIO.RequestRope[" filename > "]; procedureText _ TerminalIO.RequestRope[" (module.)procedure > "]; IF CDConditions.ChangeCondition[design: comm.design, ob: ob, procName: procedureText, fileName: fileName, data: NIL] THEN TerminalIO.WriteRope[" done\n"] ELSE TerminalIO.WriteRope[" procedure not found, but object is conditional\n"] END; CheckConditions: PROC [comm: CDSequencer.Command] = BEGIN all, done: BOOL _ FALSE; TerminalIO.WriteRope["check conditional objects\n"]; IF comm.a=$CheckAllConditions THEN all _ TRUE ELSE IF comm.a=$CheckUnloadedConditions THEN all _ FALSE ELSE all _ TerminalIO.RequestSelection[ label: "load conditional code", choice: LIST["all", "unloaded only"]]=1; IF all THEN TerminalIO.WriteRope[" reload all conditionals\n"] ELSE TerminalIO.WriteRope[" load unloaded conditionals\n"]; CheckDisabled[]; done _ CDConditions.UpdateConditions[comm.design, all]; IF done THEN { TerminalIO.WriteRope[" successfull; but:"] ; TerminalIO.WriteRope[" Warning: Imported designs are not checked; a reloading of conditionals can be forced by re-importing the designs\n"] ; } ELSE TerminalIO.WriteRope[" not successfull\n"]; END; UndoCondition: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance = CDCommandOps.TheInstance[comm, "remove condition"]; IF inst#NIL THEN IF ~ISTYPE[inst.ob.specificRef, CDConditions.CondPtr] THEN TerminalIO.WriteRope["selected ob not a condition"] ELSE { cp: CDConditions.CondPtr = NARROW[inst.ob.specificRef]; inst.ob _ cp.inst.ob; TerminalIO.WriteRope[" done\n"] }; END; WritePropagation: PROC [ob: CD.Object] = BEGIN IF ~ob.p.inDirectory THEN TerminalIO.WriteRope[" has no children; propagation makes no sense\n"] ELSE IF CDEnvironment.Propagates[ob] THEN TerminalIO.WriteRope[" (lets propagation trough)\n"] ELSE TerminalIO.WriteRope[" (stops propagation)\n"]; END; PropagationMenuSP: PROC [comm: CDSequencer.Command] = BEGIN inst: CD.Instance = CDCommandOps.TheInstance[comm, "propagation of conditional procedures input"]; IF inst#NIL THEN { TerminalIO.WriteRope[" trough "]; CDCommandOps.WriteInfo[inst]; WritePropagation[inst.ob]; IF inst.ob.p.inDirectory THEN { SELECT TerminalIO.RequestSelection[ label: "propagation", choice: LIST["stop", "continue trough"] ] FROM 1 => CDEnvironment.AllowPropagation[inst.ob, FALSE]; 2 => {CheckDisabled[]; CDEnvironment.AllowPropagation[inst.ob, TRUE]}; ENDCASE => TerminalIO.WriteRope["skipped\n"]; TerminalIO.WriteRope[" now: "]; WritePropagation[inst.ob]; CDOps.DelayedRedraw[comm.design]; }; } END; [] _ CDMenus.CreateMenu["Conditions", $ConditionsMenu]; CDSequencer.ImplementCommand[$CheckConditions, CheckConditions]; CDSequencer.ImplementCommand[$CheckUnloadedConditions, CheckConditions]; CDSequencer.ImplementCommand[$CheckAllConditions, CheckConditions]; CDSequencer.ImplementCommand[$DrawConditionS, ChangeCondition]; CDSequencer.ImplementCommand[$RemoveConditionS, UndoCondition]; CDSequencer.ImplementCommand[$CPropagationMenuS, PropagationMenuSP]; CDMenus.CreateEntry[$ConditionsMenu, "make conditional", $DrawConditionS]; CDMenus.CreateEntry[$ConditionsMenu, "undo conditional", $RemoveConditionS]; CDMenus.CreateEntry[$ConditionsMenu, "re-Check all code", $CheckAllConditions]; CDMenus.CreateEntry[$ConditionsMenu, "check unloaded code", $CheckUnloadedConditions]; CDMenus.CreateEntry[$ConditionsMenu, "determine propagation", $CPropagationMenuS]; CDMenus.ImplementMenuCommand[$ConditionsMenu, $ConditionsMenu]; CDMenus.CreateEntry[$GlobalMenu, "conditions", $ConditionsMenu]; END. |CDConditionsCommands.mesa (part of ChipNDale) Copyright c 1983, 1985 by Xerox Corporation. All rights reserved. by Christian Jacobi, July 11, 1983 3:42 pm last edited Christian Jacobi, April 30, 1985 11:50:09 am PDT --[done: multiple, cellOb: ob] _ CDCells.CreateCellSelected[comm.design, "-dummy"]; --IF NOT multiple THEN {TerminalIO.WriteRope["not done\n"]; RETURN}; Ê1˜šœ/™/Jšœ Ïmœ7™BJšœ+™+Jšœ<™<—J˜šÏk ˜ Jšžœ˜Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ˜J˜J˜ J˜ J˜J˜ J˜—šÏbœžœž˜#JšžœV˜]—Jšž˜J˜Jšœ žœžœ˜J˜šÏn œžœ˜Jšž˜šžœ žœ˜J˜?Jšžœ˜J˜—Jšžœ˜—J˜š œžœ˜3Jšž˜Jšœžœ˜#Jšœžœ˜Jšœžœ ˜Jšœ žœ˜J˜3Jšœ8˜8Jšžœžœžœ2žœ˜Kšžœ žœ˜JšœBžœ˜IJšœS™SJšœD™DJ˜—Jšœ˜šžœžœ-žœ˜