next up previous contents index
Next: Scenario ``display'' Up: Morphine - Reference Manual Previous: Scenario ``morphine_kernel''

Subsections

     
Scenario ``source''

Scenario source provides commands to retrieve and display Mercury source (and intermediate) code.

Commands

listing(Module, ProcOrType, Listing) {ls}    
Retrieves the source code of a Mercury procedure or a Mercury type ProcOrType defined in the module Module and unifies it in Listing. Module can be either a library or a user defined module. Note: to be able to retrieve library procedures or types with listing/3, you need to have the source of the Mercury library somewhere and you need to make sure that the environment variable LIB_MERCURY has been set correctly to the path of the Mercury library in the sh script Morphine.
Module : is_atom_or_string
ProcOrType : is_mercury_proc_or_type
Listing : is_list_or_var
type of command : opium

listing(Module, PredOrFuncOrType) {ls}    
listing/2 is the same command as listing/3 except it prints the listing of the code on the standard output.

Example:

1.
listing(foo, bar/3, List) unify List with the list of terms defining the Mercury predicate bar/3.
2.
listing(``~/dir/foo'', bar) will display all the predicates bar/n defined in the module foo which is in ``~/dir/'' directory.
3.
listing(io, io__read/3) will display the source of the Mercury library predicate io__read/3 defined in the Mercury module io.


Module : is_atom_or_string
PredOrFuncOrType : is_mercury_proc_or_type
type of command : opium

listing_hlds(Module, PredOrFuncOrType, Listing)    
See listing_hlds/2.
Module : is_atom_or_string
PredOrFuncOrType : is_mercury_proc_or_type
Listing : is_list_or_var
type of command : opium

listing_hlds(Module, PredOrFuncOrType)    
listing_hlds/2 and listing_hlds/3 are the same commands as listing/2 and listing/3 except they will list the HLDS procedures instead of the source code. To be able to list such HLDS code, you need to compile your module with ``-dfinal'' option.
Module : is_atom_or_string
PredOrFuncOrType : is_mercury_proc_or_type
type of command : opium

listing_current_procedure {lcp}    
listing_current_procedure/0 prints the source code of the current procedure on the user window. If the current procedure is defined in a file that is not in the current directory, you need to specify the path of this file with listing_current_procedure/1.
type of command : opium

listing_current_procedure(Path) {lcp}    
listing_current_procedure/1 is the same as listing_current_procedure/0 except you specify the path of the module of the current procedure.
Path : atom
type of command : opium

Types

is_mercury_proc_or_type    
Type which succeeds if its argument is of the form Name or Name/Arity, where Name is an atom and Arity an integer.

is_atom_or_string    
Type which succeed for an atom or a string.


next up previous contents index
Next: Scenario ``display'' Up: Morphine - Reference Manual Previous: Scenario ``morphine_kernel''
jahier@irisa.fr