DIRECTORY List, Rope, OrderedSymbolTableRef, VFonts; Rosemary: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; AList: TYPE = List.AList; SymbolTable: TYPE = OrderedSymbolTableRef.Table; Warning: SIGNAL [msg: ROPE, data: REF ANY _ NIL]; Error: ERROR [msg: ROPE, data: REF ANY _ NIL]; InterfaceMismatch: ERROR [cell: Cell, index: CARDINAL, expected, got: SignalType]; Stop: SIGNAL [msg: ROPE _ NIL, data: REF ANY _ NIL]; RegisterCellClass: PROCEDURE [className: ROPE, expandProc: ExpandProc _ NIL, ioCreator: IOCreator _ NIL, initializer: Initializer _ NIL, evalProc, testProc: EvalProc _ NIL, ports: Ports, ioTemplate: REF ANY _ Unspecified]; ExpandProc: TYPE = PROCEDURE [thisCell: Cell, initData: REF ANY]; IOCreator: TYPE = PROC [cell: Cell, initData: REF ANY]; Initializer: TYPE = PROCEDURE [cell: Cell, initData: REF ANY, leafily: BOOLEAN]; EvalProc: TYPE = PROCEDURE [cell: Cell]; Unspecified: REF ANY; CreateTopCell: PROC [instanceName, className: ROPE, initData: REF ANY _ NIL, decider: ExpandDeciderClosure] RETURNS [cell: Cell]; ExpandDeciderClosure: TYPE = REF ExpandDeciderClosureRep; ExpandDeciderClosureRep: TYPE = RECORD [ Decide: ExpandDecider, otherData: REF ANY]; ExpandDecider: TYPE = PROC [cell: Cell, otherData: REF ANY] RETURNS [ExpandDecision]; ExpandDecision: TYPE = {Leaf, Inline, Nested}; Possible: PROC [cell: Cell, whatToDo: ExpandDecision] RETURNS [possible: BOOLEAN]; CreateNode: PROCEDURE [within: Cell, name: ROPE, type: SignalType _ NIL --means unspecified--] RETURNS [node: Node]; CreateCell: PROCEDURE [within: Cell, instanceName, className, interfaceNodes: ROPE, initData: REF ANY _ NIL] RETURNS [cell: Cell]; AddNodeWatcher: PROC [node: Node, watcher: NodeWatcher, priority: Priority _ 0]; RemoveNodeWatcher: PROC [node: Node, watcher: NodeWatcher, priority: Priority _ 0]; NodeWatcher: TYPE = RECORD [ notify: NodeNotifyProc, clientData: REF ANY _ NIL]; NodeNotifyProc: TYPE = PROC [node: Node, clientData: REF ANY]; Priority: TYPE = [0..1]; AddCellEventWatcher: PROC [cell: Cell, event: ATOM, watcher: CellWatcher]; RemoveCellEventWatcher: PROC [cell: Cell, event: ATOM, watcher: CellWatcher]; CellWatcher: TYPE = RECORD [ notify: CellNotifyProc, clientData: REF ANY _ NIL]; CellNotifyProc: TYPE = PROC [cell: Cell, clientData: REF ANY]; AddGlobalEventWatcher: PROC [event: ATOM, watcher: GlobalWatcher]; RemoveGlobalEventWatcher: PROC [event: ATOM, watcher: GlobalWatcher]; GlobalWatcher: TYPE = RECORD [ notify: GlobalNotifyProc, clientData: REF ANY _ NIL]; GlobalNotifyProc: TYPE = PROC [clientData: REF ANY]; ScheduleCell: PROCEDURE [cell: Cell]; Run: PROCEDURE [str: Structure]; stop: BOOLEAN; SingleStep: PROCEDURE [str: Structure]; Eval: PROC [cell: Cell]; AllowToModify: PROC [cell: Cell, modifier: ModifyProc, blindly: BOOLEAN _ FALSE]; ModifyProc: TYPE = PROC [cell: Cell] RETURNS [subtle: BOOLEAN _ FALSE]; CleanUpAfterModify: PROC [cell: Cell]; Test: PROC [subject: Cell, parms: TestParms]; TestParms: TYPE = REF TestParmsRep; TestParmsRep: TYPE = RECORD [ stopBefore, stopAfter: BOOLEAN _ FALSE]; CellToStr: PROCEDURE [cell: Cell] RETURNS [str: Structure]; UpToReal: PROCEDURE [cell: Cell] RETURNS [realCell: Cell]; NotifyCellEvent: PROCEDURE [cell: Cell, event: ATOM]; NotifyGlobalEvent: PROCEDURE [event: ATOM]; Cell: TYPE = REF CellRep; CellRep: TYPE = RECORD [ name: ROPE, class: CellClass, nextInstance: Cell, parent, leftChild, rightSibling: Cell, firstInternalNode: Node, internalNodes, components: SymbolTable, interfaceNodes: NodeS, other: AList, type: CellType, expansion: ExpandDecision, realCellStuff: RealCellStuff -- non-NIL only for Real Cells ]; CellType: TYPE = {Real, Shadow}; RealCellStuff: TYPE = REF RealCellStuffRep; RealCellStuffRep: TYPE = RECORD [ schedNext: Cell, newIO, oldIO: REF ANY, newIOAsWP, oldIOAsWP: WordPtr, locked: BOOLEAN _ FALSE, initData: REF ANY _ NIL, state: REF ANY, eval: EvalProc, schedWatchers, evalWatchers: CellWatcherList _ NIL]; notInSchedule: Cell; CellWatcherList: TYPE = LIST OF CellWatcher; Structure: TYPE = REF StructureRep; StructureRep: TYPE = RECORD [ container, mirror: Cell, schedFirst, schedLast: Cell, locked: BOOLEAN _ FALSE, insideNodes: NodeS]; NodeS: TYPE = REF NodeSR; NodeSR: TYPE = RECORD [nodes: SEQUENCE length: CARDINAL OF Node]; CellClass: TYPE = REF CellClassRep; CellClassRep: TYPE = RECORD [ name: ROPE, expand: ExpandProc, ioCreator: IOCreator, initializer: Initializer, eval: EvalProc, test: EvalProc, ports: Ports, ioWordCount: CARDINAL, ioTemplate: REF ANY, firstInstance: Cell]; Ports: TYPE = REF PortsRep; PortsRep: TYPE = RECORD [ ports: SEQUENCE length: CARDINAL OF Port]; Port: TYPE = RECORD [ firstWord, wordCount: CARDINAL, name: ROPE, type: SignalType, input, output: BOOLEAN _ FALSE]; Node: TYPE = REF NodeRep; NodeRep: TYPE = RECORD [ name: ROPE, type: SignalType _ NIL, visible: Socket _ [NIL, LAST[CARDINAL]], unwriteability: INTEGER _ 0, readers: SocketList _ NIL, watchers: ARRAY Priority OF NodeWatcherList _ ALL[NIL], next: Node _ NIL, other: AList _ NIL]; SocketList: TYPE = LIST OF Socket; Socket: TYPE = RECORD [cell: Cell, index: CARDINAL]; NodeWatcherList: TYPE = LIST OF NodeWatcher; SignalType: TYPE = REF SignalTypeRep; SignalTypeRep: TYPE = RECORD [ toRope: ToRopeProc, fromRope: FromRopeProc, init: TypeInitProc, maxWidth: MaxWidthProc, parseTest: TestParseProc, unParseTest: TestUnParseProc, typeData: REF ANY]; ToRopeProc: TYPE = PROCEDURE [where: WordPtr, typeData: REF ANY] RETURNS [rope: ROPE]; FromRopeProc: TYPE = PROCEDURE [rope: ROPE, where: WordPtr, typeData: REF ANY] RETURNS [success: BOOLEAN]; TypeInitProc: TYPE = PROC [where: WordPtr, typeData: REF ANY]; MaxWidthProc: TYPE = PROC [typeData: REF ANY, font: VFonts.Font] RETURNS [INTEGER]; TestParseProc: TYPE = PROC [rope: ROPE, typeData: REF ANY] RETURNS [success: BOOLEAN, testProc: TestProc, testData: REF ANY _ NIL]; TestUnParseProc: TYPE = PROC [testProc: TestProc, testData: REF ANY, typeData: REF ANY, subject: ROPE] RETURNS [rope: ROPE]; TestProc: TYPE = PROC [testData: REF ANY, where: WordPtr, typeData: REF ANY] RETURNS [passes: BOOLEAN]; WordPtr: TYPE = LONG POINTER TO CARDINAL; cellClasses: SymbolTable; roots: SymbolTable; LongCellName: PROC [cell: Cell] RETURNS [ln: ROPE]; LookupCell: PROC [ path: LIST OF ROPE, from: Cell _ NIL --NIL means first name names root--] RETURNS [cell: Cell]; RootStructure: PROC [cell: Cell] RETURNS [str: Structure]; SocketToWP: PROC [s: Socket] RETURNS [wp: WordPtr]; GetIndex: PROC [ports: Ports, key: ROPE] RETURNS [index: CARDINAL]; notFound: CARDINAL = LAST[CARDINAL]; END. ΊFILE: Rosemary.mesa, from [Indigo]Release>Rosemary.DF last changed by Barth, June 9, 1983 11:08 am Last Edited by: Spreitzer, September 15, 1983 10:24 am This file gives the data structure for, and most Ops on, a Rosemary simulation. Familiar Types: Errors and Signals: Raised by Test procs and breakpoints. Specifying structure: expandProc: ExpandProc calls Create(Cell/Node) to describe structure. ioCreator: IOCreator Called to create IO data structure. initializer: Initializer May initialize IO. Creates state if leafily. evalProc: EvalProc Copies newIO into oldIO, then (maybe) changes newIO. testProc: EvalProc Performs a test on the cell. interfaceNodes must be empty at the top Specifying Behavior: 0 is for ordinary mortals, like breakpoints 1 is for things like the display, which should be updated first Events raised by RosemaryImpl: $Schedule when cell comes off or goes on or moves to head of schedule $Eval after EvalProc called Popular events: $Stop End of long user-initiated activity $Start Begin of long user-initiated activity Operations: put it in the schedule of the structure it participates in; a No-Op if already Scheduled. All ancestor cells are also Scheduled. Untill schedule empty, or... To suspend all running, set this; when sampled, Stop will be raised. Remove one thing from Schedule and do it Call this from inside a test proc to run the Cell (and do some random likage, so CALL THIS ONLY FROM WITHIN A TEST PROC). Copies newIO into oldIO, then calls modifier, then cleans up; Embeds itself recursively up to the root. If blindly, then newIO not copied into oldIO, and all ports are assumed to change. allowed to modify cell's output entries in newIO. needn't first copy into oldIO. Setting subtle forces the cell to be scheduled. compares newIO to oldIO, distributes and schedules from differences Calls the Cell's Test proc, possibly surrounded by SIGNAL Stop["About to eval/Just eval'ed", cell]. gives the structure this cell contains; if this cell is an Inline expansion, it has to go recursively to parent Returns nearest ancestor, or self, that is a Real Cell. Data Structure: This goes in the schedNext slot of an unscheduled cell. Exploring the Data Structure: Κ ˆ– "cedar" style˜Jšœ?™?JšΟc,™,J™6J™IcodešΟlO™OK˜IunitšΟk œ+˜4L˜LšΠbxœŸœŸ œ˜L˜LšŸ˜K˜šž™K˜KšŸœŸœŸœ˜KšœŸœ˜Kšœ Ÿœ˜0—J˜šž™J˜Jš ΟbœŸœŸœŸœŸœŸœ˜1J˜Jš ‘œŸœŸœŸœŸœŸœ˜.J˜š‘œŸœ ˜%KšœŸœ˜Kšœ˜—K˜šΟnœŸœŸœŸœŸœŸœŸœ˜4K™%——K˜šž™L™š’œŸ œ ŸœŸœŸœŸœ!ŸœŸœŸœ˜ήK˜šœ™J™.—J˜šœ™J™#—J˜šœ™J™J™—J™šœ™J™4—J™šœ™J™—K˜Kš ’ œŸœŸ œŸœŸœ˜AJ˜Jš ’ œŸœŸœŸœŸœ˜7J™Kš ’ œŸœŸ œŸœŸœ Ÿœ˜PK˜Kš’œŸœŸ œ˜(K˜Kšœ ŸœŸœ˜—K˜K˜š’ œŸœŸœ ŸœŸœŸœ!Ÿœ˜K™'K˜KšœŸœŸœ˜9šœŸœŸœ˜(Kšœ"ŸœŸœ˜+—K˜Kš ’ œŸœŸœŸœŸœŸœ˜UK˜KšœŸœ˜.K˜Kš’œŸœ(Ÿœ Ÿœ˜R—K˜Kš ’ œŸ œŸœŸœœŸœ˜tK˜Kš’ œŸ œ9Ÿœ ŸœŸœŸœŸœ˜‚K˜—K˜šž™K˜Kš’œŸœ<˜Pš’œŸœ<˜SK˜šœ ŸœŸœ˜J˜Jšœ ŸœŸœŸœ˜—J˜Jš ’œŸœŸœŸœŸœ˜>J˜šœ Ÿœ ˜J™+J™?—J˜—K˜Kš’œŸœŸœ˜Jš’œŸœŸœ˜MK˜šœ ŸœŸœ˜J˜Jšœ ŸœŸœŸœ˜—J˜Jš ’œŸœŸœŸœŸœ˜>J˜™J™EJ™—K˜—Kš’œŸœ Ÿœ˜Bš’œŸœ Ÿœ˜EK˜šœŸœŸœ˜K˜Kšœ ŸœŸœŸœ˜—K˜Kš ’œŸœŸœŸœŸœ˜4K˜™J™*J™-——K˜—K˜šž ™ K™š’ œŸ œ˜%K™;K™K™&—K˜š’œŸ œ˜ K™K˜šœŸœ˜K™D——K˜š’ œŸ œ˜'K™(—K˜š’œŸœ˜K™y—K˜š’ œŸœ-ŸœŸœ˜QK™=K™)K™RK˜š ’ œŸœŸœŸœ ŸœŸœ˜GK™1K™K™/——K˜š’œŸœ˜&K™C—K˜š’œŸœ#˜-K™cK˜Kšœ ŸœŸœ˜#šœŸœŸœ˜KšœŸœŸœ˜(——K˜š’ œŸ œŸœ˜;K™'K™G—K˜š’œŸ œŸœ˜:K™7—K˜Kš’œŸ œŸœ˜5K˜Kš’œŸ œ Ÿœ˜+K˜—K˜šž™K™JšœŸœŸœ ˜šœ ŸœŸœ˜JšœŸœ˜ J˜J˜J˜&J˜J˜'J˜J˜ Jšœ˜J˜Jšœ˜;Jšœ˜—J˜Jšœ Ÿœ˜ J˜JšœŸœŸœ˜+šœŸœŸœ˜!Jšœ˜JšœŸœŸœ˜Jšœ˜JšœŸœŸœ˜Jšœ ŸœŸœŸœ˜JšœŸœŸœ˜J˜Jšœ/Ÿœ˜4J˜šœ˜J™7——J˜JšœŸœŸœŸœ ˜,J˜Jšœ ŸœŸœ˜#šœŸœŸœ˜J˜J˜JšœŸœŸœ˜Jšœ˜—J˜JšœŸœŸœ˜Jš œŸœŸœ Ÿœ ŸœŸœ˜AJ˜Jšœ ŸœŸœ˜#šœŸœŸœ˜JšœŸœ˜ J˜J˜J˜J˜J˜J˜ Jšœ Ÿœ˜Jšœ ŸœŸœ˜Jšœ˜—J˜JšœŸœŸœ ˜šœ ŸœŸœ˜JšœŸœ ŸœŸœ˜*—J˜šœŸœŸœ˜JšœŸœ˜JšœŸœ˜ Jšœ˜JšœŸœŸœ˜ —J˜JšœŸœŸœ ˜šœ ŸœŸœ˜JšœŸœ˜ JšœŸœ˜JšœŸœŸœŸœ˜(JšœŸœ˜JšœŸœ˜Jš œ Ÿœ ŸœŸœŸœ˜7Jšœ Ÿœ˜JšœŸœ˜—J˜Jšœ ŸœŸœŸœ˜"JšœŸœŸœŸœ˜4J˜JšœŸœŸœŸœ ˜,J˜Jšœ ŸœŸœ˜%šœŸœŸœ˜J˜J˜J˜J˜J˜J˜Jšœ ŸœŸœ˜—J˜Jš’ œŸœŸ œŸœŸœŸœŸœ˜VJš’ œŸœŸ œŸœŸœŸœŸœ Ÿœ˜jJš ’ œŸœŸœŸœŸœ˜>Jš’ œŸœŸœ ŸœŸœŸœŸœ˜SJš’ œŸœŸœŸœ ŸœŸœŸœ Ÿœ ŸœŸœŸœ˜ƒJš’œŸœŸœ ŸœŸœ ŸœŸœ ŸœŸœŸœ˜|J˜Jš’œŸœŸœ ŸœŸœŸœŸœŸœ Ÿœ˜gJ˜Jš œ ŸœŸœŸœŸœŸœ˜)J˜J˜K˜—K˜K™šž™K™Jš’ œŸœŸœŸœ˜3K˜š’ œŸœ˜KšœŸœŸœŸœ˜Kšœ Ÿœ#œ˜5KšŸœ˜—K˜Kš’ œŸœŸœ˜:K˜Kš’ œŸœ Ÿœ˜3K˜š ’œŸœŸœŸœ Ÿœ˜CK˜Kšœ ŸœŸœŸœ˜$—K˜—KšŸœ˜—…—κ.,