UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

43 lines 2.08 kB
"use strict"; 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"); function processGet(name, args, rootId, data) { if (args.length !== 1) { logger_1.dataflowLogger.warn(`symbol access with ${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.unpackArgument)(args[0]); if (retrieve === undefined || retrieve.type !== type_1.RType.String) { logger_1.dataflowLogger.warn(`symbol access with ${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, namespace: undefined }; const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args: (0, make_argument_1.wrapArgumentsUnnamed)([treatTargetAsSymbol], data.completeAst.idMap), rootId, data, origin: 'builtin:get' }); const firstArg = processedArguments[0]; if (firstArg) { // get 'reads' its first argument information.graph.addEdge(rootId, firstArg.entryPoint, edge_1.EdgeType.Reads); } return information; } //# sourceMappingURL=built-in-get.js.map