FunctionRewriter class

(Shortest import: from brian2.parsing.functions import FunctionRewriter)

class brian2.parsing.functions.FunctionRewriter(func, numcalls=0)[source]

Bases: ast.NodeTransformer

Inlines a function call using temporary variables

numcalls is the number of times the function rewriter has been called so far, this is used to make sure that when recursively inlining there is no name aliasing. The substitute_abstract_code_functions ensures that this is kept up to date between recursive runs.

The pre attribute is the set of lines to be inserted above the currently being processed line, i.e. the inline code.

The visit method returns the current line processed so that the function call is replaced with the output of the inlining.