BcdOpsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Sandman, July 17, 1980 11:55 AM
Rovner, 4-Feb-82 11:28:51
Levin, May 13, 1983 5:22 pm
Russ Atkinson (RRA) January 31, 1985 11:27:50 am PST
DIRECTORY
BcdDefs USING [Base, BcdBase, CTHandle, CTIndex, CTNull, CTRecord, EVHandle, EVIndex, EVNull, EVRecord, EXPHandle, EXPIndex, EXPNull, EXPRecord, FPHandle, FPIndex, FPRecord, FPNull, FTHandle, FTIndex, FTNull, FTRecord, IMPHandle, IMPIndex, IMPNull, IMPRecord, Link, MTHandle, MTIndex, MTNull, MTRecord, Namee, NameRecord, NTHandle, NTIndex, NTNull, NTRecord, NullName, SGHandle, SGIndex, SGNull, SGRecord, SpaceID, SPHandle, SPIndex, SPNull, SPRecord, VersionStamp],
BcdOps USING [];
BcdOpsImpl: PROGRAM EXPORTS BcdOps = PUBLIC { OPEN BcdDefs;
ProcessConfigs:
PROC [bcd: BcdBase, proc:
PROC [CTHandle, CTIndex]
RETURNS [
BOOL]]
RETURNS [cth: CTHandle, cti: CTIndex] =
{
ctb: Base = LOOPHOLE[bcd + bcd.ctOffset];
i: CARDINAL;
cti ← FIRST[CTIndex];
FOR i
IN [0..bcd.nConfigs)
DO
cth ← @ctb[cti];
IF proc[cth, cti] THEN RETURN;
cti ← cti + SIZE[CTRecord] + cth.nControls;
ENDLOOP;
RETURN[NIL, CTNull];
};
ProcessExternals:
PROC [bcd: BcdBase, proc:
PROC [EVHandle, EVIndex]
RETURNS [
BOOL]]
RETURNS [evh: EVHandle, evi: EVIndex] =
{
evb: Base = LOOPHOLE[bcd + bcd.evOffset];
FOR evi ←
FIRST[EVIndex], evi +
SIZE[EVRecord] + evh.length
UNTIL evi =
bcd.evLimit DO evh ← @evb[evi]; IF proc[evh, evi] THEN RETURN; ENDLOOP;
RETURN[NIL, EVNull];
};
ProcessExports:
PROC [bcd: BcdBase, proc:
PROC [EXPHandle, EXPIndex]
RETURNS [
BOOL]]
RETURNS [eth: EXPHandle, eti: EXPIndex] =
{
etb: Base = LOOPHOLE[bcd + bcd.expOffset];
i: CARDINAL;
eti ← FIRST[EXPIndex];
FOR i
IN [0..bcd.nExports)
DO
eth ← @etb[eti];
IF proc[eth, eti] THEN RETURN;
eti ← eti + SIZE[EXPRecord] + eth.size;
ENDLOOP;
RETURN[NIL, EXPNull];
};
ProcessFiles:
PROC [bcd: BcdBase, proc:
PROC [FTHandle, FTIndex]
RETURNS [
BOOL]]
RETURNS [fth: FTHandle, fti: FTIndex] =
{
ftb: Base = LOOPHOLE[bcd + bcd.ftOffset];
FOR fti ←
FIRST[FTIndex], fti +
SIZE[FTRecord]
UNTIL fti = bcd.ftLimit
DO
fth ← @ftb[fti]; IF proc[fth, fti] THEN RETURN; ENDLOOP;
RETURN[NIL, FTNull];
};
ProcessImports:
PROC [bcd: BcdBase, proc:
PROC [IMPHandle, IMPIndex]
RETURNS [
BOOL]]
RETURNS [ith: IMPHandle, iti: IMPIndex] =
{
itb: Base = LOOPHOLE[bcd + bcd.impOffset];
i: CARDINAL;
iti ← FIRST[IMPIndex];
FOR i
IN [0..bcd.nImports)
DO
ith ← @itb[iti];
IF proc[ith, iti] THEN RETURN;
iti ← iti + SIZE[IMPRecord];
ENDLOOP;
RETURN[NIL, IMPNull];
};
ProcessModules:
PROC [bcd: BcdBase, proc:
PROC [MTHandle, MTIndex]
RETURNS [
BOOL]]
RETURNS [mth: MTHandle, mti: MTIndex] =
{
mtb: Base = LOOPHOLE[bcd + bcd.mtOffset];
i: CARDINAL;
mti ← FIRST[MTIndex];
FOR i
IN [0..bcd.nModules)
DO
mth ← @mtb[mti];
IF proc[mth, mti] THEN RETURN;
mti ← mti + (
WITH m: mtb[mti]
SELECT
FROM
direct => SIZE[MTRecord[direct]] + m.length*SIZE[Link],
indirect => SIZE[MTRecord[indirect]],
multiple => SIZE[MTRecord[multiple]],
ENDCASE => ERROR)
ENDLOOP;
RETURN[NIL, MTNull];
};
ProcessNames:
PROC [bcd: BcdBase, proc:
PROC [NTHandle, NTIndex]
RETURNS [
BOOL]]
RETURNS [nth: NTHandle, nti: NTIndex] =
{
ntb: Base = LOOPHOLE[bcd + bcd.ntOffset];
FOR nti ←
FIRST[NTIndex], nti +
SIZE[NTRecord]
UNTIL nti = bcd.ntLimit
DO
nth ← @ntb[nti]; IF proc[nth, nti] THEN RETURN; ENDLOOP;
RETURN[NIL, NTNull];
};
ProcessSegs:
PROC [bcd: BcdBase, proc:
PROC [SGHandle, SGIndex]
RETURNS [
BOOL]]
RETURNS [sgh: SGHandle, sgi: SGIndex] =
{
sgb: Base = LOOPHOLE[bcd + bcd.sgOffset];
FOR sgi ←
FIRST[SGIndex], sgi +
SIZE[SGRecord]
UNTIL sgi = bcd.sgLimit
DO
sgh ← @sgb[sgi]; IF proc[sgh, sgi] THEN RETURN; ENDLOOP;
RETURN[NIL, SGNull];
};
ProcessSpaces:
PROC [bcd: BcdBase, proc:
PROC [SPHandle, SPIndex]
RETURNS [
BOOL]]
RETURNS [sph: SPHandle, spi: SPIndex] =
{
spb: Base = LOOPHOLE[bcd + bcd.spOffset];
FOR spi ←
FIRST[SPIndex], spi +
SIZE[SPRecord] + sph.length*
SIZE[SpaceID]
UNTIL spi = bcd.spLimit DO
sph ← @spb[spi]; IF proc[sph, spi] THEN RETURN; ENDLOOP;
RETURN[NIL, SPNull];
};
FindName:
PROC [bcd: BcdBase, owner: Namee]
RETURNS [name: NameRecord] =
{
FindOwner:
PROC [nth: NTHandle, nti: NTIndex]
RETURNS [
BOOL] =
{
RETURN[owner = nth.item];
};
n: NTHandle ← ProcessNames[bcd, FindOwner].nth;
RETURN[IF n = NIL THEN NullName ELSE n.name]
};
ModuleVersion:
PROC [bcd: BcdBase, mti: MTIndex]
RETURNS [version: VersionStamp] = {
mtb: Base = LOOPHOLE[bcd + bcd.mtOffset];
ftb: Base = LOOPHOLE[bcd + bcd.ftOffset];
RETURN[ftb[mtb[mti].file].version];
};
ProcessFramePacks:
PUBLIC
PROC [ bcd: BcdBase, proc:
PROC [fph: FPHandle, fpi: FPIndex]
RETURNS [
BOOL]]
RETURNS [fph: FPHandle, fpi: FPIndex] = {
fpb: Base = LOOPHOLE[bcd + bcd.fpOffset];
FOR fpi: FPIndex ← FIRST[FPIndex], fpi + SIZE[FPRecord] + fph.length*SIZE[MTIndex]
UNTIL fpi = bcd.fpLimit
DO
fph ← @fpb[fpi];
IF proc[fph, fpi] THEN RETURN[fph, fpi];
ENDLOOP;
RETURN[NIL, FPNull];
};
}.