UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

30 lines 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.overwriteEnvironment = overwriteEnvironment; const scoping_1 = require("./scoping"); /** * Assumes, that all definitions within next replace those within base (given the same name). * <b>But</b> if all definitions within next are maybe, then they are appended to the base definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironment}. * @see {@link Environment.overwrite} - for details on how definitions are handled. */ function overwriteEnvironment(base, next, applyCds) { if (base === undefined) { return next; } else if (next === undefined) { return base; } if (base.level !== next.level) { while (next.level < base.level) { next = (0, scoping_1.pushLocalEnvironment)(next); } while (next.level > base.level) { base = (0, scoping_1.pushLocalEnvironment)(base); } } return { current: base.current.overwrite(next.current, applyCds), level: base.level }; } //# sourceMappingURL=overwrite.js.map