## note.api
#
# User definable annotations.
#
# Note: annotations will henceforth be used
# extensively in all parts of the optimizer.
#
# Idea is stolen from Stephen Weeks
#
# -- Allen Leung
# Compiled by:
#
src/lib/std/standard.libapi Note {
Note;
Notes = List( Note );
exception NO_NOTE_FOUND;
Notekind(X)
=
{ get: Notes -> Null_Or(X),
peek: Note -> Null_Or(X),
lookup: Notes -> X,
is_in: Notes -> Bool, # TRUE iff a note of our kind is present in given Notes list.
set: (X, Notes) -> Notes,
rmv: Notes -> Notes,
x_to_note: X -> Note
};
Flag = Notekind( Void );
# Make a new kind of note.
# Client should provide a prettyprinting function.
make_notekind: Null_Or( X -> String ) -> Notekind(X);
make_notekind'
:
{ to_string: X -> String,
get: Exception -> X,
x_to_note: X -> Exception
}
->
Notekind(X);
to_string # Pretty print an annotation
:
Note -> String;
attach_prettyprinter # Attach a pretty printer
:
(Note -> String) -> Void;
};