UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

94 lines 3.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FunctionDefinitionVertex = exports.VariableDefinitionVertex = exports.FunctionCallVertex = exports.UseVertex = exports.ValueVertex = exports.ValidVertexTypeReverse = exports.ValidVertexTypes = exports.VertexType = void 0; var VertexType; (function (VertexType) { VertexType["Value"] = "value"; VertexType["Use"] = "use"; VertexType["FunctionCall"] = "fcall"; VertexType["VariableDefinition"] = "vdef"; VertexType["FunctionDefinition"] = "fdef"; })(VertexType || (exports.VertexType = VertexType = {})); exports.ValidVertexTypes = new Set(Object.values(VertexType)); exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k])); /** * Helpers for {@link DataflowGraphVertexValue} vertices. * @example * ```ts * ValueVertex.is(graph.getVertex(id)) // true for a constant like `42` * ``` */ exports.ValueVertex = { name: 'ValueVertex', /** Whether the given vertex is a value vertex. */ is(vertex) { return vertex?.tag === VertexType.Value; } }; /** * Helpers for {@link DataflowGraphVertexUse} vertices. * @example * ```ts * UseVertex.is(graph.getVertex(id)) // true for a read of `x` * ``` */ exports.UseVertex = { name: 'UseVertex', /** Whether the given vertex is a use vertex. */ is(vertex) { return vertex?.tag === VertexType.Use; } }; /** * Helpers for {@link DataflowGraphVertexFunctionCall} vertices. * @example * ```ts * const vertex = graph.getVertex(id); * FunctionCallVertex.is(vertex) && vertex.name // the call's effective name * FunctionCallVertex.hasOrigin(vertex, 'builtin:eval') // the call is an eval * ``` */ exports.FunctionCallVertex = { name: 'FunctionCallVertex', /** Whether the given vertex is a function call vertex. */ is(vertex) { return vertex?.tag === VertexType.FunctionCall; }, /** * Whether the given vertex is a function call carrying the given origin. * Deliberately not a type predicate: a `false` says nothing about the tag, the call may simply carry another origin. */ hasOrigin(vertex, origin) { return exports.FunctionCallVertex.is(vertex) && vertex.origin.includes(origin); } }; /** * Helpers for {@link DataflowGraphVertexVariableDefinition} vertices. * @example * ```ts * VariableDefinitionVertex.is(graph.getVertex(id)) // true for the `x` of `x <- 1` * ``` */ exports.VariableDefinitionVertex = { name: 'VariableDefinitionVertex', /** Whether the given vertex is a variable definition vertex. */ is(vertex) { return vertex?.tag === VertexType.VariableDefinition; } }; /** * Helpers for {@link DataflowGraphVertexFunctionDefinition} vertices. * @example * ```ts * const vertex = graph.getVertex(id); * FunctionDefinitionVertex.is(vertex) && vertex.exitPoints // where the body returns * ``` */ exports.FunctionDefinitionVertex = { name: 'FunctionDefinitionVertex', /** Whether the given vertex is a function definition vertex. */ is(vertex) { return vertex?.tag === VertexType.FunctionDefinition; } }; //# sourceMappingURL=vertex.js.map