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, the emptyenv, 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.

  • define - to define a new IdentifierDefinition|identifier definition within an environment
  • resolveByName - to resolve an Identifier|identifier/name to its IdentifierDefinition|definitions within an environment
  • makeReferenceMaybe - to attach control dependencies to a reference
  • pushLocalEnvironment - to create a new local scope
  • popLocalEnvironment - to remove the current local scope
  • appendEnvironment - to append an environment to the current one
  • overwriteEnvironment - to overwrite the definitions in the current environment with those of another one
interface REnvironmentInformation {
    current: IEnvironment;
    level: number;
}

Implemented by

Properties

Properties

current: IEnvironment

The currently active environment (the stack is represented by the currently active IEnvironment#parent). Environments are maintained within the dataflow graph.

level: number

nesting level of the environment, will be 0 for the global/root environment