UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

28 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cloneEnvironmentInformation = cloneEnvironmentInformation; const environment_1 = require("./environment"); function cloneEnvironment(environment, recurseParents) { if (environment === undefined) { return undefined; } else if (environment.id === environment_1.BuiltInEnvironment.id) { return environment_1.BuiltInEnvironment; } /* make sure the clone has the same id */ const clone = new environment_1.Environment(recurseParents ? cloneEnvironment(environment.parent, recurseParents) : environment.parent); clone.memory = new Map(JSON.parse(JSON.stringify([...environment.memory]))); return clone; } /** * Produce a clone of the given environment information. * @param environment - The environment information to clone. * @param recurseParents - Whether to clone the parent environments as well. */ function cloneEnvironmentInformation(environment, recurseParents = true) { return { current: cloneEnvironment(environment.current, recurseParents), level: environment.level }; } //# sourceMappingURL=clone.js.map