CodeTools[ProgramAnalysis] - Maple Programming Help

Home : Support : Online Help : Programming : CodeTools : Program Analysis : CodeTools/ProgramAnalysis/StaticCallGraph

CodeTools[ProgramAnalysis]

 StaticCallGraph
 create a static call graph from a Maple procedure

 Calling Sequence StaticCallGraph(P, opts)

Parameters

 P - Maple procedure, appliable module, or set of procedures or appliable modules opts - one or more options as described below

Options

 The options argument can contain one or more of the options shown below.
 • maxdepth=posint or infinity
 The maximum depth of procedure calls to examine. The default is infinity, meaning the static call graph is traversed to arbitrary depth.

Description

 • StaticCallGraph(P) returns a directed graph which represents a static call graph for the input P. The vertices of the graph are strings which represent procedures or appliable modules, and a directed arc exists from f to g when there is an explicit reference to g in the body of f.
 • The output is a Maple graph suitable for use with commands from the GraphTheory package.
 • This command generates only simple graphs; recursive calls in a procedure body are not translated into self-loops in the resulting graph.
 • This command simply examines the procedure body for instances of procedure names. There are many methods of invoking a procedure in Maple (for example, by constructing the procedure's name with cat or parse) which this command makes no effort to detect.

Examples

 > $\mathrm{with}\left(\mathrm{CodeTools}\left[\mathrm{ProgramAnalysis}\right]\right):$
 > $G≔\mathrm{StaticCallGraph}\left(\mathrm{maximize},\mathrm{maxdepth}=2\right)$
 ${G}{≔}{\mathrm{Graph 1: a directed unweighted graph with 22 vertices and 24 arc\left(s\right)}}$ (1)
 > $\mathrm{GraphTheory}:-\mathrm{Vertices}\left(G\right)$
 $\left[{"NumericEventHandler"}{,}{"convert"}{,}{"evalf"}{,}{"has"}{,}{"hastype"}{,}{"indets"}{,}{"length"}{,}{"max"}{,}{"maximize"}{,}{"min"}{,}{"minimize"}{,}{"minimize/Handler"}{,}{"minimize/cell/check"}{,}{"nops"}{,}{"op"}{,}{"select"}{,}{"selectremove"}{,}{"seq"}{,}{"simplify"}{,}{"sort"}{,}{"subs"}{,}{"type"}\right]$ (2)
 > $\mathrm{GraphTheory}:-\mathrm{DrawGraph}\left(G,\mathrm{style}=\mathrm{spring}\right)$

Compatibility

 • The CodeTools[ProgramAnalysis][StaticCallGraph] command was introduced in Maple 2020.