CDBottomUp.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Jacobi, December 13, 1985 5:49:59 pm PST
Jacobi, December 16, 1985 12:30:26 pm PST
CDBottomUp: CEDAR DEFINITIONS =
BEGIN
A module which allows easy implementation of bottom up calls which cache the results.
Each independent call creates a new invocation key. Results which are created with the same invocation key are allways trusted and taken from the cache. Results with a different invocation key are re-used if all the subcells haven't changed.
Calls for each application (class) - design pair should be monitored by the client, to prevent conflicts on the cached results and which invocation is the latest.
Class:
TYPE =
REF
--
READONLY
-- ClassRec;
ClassRec: PRIVATE TYPE = RECORD [do: DoProc, reUse: ReUseProc, key: REF];
--the class represents the application program; what analysis procedure should be called
Handle:
TYPE =
REF
--
READONLY
-- HandleRec;
HandleRec: TYPE = RECORD [class: Class, design: CD.Design, data: REF, invocation: REF];
--a handle represents one bottom up call sequence
DoProc:
TYPE =
PROC [handle: Handle, ob:
CD.Object]
RETURNS [val:
REF←
NIL];
--a DoProc should not recurse directly but may call DoBottomUp to get recursion going
--if ~ob.class.inDirectory then results must NOT depend on design
ReUseProc:
TYPE =
PROC [handle: Handle, ob:
CD.Object, previousVal:
REF]
RETURNS [shouldDoAain:
BOOLLSE];
--a ReUseProc should be fast and should not recurse directly nor call DoBottomUp
DoRecurse:
PROC [handle: Handle, ob:
CD.Object]
RETURNS [val:
REF, new:
BOOL];
--Starts a recursion; may be called recursively at clients own will but will use cache
--val: the result which was computed or cached
--new: whether a new result was computed this invocation (important for the engine room!)
MakeHandle:
PROC [class: Class, design:
CD.Design, data:
REF←
NIL, invocation:
REF←
NIL]
RETURNS [handle: Handle];
--Creates the handle datastructure which will be passed trough the recursion.
--class: identity of the application; determines what procedure should be called in recursion.
--design: ...
--invocation: invocation-key; (NIL creates a new invocation-key)
--data: reserved for the client
Register:
PROC [do: DoProc, reUse: ReUseProc←
NIL, key:
REF←
NIL, reRegistrationKey:
REF←
NIL]
RETURNS [class: Class];
--Registers an application of CDBottomUp
--do: will be called bottom up for all objects in the directory. Do will typically
-- call DoBottomUp to get recursion going; but for objects in the
-- directory, recursive calls of DoBottomUp have been precalled and
-- the result cached.
--reUse: is called to figure out whether objects which are already handled should
-- be handled again. It is called only for objects in the directory and
-- if do is not called anyway.
--key: property used to cache previous results; a NIL value creates a new property key.
--reRegistrationKey: property re-registration key; a NIL value ensures a new registration.
--class: identity of application.
END.