TIPUserImpl.mesa; Edit by McGregor, June 3, 1983 5:46 pm
Last Edited by: Maxwell, January 3, 1983 11:06 am
DIRECTORY
ClassIncreek USING [Increek, NewStdIncreek],
Process USING [GetCurrent],
RefTab USING [Create, Ref, Store],
TIPPrivate,
TIPUser;
TIPUserImpl: CEDAR PROGRAM
IMPORTS ClassIncreek, Process, RefTab, TIPUser
EXPORTS TIPUser, TIPPrivate
SHARES TIPUser = BEGIN OPEN TIPUser, TIPPrivate;
predTable: PUBLIC RefTab.Ref ← RefTab.Create[]; -- table for user defined predicates
CreateClient: PUBLIC PROC [notify: TIPNotifyProc ← NIL, buttons: TIPButtonProc ← NIL]
RETURNS [self: TIPClient] = TRUSTED BEGIN
self ← NEW[TIPClientRec ← [
notifyProc: notify,
buttonProc: buttons,
parseInfo: CreateParseInfo[],
matcher:
]];
self.matcher ← LOOPHOLE[Process.GetCurrent[]]; -- so is never NIL when MatchProcess begins
self.matcher ← FORK MatchProcess[self];
END;
DestroyClient: PUBLIC PROC [self: TIPClient] = TRUSTED BEGIN
self.matcher ← NIL; -- force matcher to terminate
END;
CreateParseInfo: PUBLIC PROC [parseTable: TIPTable ← NIL] RETURNS [new: TIPParseInfo] =
TRUSTED BEGIN
new ← NEW[TIPParseInfoRec ← [
inCreek: ClassIncreek.NewStdIncreek[],
localCreek: ClassIncreek.NewStdIncreek[],
timeCreek: ClassIncreek.NewStdIncreek[],
creekStack: ALL[ClassIncreek.NewStdIncreek[]],
tableHead: parseTable
]];
END;
PushTIPTable: PUBLIC PROC [user: TIPClient, table: TIPTable, opaque: BOOLEAN] = BEGIN
t: TIPTable;
FOR t ← table, t.link UNTIL t.link=NIL DO ENDLOOP;
t.link ← user.parseInfo.tableHead;
user.parseInfo.tableHead ← table;
table.opaque ← opaque;
END;
PopTIPTable: PUBLIC PROC [user: TIPClient] RETURNS [old: TIPTable] = BEGIN
garbage collector will get old table unless the client keeps a reference
IF (old←user.parseInfo.tableHead)#NIL THEN
user.parseInfo.tableHead ← user.parseInfo.tableHead.link;
END;
RegisterTIPPredicate: PUBLIC PROC [key: ATOM, p: TIPPredicate] = BEGIN
a user-defined predicate may be included in the enables list of a TIPTable via this
association mechanism.
[] ← RefTab.Store[predTable, key, NEW[TIPPredicate ← p]];
END;
END.