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;