This library provides a static mode analysis tool for ECLiPSe programs. It takes as input a Prolog program and a goal pattern, and performs an analysis of the modes that the predicates in the program will be called with, given the specified goal pattern. The mode analyser is loaded with
:- lib(modes).The usage is simple. The predicate read_source/1 is used to read in the source file to be analysed. The predicate analyze/1 starts the analysis with a given call pattern and prints the results in the form of a compilable mode declaration:
Restrictions: Programs that use coroutining features cannot be analysed.[eclipse 2]: read_source(qsort). reading qsort yes. [eclipse 3]: analyze(qsort(++,-)). % Analysed 3 call patterns of 3 predicates in 0.05 sec % Number of pending goals: 29 % Global Stack used: 12892 :- mode partition(++, ++, -, -). :- mode qsort(++, -). :- mode qsort(++, -, ++). yes. [eclipse 4]: analyze(qsort(+,-)). % Analysed 4 call patterns of 3 predicates in 0.13 sec % Number of pending goals: 54 % Global Stack used: 35968 :- mode partition(?, ?, -, -). :- mode qsort(+, -). :- mode qsort(+, -, +). yes.