LupineDeps.Mesa
Last Edited by: Spreitzer, April 8, 1985 4:48:11 pm PST
Last Edited by: Pavel, May 28, 1984 3:06:54 pm PDT
DIRECTORY BasicTime, FS, IO, MakeDo, Rope;
LupineDeps: CEDAR PROGRAM
IMPORTS BasicTime, FS, IO, MakeDo, Rope =
BEGIN
ROPE: TYPE = Rope.ROPE;
LupineCommand: TYPE = REF LupineCommandRep;
LupineCommandRep: TYPE = RECORD [
resultPrefix: ROPE,
sourceNode: MakeDo.Node,
earliestResultNode, lateIngredientNode: MakeDo.Node ← NIL,
earliestResultTime, lateIngredientTime: BasicTime.GMT ← BasicTime.nullGMT,
cmd: ROPENIL];
lupineClass: MakeDo.CommandClass ← NEW [MakeDo.CommandClassRep ← [
NotCurrent: LupineNotCurrent,
Rederive: RederiveLupine,
UpdateTime: MakeDo.FileTime,
Explain: ExplainLupine
]];
LupineFind: PROC [resultName: ROPE, finderData: REF ANY] RETURNS [found: BOOLEAN, sought: MakeDo.Node, makes, from, why: MakeDo.NodeList, cmd: ROPE, class: MakeDo.CommandClass, foundData: REF ANY] -- MakeDo.FinderProc -- =
BEGIN
EndsIn: PROC [ending: ROPE] RETURNS [ans: BOOL] = {
elen: INT = ending.Length[];
IF elen > slen THEN RETURN [FALSE];
IF (ans ← resultShort.Substr[start: slen - elen, len: elen].Equal[s2: ending, case: FALSE]) THEN {plen ← slen - elen; sending ← ending}};
Tail: PROC [ending: ROPE] RETURNS [node: MakeDo.Node] = {
node ← MakeDo.GetNode[resultPrefix.Cat[ending]];
IF ending.Equal[sending] THEN sought ← node};
resultCP: FS.ComponentPositions;
resultFull, resultPrefix, resultShort, interfaceName, sourceName, sending: ROPE;
sourceNode: MakeDo.Node;
lc: LupineCommand;
slen, plen: INT;
sought ← NIL;
[resultFull, resultCP, ] ← FS.ExpandName[resultName];
resultShort ← resultFull.Substr[start: resultCP.base.start, len: (resultCP.ext.start + resultCP.ext.length) - resultCP.base.start];
slen ← resultShort.Length[];
found ← EndsIn["RpcControl.Mesa"] OR EndsIn["RpcClientImpl.Mesa"] OR EndsIn["RpcBinderImpl.Mesa"] OR EndsIn["RpcServerImpl.Mesa"];
IF NOT found THEN RETURN;
interfaceName ← resultShort.Substr[start: 0, len: plen];
resultPrefix ← resultFull.Substr[start: 0, len: resultCP.base.start].Concat[interfaceName];
why ← LIST[sourceNode ← MakeDo.GetNode[sourceName ← resultPrefix.Cat[".BCD"]]];
foundData ← lc ← NEW [LupineCommandRep ← [
resultPrefix: resultPrefix,
sourceNode: sourceNode,
cmd: cmd ← IO.PutFR["Lupine %g TranslateInterface[%g]", IO.rope[GetSwitches[resultPrefix]], IO.rope[interfaceName]]
]];
makes ← LIST[
Tail["RpcControl.Mesa"],
Tail["RpcClientImpl.Mesa"],
Tail["RpcBinderImpl.Mesa"],
Tail["RpcServerImpl.Mesa"]];
IF sought = NIL THEN ERROR;
from ← DeriveFrom[lc];
class ← lupineClass;
END;
GetSwitches: PROC [resultPrefix: ROPE] RETURNS [switches: ROPE] = {
ss: IO.STREAMNIL;
ss ← FS.StreamOpen[resultPrefix.Cat[".LupineSwitches"] !FS.Error => CONTINUE];
IF ss = NIL THEN RETURN [NIL];
[] ← ss.SkipWhitespace[];
IF ss.EndOf[] THEN RETURN [NIL];
switches ← ss.GetLineRope[];
ss.Close[];
};
DeriveFrom: PROC [lc: LupineCommand] RETURNS [from: MakeDo.NodeList] =
BEGIN
from ← LIST[lc.sourceNode];
END;
RederiveLupine: PROC [c: MakeDo.Command] RETURNS [from: MakeDo.NodeList, cmd: ROPE] --MakeDo.RederiveProc-- = {
lc: LupineCommand ← NARROW[c.PublicPartsOfCommand[].foundData];
from ← DeriveFrom[lc];
cmd ← lc.cmd};
LupineNotCurrent: MakeDo.NotCurrentProc --PROC [c: Command] RETURNS [notCurrent: BOOLEAN]-- =
BEGIN
lc: LupineCommand;
foundData: REF ANY;
makes, from: MakeDo.NodeList;
[foundData: foundData, makes: makes, from: from] ← c.PublicPartsOfCommand[];
lc ← NARROW[foundData];
lc.earliestResultTime ← BasicTime.latestGMT;
lc.earliestResultNode ← lc.lateIngredientNode ← NIL;
FOR ml: MakeDo.NodeList ← makes, ml.rest WHILE ml # NIL DO
thisTime: BasicTime.GMT;
IF NOT MakeDo.Needed[ml.first] THEN LOOP;
thisTime ← MakeDo.Latest[ml.first];
IF thisTime # BasicTime.nullGMT AND thisTime.Period[lc.earliestResultTime] > 0
THEN {lc.earliestResultTime ← thisTime; lc.earliestResultNode ← ml.first};
ENDLOOP;
IF lc.earliestResultNode = NIL THEN RETURN [FALSE];
FOR fl: MakeDo.NodeList ← from, fl.rest WHILE fl # NIL DO
fromTime: BasicTime.GMT ← MakeDo.Latest[fl.first];
IF (fromTime # BasicTime.nullGMT) AND (fromTime.Period[lc.earliestResultTime] < 0) THEN {
lc.lateIngredientTime ← fromTime;
lc.lateIngredientNode ← fl.first;
RETURN [TRUE]};
ENDLOOP;
notCurrent ← FALSE;
END;
ExplainLupine: MakeDo.ExplainProc --PROC [c: Command, to: IO.STREAM]-- =
BEGIN
lc: LupineCommand ← NARROW[c.PublicPartsOfCommand[].foundData];
IF lc.earliestResultNode = NIL THEN to.PutRope["\tno result files existed yet.\n"]
ELSE IF lc.lateIngredientNode = NIL THEN to.PutRope["\tall result files were dated later than any ingredient file.\n"]
ELSE to.PutF["\tresult %g of %g predated ingredient %g of %g.\n", IO.rope[lc.earliestResultNode.PublicPartsOfNode[].name], IO.time[lc.earliestResultTime], IO.rope[lc.lateIngredientNode.PublicPartsOfNode[].name], IO.time[lc.lateIngredientTime]];
END;
MakeDo.AddFinder[[LupineFind], back];
END.