Preprocessing Unit Handling Library

Author(s): The Ciao Development Team, Manuel Hermenegildo, Francisco Bueno, Jose F. Morales.

This library provides predicates to load, access, modify, and pretty print module preprocessing units . A preprocessing unit of a module is made up of the following elements:

  • the module source (including dependencies, predicates, assertions, declarations, etc.),

  • the assertions for the predicates directly imported by the module,

  • the properties (and their assertions) defined in the modules transitively imported by the module (up to a file that does not export any property).

This is similar to the information stored in compiler/c_itf but extended to include the definitions of the exported and local properties transitively used by assertions of the exported predicates (and properties). This is necessary to be able to correctly interpret such assertions. When loading a preprocessing unit, this library generates .ast files , to cache this information.

Note that this is a superset of the preprocessing unit, since: a) .ast files may contain property definitions (including their assertions) not used in any assertion for an exported predicate b) not all predicates may be imported from a module (and then not all such properties may be actually needed)

Other modules and files in this library:

  • compiler/p_unit/p_unit_db: database of the data collected by the predicates exported by this library (use with care).
  • compiler/p_unit/p_printer: pretty print the current module (source) stored in the program unit database.
  • compiler/p_unit/p_unit_hooks: (included file) hook definitions to customize the behavior for treating native properties, regular types, printing program point information, etc.

Documentation on exports

Usage:preprocessing_unit(Fs,Ms,E,Opts)

Loads the preprocessing unit of Fs defining Ms.

  • The following properties should hold at call time:
    (list/2)Fs is a list of filenames.
    (list/1)Opts is a list.
  • The following properties should hold upon exit:
    (list/2)Ms is a list of moddescs.
    (switch/1)E is an atom indicating yes/no.

PREDICATEprogram/2

Usage:program(P,D)

P are the clauses (no directives) of the current module and D their dictionaries.

  • The following properties should hold at call time:
    (var/1)P is a free variable.
    (var/1)D is a free variable.
  • The following properties should hold upon exit:
    (list/2)P is a list of clauses.
    (list/2)D is a list of varnamedicts.

Usage:filtered_program_clauses(Mods,P,D)

P are the clauses of module Mod and D their dictionaries.

  • The following properties should hold at call time:
    (nonvar/1)Mods is currently a term which is not a free variable.
    (var/1)P is a free variable.
    (var/1)D is a free variable.
    (list/1)Mods is a list.
  • The following properties should hold upon exit:
    (list/1)Mods is a list.
    (list/2)P is a list of clauses.
    (list/2)D is a list of varnamedicts.

Usage:replace_program(P,D)

The database holding the program is updated by first deleting its contents and then adding the clauses in P and dictionaries in D.

  • The following properties should hold at call time:
    (list/2)P is a list of clauses.
    (varnamedict/1)D is a dictionary of variable names.

Usage:native_to_prop(NProp,Prop)

Obtain the user predicate (lit) Prop that corresponds to the native property (lit) NProp.

  • The following properties should hold at call time:
    (nonvar/1)NProp is currently a term which is not a free variable.
    (var/1)Prop is a free variable.

Usage:prop_to_native(Prop,NProp)

Obtain the native property (lit) NProp that corresponds to the (lit) Prop user predicate.

  • The following properties should hold at call time:
    (nonvar/1)Prop is currently a term which is not a free variable.
    (var/1)NProp is a free variable.

Usage:native_to_props(Props,Goals)

Maps native Props into their corresponding Goals (using native_prop_map/3 when needed).

  • The following properties should hold upon exit:
    (list/2)Props is a list of cgoals.
    (list/2)Goals is a list of cgoals.

Usage:dynamic_or_unknown_predicate(Goal)

