@informalsystems/quint
Version:
Core tool for the Quint specification language
82 lines (81 loc) • 3.16 kB
TypeScript
import { QuintDef, QuintExport, QuintImport, QuintInstance, QuintLambdaParameter } from '../ir/quintIr';
import { QuintType } from '../ir/quintTypes';
import { QuintError } from '../quintError';
import { NameResolver } from './resolver';
/**
* Possible kinds for definitions
*/
export type DefinitionKind = 'module' | 'def' | 'val' | 'assumption' | 'param' | 'var' | 'const' | 'type';
/**
* A definition to be stored in `DefinitionsByName` and `LookupTable`. Either a `QuintDef`
* or a `QuintLambdaParameter`, with additional metadata fields
*/
export type LookupDefinition = (QuintDef | ({
kind: 'param';
} & QuintLambdaParameter)) & {
hidden?: boolean;
namespaces?: string[];
importedFrom?: QuintImport | QuintInstance | QuintExport;
typeAnnotation?: QuintType;
depth?: number;
shadowing?: boolean;
};
/**
* A module's definitions, indexed by name.
*/
export type DefinitionsByName = Map<string, LookupDefinition[]>;
/**
* Definitions for each module
*/
export type DefinitionsByModule = Map<string, DefinitionsByName>;
/**
* A lookup table from IR component ids to their definitions.
* Should have an entry for every IR component with a name
* That is:
* - Name expressions
* - App expressions (opcode is a name)
* - Override parameters in instance definitions
* - Constant types (which are references to type aliases or uninterpreted types)
*
* This should be created by `resolveNames` from `resolver.ts`
*/
export type LookupTable = Map<bigint, LookupDefinition>;
/**
* A lazy mapping from module names to the definitions that are available but not used in that module.
*/
export type UnusedDefinitions = (moduleName: string) => Set<LookupDefinition>;
/**
* The result of name resolution, when successful.
*/
export type NameResolutionResult = {
table: LookupTable;
unusedDefinitions: UnusedDefinitions;
errors: QuintError[];
resolver: NameResolver;
};
export declare function getTopLevelDef(defs: DefinitionsByName, name: string): LookupDefinition | undefined;
/**
* Copy the names of a definitions table to a new one, ignoring hidden
* definitions, and optionally adding a namespace.
*
* @param originTable - The definitions table to copy from
* @param namespace - Optional namespace to be added to copied names
* @param copyAsHidden - Optional, true iff the copied definitions should be tagged as 'hidden'
*
* @returns a definitions table with the filtered and namespaced names
*/
export declare function copyNames(originTable: DefinitionsByName, namespace?: string, copyAsHidden?: boolean): DefinitionsByName;
/**
* Add namespaces to a definition's `namespaces` field, if it doesn't already
* have them on the last position or in the beginning of its name.
*
* @param def - The definition to add the namespaces to
* @param namespaces - The namespaces to be added
*
* @returns The definition with the namespaces added
*/
export declare function addNamespacesToDef(def: LookupDefinition, namespaces: string[]): LookupDefinition;
/**
* Built-in name definitions that are always resolved and generate conflicts if collected.
*/
export declare const builtinNames: string[];