getGlobalVariables: Get global variables in a source file

View source: R/collectors.R

getGlobalVariablesR Documentation

Get global variables in a source file

Description

getGlobalVariables finds the global variables in a source file or translation unit.

findGlobals finds the use of non-local variables in a translation unit, routine or expression.

Usage

getGlobalVariables(tu, fileFilter = character(), visitor = genGlobalVariablesCollector(), ...)
findGlobals(tu, fileFilter = character(), merge = TRUE, ignoreConst = TRUE, 
             visitor = genRoutineVariableRefsCollector(merge, ignoreConst), ...)

Arguments

tu

either the name of a source file or an already parsed translation unit object

fileFilter

a character vector. This is used to identify the files/directories of interest and to identify the cursors we want in the results. This can be a single string that is a regular expression. Alternatively, it can be a vector of directory or file names. For a vector of values, we check which correspond to actual file or directory names. For these, we filter the cursors based on whether they are in the specified file names, within files in the specified directories. For elements that are not files or directories, we use these as regular expressions. This mechanism allows us to include cursors by explicit file name, explicit directory, or by regular expression.

visitor

a function or S4/reference class object used as the visitor function passed to visitCursor to collect the enumeration definitions.

...

arguments passed createTU if src is the name of source file.

merge

a logical value. If TRUE, separate the global variables from the local variables/routines. ??Does this make sense??

ignoreConst

a logical value. If TRUE, we ignore variables that have a const qualifier that indicates they cannot be modified, i.e., they are constants.

Value

A list of the global variables.

See Also

getRoutines, getCppClasses, getDataStructures, getEnums, getInclusions

Examples

f = system.file("exampleCode", "globalUse.c",  package = "RCIndex")
getGlobalVariables(f)

omegahat/RClangSimple documentation built on April 25, 2024, 4:18 a.m.