
<<SMLoad.mesa>>
<<Copyright © 1985 by Xerox Corporation.  All rights reserved.>>
<<last edit by Satterthwaite, May 12, 1986 11:59:11 am PDT>>
<<>>
<<shared data definitions internal to the loader>>

DIRECTORY
BcdDefs: TYPE USING [BcdBase, EXPHandle, Link],
LoadState: TYPE USING [ConfigID, ModuleIndex, --nullConfig,-- nullModule],
PrincOps: TYPE USING [ControlLink, ControlModule, MaxNGfi, NullControl, NullLink],
TimeStamp: TYPE USING [Null, Stamp],
VM: TYPE USING [Interval, nullInterval];

SMLoad: CEDAR DEFINITIONS --IMPORTS LoadState-- ~ {

<<the modeller's representation of an interface record.  Control link entries:>>
<<for a proc,  [procedure[gfi~gfi, ep~ep, tag~TRUE]]>>
<<for an exported variable,  @variable>>
<<for a module, GlobalFramePointer>>

IR: TYPE~REF InterfaceRecord;
InterfaceRecord: TYPE~RECORD[
name: ATOM_NIL,
stamp: TimeStamp.Stamp_TimeStamp.Null,
body: SEQUENCE size: NAT OF
RECORD[link: PrincOps.ControlLink_PrincOps.NullLink]    -- the links
];

IRSeq: TYPE~REF IRSeqRecord;
IRSeqRecord: TYPE~RECORD[
body: SEQUENCE size: NAT OF IR    -- ith element is IR associated with the ith import
];


LoadInfo: TYPE~REF LoadInfoRecord;
LoadInfoRecord: TYPE~RECORD[
bcdSpace: VM.Interval_VM.nullInterval,    -- the mapped-in bcd
bcd: BcdDefs.BcdBase_NIL,                -- for bcdSpace (redundant but convenient)
config: LoadState.ConfigID_,                -- config for the containing model
moduleIndex: LoadState.ModuleIndex_LoadState.nullModule,    -- dummy gfi in that config
nModules: NAT_0,                            -- (> 1 only for configs)
imports: IRSeq_NIL,                            -- [1 to bcdBase.nImports] (0 unused)
exports: IRSeq_NIL,                            -- exports[0] is the global frame
cm: PrincOps.ControlModule_PrincOps.NullControl,
linksResolved: BOOL_FALSE,                -- accelerator
rtStarted: BOOL_FALSE                    -- types/literals acquired
];

<<the modeller's version of a dummy gfi relocation map>>
<<for importMap[0..bcdBase.nDummies),>>
<<importMap[gfi-importMap.bias] is the index into the import table for a dummy gfi>>

ImportMap: TYPE~REF ImportMapSeq;
ImportMapSeq: TYPE~RECORD[
bias: NAT_,        -- the value of bcdBase.firstDummy
map: SEQUENCE maxSize: NAT OF RECORD[
index: NAT,    -- to the import record 
whichOne: [0..PrincOps.MaxNGfi)]
];


ReplaceResult: TYPE~ {
ok, configNotReplaceable, frameTooBig, nGfiTooBig, cantCopyOldBcd,
checkForMRFailed, compilerSaysNo};


RelocateLink: PROC[loadInfo: LoadInfo, bcdLink: BcdDefs.Link] -- bcdLink.gfi < firstdummy
RETURNS[PrincOps.ControlLink];

BuildInterface: PROC[loadInfo: LoadInfo, eth: BcdDefs.EXPHandle] RETURNS[IR];
BuildFramePtrInterface: PROC[loadInfo: LoadInfo] RETURNS[IR];

<<allocation/deallocation>>

AllocateIR: PROC[stamp: TimeStamp.Stamp, name: ATOM, size: NAT] RETURNS[IR];
FreeIR: PROC[ir: IR] RETURNS[IR];        -- always gives NIL

}.

