Readonly
currentThe currently active environment (the stack is represented by the currently active IEnvironment#parent). Environments are maintained within the dataflow graph.
Readonly
levelnesting level of the environment, will be 0
for the global/root environment
An environment describes a (scoped) mapping of names to their definitions (BuiltIns).
First, yes, R stores its environments differently, potentially even with another differentiation between the
baseenv
, theemptyenv
, and other default environments (see https://adv-r.hadley.nz/environments.html). Yet, during the dataflow analysis, we want sometimes to know more (static IdentifierDefinition|reference information) and sometimes know less (to be honest, we do not want that, but statically determining all attached environments is theoretically impossible --- consider attachments by user input).One important environment is the BuiltIns|BuiltInEnvironment which contains the default definitions for R's built-in functions and constants. Please use initializeCleanEnvironments to initialize the environments (which includes the built-ins). During serialization, you may want to rely on the builtInEnvJsonReplacer to avoid the huge built-in environment.
See