UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

32 lines 964 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFunctionRecursive = isFunctionRecursive; const vertex_1 = require("../graph/vertex"); /** * Determines whether the function with the given ID is recursive. */ function isFunctionRecursive(id, graph) { const vert = graph.getVertex(id); if (!(0, vertex_1.isFunctionDefinitionVertex)(vert)) { return false; } const seen = new Set(); const toVisit = [id]; let gotStart = 0; while (toVisit.length > 0) { const currentId = toVisit.pop(); if (currentId === id && gotStart++ > 0) { return true; } if (seen.has(currentId)) { continue; } seen.add(currentId); const out = graph.outgoingEdges(currentId)?.keys() ?? []; for (const nextId of out) { toVisit.push(nextId); } } return false; } //# sourceMappingURL=recursive-function.js.map