This interface provides an object for maintaining a trace of program flow and controlling the amount of debug printing done at run-time.
By surrounding each section of code by an appropriate push()
and
pop()
call, at any time the stack of tags can be retrieved and
printed or used as an exception argument, for example.
Furthermore, the parameter p
is used to control the printing of
tags and other debugging output during run time. If a tag is
push()
ed with a lower p
than the Debug.T
object was
initialized with, it is printed immediately. Similarly, a call to
print()
only results in output if its p
argument is less than
the value of the Debug.T
object.
INTERFACEDebug ; IMPORT Atom, AtomList; TYPE T <: Public; Public = OBJECT METHODS init(name: TEXT; p: INTEGER): T; push(p: INTEGER; tag: Atom.T); pop (p: INTEGER); print(p: INTEGER; text: TEXT); getList(): AtomList.T; getText(): TEXT; crash (t: TEXT; al: AtomList.T); END; PROCEDURE AtomListToText (al: AtomList.T) : TEXT; PROCEDURE PrintAtomList (t: TEXT; al: AtomList.T); PROCEDURE Crash (t: TEXT; al: AtomList.T); END Debug.