AMModelPrivate.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Russ Atkinson, February 11, 1985 11:54:56 pm PST
Rovner, July 13, 1983 6:02 pm
DIRECTORY
AMBridge USING[RemoteGlobalFrameHandle],
AMModel USING[CharIndex, Class, Context],
AMTypes USING[TV],
BcdDefs USING[VersionStamp, BcdBase],
LoadState USING[ConfigID],
PrincOps USING[EPRange, MaxNGfi, BytePC, GlobalFrameHandle],
Rope USING[ROPE],
RTSymbolDefs USING[SymbolTableBase],
RTTypesPrivate USING[TypedVariableRec],
WorldVM USING[World];
AMModelPrivate: DEFINITIONS
= BEGIN OPEN AMModel, Rope, RTSymbolDefs, WorldVM;
FGIndex: TYPE = RECORD[fgCard: CARDINAL, fudge: BOOL];
fgCard is used to index the fine grain table
fudge is used to indicate that this index indicates the "missing" index for the last statement in the procedure. This kludge should be resolved when the compiler actually puts out an FGI for the last statement. Until then, if fudge is true, we will try to compensate for the missing FGI in a transparent manner. Fudge should only be true if fgCard is the last fgi for a procedure.
FGNull: FGIndex = [LAST[CARDINAL], FALSE];
EPI: TYPE = [0..PrincOps.EPRange*PrincOps.MaxNGfi);
PCOffset: TYPE = INT; -- # of bytes from start of procedure
NullPCOffset: PCOffset = -1; -- indicates no such PCOffset available
RefTVRec: TYPE = REF RTTypesPrivate.TypedVariableRec;
either binder output bundle for a config, or compiler output bundle
for a prog module, DEFs module, proc, or statement
SectionRec: TYPE =
RECORD[ SELECT class: Class FROM
model => [
configName: ROPE ← , -- require specification
versionStamp: BcdDefs.VersionStamp ← ,
configContext: ConfigContext ← NIL -- useful if it's loaded, but not required
],
prog => [
moduleName: ROPE ← ,
versionStamp: BcdDefs.VersionStamp ← ,
someGFHTV: RefTVRec ← NIL -- useful if it's loaded, not required
],
interface => [
moduleName: ROPE ← ,
versionStamp: BcdDefs.VersionStamp ←
],
proc => [
prog: REF prog SectionRec ← ,
entryPointIndex: EPI,
procTV: RefTVRec ← NIL -- useful if it's loaded, but not required
],
statement => [
prog: REF prog SectionRec ← ,
fgtIndex: FGIndex
]
ENDCASE
];
A Context is either a ConfigContext, a StatementContext, or a TV for a
global frame, local frame or IR instance.
ConfigContext: TYPE = REF ConfigContextObj;
ConfigContextObj: TYPE =
RECORD[world: World ← ,
worldIncarnation: LONG CARDINAL,
configIndex: LoadState.ConfigID ←
LoadState.nullConfig represents rootContext
];
StatementContext: TYPE = REF StatementContextObj;
StatementContextObj: TYPE = RECORD[localFrameTV: RefTVRec];
The procedures below are implemented in AMModelPrivateImpl (Russ Atkinson). They deal with the fine grain table, entry points, and character indexes. BEWARE: there is currently no FGI for the last statement in a procedure. This will probably effect character position to fgi translation, and produce other unfortunate effects until this bug is fixed. The use of fudge is an attempt to get around this problem.
FGIToEPI: PROC [stb: SymbolTableBase, fgi: FGIndex] RETURNS [EPI];
returns entry point for the given fgi (epi = 0 for start proc OR invalid fgi)
EPIToFirstFGI: PROC [stb: SymbolTableBase, epi: EPI, skipArgs: BOOL] RETURNS [FGIndex];
returns first fine grain index for the given procedure. If skipArgs, then we skip over fgi's until the point where the arguments have been popped from the stack. If there are no arguments to the procedure, then skipArgs should be FALSE! (FGNull for invalid epi)
EPIToLastFGI: PROC [stb: SymbolTableBase, epi: EPI] RETURNS [FGIndex];
returns last fine grain index for the given procedure
(FGNull for invalid epi)
EPIToFirstPC: PROC [stb: SymbolTableBase, epi: EPI, skipArgs: BOOL] RETURNS [PCOffset];
returns offset of first byte in the procedure. skipArgs has the same interpretation as for EPIToFirstFGI.
EPIToLastPC: PROC [stb: SymbolTableBase, epi: EPI] RETURNS [PCOffset];
returns offset of last byte in the procedure (may be padding byte)
CharIndexToFGI: PROC [stb: SymbolTableBase, ci: CharIndex] RETURNS [FGIndex];
returns the "best" fine grain index for the given character position
(FGNull for invalid position)
PCToFGI: PROC [stb: SymbolTableBase, epi: EPI, pc: PCOffset] RETURNS [FGIndex];
returns the "best" fine grain index for the given pc offset in the given procedure
(FGNull for invalid epi or invalid pc)
NextFGI: PROC [stb: SymbolTableBase, fgi: FGIndex, epi: EPI] RETURNS [FGIndex];
returns FGNull if next fgi is in a different proc than entryPointIndex
FGIToFirstChar: PROC [stb: SymbolTableBase, fgi: FGIndex] RETURNS [CharIndex];
returns character position of first byte in the fine grain entry
(-1 for invalid fgi)
FGIToLastChar: PROC [stb: SymbolTableBase, fgi: FGIndex] RETURNS [CharIndex];
returns character position of last byte in the fine grain entry
(-1 for invalid fgi)
FGIToFirstPC: PROC [stb: SymbolTableBase, fgi: FGIndex] RETURNS [PCOffset];
returns offset of first byte in the fine grain entry (NullPCOffset for invalid fgi)
FGIToLastPC: PROC [stb: SymbolTableBase, fgi: FGIndex] RETURNS [PCOffset];
returns offset of last byte in the fine grain entry (NullPCOffset for invalid fgi)
ProgPCToFGI: PROC [prog: AMTypes.TV, pc: PrincOps.BytePC] RETURNS [FGIndex];
GetModuleSTB: PROC [bcd: BcdDefs.BcdBase, versionStamp: BcdDefs.VersionStamp] RETURNS [SymbolTableBase];
GetLocalBCD: PROC [gfh: PrincOps.GlobalFrameHandle] RETURNS [BcdDefs.BcdBase];
GetRemoteBCD: PROC [rgfh: AMBridge.RemoteGlobalFrameHandle] RETURNS [BcdDefs.BcdBase];
FindMatchingGlobalFrames: PROC [ world: World, name: ROPE, proc: PROC [ROPE, Context] RETURNS [--stop:-- BOOL] ] RETURNS [ans: Context ← NIL];
END.