UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

39 lines 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.processSpecialBinOp = processSpecialBinOp; const known_call_handling_1 = require("../known-call-handling"); const logger_1 = require("../../../../../logger"); const edge_1 = require("../../../../../graph/edge"); const identifier_1 = require("../../../../../environments/identifier"); const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name"); /** * Process a special built-in binary operator, possibly lazily. * Only `&&`/`||` short-circuit: their right-hand side gets a control dependency and only the left is read. * The vectorized `&`/`|` evaluate both and hence use `lazy: false`. * Not related to R's special binary operators like `%in%`. */ function processSpecialBinOp(name, args, rootId, data, config) { if (args.length != 2) { logger_1.dataflowLogger.warn(`Logical bin-op ${identifier_1.Identifier.toString(name.content)} has something else than 2 arguments, skipping`); return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'default' }).information; } const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, patchData: (d, i) => { if (config.lazy && i === 1) { return { ...d, cds: [...d.cds ?? [], { id: rootId, when: config.evalRhsWhen ?? true }] }; } return d; }, origin: built_in_proc_name_1.BuiltInProcName.SpecialBinOp }); for (const arg of processedArguments) { if (arg) { information.graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.Reads); } if (config.lazy) { break; } } return information; } //# sourceMappingURL=built-in-special-bin-op.js.map