CDConditionsCommands.mesa (part of ChipNDale)
Copyright © 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
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;
--[done: multiple, cellOb: ob] ← CDCells.CreateCellSelected[comm.design, "-dummy"];
--IF NOT multiple THEN {TerminalIO.WriteRope["not done\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.