% $Id: NewPortObjectDebug.oz,v 1.1 2008/11/17 19:33:32 leavens Exp leavens $ % Debugging versions of NewPortObject \insert 'NewPortObject.oz' declare % Curried function to generate a function that, for a given Depth and Width, % will return a function that when given an initial state and message function, % will act like NewPortObject but will % print starting state and message for each message processed in the emulator. fun {NewPortObjectDebugCallsMaker Depth Width} fun {$ Init Fun} {NewPortObject Init fun {$ State Msg} {System.showInfo 'In state: '#{Value.toVirtualString State Depth Width}} {System.showInfo ' with message: '#{Value.toVirtualString Msg Depth Width}} {Fun State Msg} end} end end % Curried function to generate a function that, for a given Depth and Width, % will return a function that when given an initial state and message function, % will act like NewPortObject but will % print the resulting state for each message processed in the emulator. fun {NewPortObjectDebugNewStateMaker NPO Depth Width} fun {$ Init Fun} {NPO Init fun {$ State Msg} local NewState = {Fun State Msg} in {System.showInfo 'New state: '#{Value.toVirtualString NewState Depth Width}#"\n"} NewState end end} end end % Acts like NewPortObject but will % print starting state and message for each message processed in the emulator. fun {NewPortObjectDebugCalls Init Fun} {{NewPortObjectDebugCallsMaker 5 20} Init Fun} end % Acts like NewPortObject but will % print the resulting state for each message processed in the emulator. fun {NewPortObjectDebugNewState Init Fun} {{NewPortObjectDebugNewStateMaker NewPortObject 5 20} Init Fun} end % Acts like NewPortObject but will % print starting state and message for each message processed % and the resulting state for each message processed in the emulator. fun {NewPortObjectDebug Init Fun} {{NewPortObjectDebugNewStateMaker NewPortObjectDebugCalls 5 20} Init Fun} end