<<>> <> <> <> <> <<>> DIRECTORY Commander, CommandTool, Convert, FS, IO, Rope, SummonerLoadDeps, SymTab; SummonerLoadDepsCmds: CEDAR PROGRAM IMPORTS Commander, CommandTool, Convert, FS, IO, Rope, SummonerLoadDeps, SymTab ~ BEGIN OPEN SummonerLoadDeps; RederiveSummonerLoadCmd: Commander.CommandProc = { <<[cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]>> args: CommandTool.ArgumentVector ~ CommandTool.Parse[cmd: cmd, starExpand: TRUE]; 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.Cat[args[k], ".summonerLoad"]; fileName: ROPE ~ FS.ExpandName[name: Rope.Cat[args[k], ".summonerInstall"] ! FS.Error => {msg _ IO.PutFR[format: "Could not find %g.summonerInstall.\n", v1: [rope[args[k]]]]; EXIT}].fullFName; BuildGFI[loadName]; s _ FS.StreamOpen[fileName: loadName, accessOptions: create]; IO.PutF[stream: s, format: "-- %g\n-- Copyright 1986 by Xerox Corporation. All rights reserved.\n\n", v1: [rope[Rope.Cat[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.