UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

59 lines 1.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RArgument = void 0; const model_1 = require("../model"); const type_1 = require("../type"); const r_function_call_1 = require("./r-function-call"); /** * Helper for working with {@link RArgument} AST nodes. */ exports.RArgument = { ...model_1.RNode, name: 'RArgument', /** * Type guard for {@link RArgument} nodes. * @see {@link RArgument.isUnnamed} - to check whether an argument is unnamed */ is(node) { return node?.type === type_1.RType.Argument; }, /** * Type guard for named arguments, i.e. arguments with a name. */ isNamed(node) { return exports.RArgument.is(node) && node.name !== undefined; }, /** * Type guard for unnamed arguments, i.e. arguments without a name. */ isUnnamed(node) { return exports.RArgument.is(node) && node.name === undefined && node.value !== undefined; }, /** * Type guard for arguments with a value, i.e. arguments that are not just placeholders without a value. */ isWithValue(node) { return exports.RArgument.is(node) && node.value !== undefined; }, getWithId(args, id) { if (id === undefined) { return undefined; } for (const arg of args) { if (arg === r_function_call_1.EmptyArgument) { continue; } if (arg.info.id === id) { return arg; } } return undefined; }, /** * Retrieve the value of the argument with the given id from the list of arguments. */ getValue(args, id) { return exports.RArgument.getWithId(args, id)?.value; } }; //# sourceMappingURL=r-argument.js.map