-- File PackCodeImplB.mesa -- Last edited by Lewis on 5-Jan-82 11:06:51 -- Last edited by Satterthwaite, December 29, 1982 10:09 am DIRECTORY Alloc USING [Handle, Notifier, Words], BcdDefs, BcdOps USING [ CTHandle, EXPHandle, IMPHandle, MTHandle, NameString, NTHandle, ProcessConfigs, ProcessExports, ProcessImports, ProcessModules, ProcessNames], BcdUtilDefs: TYPE USING [ EnterFile, EnterSegment, Init, MapName, MergeFile, SetFileVersion], Error USING [ErrorName], Inline: TYPE USING [LongCOPY], PackagerDefs USING [globalData, GlobalData], PackCode, SourceBcd USING [bcdBases, bcdHeader], Table USING [Base, OrderedIndex]; PackCodeImplB: PROGRAM IMPORTS Alloc, BcdOps, BcdUtilDefs, Error, Inline, PackagerDefs, PackCode, SourceBcd EXPORTS PackCode = BEGIN OPEN PackCode; gd: PackagerDefs.GlobalData; table: Alloc.Handle _ NIL; spb, sgb, fpb: Table.Base; itb, etb, ctb, mtb, ntb, lfb: Table.Base; ssb: BcdOps.NameString; NotifyB: PUBLIC Alloc.Notifier = BEGIN sgb _ base[BcdDefs.sgtype]; spb _ base[BcdDefs.sptype]; fpb _ base[BcdDefs.fptype]; ssb _ base[BcdDefs.sstype]; itb _ base[BcdDefs.imptype]; etb _ base[BcdDefs.exptype]; ctb _ base[BcdDefs.cttype]; mtb _ base[BcdDefs.mttype]; ntb _ base[BcdDefs.nttype]; lfb _ base[BcdDefs.lftype]; END; RemapOldBcd: PUBLIC PROC = BEGIN Copy: PROC [from: LONG POINTER, nwords: CARDINAL, to: LONG POINTER] = Inline.LongCOPY; NullIndex: Table.OrderedIndex = LOOPHOLE[0]; gd _ PackagerDefs.globalData; table _ gd.ownTable; BcdUtilDefs.Init[ownTable: gd.ownTable]; IF table.Words[ table: BcdDefs.imptype, size: LOOPHOLE[SourceBcd.bcdHeader.impLimit]] # NullIndex THEN SIGNAL PackError[NonZeroBase]; Copy[ from: SourceBcd.bcdBases.itb, nwords: LOOPHOLE[SourceBcd.bcdHeader.impLimit], to: itb]; IF table.Words[ table: BcdDefs.exptype, size: LOOPHOLE[SourceBcd.bcdHeader.expLimit]] # NullIndex THEN SIGNAL PackError[NonZeroBase]; Copy[ from: SourceBcd.bcdBases.etb, nwords: LOOPHOLE[SourceBcd.bcdHeader.expLimit], to: etb]; IF table.Words[ table: BcdDefs.cttype, size: LOOPHOLE[SourceBcd.bcdHeader.ctLimit]] # NullIndex THEN SIGNAL PackError[NonZeroBase]; Copy[ from: SourceBcd.bcdBases.ctb, nwords: LOOPHOLE[SourceBcd.bcdHeader.ctLimit], to: ctb]; IF table.Words[ table: BcdDefs.mttype, size: LOOPHOLE[SourceBcd.bcdHeader.mtLimit]] # NullIndex THEN SIGNAL PackError[NonZeroBase]; Copy[ from: SourceBcd.bcdBases.mtb, nwords: LOOPHOLE[SourceBcd.bcdHeader.mtLimit], to: mtb]; IF table.Words[ table: BcdDefs.lftype, size: LOOPHOLE[SourceBcd.bcdHeader.lfLimit]] # NullIndex THEN SIGNAL PackError[NonZeroBase]; Copy[ from: SourceBcd.bcdBases.lfb, nwords: LOOPHOLE[SourceBcd.bcdHeader.lfLimit], to: lfb]; IF table.Words[ table: BcdDefs.nttype, size: LOOPHOLE[SourceBcd.bcdHeader.ntLimit]] # NullIndex THEN SIGNAL PackError[NonZeroBase]; Copy[ from: SourceBcd.bcdBases.ntb, nwords: LOOPHOLE[SourceBcd.bcdHeader.ntLimit], to: ntb]; [] _ BcdOps.ProcessImports[SourceBcd.bcdHeader, RemapImports]; [] _ BcdOps.ProcessExports[SourceBcd.bcdHeader, RemapExports]; [] _ BcdOps.ProcessConfigs[SourceBcd.bcdHeader, RemapConfigs]; [] _ BcdOps.ProcessModules[SourceBcd.bcdHeader, RemapModules]; [] _ BcdOps.ProcessNames[SourceBcd.bcdHeader, RemapInstances]; END; RemapInstances: PROC [nth: BcdOps.NTHandle, nti: BcdDefs.NTIndex] RETURNS [BOOLEAN] = BEGIN OPEN nte: ntb[nti]; nte.name _ BcdUtilDefs.MapName[SourceBcd.bcdBases, nth.name]; RETURN [FALSE]; END; MapFile: PROC [fti: BcdDefs.FTIndex] RETURNS [BcdDefs.FTIndex] = BEGIN SELECT fti FROM BcdDefs.FTSelf => BEGIN new: BcdDefs.FTIndex _ BcdUtilDefs.EnterFile[gd.sourceBcdName]; BcdUtilDefs.SetFileVersion[new, gd.sourceBcdVersion]; RETURN[new]; END; BcdDefs.FTNull => RETURN[fti]; ENDCASE => RETURN[BcdUtilDefs.MergeFile[SourceBcd.bcdBases, fti]]; END; RemapImports: PROC [imph: BcdOps.IMPHandle, impi: BcdDefs.IMPIndex] RETURNS [BOOLEAN] = BEGIN OPEN impe: itb[impi]; impe.name _ BcdUtilDefs.MapName[SourceBcd.bcdBases, imph.name]; impe.file _ MapFile[imph.file]; RETURN [FALSE] END; RemapExports: PROC [exph: BcdOps.EXPHandle, expi: BcdDefs.EXPIndex] RETURNS [BOOLEAN] = BEGIN OPEN expe: etb[expi]; expe.name _ BcdUtilDefs.MapName[SourceBcd.bcdBases, exph.name]; expe.file _ MapFile[exph.file]; RETURN [FALSE] END; RemapConfigs: PROC [cth: BcdOps.CTHandle, cti: BcdDefs.CTIndex] RETURNS [BOOLEAN] = BEGIN OPEN cte: ctb[cti]; cte.name _ BcdUtilDefs.MapName[SourceBcd.bcdBases, cth.name]; cte.file _ IF cth.config = BcdDefs.CTNull THEN BcdDefs.FTSelf ELSE MapFile[cth.file]; RETURN [FALSE] END; RemapModules: PROC [mth: BcdOps.MTHandle, mti: BcdDefs.MTIndex] RETURNS [BOOLEAN] = BEGIN OPEN mte: mtb[mti]; sgr: BcdDefs.SGRecord _ SourceBcd.bcdBases.sgb[mth.sseg]; IF ~mth.packageable THEN Error.ErrorName[error, "has already been packaged!"L, mth.name]; mte.name _ BcdUtilDefs.MapName[SourceBcd.bcdBases, mth.name]; mte.file _ MapFile[mth.file]; sgr.file _ MapFile[sgr.file]; mte.sseg _ BcdUtilDefs.EnterSegment[sgr]; mte.packageable _ FALSE; -- mtb[mti].code will be fixed up later RETURN [FALSE] END; END.