@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
47 lines • 2.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.processGet = processGet;
const known_call_handling_1 = require("../known-call-handling");
const unpack_argument_1 = require("../argument/unpack-argument");
const make_argument_1 = require("../argument/make-argument");
const logger_1 = require("../../../../../logger");
const retriever_1 = require("../../../../../../r-bridge/retriever");
const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
const edge_1 = require("../../../../../graph/edge");
const identifier_1 = require("../../../../../environments/identifier");
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
/**
* Processes a built-in 'get' function call.
*/
function processGet(name, args, rootId, data) {
if (args.length !== 1) {
logger_1.dataflowLogger.warn(`symbol access with ${identifier_1.Identifier.toString(name.content)} has not 1 argument, skipping`);
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
}
const retrieve = (0, unpack_argument_1.unpackNonameArg)(args[0]);
if (retrieve === undefined || retrieve.type !== type_1.RType.String) {
logger_1.dataflowLogger.warn(`symbol access with ${identifier_1.Identifier.toString(name.content)} has not 1 argument, skipping`);
return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
}
const treatTargetAsSymbol = {
type: type_1.RType.Symbol,
info: retrieve.info,
content: (0, retriever_1.removeRQuotes)(retrieve.lexeme),
lexeme: retrieve.lexeme,
location: retrieve.location
};
const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({
name,
args: (0, make_argument_1.wrapArgumentsUnnamed)([treatTargetAsSymbol], data.completeAst.idMap),
rootId,
data,
origin: built_in_proc_name_1.BuiltInProcName.Get
});
const firstArg = processedArguments[0];
if (firstArg) {
// get 'reads' its first argument
information.graph.addEdge(rootId, firstArg.entryPoint, edge_1.EdgeType.Returns | edge_1.EdgeType.Reads);
}
return information;
}
//# sourceMappingURL=built-in-get.js.map