@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
56 lines • 2.13 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UnsupportedFunctions = void 0;
const identifier_1 = require("../dataflow/environments/identifier");
const vertex_1 = require("../dataflow/graph/vertex");
const record_1 = require("../util/record");
function unsupportedFunctions(functions) {
return record_1.Record.entries(functions).map(([identifier, info]) => ({ identifier: identifier_1.Identifier.parse(identifier), ...info }));
}
/**
* List of known function calls that may change the environment unresolvable/implicitly.
*/
const UnsupportedFunctionsList = unsupportedFunctions({
'base::.Primitive': {},
'base::.Internal': {},
'base::.External': {},
'base::.Call': {},
'base::.C': {},
'base::.Fortran': {},
'base::.dyn.load': {},
'base::eval': {},
'base::evalq': {},
'base::eval.parent': {},
'rlang::eval_tidy': {},
'rlang::eval_bare': {},
'base::body<-': {},
'base::formals<-': {},
'base::environment<-': {},
'base::load': {},
'base::attach': {},
'base::detach': {},
'base::rm': {},
'base::remove': {},
'base::list2env': {},
'base::assign': { condition: (vertex, dfg) => dfg.unknownSideEffects.has(vertex.id) },
'base::delayedAssign': { condition: (vertex, dfg) => dfg.unknownSideEffects.has(vertex.id) },
'utils::assignInNamespace': {},
'utils::assignInMyNamespace': {},
});
/**
* Helper for unsupported functions that may change the environment.
*/
exports.UnsupportedFunctions = {
name: 'UnsupportedFunctions',
/**
* Checks whether a data flow graph vertex represents an unsupported (environment-changing) function call (e.g. `eval`, `load`, `attach`, `rm`, ...)
*/
isUnsupportedCall(vertex, dfg) {
if (!vertex_1.FunctionCallVertex.is(vertex)) {
return false;
}
const entry = UnsupportedFunctionsList.find(entry => identifier_1.Identifier.matches(vertex.name, entry.identifier));
return entry !== undefined && (entry.condition?.(vertex, dfg) ?? true);
}
};
//# sourceMappingURL=unsupported-functions.js.map