DIRECTORY Core, IO, Rope, RoseBehavior, RoseControl, RoseValuing, RoseWireTypes; RoseValuingImpl: CEDAR PROGRAM IMPORTS IO, RoseControl EXPORTS RoseValuing = BEGIN OPEN RoseValuing, RC: RoseControl, RWT: RoseWireTypes; Ptr: TYPE = RC.Ptr; RoseWire: TYPE = RC.RoseWire; RoseWireType: TYPE = RC.RoseWireType; NotificationRegistration: TYPE = REF NotificationRegistrationPrivate; NotificationRegistrationPrivate: PUBLIC TYPE = RECORD [ ctlNR: RC.NotificationRegistration, event: Event, wire: Wire, sim: Simulation, format: Format, notify: EventConsumerProc, data: REF ANY _ NIL ]; GetBool: PUBLIC PROC [w: Wire, s: Simulation] RETURNS [b: BOOL] = { rw: RoseWire = RC.LookupRoseWire[s, w]; Consume: PROC [rwt: RoseWireType, ptr: Ptr] = { SELECT rwt FROM RC.boolType => b _ RC.ReadBool[ptr]; RC.bitType => b _ SELECT RC.ReadSwitch[ptr].val FROM L => FALSE, H => TRUE, X => ERROR, ENDCASE => ERROR; ENDCASE => ERROR; }; RC.ExhibitValue[rw, Consume]; }; SetBool: PUBLIC PROC [w: Wire, s: Simulation, b: BOOL, fs: ForceScope] = { rw: RoseWire = RC.LookupRoseWire[s, w]; Produce: PROC [rwt: RoseWireType, ptr: Ptr] = { SELECT rwt FROM RC.boolType => RC.WriteBool[ptr, b]; RC.bitType => RC.WriteSwitch[ptr, [s: ALL[none], val: IF b THEN H ELSE L]]; ENDCASE => ERROR; }; RC.SetForce[rw, fs]; RC.ExhibitValue[rw, Produce]; }; GetLevel: PUBLIC PROC [w: Wire, s: Simulation] RETURNS [l: RoseBehavior.Level] = { rw: RoseWire = RC.LookupRoseWire[s, w]; Consume: PROC [rwt: RoseWireType, ptr: Ptr] = { SELECT rwt FROM RC.boolType => l _ IF RC.ReadBool[ptr] THEN H ELSE L; RC.bitType => l _ RC.ReadSwitch[ptr].val; ENDCASE => ERROR; }; RC.ExhibitValue[rw, Consume]; }; SetLevel: PUBLIC PROC [w: Wire, s: Simulation, l: RoseBehavior.Level, fs: ForceScope] = { rw: RoseWire = RC.LookupRoseWire[s, w]; Produce: PROC [rwt: RoseWireType, ptr: Ptr] = { SELECT rwt FROM RC.boolType => RC.WriteBool[ ptr, SELECT l FROM L => FALSE, H => TRUE, X => ERROR, ENDCASE => ERROR ]; RC.bitType => RC.WriteSwitch[ptr, [s: ALL[none], val: l]]; ENDCASE => ERROR; }; RC.SetForce[rw, fs]; RC.ExhibitValue[rw, Produce]; }; formatName: ARRAY Format OF ROPE = [ idiosyncratic: "idiosyncratic", num2: "2", num4: "4", num8: "8", num16: "16" ]; GetRope: PUBLIC PROC [w: Wire, s: Simulation, f: Format] RETURNS [r: ROPE] = { rw: RoseWire = RC.LookupRoseWire[s, w]; Consume: PROC [rwt: RoseWireType, ptr: Ptr] = { fmt: RWT.Format = rwt.class.super.GetFormat[rwt, formatName[f]]; r _ fmt.FormatValue[rwt, fmt, ptr]; }; RC.ExhibitValue[rw, Consume]; }; SetRope: PUBLIC PROC [w: Wire, s: Simulation, f: Format, r: ROPE, fs: ForceScope] RETURNS [success: BOOL] = { rw: RoseWire = RC.LookupRoseWire[s, w]; Produce: PROC [rwt: RoseWireType, ptr: Ptr] = { fmt: RWT.Format = rwt.class.super.GetFormat[rwt, formatName[f]]; success _ fmt.ParseValue[rwt, fmt, ptr, IO.RIS[r]]; }; RC.SetForce[rw, fs]; RC.ExhibitValue[rw, Produce]; }; AddNotification : PUBLIC PROC [ event: Event, wire: Wire, sim: Simulation, format: Format, notify: EventConsumerProc, data: REF ANY _ NIL] RETURNS [registration: NotificationRegistration] = { rw: RoseWire = RC.LookupRoseWire[sim, wire]; registration _ NEW [NotificationRegistrationPrivate _ [ ctlNR: NIL, event: event, wire: wire, sim: sim, format: format, notify: notify, data: data ]]; registration.ctlNR _ RC.AddNotification[ event: event, on: rw, notify: Notify, data: registration ]; }; Notify : PROC [ event: Event, on: RoseWire, type: RoseWireType, ptr: Ptr, data: REF ANY] = { nr: NotificationRegistration = NARROW[data]; r: ROPE _ NIL; SELECT event FROM NewQ, NewUD, NewVal => { fmt: RWT.Format = type.class.super.GetFormat[type, formatName[nr.format]]; r _ fmt.FormatValue[type, fmt, ptr]; }; Perturbed, Found => NULL; ENDCASE => ERROR; nr.notify[event, nr.wire, nr.sim, r, nr.data]; }; RemoveNotification: PUBLIC PROC [registration: NotificationRegistration] = { nr: NotificationRegistration = NARROW[registration]; RC.RemoveNotification[nr.ctlNR]; }; END. „RoseValuingImpl.Mesa Spreitzer, October 25, 1985 8:11:01 pm PDT Valid for {NewQ, NewUD, NewVal}, but not {Perturbed, Found}. Κχ– "cedar" style˜code™K™*—K˜KšΟk œœ>˜PK˜šΠbxœœ˜Kšœœ ˜Kšœ ˜Kšœ˜K˜—Kšœœœœ˜