@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
66 lines (65 loc) • 3.85 kB
TypeScript
/**
* Decoding a {@link PkgBlob} into the reader-facing views: the on-disk tuple form, the decoded function/
* dependency records, and the {@link LibraryExports} export view. Pure -- no I/O, no mutation of inputs.
* Split out of `../sigdb` so the reader/writer there does not carry the per-record decoding.
*/
import { type DepType, type LibraryExports, type PkgBlob, type PkgBlobTuple, type SigDbPkgMeta } from './schema';
/** the CRAN status of a version, used to build (or skip) its source-tarball link */
export interface CranBlobInfo {
readonly latest: string;
readonly archived: boolean;
readonly cran: boolean;
}
/**
* Reconstruct the CRAN source blob link which is the newest non-archived version lives under `src/contrib`,
* every other under `Archive`.
*/
export declare function cranBlobUrl(cranBase: string, pkg: string, version: string, opts: CranBlobInfo): string | undefined;
/** a {@link PkgBlob} in its compact on-disk tuple form (drops the trailing `dates` when empty) */
export declare const blobTuple: (b: Readonly<PkgBlob>) => PkgBlobTuple;
/** the inverse of {@link blobTuple}: rebuild a {@link PkgBlob} from its on-disk tuple */
export declare function tupleToBlob(t: PkgBlobTuple): PkgBlob;
/** one decoded parameter of a function signature */
export interface SigParameter {
readonly name: string;
readonly forced: boolean;
readonly optional: boolean;
readonly default?: string;
}
/** the decoded view of one function at one package version */
export interface DecodedFunction {
readonly name: string;
readonly file?: string;
readonly line: number;
readonly exported: boolean;
readonly props: readonly string[];
readonly signature: readonly SigParameter[];
readonly callees: readonly string[];
/** the Rd help topic (man-page name) documenting this function, when it differs from {@link name} */
readonly topic?: string;
}
/**
* The formal parameter names of a known signature, ready for `RFunctionCall.matchArgumentsToParameters`: the
* `...` parameter is excluded so partial (`pmatch`) matches against the remaining names stay unambiguous.
*/
export declare function signatureParameterNames(signature: readonly SigParameter[]): string[];
/**
* The transitive callees of `name`. Each local callee that is itself a function of `functions` (one package
* version's set) is expanded, names outside the set stay as leaves. Deduplicated and ascending.
*/
export declare function transitiveCallees(functions: readonly DecodedFunction[], name: string): string[];
/** decode one of a blob's function records against the global string dictionary */
export declare function decodeFunction(strings: readonly string[], blob: Readonly<PkgBlob>, fnIdx: number): DecodedFunction;
/** a decoded package dependency of one version (`type` is the compact {@link DepType} enum; map to a label via {@link DepTypeNames}) */
export interface ResolvedDependency {
readonly name: string;
readonly type: DepType;
/** version qualifier as declared in DESCRIPTION, e.g. `>= 3.0.0` (absent = any version) */
readonly constraint?: string;
}
/** decode the declared dependencies of one blob version (empty when it declares none / the bundle omits them) */
export declare function decodeDependencies(strings: readonly string[], blob: Readonly<PkgBlob>, ver: string): ResolvedDependency[];
/** the function indices of a blob version (undoing the delta encoding) */
export declare function versionFnIndices(blob: Readonly<PkgBlob>, ver: string): number[] | undefined;
/** derive the {@link LibraryExports} export view of one package version from its blob + metadata */
export declare function deriveLibraryExports(strings: readonly string[], blob: Readonly<PkgBlob>, meta: SigDbPkgMeta, pkg: string, version?: string, cranBase?: string): LibraryExports | undefined;