Learn R Programming

SpaDES.core (version 2.0.5)

.findElementsInEnv: Find all references to sim$

Description

Find all references to sim$

.parsingSim will pull out the various ways to use sim, e.g., sim$xxx, sim[["xxx"]], sim[[P(sim)$xxx]]

Usage

.findElementsInEnv(
  envToFindSim = parent.frame(),
  moduleEnv = parent.frame(),
  type
)

.findElement(x, type)

.parsingSim(x, type)

Value

A character string with all sim objects found.

Arguments

envToFindSim

An environment where sim is defined. This is used when the element accessing the simList is actually a call, e.g., sim[[P(sim)$stackName]]

moduleEnv

The environment where the module functions are.

type

Either "get", "assign", or "globals". See details.

x

A call in which to search for sim

Author

Eliot McIntire

Details

.findElementsInEnv is a wrapper around .findElements. It will convert function code to a call, and then pass it to .findElements. It also does some cleaning for duplications, NA values, and cases where the element inside a sim[["xxx"]] is a variable that should be evaluated, rather than simply taken verbatim (e.g., sim[[P(sim)$stackName]]).

When type = "get", the function scans for sim$xxx or sim[["xxx"]]] on the RHS of an assignment operator or when there is no assignment. When type = "assign", the function scans for sim$xxx or sim[["xxx"]] on the LHS of an assignment operator. When type = "globals", the function scans for all functions (i.e., "globals") being used. This is similar to codetools::findGlobals(), but faster.

.findElement will omit whatever it finds inside a is.null(), when type = "assign". Usually this is a test of existence of that object, in order to assign to that object. It is only reading it to determine whether or not it should write to it.