TIPUserImpl.mesa; Edit by McGregor, November 23, 1982 1:29 pm
Last Edited by: Maxwell, January 3, 1983 11:06 am
DIRECTORY
ClassIncreek USING [Increek, NewStdIncreek],
RefTab USING [Create, Ref, Store],
TIPPrivate,
TIPUser;
TIPUserImpl: CEDAR PROGRAM
IMPORTS ClassIncreek, 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] = BEGIN
self ← NEW[TIPClientRec ← [
notifyProc: notify,
buttonProc: buttons,
parseInfo: CreateParseInfo[],
matcher:
]];
self.matcher ← FORK MatchProcess[self];
END;
DestroyClient: PUBLIC PROC [self: TIPClient] = TRUSTED BEGIN
self.parseInfo.inCreek ← NIL;
self.parseInfo.localCreek ← NIL;
self.parseInfo.timeCreek ← NIL;
FOR i: CARDINAL IN [0..10) DO
self.parseInfo.creekStack[i] ← NIL
ENDLOOP;
JOIN self.matcher;
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.