SummonerLoadDepsCmds.mesa
Copyright Ó 1986, 1991 by Xerox Corporation. All rights reserved.
Eric Nickell, September 30, 1986 4:22:14 pm PDT
Mike Spreitzer February 9, 1987 2:37:51 pm PST
Willie-s, September 27, 1991 5:12 pm PDT
Michael Plass, November 27, 1991 10:53 am PST
DIRECTORY
Commander, CommanderOps, Convert, FS, IO, Rope, SummonerLoadDeps, SymTab;
SummonerLoadDepsCmds: CEDAR PROGRAM
IMPORTS Commander, CommanderOps, Convert, FS, IO, Rope, SummonerLoadDeps, SymTab
~ BEGIN OPEN SummonerLoadDeps;
RederiveSummonerLoadCmd: Commander.CommandProc = {
[cmd: Commander.Handle] RETURNS [result: REF ANY ← NIL, msg: ROPE ← NIL]
args: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd: cmd];
FOR k: NAT IN [1..args.argc) DO
BuildGFI: PROC [loadName: ROPE] ~ {
stream: IO.STREAM;
stream ¬ FS.StreamOpen[fileName: loadName ! FS.Error => GOTO Exit];
DO
line: ROPE ~ IO.GetLineRope[stream ! IO.EndOfStream => EXIT];
IF Rope.Match[pattern: "* (*)*", object: line] THEN {
module: ROPE ~ Rope.Substr[base: line, len: Rope.Find[s1: line, s2: " "]];
number: ROPE ¬ Rope.Substr[base: line, start: Rope.Find[s1: line, s2: "("]+1];
value: NAT;
number ¬ Rope.Substr[base: number, len: Rope.Find[s1: number, s2: ")"]];
value ¬ Convert.CardFromRope[r: number ! Convert.Error => LOOP];
[] ¬ SymTab.Store[x: gfi, key: module, val: NEW[NAT ¬ value]];
};
ENDLOOP;
EXITS Exit => {};
};
EachPackageName: SymTab.EachPairAction = {
[key: SymTab.Key, val: SymTab.Val] RETURNS [quit: BOOL]
RETURN [FALSE]
};
Other: PROC [line: ROPE] ~ {
s: IO.STREAM ~ IO.RIS[line];
[] ¬ IO.SkipWhitespace[stream: s];
IF ~ IO.EndOf[s] THEN {
IO.PutF[stream: cmd.out, format: "%lUnrecognized line: \"%g\".", v1: [rope["i"]], v2: [rope[line]], v3: [rope[" "]]];
result ¬ $Failure;
};
};
Run: PROC [package: ROPE] ~ {
EstimatedGFIs: PROC [module: ROPE] RETURNS [gfis: NAT ¬ 1] ~ {
ref: REF;
IF (ref ¬ (SymTab.Fetch[x: gfi, key: module].val)) # NIL THEN gfis ¬ NARROW[ref, REF NAT]­;
};
IF SymTab.Fetch[x: x, key: package].found THEN RETURN; --Don't run a package more than once
IO.PutF[stream: s, format: "%g (%g)\n", v1: [rope[package]], v2: [cardinal[EstimatedGFIs[package]]]];
[] ¬ SymTab.Store[x: x, key: package, val: NIL];
};
x: SymTab.Ref ~ SymTab.Create[case: FALSE]; --Packages listed in the file
y: SymTab.Ref ~ SymTab.Create[case: FALSE]; --Version Map warnings
gfi: SymTab.Ref ~ SymTab.Create[case: FALSE]; --Version Map warnings
s: IO.STREAM;
loadName: ROPE ~ Rope.Concat[args[k], ".summonerLoad"];
fileName: ROPE ~ FS.ExpandName[name: Rope.Concat[args[k], ".summonerInstall"] ! FS.Error => {msg ¬ IO.PutFR1["Could not find %g.summonerInstall.\n", [rope[args[k]]]]; EXIT}].fullFName;
BuildGFI[loadName];
s ¬ FS.StreamOpen[fileName: loadName, accessOptions: create];
IO.PutF1[s, "-- %g\n-- Copyright 1990 by Xerox Corporation. All rights reserved.\n\n", [rope[Rope.Concat[args[k], ".summonerLoad"]]]];
{
ENABLE {
CantFind => {
IF SymTab.Fetch[x: y, key: full].found THEN RESUME;
IO.PutF[stream: cmd.out, format: "%lNeed \"%g\".%l\n", v1: [rope["i"]], v2: [rope[full]], v3: [rope[" "]]];
[] ¬ SymTab.Store[x: y, key: full, val: NIL];
result ¬ $Failure; --Consider having to looking at the version map a flop
RESUME;
};
};
RecurseThroughInstall[file: fileName, install: NIL, run: Run, other: Other, recurseVMap: FALSE];
};
IO.Close[self: s];
ENDLOOP;
};
Commander.Register[key: "RederiveSummonerLoad", proc: RederiveSummonerLoadCmd];
END.