findAssignTo: Find variable declarations and assignments.

View source: R/assignTo.R

findAssignToR Documentation

Find variable declarations and assignments.

Description

This finds the variable declarations and assignments to variables in an abstract syntax tree.

Usage

findAssignTo(cur, var = character(), collector = genDeclAssignCollector())

Arguments

cur

the starting CXCursor

var

a character vector of zero or more variable names. If this is non-empty, only declarations and assignments to variables in this vector are included in the result.

collector

the closures that collect the assignments/declarations as we iterate over the abstract syntax tree.

Value

A list of zero or more CXCursor objects.

Author(s)

Duncan Temple Lang

See Also

createTU getVariables

Examples

f = system.file("exampleCode/assignment.c", package = "RCIndex")
tu = createTU(f)

# All assignments
asgn = findAssignTo(tu)
table(names(asgn))


# Get the declarations and assignments for variables and and b
b = findAssignTo(tu, c("a", "b"))

# Just b
b = findAssignTo(tu, "b")

omegahat/RClangSimple documentation built on Aug. 17, 2024, 10:23 a.m.