getInOutArgs: Determine which parameters are also output values

Description Usage Arguments Details Author(s) See Also Examples

Description

This function (and the collection of supporting methods for recursive processing of the nodes) attempts to determine whether any of the mutable parameters, i.e. pointers or references, are actually modified with the body of the routine. If they are, these are probably out variables that we would want to return to the R user in a call to the specified routine.

This is incomplete at present and more a working prototype for people to add methods for new cases.

It does not try to determine inout variables, but just out. An inout parameter is one whose value is also used as an input to the code, i.e. is on the right hand side or in a call to another routine within the code and not just assigned a value.

Usage

1
getInOutArgs(routine, nodes, params = list())

Arguments

routine

the resolved routine of interest. In the future, we will add support for working with the simple routine description or node returned from getRoutines, i.e. one will not have to resolve the routine, although this is not typically a hardship.

nodes

the parser, i.e. array of nodes. This is the return value from parseTU and is a reference to a Perl object of class GCC::TranslationUnit::Parser.

params

this is not usually specified by the top-level caller but calculated from the definition of the routine and passed to the recursive calls. This is the character vector giving the index or identifier of the parm_decl nodes corresponding to the mutable parameters of the routine.

Details

We need to enhance this to deal with assignments to local variables which are themselves modified. Also, we need to add a mechanism to identify the routines that are called with any of these parameters and the identity of the parameters so we can recursively determine things.

Author(s)

Duncan Temple Lang

See Also

createMethodBinding getCallGraph

Examples

1
2
3
4
5
6
 filename = system.file("examples", "inout", "inout.c.tu", package = "RGCCTranslationUnit")
 o = parseTU(filename)
 rr = getRoutines(o, "inout.c")
 routines = resolveType(rr, o)
 getInOutArgs(routines$foo, o)
 getInOutArgs(routines$bar, o)

omegahat/RGCCTranslationUnit documentation built on May 24, 2019, 1:53 p.m.