UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

46 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RFunctionDefinition = void 0; const model_1 = require("../model"); const type_1 = require("../type"); /** * Helper for working with {@link RFunctionDefinition} AST nodes. */ exports.RFunctionDefinition = { ...model_1.RNode, name: 'RFunctionDefinition', /** * Type guard for {@link RFunctionDefinition} nodes. */ is(node) { return node?.type === type_1.RType.FunctionDefinition; }, /** * Checks whether the given id is part of a function definition, and if so, this returns the id of the * inner-most function definition. * @see {@link RFunctionDefinition.rootFunctionDefinition} - for the outer-most function definition */ wrappingFunctionDefinition(n, idMap) { for (const p of model_1.RNode.iterateParents(n, idMap)) { if (exports.RFunctionDefinition.is(p)) { return p; } } return undefined; }, /** * Checks whether the given id is part of a function definition, and if so, this returns the id of the * outer-most function definition. * @see {@link RFunctionDefinition.wrappingFunctionDefinition} - for the inner-most function definition */ rootFunctionDefinition(n, idMap) { let root = undefined; for (const p of model_1.RNode.iterateParents(n, idMap)) { if (exports.RFunctionDefinition.is(p)) { root = p; } } return root; } }; //# sourceMappingURL=r-function-definition.js.map