-- AMModelBridgeImpl.Mesa -- last modified on October 25, 1982 4:52 pm by Paul Rovner DIRECTORY AMBridge USING[IsRemote, TVToRemoteProc, TVToProc, GetWorld, GetWorldIncarnation, RemoteGFHFromTV, TVForRemoteProc, TVForProc, GFHFromTV], AMModel USING[Context, Section, ContextSection], AMModelBridge USING[LoadedSection, ContextForFrame, FrameFromContext], AMModelPrivate USING[SectionRec, ProgPCToFGI, z], AMTypes USING[GlobalParent], PrincOps USING[BytePC, ControlLink, EPRange, ProcDesc], RTBasic USING[TV], RTTypesPrivate USING[UnwindIndirectProcDesc], RTTypesRemotePrivate USING[UnwindRemoteIndirectProcDesc, GetRemoteGFHeader]; AMModelBridgeImpl: PROGRAM IMPORTS AMBridge, AMModel, AMModelBridge, AMModelPrivate, AMTypes, RTTypesPrivate, RTTypesRemotePrivate EXPORTS AMModel, AMModelBridge = BEGIN OPEN AMModel, AMModelBridge, AMModelPrivate, PrincOps, RTBasic, RTTypesPrivate, RTTypesRemotePrivate; -- TYPEs -- either binder output bundle for a config, or compiler output bundle -- for a prog module, DEFs module, proc, or statement Section: TYPE = REF SectionObj; SectionObj: PUBLIC TYPE = SectionRec; LoadedSection: TYPE = AMModelBridge.LoadedSection; -- A LoadedSection is a convenience for clients of AMModelBridge. Each represents one of: -- loaded compiler output bundle for a prog module [prog, prog] -- loaded compiler output bundle for a proc [proc, prog] -- loaded compiler output bundle for a statement [statement, prog] LoadedSectionForProc: PUBLIC PROC[tv: TV--proc--] RETURNS[ans: LoadedSection _ [NIL, NIL]] = { c: Context; s: Section; ans.context _ AMModelBridge.ContextForFrame[AMTypes.GlobalParent[tv]]; c _ ans.context; s _ ContextSection[c]; ans.section _ z.NEW[SectionObj _ [proc[prog: NARROW[s], entryPointIndex: IF AMBridge.IsRemote[tv] THEN LOOPHOLE [UnwindRemoteIndirectProcDesc [AMBridge.TVToRemoteProc[tv]].pd, ControlLink].ep ELSE UnwindIndirectProcDesc [LOOPHOLE[AMBridge.TVToProc[tv], ControlLink]].ep, procTV: NARROW[tv]]]]; }; ProcFromLoadedSection: PUBLIC PROC[proc: LoadedSection] RETURNS[TV--proc--] = {s: Section = proc.section; sr: REF proc SectionObj _ NARROW[s]; IF sr.procTV # NIL THEN RETURN[sr.procTV] ELSE {IF AMBridge.IsRemote[FrameFromContext[proc.context]] THEN {pd: PrincOps.ProcDesc _ PrincOps.ControlLink[procedure[gfi: 0, ep: 0, tag: TRUE]]; pd.gfi _ GetRemoteGFHeader [AMBridge.RemoteGFHFromTV[FrameFromContext[proc.context]]].gfi + sr.entryPointIndex/PrincOps.EPRange; pd.ep _ sr.entryPointIndex MOD PrincOps.EPRange; RETURN[AMBridge.TVForRemoteProc [[world: AMBridge.GetWorld[FrameFromContext[proc.context]], worldIncarnation: AMBridge.GetWorldIncarnation [FrameFromContext[proc.context]], pd: pd]]]} ELSE {pd: PrincOps.ProcDesc _ PrincOps.ControlLink[procedure[gfi: 0, ep: 0, tag: TRUE]]; pd.gfi _ AMBridge.GFHFromTV[FrameFromContext[proc.context]].gfi + sr.entryPointIndex/PrincOps.EPRange; pd.ep _ sr.entryPointIndex MOD PrincOps.EPRange; RETURN[AMBridge.TVForProc[LOOPHOLE[pd]]]} }; }; LoadedSectionForProgPC: PUBLIC PROC[prog: Context, pc: BytePC] RETURNS[ans: LoadedSection _ [NIL, NIL]] = { s: Section = ContextSection[prog]; ans.context _ prog; ans.section _ z.NEW[SectionObj _ [statement [prog: NARROW[s], fgtIndex: ProgPCToFGI[FrameFromContext[prog], pc]]]]; }; END.