FrameImpl.mesa
last modified by Levin on July 1, 1983 4:58 pm
DIRECTORY
MesaRuntimeInit USING [],
PrincOps
USING [
ControlLink, EPRange, GFT, GFTItem, GlobalFrameHandle, NullProgram, SD, sGFTLength, UnboundLink],
PrincOpsUtils USING [],
RuntimeError USING [UnboundProcedure];
FrameImpl:
PROGRAM
IMPORTS RuntimeError
EXPORTS MesaRuntimeInit, PrincOpsUtils =
BEGIN
OPEN PrincOps;
Exported to PrincOpsUtils (Global Frame stuff)
GlobalFrame:
PUBLIC SAFE PROC [link:
--ControlLink--
UNSPECIFIED]
RETURNS [PROGRAM] = TRUSTED {
DO
OPEN l: LOOPHOLE[link, ControlLink];
SELECT
TRUE
FROM
l = UnboundLink => link ← SIGNAL RuntimeError.UnboundProcedure[link];
l.proc =>
IF l.gfi
IN [1..
SD[sGFTLength])
THEN {
gftItem: GFTItem ← GFT[l.gfi];
gftItem.epbias ← 0;
RETURN[LOOPHOLE[gftItem.framePtr]]
}
ELSE RETURN[NullProgram];
l.indirect => link ← l.link^;
link = 0 => RETURN[NullProgram];
ENDCASE => RETURN[LOOPHOLE[l.frame.accesslink]]
ENDLOOP;
};
GlobalFrameAndEntryPoint:
PUBLIC SAFE PROC [link:
--ControlLink--
UNSPECIFIED]
RETURNS [gf: GlobalFrameHandle, ep: CARDINAL] = TRUSTED {
DO
OPEN l: LOOPHOLE[link, ControlLink];
SELECT
TRUE
FROM
l = UnboundLink => link ← SIGNAL RuntimeError.UnboundProcedure[link];
l.proc =>
IF l.gfi
IN [1..
SD[sGFTLength])
THEN {
gftItem: GFTItem ← GFT[l.gfi];
RETURN[gf: gftItem.framePtr, ep: gftItem.epbias*EPRange+l.ep]
}
ELSE ERROR;
l.indirect => link ← l.link^;
ENDCASE => ERROR; -- not meaningful for type-0 control links
ENDLOOP;
};
END.