@informalsystems/quint
Version:
Core tool for the Quint specification language
70 lines (69 loc) • 3.01 kB
TypeScript
/**
* Name collection for Quint name resolution.
*
* @author Gabriela Moreira
*
* @module
*/
import { IRVisitor } from '../ir/IRVisitor';
import { QuintError } from '../quintError';
import { QuintAssume, QuintConst, QuintExport, QuintImport, QuintInstance, QuintModule, QuintOpDef, QuintTypeDef, QuintVar } from '../ir/quintIr';
import { DefinitionsByModule, DefinitionsByName, LookupDefinition, LookupTable } from './base';
/**
* Collects all top-level definitions in Quint modules. Used internally by
* `NameResolver`. Also handles imports, instances and exports, collecting
* definitions from those statements and managing their level of visibility.
*/
export declare class NameCollector implements IRVisitor {
definitionsByName: DefinitionsByName;
definitionsByModule: DefinitionsByModule;
errors: QuintError[];
table: LookupTable;
definitionDepth: number;
private currentModuleName;
switchToModule(moduleName: string): void;
enterModule(module: QuintModule): void;
exitModule(module: QuintModule): void;
enterVar(def: QuintVar): void;
enterConst(def: QuintConst): void;
enterOpDef(def: QuintOpDef): void;
enterTypeDef(def: QuintTypeDef): void;
enterAssume(def: QuintAssume): void;
enterInstance(decl: QuintInstance): void;
enterImport(decl: QuintImport): void;
enterExport(decl: QuintExport): void;
/** Public interface to manipulate the collected definitions. Used by
* `NameResolver` to add and remove scoped definitions */
/**
* Collects a definition. If the identifier is an underscore or a built-in
* name, the definition is not collected. If the identifier conflicts with a
* previous definition, a conflict is recorded.
*
* @param def - The definition object to collect.
* @param name - An optional name for the definition, if the name is different
* than `def.name` (i.e. in import-like statements).
* @param source - An optional source identifier for the definition, if the
* source is different than `def.id` (i.e. in import-like statements).
*
* @returns The definition object that was collected.
*/
collectDefinition(def: LookupDefinition, importedFrom?: QuintImport | QuintExport | QuintInstance): LookupDefinition;
/**
* Deletes the definition with the given identifier from the collected definitions.
*
* @param identifier - The identifier of the definition to delete.
*/
deleteDefinition(identifier: string): void;
/**
* Gets the definition with the given name, in the current (visiting) scope
*
* @param identifier - The identifier of the definition to retrieve.
*
* @returns The definition object for the given identifier, or undefined if a
* definitions with that identifier was never collected.
*/
getDefinition(identifier: string): LookupDefinition | undefined;
private namespaces;
private collectTopLevelDefinitions;
private recordConflict;
}