-- BBObjectLocation.mesa
-- Russ Atkinson, November 1, 1982 3:31 pm

DIRECTORY
AMEvents USING [Event],
PrincOps USING [BYTE, BytePC],
RTBasic USING [TV];

BBObjectLocation: CEDAR DEFINITIONS
= BEGIN OPEN AMEvents, RTBasic;

Location: TYPE = REF LocationRep;
LocationRep: TYPE; -- opaque

BreakpointId: TYPE = REF BreakpointIdRep;
BreakpointIdRep: TYPE;

LocationError: ERROR [code: LocationErrorCode];
LocationErrorCode: TYPE =
{duplicateId, notALink, cantUseGlobalFrame, badGFandPC};

SourceIndex: TYPE = CARDINAL; -- for now, anyhow.
siNull: SourceIndex=LAST[SourceIndex];

EntryLocation: PROC [self: Location] RETURNS [newLoc: Location];
-- returns the entry location for self

ExitLocation: PROC [self: Location] RETURNS [newLoc: Location];
-- returns the exit location for self

SetBreakpoint: UNSAFE PROC
[self: Location, handler: BreakpointHandler, data: REFNIL]
RETURNS [rId: BreakpointId];

ClearBreakpoint: UNSAFE PROC
[self: Location, id: BreakpointId] RETURNS [rId: BreakpointId];

IsLocationAtLocation: PROC
[self: Location, loc: Location] RETURNS [yes: BOOL];

IsFrameAtLocation: PROC
[self: Location, frame: TV -- Local frame --] RETURNS [yes: BOOL];

LocationFromGFandPC: PROC
[gf: TV, pc: PrincOps.BytePC] RETURNS [Location];
-- returns the location corresponding to the given gf and pc
-- LocationError[badGFandPC] occurs if illegal arguments are given

GFandPCFromLocation: PROC [loc: Location] RETURNS [gf: TV, pc: PrincOps.BytePC];
-- returns the GF and PC for the given location

TVFromLocation: PROC [loc: Location] RETURNS [TV];
-- returns the TV for the given location

ByteAtGFandPC: PROC
[gf: TV, pc: PrincOps.BytePC]
RETURNS [PrincOps.BYTE];
-- returns exact byte currently at given gf and pc

-- Non-operations

CatchBreakpoint: UNSAFE PROC [event: Event] RETURNS [handled: BOOL];
-- for use by BBNubImpl in handling breakpoints
-- hyper-primitive, of course

-- A link is a TV for a procedure descriptor, local frame, or global frame.
-- In TVSuccessor/Predecessor, it may not be a global frame if loc is NIL

TVToLocation: PROC
[tv: TV -- link --] RETURNS [l: Location];

SourceToLocation: PROC
[tv: TV -- link --, sourceIndex: CARDINAL] RETURNS [l: Location];

LocationToSource: PROC
[loc: Location] RETURNS [gf: TV, sourceIndex: CARDINAL];

BreakpointHandler: TYPE = PROC
[event: Event, id: BreakpointId, data: REF];

END.......