Goal is an atom for a predicate such that all its clauses might not be available or may change in the program unit.

    No further documentation available for this predicate.

    Usage:add_assertion(Assrt)

    Add assertion Assrt to internal DB.

      Usage:add_directive(C)

      The directive C is added to the program data base. This directive will be considered as read from the program, i.e., analizers, transformations and output will use/show it.

      • The following properties should hold at call time:
        (term/1)C is any term.

      Usage:erase_directive(D)

      Erase directive D (previously added with add_directive/1

      • The following properties should hold at call time:
        (term/1)D is any term.

      Usage:type_of_directive(Type,Body)

      There is a directive of the form :- Type Body (of arity one).

        Usage:pr_key_clean(M)

        Removes all information about predicate order for M.

        • The following properties should hold globally:
          (det/1)Calls of the form pr_key_clean(M) are deterministic.

        PREDICATEpr_key_add/2

        Usage 1:pr_key_add(M,K)

        Add a predicate key (once)

        • The following properties should hold at call time:
          (atm/1)M is an atom.
          (cgoal/1)K is a term which represents a goal, i.e., an atom or a structure.
        • The following properties should hold globally:
          (det/1)Calls of the form pr_key_add(M,K) are deterministic.

        Usage 2:pr_key_add(M,K)

        Add a predicate key (once), extract module from key

        • The following properties should hold at call time:
          (var/1)M is a free variable.
          (cgoal/1)K is a term which represents a goal, i.e., an atom or a structure.
        • The following properties should hold globally:
          (det/1)Calls of the form pr_key_add(M,K) are deterministic.

        PREDICATEpr_key_get/2

        Usage:pr_key_get(M,K)

        Enumerate predicate keys

        • The following properties should hold upon exit:
          (atm/1)M is an atom.
          (cgoal/1)K is a term which represents a goal, i.e., an atom or a structure.
        • The following properties should hold globally:
          (multi/1)Calls of the form pr_key_get(M,K) are multi-deterministic.

        Usage:add_defined_pred(ClKey,M)

        Add the necessary data in itf_db to define the predicate ClKey in the module M.

        • The following properties should hold at call time:
          (term/1)ClKey is any term.
          (atm/1)M is an atom.
        • The following properties should hold globally:
          (det/1)Calls of the form add_defined_pred(ClKey,M) are deterministic.

        Usage:new_predicate(F,A,NewF)

        Checks whether there is a predicate F/A in the program and returns NewF so that there is no predicate NewF/A in the program.

        • The following properties should hold at call time:
          (nonvar/1)F is currently a term which is not a free variable.
          (nonvar/1)A is currently a term which is not a free variable.
          (var/1)NewF is a free variable.
        • The following properties should hold globally:
          (det/1)Calls of the form new_predicate(F,A,NewF) are deterministic.

        Usage:

        Returns the specs of predicates defined in the current punit.

        • Call and exit should be compatible with:
          (list/1)Arg1 is a list.
        • The following properties should hold at call time:
          (var/1)Arg1 is a free variable.

        Usage:

        Returns the specs of predicates defined in the current punit.

        • Call and exit should be compatible with:
          (list/1)Arg1 is a list.
        • The following properties should hold at call time:
          (var/1)Arg1 is a free variable.

        Usage:inject_output_package(A)

        Inject the package A in the current program database (including the output package list). The necesary information from these packages is loaded for correct treatment and unexpansion.

        • The following properties should hold at call time:
          (atm/1)A is an atom.

        Usage:add_output_package(A)

        Add the package A to the output packages list

        • The following properties should hold at call time:
          (atm/1)A is an atom.

        Usage:get_output_package(X)

        X is a package that will be included in the output (module directive).

          Usage:add_output_operator(Prec,Type,OP)

          Define an operator for output (same arguments as in op/3).

          • The following properties should hold at call time:
            (int/1)Prec is an integer.
            (atm/1)Type is an atom.
            (atm_or_atm_list/1)OP is an atom or a list of atoms.

          Usage:get_output_operator(Pred,Type,OP)

          Enumerate output operators (same arguments as in op/3).

          • The following properties should hold upon exit:
            (int/1)Pred is an integer.
            (atm/1)Type is an atom.
            (atm_or_atm_list/1)OP is an atom or a list of atoms.

          PREDICATEadd_comment/1

          Usage:add_comment(Comment)

          Add comment to the comment db

          • The following properties should hold at call time:
            (string/1)Comment is a string (a list of character codes).

          PREDICATEget_comment/1

          Usage:get_comment(Comment)

          Retrieves comments from the comment db

          • The following properties should hold upon exit:
            (string/1)Comment is a string (a list of character codes).

          Usage:

          Cleans up the comment db

            No further documentation available for this predicate.

            No further documentation available for this predicate.

            Usage:

            Clean up all facts that p_unit asserts.

              Usage:get_call_from_call_assrt(Sg,M,Status,Call,Source,LB,LE)

              Returns in Call, upon backtracking call patterns from calls assertions related to Sg, in module M. Also takes care of disjunctions.

                PREDICATEp_unit_log/1
                No further documentation available for this predicate.

                No further documentation available for this predicate.

                Usage:get_pred_mod_defined(Sg,Mod)

                Returns the module where a predicate given by goal Sg is defined. If the Sg is multifile, the modules where it is defined are enumerated.

                • The following properties should hold at call time:
                  (nonvar/1)Sg is currently a term which is not a free variable.
                  (var/1)Mod is a free variable.
                • The following properties should hold globally:
                  (nondet/1)Calls of the form get_pred_mod_defined(Sg,Mod) are non-deterministic.

                No further documentation available for this predicate.

                No further documentation available for this predicate.

                No further documentation available for this predicate.

                No further documentation available for this predicate.

                No further documentation available for this predicate.

                Usage:

                Cleans up libcache.

                  Usage:

                  Checks if the libcache is loaded

                    Usage:load_libcache(DataDir)

                    Load the preprocessed library cache (specified in the core/Manifest/core.libcache.pl module.

                      Usage:gen_libcache(DataDir)

                      Generate the preprocessed library cache (specified in the core/Manifest/core.libcache.pl module. .

                        (UNDOC_REEXPORT)type_of_goal/2
                        Imported from p_unit_basic (see the corresponding documentation for details).

                        Documentation on multifiles

                        PREDICATEdefine_flag/3

                        Usage:define_flag(Flag,FlagValues,Default)

                        • The following properties hold upon exit:
                          (atm/1)Flag is an atom.
                          (flag_values/1)Define the valid flag values
                        The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.

                        No further documentation available for this predicate. The predicate is multifile.