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