Program structure for intermodular analysis

This module contains the functionality to compute the intermodular graph of a program, i.e., the dependencies of its modules.

The predicate compute_intermodule_graph/1 calls the Ciao compiler to obtain which modules are in the intermodular punit, which is controlled by the flag punit_boundary. This is done by:

  • process_changed_module/1: Is executed if the module changed (w.r.t. the .itf file.

  • check_stop_one_module/1: Decides whether the compiler needs to keep processing the modules imported by the current module.

  • redo_unchanged_module/1: Is executed if there were no changes since the last time the module was compiled, if always fails because it is asking whether to process the file again.


Documentation on exports

Usage:compute_punit_modules(TopLevel,ModList,Error)

ModList is the list of modules to analyze. This list is formed by the modules which have their .reg file outdated, or if the module is not completely analyzed (some of the entries in the .reg file are marked or invalid). For those modules which have no .reg file, the parents of the module are included in the list (as there are no call patterns for those modules without

  1. reg file).
The structure of the elements in the list is a term (Mod,Depth,Force), where Mod stands for the module name, Depth is the maximum depth without cycles in the intermodular graph, and Force marks those modules which must be completely reanalyzed (only useful for the parents of the modules with no reg file).

  • The following properties should hold at call time:
    (nonvar/1)TopLevel is currently a term which is not a free variable.
  • The following properties should hold upon exit:
    (nonvar/1)ModList is currently a term which is not a free variable.
    (nonvar/1)Error is currently a term which is not a free variable.
  • The following properties should hold globally:
    (not_fails/1)All the calls of the form compute_punit_modules(TopLevel,ModList,Error) do not fail.
    (is_det/1)All calls of the form compute_punit_modules(TopLevel,ModList,Error) are deterministic.

Usage:get_punit_modules(ModList)

Obtains ModList, the list of modules in the program unit that is currently loaded. This list is formed by the modules which appear in the top-down modular graph traversal with registries set to read_write mode (and including library modules if punit_boundary flag is set to 'on'. compute_punit_modules/2 needs to be called before.

  • The following properties should hold upon exit:
    (nonvar/1)ModList is currently a term which is not a free variable.
    (list/1)ModList is a list.
  • The following properties should hold globally:
    (not_fails/1)All the calls of the form get_punit_modules(ModList) do not fail.
    (is_det/1)All calls of the form get_punit_modules(ModList) are deterministic.

Usage:get_punit_included_files(IncludeList)

Returns the list of included files in the program unit. This list includes not only files explicitly included with :- include declarations, but also packages used. compute_punit_modules/2 needs to be called before.

  • The following properties should hold upon exit:
    (nonvar/1)IncludeList is currently a term which is not a free variable.
    (list/2)IncludeList is a list of filenames.
  • The following properties should hold globally:
    (not_fails/1)All the calls of the form get_punit_included_files(IncludeList) do not fail.
    (is_det/1)All calls of the form get_punit_included_files(IncludeList) are deterministic.

Usage:get_all_module_cycles(TopLevelFile,CycleList)

Obtains CycleList, the list of cycles in the program unit whose top-level module is TopLevelFile. A cycle is a ciclic dependency in the module dependency graph. Every element of CycleList is a list of the modules which belong to each cycle. Modules not belonging to any cycle are represented as one-element lists. CycleList is sorted as a post-order traversal of the inter-cycle dependency graph.

The modules included in CycleList are those which appear in the top-down modular graph traversal with registries set to read_write mode (and including library modules if punit_boundary flag is set to 'on'.)

  • The following properties should hold at call time:
    (nonvar/1)TopLevelFile is currently a term which is not a free variable.
  • The following properties should hold upon exit:
    (nonvar/1)CycleList is currently a term which is not a free variable.
    (list/1)CycleList is a list.
  • The following properties should hold globally:
    (not_fails/1)All the calls of the form get_all_module_cycles(TopLevelFile,CycleList) do not fail.
    (is_det/1)All calls of the form get_all_module_cycles(TopLevelFile,CycleList) are deterministic.

Usage:module_is_processable(Base)

Succeeds if module in Base can be processed by intermodular preprocessing tools. This predicate may have to load the registry file of that module, in order to check that the module has read-write mode.

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

No further documentation available for this predicate.

Usage:read_registry_file(Module,Base,Verb)

Reads the registry file of Module and loads it into registry/2, erasing any previous registry information for that module. Base must be the absolute file name, but excluding file extension.

  • The following properties should hold at call time:
    (nonvar/1)Module is currently a term which is not a free variable.
    (nonvar/1)Base is currently a term which is not a free variable.
    (nonvar/1)Verb is currently a term which is not a free variable.
    (atm/1)Module is an atom.
    (atm/1)Base is an atom.
    (atm/1)Verb is an atom.
  • The following properties should hold globally:
    (not_fails/1)All the calls of the form read_registry_file(Module,Base,Verb) do not fail.
    (is_det/1)All calls of the form read_registry_file(Module,Base,Verb) are deterministic.

Usage:write_registry_file(Base,Module,Verb)

Writes to disk the registry information stored in memory for module Module which has as base file name Base.

  • The following properties should hold at call time:
    (atm/1)Base is an atom.
    (atm/1)Module is an atom.
    (atm/1)Verb is an atom.
  • The following properties should hold globally:
    (not_fails/1)All the calls of the form write_registry_file(Base,Module,Verb) do not fail.
    (is_det/1)All calls of the form write_registry_file(Base,Module,Verb) are deterministic.

PREDICATEopen_mode/3

Usage:open_mode(Base,Type,OpenMode)

Module with basename Base is of type Type and it is opened with mode OpenMode. Type can be user or library. OpenMode is used to indicate if an imported module's registry can be updated. It can take the values read_write or read_only.

    Usage:change_open_mode(Base,OpenMode)

    OpenMode is the new open mode of the module with basename Base. OpenMode can take the values read_write and read_only.

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

    Usage:save_registry_info(Verb,CurrBase,Info)

    Writes on disk the registry information of the modules related to the current module (CurrBase) which have been modified. This information is updated by gen_registry_info/3. Even if this predicate is used, save_registry_info/2 must be used after performing intermodular preprocessing.

    • The following properties should hold at call time:
      (nonvar/1)Verb is currently a term which is not a free variable.
      (nonvar/1)CurrBase is currently a term which is not a free variable.
      (atm/1)Verb is an atom.
      (atm/1)CurrBase is an atom.
      (term/1)Info is any term.
    • The following properties should hold globally:
      (not_fails/1)All the calls of the form save_registry_info(Verb,CurrBase,Info) do not fail.
      (is_det/1)All calls of the form save_registry_info(Verb,CurrBase,Info) are deterministic.

    Usage:save_registry_info(Verb,Info)

    Writes on disk the registry information of the modules loaded into Ciaopp or related to modules loaded into Ciaopp. This information is updated by gen_registry_info/3. This predicate must be called after performing intermodular preprocessing (analysis, specialization...), even if save_registry_info/3 has been used.

    • The following properties should hold at call time:
      (nonvar/1)Verb is currently a term which is not a free variable.
      (atm/1)Verb is an atom.
      (term/1)Info is any term.
    • The following properties should hold globally:
      (not_fails/1)All the calls of the form save_registry_info(Verb,Info) do not fail.
      (is_det/1)All calls of the form save_registry_info(Verb,Info) are deterministic.

    Usage:

    Gets the list of imported modules from the current module. This list is obtained from the itf information of the current module, and is stored in imported_module/1.

    • The following properties should hold globally:
      (not_fails/1)All the calls of the form compute_imported_modules do not fail.
      (is_det/1)All calls of the form compute_imported_modules are deterministic.

    No further documentation available for this predicate.

    Usage:get_modules_analyzed(ModList)

    Returns the list of modules analyzed the last time a modular analysis was executed.

    • The following properties should hold upon exit:
      (list/1)ModList is a list.

    Usage:set_modules_analyzed(ModList)

    Sets the list of modules which have been analyzed.

    • The following properties should hold at call time:
      (list/1)ModList is a list.