UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

41 lines 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.processRm = processRm; const known_call_handling_1 = require("../known-call-handling"); const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call"); const logger_1 = require("../../../../../logger"); const remove_1 = require("../../../../../environments/remove"); const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type"); function processRm(name, args, rootId, data) { if (args.length === 0) { logger_1.dataflowLogger.warn('empty rm, skipping'); return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information; } const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'builtin:rm' }).information; const names = []; for (const arg of args) { if (arg === r_function_call_1.EmptyArgument) { logger_1.dataflowLogger.warn('empty argument in rm, skipping'); continue; } const unpacked = arg.value; if (unpacked === undefined || (unpacked.type !== type_1.RType.Symbol && unpacked.type !== type_1.RType.String)) { logger_1.dataflowLogger.warn(`argument is not a symbol or string, skipping ${JSON.stringify(unpacked)}`); } else if (unpacked.type === type_1.RType.Symbol) { names.push(unpacked.content); } else if (unpacked.type === type_1.RType.String) { names.push(unpacked.content.str); } } let env = res.environment; for (const name of names) { env = (0, remove_1.remove)(name, env); } return { ...res, environment: env }; } //# sourceMappingURL=built-in-rm.js.map