1 import { Code, Name } from "./code";
6 export interface NameValue {
11 export declare type ValueReference = unknown;
12 interface ScopeOptions {
13 prefixes?: Set<string>;
16 interface ValueScopeOptions extends ScopeOptions {
21 export declare type ScopeStore = Record<string, ValueReference[] | undefined>;
22 declare type ScopeValues = {
23 [Prefix in string]?: Map<unknown, ValueScopeName>;
25 export declare type ScopeValueSets = {
26 [Prefix in string]?: Set<ValueScopeName>;
28 export declare enum UsedValueState {
32 export declare type UsedScopeValues = {
33 [Prefix in string]?: Map<ValueScopeName, UsedValueState | undefined>;
35 export declare const varKinds: {
40 export declare class Scope {
41 protected readonly _names: {
42 [Prefix in string]?: NameGroup;
44 protected readonly _prefixes?: Set<string>;
45 protected readonly _parent?: Scope;
46 constructor({ prefixes, parent }?: ScopeOptions);
47 toName(nameOrPrefix: Name | string): Name;
48 name(prefix: string): Name;
49 protected _newName(prefix: string): string;
56 export declare class ValueScopeName extends Name {
57 readonly prefix: string;
60 constructor(prefix: string, nameStr: string);
61 setValue(value: NameValue, { property, itemIndex }: ScopePath): void;
63 interface VSOptions extends ValueScopeOptions {
66 export declare class ValueScope extends Scope {
67 protected readonly _values: ScopeValues;
68 protected readonly _scope: ScopeStore;
69 readonly opts: VSOptions;
70 constructor(opts: ValueScopeOptions);
72 name(prefix: string): ValueScopeName;
73 value(nameOrPrefix: ValueScopeName | string, value: NameValue): ValueScopeName;
74 getValue(prefix: string, keyOrRef: unknown): ValueScopeName | undefined;
75 scopeRefs(scopeName: Name, values?: ScopeValues | ScopeValueSets): Code;
76 scopeCode(values?: ScopeValues | ScopeValueSets, usedValues?: UsedScopeValues, getCode?: (n: ValueScopeName) => Code | undefined): Code;
77 private _reduceValues;