@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
54 lines • 2.98 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Resolve = void 0;
const resolve_by_name_1 = require("./resolve-by-name");
const alias_tracking_1 = require("../eval/resolve/alias-tracking");
const resolve_args_1 = require("../../abstract-interpretation/data-frame/resolve-args");
/**
* The helper object for resolution: from a name to the definitions it may refer to, and from a node to the
* value(s) it may hold. Reachable as {@link Dataflow.resolve} as well.
*
* Take the narrowest entry point that answers your question, they differ a lot in cost:
*
* - {@link Resolve.byName} walks the environment layers once and answers repeat questions from the layer's own
* lookup cache. Use it whenever the {@link ReferenceType} does not matter.
* - {@link Resolve.byNameAndType} additionally filters and merges the definitions of every layer it passes.
* Given the unknown reference type it only forwards to {@link Resolve.byName}, so ask that one directly instead.
* - {@link Resolve.toValue} and the {@link Resolve.argument} family run the evaluator on top of a resolution.
* @example
* ```ts
* Resolve.byName('x', environment); // every definition `x` may refer to
* Resolve.toValue(id, { graph, ctx }); // the value(s) the node may hold
* Resolve.argument.value(call, 'file', ...); // the value of a named argument
* ```
*/
exports.Resolve = {
name: 'Resolve',
/** Every definition the identifier may refer to, whatever its type. */
byName: resolve_by_name_1.resolveByNameAnyType,
/** The definitions the identifier may refer to that fit the wanted {@link ReferenceType}. */
byNameAndType: resolve_by_name_1.resolveByName,
/** Whether the name always, never, or maybe refers to a built-in constant of the given value. */
toBuiltIn: resolve_by_name_1.resolvesToBuiltInConstant,
/** The constant values the name resolves to. */
toConstants: alias_tracking_1.resolveToConstants,
/** The value(s) the node may hold, tracking aliases as the configuration allows. */
toValue: alias_tracking_1.resolveIdToValue,
/** The single string the node resolves to, or `undefined` if it is not exactly one. */
toSingleString: alias_tracking_1.resolveIdToSingleString,
/** The same, for the arguments of a call. */
argument: {
name: 'argument',
/** The argument's name. */
toName: resolve_args_1.resolveIdToArgName,
/** The argument's value. */
value: resolve_args_1.resolveIdToArgValue,
/** The argument's value as a vector of strings. */
stringVector: resolve_args_1.resolveIdToArgStringVector,
/** The argument's value as the name of the symbol it holds. */
symbolName: resolve_args_1.resolveIdToArgValueSymbolName,
/** The length of the vector the argument holds. */
vectorLength: resolve_args_1.resolveIdToArgVectorLength
}
};
//# sourceMappingURL=resolve-helper.js.map