
<<SMBind.mesa>>
<<Copyright  1985 by Xerox Corporation.  All rights reserved.>>
<<last edit by Satterthwaite, May 12, 1986 12:00:14 pm PDT>>
<<>>
<<shared data definitions internal to the binder>>

DIRECTORY
BcdDefs: TYPE USING [
BcdBase, ControlItem, EXPHandle, Link, ModuleIndex,
--IRLinkLimit, MaxNDMi, MaxNMi,-- MTNull, NullLink, NullModule, ProcLimit],
TimeStamp: TYPE USING [Null, Stamp],
VM: TYPE USING [Interval, nullInterval];

SMBind: CEDAR DEFINITIONS ~ {

<<the modeller's representation of an interface record.  Control link entries:>>
<<for a proc,        [procedure[gfi~gfi, ep~ep, tag~TRUE]]>>
<<for a variable,    [variable[vgfi~gfi,  var~evi, vtag~var]]>>
<<for a module,        [variable[vgfi~gfi,  var~0, vtag~var]]>>
<<for an import,    [procedure[gfi~dummyGfi, ep~index, tag~TRUE]]>>

IR: TYPE~REF InterfaceRecord;

InterfaceRecord: TYPE~RECORD[
name: ATOM_NIL,
stamp: TimeStamp.Stamp_TimeStamp.Null,
variants: SELECT tag: * FROM
virtual => [
dummyGfi: BcdDefs.ModuleIndex_BcdDefs.NullModule,
index: CARDINAL],    -- to IMPRecord in bcd
real => [SEQUENCE size: NAT OF
RECORD[link: BcdDefs.Link_BcdDefs.NullLink]    -- the links
],
ENDCASE
];

VIR: TYPE~REF InterfaceRecord.virtual;
RIR: TYPE~REF InterfaceRecord.real;

IRIndex: TYPE~[0..BcdDefs.ProcLimit*64--BcdDefs.IRLinkLimit--);

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


BindInfo: TYPE~REF BindInfoRecord;
BindInfoRecord: TYPE~RECORD[
bcdSpace: VM.Interval_VM.nullInterval,    -- the mapped-in bcd
bcd: BcdDefs.BcdBase_NIL,                -- for bcdSpace (redundant but convenient)
moduleIndex: BcdDefs.ModuleIndex_BcdDefs.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: BcdDefs.ControlItem_[module[BcdDefs.MTNull]],
linksResolved: BOOL_FALSE                -- accelerator
];

<<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..4--BcdDefs.MaxNMi--)]
];


RelocateLink: PROC[bindInfo: BindInfo, bcdLink: BcdDefs.Link] RETURNS[BcdDefs.Link];
ImportLink: PROC[gfi: BcdDefs.ModuleIndex, ep: IRIndex] RETURNS[BcdDefs.Link];

BuildInterface: PROC[bindInfo: BindInfo, eth: BcdDefs.EXPHandle] RETURNS[RIR];
BuildFramePtrInterface: PROC[bindInfo: BindInfo] RETURNS[RIR];

<<allocation/deallocation>>

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

}.

