-- BBVForUserExec.mesa
-- Russ Atkinson, November 15, 1982 11:03 am

DIRECTORY
BBBreak USING [BreakIndex, NullIndex],
PrintTV USING [PutClosure],
Rope USING [ROPE],
RTBasic USING [TV],
WorldVM USING [World];

BBVForUserExec: CEDAR DEFINITIONS
= BEGIN OPEN BBBreak, PrintTV, Rope, RTBasic, WorldVM;

-- operations that report results (including intermediate results) as they go

SetBreak: PROC
[report: ReportProc, world: World ← NIL, entry,exit: BOOLFALSE]
RETURNS [break: BreakIndex ← NullIndex];
-- set a new breakpoint at the current selection
-- returns BBBreak.NullIndex if not successful
-- world = NIL => use LocalWorld
-- entry forces entry-point breakpoint, exit goes to the end
-- (can set both entry & exit breakpoints)

ClearBreak: PROC
[report: ReportProc, world: World ← NIL, entry,exit: BOOLFALSE]
RETURNS [break: BreakIndex ← NullIndex];
-- clears the breakpoint at the current selection
-- returns BBBreak.NullIndex if no such break or not successful
-- world = NIL => use LocalWorld
-- entry forces entry-point breakpoint, exit goes to the end
-- (can clear both entry & exit breakpoints)

GetBreak: PROC
[report: ReportProc, world: World ← NIL, entry,exit: BOOLFALSE]
RETURNS [break: BreakIndex ← NullIndex];
-- get the breakpoint (if any) associated with the current selection
-- returns BBBreak.NullIndex if no such breakpoint or not successful
-- world = NIL => use LocalWorld
-- entry forces entry-point breakpoint, exit goes to the end
-- (both => give either one set (test entry first))

DisplayFrame: PROC
[frame: TV, put: PutClosure, report: ReportProc, args,vars,allVars: BOOLFALSE];
-- displays the local or global frame to the put proc
-- args => print arguments, vars => print variables
-- allVars => print all variables (otherwise just top-level variables)

SourceFromTV: PROC [tv: TV, report: ReportProc, backupPC: BOOLTRUE]
RETURNS [name: ROPE, index: INT];
-- gets the source file name and the source index for the given TV
-- which must be a local frame or global frame
-- if not successful, then name = NIL & index < 0
-- if the TV is a local frame, we use backupPC to determine whether we
-- subtract 1 from the pc to determine the "context pc" (don't do this for a break)

OpenSource: PROC [name: ROPE, index: INT, chars: INT ← 2, report: ReportProc];
-- uses the results of GetSource to open a viewer on the source
-- if index >= 0, then also sets the selection to the given index (for chars characters)

ReportProc: TYPE = PROC [msg: ROPE, severity: Severity];
-- type of user-supplied procedure used to report results in above operations

ReportError: ERROR [msg: ROPE, severity: Severity];
-- error used if supplied ReportProc = NIL and severity IN [warning..fatal]

Severity: TYPE = {success, comment, warning, fatal};
-- success => operation is completed
-- comment => intermediate information
-- warning => something is wrong, but not fatal
-- fatal => operation is completed, but did not succeed

END.