vba-interpreter 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-CAVxm72C.js","names":[],"sources":["../src/semantic/procedure.ts","../src/semantic/symbols.ts","../src/semantic/types.ts","../src/semantic/declare.ts","../src/semantic/diagnostics.ts","../src/semantic/module.ts","../src/semantic/operands.ts","../src/semantic/program.ts","../src/semantic/library/constants.ts","../src/semantic/library/entry.ts","../src/semantic/library/functions.ts","../src/semantic/library/index.ts","../src/semantic/scope.ts","../src/semantic/types-resolve.ts","../src/semantic/bind/context.ts","../src/semantic/bind/names.ts","../src/semantic/bind/calls.ts","../src/semantic/bind/expressions.ts","../src/semantic/bind/locals.ts","../src/semantic/bind/statements.ts","../src/semantic/bind/program.ts"],"sourcesContent":["// A bound procedure: its parameters, frame layout, labels, With blocks and the facts executors use\n// to choose a fast path (does it jump, trap errors, call host objects?).\nimport type { LabelStatement, ProcedureDeclaration, ProcedureKind } from '../lang/index';\nimport type { WithBlock } from './bindings';\nimport type { LibraryFunction } from './library/index';\nimport type { BoundModule } from './module';\nimport type { ConstSymbol, ParamSymbol, VariableSymbol } from './symbols';\nimport type { StaticType } from './types';\n\n/** What a procedure body contains, for executors that pick a simpler path when they can. */\nexport class ProcedureFacts {\n\t/** Contains `GoTo`. */\n\thasGoTo = false;\n\t/** Contains `GoSub`, or `On ... GoSub`. */\n\thasGoSub = false;\n\t/** Contains `On ... GoTo` or `On ... GoSub`. */\n\thasOnGoTo = false;\n\t/** Contains an `On Error` statement. */\n\thasOnError = false;\n\t/** Contains a `Resume` statement. */\n\thasResume = false;\n\t/** Has a line-number label (`10 x = 1`), which `Erl` reports. */\n\thasLineNumbers = false;\n\t/** Contains `End` or `Stop`. */\n\thasEnd = false;\n\t/** Calls a procedure of the project. */\n\treadonly callees = new Set<BoundProcedure>();\n\t/** The library functions it calls. */\n\treadonly library = new Set<LibraryFunction>();\n\t/**\n\t * Touches something that may answer asynchronously: a host object, a run-time member, an\n\t * asynchronous library function or an event. A procedure whose transitive callees are all free\n\t * of it can run synchronously.\n\t */\n\tdynamic = false;\n\t/**\n\t * Writes storage another activation can see: a module or class field, a ByRef parameter, an\n\t * object's member, or a host name. Callees are not included (see `callees`). With\n\t * `usage.written` of a parameter, this tells whether a ByRef argument can be read-only.\n\t */\n\twritesShared = false;\n\t/** Raises an event (`RaiseEvent`). */\n\traisesEvents = false;\n\t/**\n\t * Evaluates an expression that may run code implicitly (`BoundProgram.mayCallDefault`): an\n\t * object's default member or enumerator. The default member of a class-typed operand is also\n\t * in `callees`.\n\t */\n\timplicitCalls = false;\n}\n\n/**\n * One procedure of a bound module (each Property accessor is its own procedure), with its\n * symbols, frame layout, labels and `With` blocks.\n */\nexport class BoundProcedure {\n\t/** Parameters in order; parameter i is frame slot i. */\n\treadonly params: ParamSymbol[] = [];\n\t/** The return value of a Function or Property Get (frame slot `params.length`), else null. */\n\tresult: VariableSymbol | null = null;\n\t/** `Dim` and implicit locals: frame slots from `params.length + 1`. */\n\treadonly locals: VariableSymbol[] = [];\n\t/** `Static` locals (and every local of a `Static Sub`): slots of the procedure's static store. */\n\treadonly statics: VariableSymbol[] = [];\n\t/** Constants declared inside the procedure. */\n\treadonly consts: ConstSymbol[] = [];\n\t/** The `Label` statement that defines each label or line number (lower case). */\n\treadonly labels = new Map<string, LabelStatement>();\n\t/** `With` blocks by id (the index here). */\n\treadonly withBlocks: WithBlock[] = [];\n\t/** What the body contains. */\n\treadonly facts = new ProcedureFacts();\n\n\tconstructor(\n\t\t/** A number unique among the program's symbols and procedures. */\n\t\treadonly id: number,\n\t\t/** The module that declares it. */\n\t\treadonly module: BoundModule,\n\t\t/** The procedure's AST node. */\n\t\treadonly declaration: ProcedureDeclaration,\n\t\t/** The declared return type of a Function or Property Get; null for Sub/Let/Set. */\n\t\treadonly returnType: StaticType | null,\n\t) {}\n\n\t/** The procedure name, as declared. */\n\tget name(): string {\n\t\treturn this.declaration.name.name;\n\t}\n\n\t/** `Sub`, `Function`, `PropertyGet`, `PropertyLet` or `PropertySet`. */\n\tget kind(): ProcedureKind {\n\t\treturn this.declaration.procedureKind;\n\t}\n\n\t/** Callable from other modules by early binding: Public or Friend. */\n\tget isPublic(): boolean {\n\t\treturn this.declaration.scope !== 'Private';\n\t}\n\n\t/**\n\t * Who may call it: `public` everyone, `friend` early-bound callers in the project only (late\n\t * binding through `As Object` raises 438), `private` its own module.\n\t */\n\tget visibility(): 'public' | 'friend' | 'private' {\n\t\tconst scope = this.declaration.scope;\n\t\treturn scope === 'Private' ? 'private' : scope === 'Friend' ? 'friend' : 'public';\n\t}\n\n\t/** `Module1.Foo`. */\n\tget qualifiedName(): string {\n\t\treturn `${this.module.name}.${this.name}`;\n\t}\n\n\t/** Frame slots: parameters, the result slot, then locals. */\n\tget frameSize(): number {\n\t\treturn this.params.length + 1 + this.locals.length;\n\t}\n}\n\n/**\n * Everything one name of a module stands for: a Sub or Function (`method`), or the Property\n * Get/Let/Set procedures that share a name. Calls bind to the group; the executor picks the\n * accessor from the context (read, Let assignment, Set assignment).\n */\nexport class PropertyGroup {\n\t/** The Sub or Function of this name, if the name is one. */\n\tmethod: BoundProcedure | null = null;\n\t/** The `Property Get` of this name. */\n\tget: BoundProcedure | null = null;\n\t/** The `Property Let` of this name. */\n\tlet: BoundProcedure | null = null;\n\t/** The `Property Set` of this name. */\n\tset: BoundProcedure | null = null;\n\n\tconstructor(\n\t\t/** The name, as first declared. */\n\t\treadonly name: string,\n\t\t/** The module that declares the group. */\n\t\treadonly module: BoundModule,\n\t) {}\n\n\t/** The procedure a read or call uses: the method, else Property Get. */\n\tget reader(): BoundProcedure | null {\n\t\treturn this.method ?? this.get;\n\t}\n\n\t/** The procedure an access runs: Function or Get to read, Sub (else Get) to call, Let, Set. */\n\tforAccess(access: 'get' | 'call' | 'let' | 'set'): BoundProcedure | null {\n\t\tswitch (access) {\n\t\t\tcase 'get':\n\t\t\t\treturn this.reader;\n\t\t\tcase 'call':\n\t\t\t\treturn this.method ?? this.get;\n\t\t\tcase 'let':\n\t\t\t\treturn this.let;\n\t\t\tcase 'set':\n\t\t\t\treturn this.set;\n\t\t}\n\t}\n\n\tget any(): BoundProcedure {\n\t\tconst p = this.method ?? this.get ?? this.let ?? this.set;\n\t\tif (!p) throw new Error(`empty procedure group ${this.name}`);\n\t\treturn p;\n\t}\n\n\t/** True when any member of the group is public. */\n\tget isPublic(): boolean {\n\t\treturn [this.method, this.get, this.let, this.set].some((p) => p !== null && p.isPublic);\n\t}\n\n\t/**\n\t * Puts a procedure in its slot. Returns false, and changes nothing, when the slot is taken or\n\t * the procedure would mix a Sub or Function with Property procedures (a duplicate declaration).\n\t */\n\tadd(procedure: BoundProcedure): boolean {\n\t\tconst slot =\n\t\t\tprocedure.kind === 'PropertyGet'\n\t\t\t\t? 'get'\n\t\t\t\t: procedure.kind === 'PropertyLet'\n\t\t\t\t\t? 'let'\n\t\t\t\t\t: procedure.kind === 'PropertySet'\n\t\t\t\t\t\t? 'set'\n\t\t\t\t\t\t: 'method';\n\t\tif (this[slot] !== null) return false;\n\t\tif (slot === 'method' && (this.get || this.let || this.set)) return false;\n\t\tif (slot !== 'method' && this.method) return false;\n\t\tthis[slot] = procedure;\n\t\treturn true;\n\t}\n}\n","// The declared entities of a project ([MS-VBAL] 5.2, 5.3): variables, parameters, constants,\n// enums, user-defined types, events and Declare statements. Every symbol has a program-wide unique\n// `id`. Variables and parameters also carry a `slot`: their index in the storage that holds them\n// (the procedure frame for locals and parameters, the static store for Static locals, the module\n// or class instance for module variables), so executors can use arrays instead of name lookups.\nimport type {\n\tArrayBound,\n\tConstDeclaration,\n\tDeclareStatement,\n\tEnumDeclaration,\n\tEventDeclaration,\n\tExpression,\n\tNameRef,\n\tParameter,\n\tTypeDeclaration,\n\tVariableDeclarator,\n} from '../lang/index';\nimport type { StaticType } from './types';\n\n/**\n * Where a variable lives: `local` in the frame, `static` in the procedure's static store (per\n * instance in a class module), `module` once per standard or document module, `instance` once per\n * object of a class module, `result` the return value of a Function or Property Get.\n */\nexport type VariableScope = 'local' | 'static' | 'module' | 'instance' | 'result';\n\n/** How a variable is used, collected while binding (both executors use it to optimise). */\nexport class UsageFacts {\n\t/** Read anywhere. */\n\tread = false;\n\t/** Assigned with Let (`x = ...`). */\n\tletWritten = false;\n\t/** Assigned with Set. */\n\tsetWritten = false;\n\t/** A For or For Each counter. */\n\tforCounter = false;\n\t/** ReDim or Erase target. */\n\tredimmed = false;\n\t/** An element or field of it is written (`a(1) = ...`, `u.x = ...`). */\n\tpartWritten = false;\n\t/** Target of `Mid(x, ...) =`, `LSet` or `RSet`. */\n\tstringStatement = false;\n\t/** Passed ByRef (as a variable reference) to a procedure that may write it. */\n\tpassedByRef = false;\n\n\t/** True when any of the write facts above is set. */\n\tget written(): boolean {\n\t\treturn (\n\t\t\tthis.letWritten ||\n\t\t\tthis.setWritten ||\n\t\t\tthis.forCounter ||\n\t\t\tthis.redimmed ||\n\t\t\tthis.partWritten ||\n\t\t\tthis.stringStatement ||\n\t\t\tthis.passedByRef\n\t\t);\n\t}\n}\n\n/** A variable: a local, a Static local, a module or instance variable, or a function result. */\nexport interface VariableSymbol {\n\t/** Marks a variable symbol. */\n\treadonly kind: 'variable';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The name, as declared. */\n\treadonly name: string;\n\t/** Where the variable lives. */\n\treadonly scope: VariableScope;\n\t/** The module that declares it. */\n\treadonly module: string;\n\t/** Visible from other modules (`Public`/`Global` at module level). */\n\treadonly isPublic: boolean;\n\t/** The declared type (for an array, the array type). */\n\treadonly type: StaticType;\n\t/** Array bounds as written (`Dim a(1 To 3, 5)`); empty for `a()`; null when not an array. */\n\treadonly bounds: readonly ArrayBound[] | null;\n\t/** `As New Class`: created on first use, and again after `Set x = Nothing`. */\n\treadonly isNew: boolean;\n\t/** Declared `WithEvents`: its `name_Event` Subs handle the object's events. */\n\treadonly withEvents: boolean;\n\t/** True for an undeclared variable created implicitly (no `Option Explicit`). */\n\treadonly implicit: boolean;\n\t/** The index in its storage (see the file comment). */\n\treadonly slot: number;\n\t/** Its declarator; null for a function result or an implicit variable. */\n\treadonly declaration: VariableDeclarator | null;\n\t/** How the body uses it. */\n\treadonly usage: UsageFacts;\n}\n\n/** A parameter of a procedure. */\nexport interface ParamSymbol {\n\t/** Marks a parameter symbol. */\n\treadonly kind: 'param';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The name, as declared. */\n\treadonly name: string;\n\t/** Its 0-based position in the parameter list. */\n\treadonly index: number;\n\t/** The frame slot (equal to `index`). */\n\treadonly slot: number;\n\t/** How it is passed: `ByRef` when the declaration says neither. */\n\treadonly passing: 'ByRef' | 'ByVal';\n\t/** Declared `Optional`. */\n\treadonly optional: boolean;\n\t/** The default of an Optional parameter, a constant expression bound in the module scope. */\n\treadonly defaultValue: Expression | null;\n\t/** Declared `ParamArray`: it collects the remaining arguments. */\n\treadonly paramArray: boolean;\n\t/** The declared type; `name()` parameters are arrays. */\n\treadonly type: StaticType;\n\t/** Its AST node. */\n\treadonly declaration: Parameter;\n\t/** How the body uses it. */\n\treadonly usage: UsageFacts;\n}\n\n/** A constant declared with `Const`, at module level or in a procedure. */\nexport interface ConstSymbol {\n\t/** Marks a constant symbol. */\n\treadonly kind: 'const';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The name, as declared. */\n\treadonly name: string;\n\t/** The module that declares it. */\n\treadonly module: string;\n\t/** The procedure for a local `Const`, else null. */\n\treadonly procedure: string | null;\n\t/** Visible from other modules (`Public Const` in a standard module). */\n\treadonly isPublic: boolean;\n\t/** The declared type, or null when the type comes from the value. */\n\treadonly type: StaticType | null;\n\t/** The value expression, a constant expression. */\n\treadonly value: Expression;\n\t/** The `Const` statement that declares it. */\n\treadonly declaration: ConstDeclaration;\n\t/** The name as written in that statement. */\n\treadonly nameRef: NameRef;\n}\n\n/** A member of an `Enum`. */\nexport interface EnumMemberSymbol {\n\t/** Marks an enum member symbol. */\n\treadonly kind: 'enumMember';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The member name, as declared. */\n\treadonly name: string;\n\t/** The name of the `Enum` it belongs to. */\n\treadonly enumName: string;\n\t/** The module that declares the `Enum`. */\n\treadonly module: string;\n\t/** The value expression; null means one more than `previous` (or 0 for the first member). */\n\treadonly value: Expression | null;\n\t/** The member before it in the `Enum`, or null for the first. */\n\treadonly previous: EnumMemberSymbol | null;\n\t/** Visible from other modules, as its `Enum` is. */\n\treadonly isPublic: boolean;\n}\n\n/** An `Enum` declaration. */\nexport interface EnumSymbol {\n\t/** Marks an enum symbol. */\n\treadonly kind: 'enum';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The name, as declared. */\n\treadonly name: string;\n\t/** The module that declares it. */\n\treadonly module: string;\n\t/** Visible from other modules (an `Enum` is public unless declared `Private`). */\n\treadonly isPublic: boolean;\n\t/** Its members, in source order. */\n\treadonly members: readonly EnumMemberSymbol[];\n\t/** Its AST node. */\n\treadonly declaration: EnumDeclaration;\n}\n\n/** A field of a user-defined type. */\nexport interface UdtFieldSymbol {\n\t/** The field name, as declared. */\n\treadonly name: string;\n\t/** The field's type (for an array field, the array type). */\n\treadonly type: StaticType;\n\t/** Array bounds of an array field; null when not an array. */\n\treadonly bounds: readonly ArrayBound[] | null;\n}\n\n/** A user-defined type, declared with `Type ... End Type`. */\nexport interface UdtSymbol {\n\t/** Marks a user-defined type symbol. */\n\treadonly kind: 'udt';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The name, as declared. */\n\treadonly name: string;\n\t/** The module that declares it. */\n\treadonly module: string;\n\t/** Visible from other modules (a `Type` is public unless declared `Private`). */\n\treadonly isPublic: boolean;\n\t/** Filled in once every type of the project is known (a field may name a later Type). */\n\treadonly fields: UdtFieldSymbol[];\n\t/** Its AST node. */\n\treadonly declaration: TypeDeclaration;\n}\n\n/** An `Event` declared in a class module, raised with `RaiseEvent`. */\nexport interface EventSymbol {\n\t/** Marks an event symbol. */\n\treadonly kind: 'event';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The event name, as declared. */\n\treadonly name: string;\n\t/** The class module that declares it. */\n\treadonly module: string;\n\t/** The event's parameters, as written. */\n\treadonly parameters: readonly Parameter[];\n\t/** Its AST node. */\n\treadonly declaration: EventDeclaration;\n}\n\n/** A `Declare` statement: kept so calls bind, but executors refuse to call it (error 445). */\nexport interface DeclareSymbol {\n\t/** Marks a `Declare` symbol. */\n\treadonly kind: 'declare';\n\t/** Unique in the program. */\n\treadonly id: number;\n\t/** The procedure name, as declared. */\n\treadonly name: string;\n\t/** The module that declares it. */\n\treadonly module: string;\n\t/** Visible from other modules (not declared `Private`). */\n\treadonly isPublic: boolean;\n\t/** Its AST node. */\n\treadonly declaration: DeclareStatement;\n}\n\n/** Hands out program-wide unique ids. */\nexport class IdSource {\n\tprivate next = 1;\n\ttake(): number {\n\t\treturn this.next++;\n\t}\n}\n","// Static (declared) types ([MS-VBAL] 2.1, 5.2.3.1): what the binder knows about a symbol or an\n// expression before the program runs. Both executors read them to pick Let-coercions, the strict\n// overflow flag of the operators (no operand declared Variant) and typed comparisons.\nimport type { Expression } from '../lang/index';\nimport type { UdtSymbol } from './symbols';\n\n/** The scalar types a variable can be declared with. */\nexport type ScalarTypeName =\n\t| 'Boolean'\n\t| 'Byte'\n\t| 'Integer'\n\t| 'Long'\n\t| 'LongLong'\n\t| 'LongPtr'\n\t| 'Single'\n\t| 'Double'\n\t| 'Currency'\n\t| 'Decimal'\n\t| 'Date'\n\t| 'String';\n\n/** `Variant`, and the type of anything the binder cannot type statically. */\nexport interface VariantType {\n\t/** Marks the Variant type. */\n\treadonly kind: 'variant';\n}\n\n/** A scalar type: a number, `Boolean`, `Date` or `String` (also an `Enum`, stored as `Long`). */\nexport interface ScalarType {\n\t/** Marks a scalar type. */\n\treadonly kind: 'scalar';\n\t/** Which scalar type. */\n\treadonly name: ScalarTypeName;\n\t/** The `VarType` number ([MS-VBAL] 6.1.1.16), the runtime's `VT.*`. */\n\treadonly vt: number;\n\t/** `String * n`: the length expression (a constant expression). */\n\treadonly fixedLength: Expression | null;\n\t/** Set when the type is an Enum (stored as Long). */\n\treadonly enumName: string | null;\n}\n\n/** `Object`, a class of the project, or a host type (`Range`, `Excel.Worksheet`). */\nexport interface ObjectType {\n\t/** Marks an object type. */\n\treadonly kind: 'object';\n\t/** The type as written; null for `Object`. */\n\treadonly className: string | null;\n\t/** The class module of the project it names, when it names one. */\n\treadonly classModule: string | null;\n}\n\n/** A user-defined type (`Type ... End Type`). */\nexport interface UdtType {\n\t/** Marks a user-defined type. */\n\treadonly kind: 'udt';\n\t/** The type's declaration. */\n\treadonly udt: UdtSymbol;\n}\n\n/** An array type. */\nexport interface ArrayType {\n\t/** Marks an array type. */\n\treadonly kind: 'array';\n\t/** The type of each element. */\n\treadonly element: StaticType;\n\t/** The number of dimensions when declared with bounds; null for a dynamic array. */\n\treadonly rank: number | null;\n\t/** Declared with bounds (`Dim a(3)`): cannot be ReDimmed. */\n\treadonly fixed: boolean;\n}\n\n/** The type the binder knows for a symbol or expression before the program runs. */\nexport type StaticType = VariantType | ScalarType | ObjectType | UdtType | ArrayType;\n\nconst VTS: Readonly<Record<ScalarTypeName, number>> = {\n\tBoolean: 11,\n\tByte: 17,\n\tInteger: 2,\n\tLong: 3,\n\tLongLong: 20,\n\tLongPtr: 20,\n\tSingle: 4,\n\tDouble: 5,\n\tCurrency: 6,\n\tDecimal: 14,\n\tDate: 7,\n\tString: 8,\n};\n\n/** The Variant type. */\nexport const VARIANT: VariantType = Object.freeze({ kind: 'variant' });\n/** The plain `Object` type: an object of no known class. */\nexport const OBJECT: ObjectType = Object.freeze({\n\tkind: 'object',\n\tclassName: null,\n\tclassModule: null,\n});\n\nconst scalars = new Map<ScalarTypeName, ScalarType>();\n\n/** The scalar type of a name (shared instances for the plain types). */\nexport function scalarType(\n\tname: ScalarTypeName,\n\tfixedLength: Expression | null = null,\n\tenumName: string | null = null,\n): ScalarType {\n\tif (fixedLength === null && enumName === null) {\n\t\tlet t = scalars.get(name);\n\t\tif (!t) {\n\t\t\tt = Object.freeze({ kind: 'scalar', name, vt: VTS[name], fixedLength, enumName });\n\t\t\tscalars.set(name, t);\n\t\t}\n\t\treturn t;\n\t}\n\treturn Object.freeze({ kind: 'scalar', name, vt: VTS[name], fixedLength, enumName });\n}\n\n/** `VarType` number of a scalar type name. */\nexport const vtOfScalar = (name: ScalarTypeName): number => VTS[name];\n\n/** True when the type is Variant: operators then use VBA's Variant rules (no strict overflow). */\nexport const isVariant = (t: StaticType): boolean => t.kind === 'variant';\n\n/**\n * The `VarType` an executor coerces stores to: a scalar's VT, 9 for objects, 36 for UDTs, 12\n * (Variant) for Variants and arrays.\n */\nexport function storageVt(t: StaticType): number {\n\tswitch (t.kind) {\n\t\tcase 'scalar':\n\t\t\treturn t.vt;\n\t\tcase 'object':\n\t\t\treturn 9;\n\t\tcase 'udt':\n\t\t\treturn 36;\n\t\tdefault:\n\t\t\treturn 12;\n\t}\n}\n\n/** The scalar type names a `DefType` statement or a type suffix maps to. */\nexport const SUFFIX_TYPES: Readonly<Record<string, ScalarTypeName>> = {\n\t'%': 'Integer',\n\t'&': 'Long',\n\t'^': 'LongLong',\n\t'!': 'Single',\n\t'#': 'Double',\n\t'@': 'Currency',\n\t$: 'String',\n};\n\n/** Ranks numeric types for the result type of an arithmetic operator ([MS-VBAL] 5.6.9.3). */\nconst NUMERIC_RANK: Readonly<Partial<Record<ScalarTypeName, number>>> = {\n\tByte: 1,\n\tBoolean: 2,\n\tInteger: 2,\n\tLong: 3,\n\tLongLong: 4,\n\tLongPtr: 4,\n\tCurrency: 5,\n\tSingle: 6,\n\tDouble: 7,\n\tDate: 8,\n\tDecimal: 9,\n};\n\n/** An approximate result type of `a op b` for two declared scalar operands. */\nexport function widerScalar(a: ScalarType, b: ScalarType): ScalarType {\n\tconst ra = NUMERIC_RANK[a.name] ?? 7;\n\tconst rb = NUMERIC_RANK[b.name] ?? 7;\n\tconst name = ra >= rb ? a.name : b.name;\n\treturn scalarType(name === 'Boolean' ? 'Integer' : name === 'String' ? 'Double' : name);\n}\n","// Module-level declarations ([MS-VBAL] 5.2): options, DefType, variables, constants, enums,\n// user-defined types, events, Declare statements, procedures and class attributes. Runs in two\n// passes over the project: `collectTypes` first registers every type name (a declaration may name\n// a type declared later or in another module), then `declareMembers` resolves everything else.\nimport type {\n\tAttributeStatement,\n\tModuleMember,\n\tNameRef,\n\tParameter,\n\tProcedureDeclaration,\n\tSpan,\n} from '../lang/index';\nimport type { DiagnosticSink } from './diagnostics';\nimport type { BoundModule, ModuleMemberSymbol } from './module';\nimport { BoundProcedure, PropertyGroup } from './procedure';\nimport {\n\tUsageFacts,\n\ttype ConstSymbol,\n\ttype EnumMemberSymbol,\n\ttype EnumSymbol,\n\ttype IdSource,\n\ttype ParamSymbol,\n\ttype UdtSymbol,\n\ttype VariableSymbol,\n} from './symbols';\nimport type { TypeIndex, TypeResolver } from './types-resolve';\nimport { scalarType, VARIANT, type ScalarTypeName } from './types';\n\nconst isPublicScope = (scope: string | null, standardDefault: boolean): boolean =>\n\tscope === null ? standardDefault : scope === 'Public' || scope === 'Global';\n\nexport class ModuleDeclarer {\n\tconstructor(\n\t\tprivate readonly ids: IdSource,\n\t\tprivate readonly index: TypeIndex,\n\t\tprivate readonly types: TypeResolver,\n\t\tprivate readonly diagnostics: DiagnosticSink,\n\t) {}\n\n\t/** Pass 1: options, DefType, UDT and Enum names. */\n\tcollectTypes(m: BoundModule): void {\n\t\tthis.index.addModule(m);\n\t\tlet base: 0 | 1 = 0;\n\t\tlet compareText = false;\n\t\tlet explicit = false;\n\t\tlet privateModule = false;\n\t\tfor (const member of m.ast.members) {\n\t\t\tswitch (member.kind) {\n\t\t\t\tcase 'OptionBase':\n\t\t\t\t\tbase = member.base;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'OptionCompare':\n\t\t\t\t\tcompareText = member.mode === 'Text';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'OptionExplicit':\n\t\t\t\t\texplicit = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'OptionPrivateModule':\n\t\t\t\t\tprivateModule = true;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'DefTypeStatement':\n\t\t\t\t\tfor (const r of member.ranges) this.defType(m, member.type, r.from, r.to);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'TypeDeclaration': {\n\t\t\t\t\tconst udt: UdtSymbol = {\n\t\t\t\t\t\tkind: 'udt',\n\t\t\t\t\t\tid: this.ids.take(),\n\t\t\t\t\t\tname: member.name.name,\n\t\t\t\t\t\tmodule: m.name,\n\t\t\t\t\t\tisPublic: member.scope !== 'Private',\n\t\t\t\t\t\tfields: [],\n\t\t\t\t\t\tdeclaration: member,\n\t\t\t\t\t};\n\t\t\t\t\tm.udts.push(udt);\n\t\t\t\t\tthis.index.addUdt(udt);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'EnumDeclaration':\n\t\t\t\t\tthis.declareEnum(m, member);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'AttributeStatement':\n\t\t\t\t\tthis.moduleAttribute(m, member);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t}\n\t\t}\n\t\tm.options = { base, compareText, explicit, privateModule };\n\t}\n\n\tprivate defType(m: BoundModule, type: string, from: string, to: string): void {\n\t\tif (type === 'Variant' || type === 'Object') return;\n\t\tconst t = (type === 'LongPtr' ? 'LongLong' : type) as ScalarTypeName;\n\t\tconst a = from.toLowerCase().charCodeAt(0);\n\t\tconst b = to.toLowerCase().charCodeAt(0);\n\t\tfor (let c = Math.min(a, b); c <= Math.max(a, b) && c - a < 26; c++)\n\t\t\tm.defTypes.set(String.fromCharCode(c), t);\n\t}\n\n\tprivate moduleAttribute(m: BoundModule, a: AttributeStatement): void {\n\t\tif (a.name.toLowerCase() !== 'vb_predeclaredid') return;\n\t\tconst v = a.values[0];\n\t\tm.predeclared = v?.kind === 'BooleanLiteral' && v.value;\n\t}\n\n\tprivate declareEnum(\n\t\tm: BoundModule,\n\t\tdecl: Extract<ModuleMember, { kind: 'EnumDeclaration' }>,\n\t): void {\n\t\tconst members: EnumMemberSymbol[] = [];\n\t\tconst isPublic = decl.scope !== 'Private';\n\t\tlet previous: EnumMemberSymbol | null = null;\n\t\tfor (const em of decl.members) {\n\t\t\tconst symbol: EnumMemberSymbol = {\n\t\t\t\tkind: 'enumMember',\n\t\t\t\tid: this.ids.take(),\n\t\t\t\tname: em.name.name,\n\t\t\t\tenumName: decl.name.name,\n\t\t\t\tmodule: m.name,\n\t\t\t\tvalue: em.value,\n\t\t\t\tprevious,\n\t\t\t\tisPublic,\n\t\t\t};\n\t\t\tmembers.push(symbol);\n\t\t\tprevious = symbol;\n\t\t}\n\t\tconst symbol: EnumSymbol = {\n\t\t\tkind: 'enum',\n\t\t\tid: this.ids.take(),\n\t\t\tname: decl.name.name,\n\t\t\tmodule: m.name,\n\t\t\tisPublic,\n\t\t\tmembers,\n\t\t\tdeclaration: decl,\n\t\t};\n\t\tm.enums.push(symbol);\n\t\tthis.index.addEnum(symbol);\n\t\tthis.addMember(m, decl.name, symbol);\n\t\tfor (const member of members) m.members.set(member.name.toLowerCase(), member);\n\t}\n\n\t/** Pass 2: UDT fields, variables, constants, events, Declares, procedures, Implements. */\n\tdeclareMembers(m: BoundModule): void {\n\t\tconst standard = m.kind === 'standard';\n\t\tfor (const member of m.ast.members) {\n\t\t\tswitch (member.kind) {\n\t\t\t\tcase 'TypeDeclaration':\n\t\t\t\t\tthis.udtFields(m, member);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'VariableDeclaration':\n\t\t\t\t\tfor (const d of member.declarators) {\n\t\t\t\t\t\tconst symbol: VariableSymbol = {\n\t\t\t\t\t\t\tkind: 'variable',\n\t\t\t\t\t\t\tid: this.ids.take(),\n\t\t\t\t\t\t\tname: d.name.name,\n\t\t\t\t\t\t\tscope: m.perInstance ? 'instance' : 'module',\n\t\t\t\t\t\t\tmodule: m.name,\n\t\t\t\t\t\t\tisPublic: member.keyword === 'Public' || member.keyword === 'Global',\n\t\t\t\t\t\t\ttype: this.types.declared(d.name, d.asClause, d.dimensions?.bounds ?? null, m),\n\t\t\t\t\t\t\tbounds: d.dimensions?.bounds ?? null,\n\t\t\t\t\t\t\tisNew: d.asClause?.isNew ?? false,\n\t\t\t\t\t\t\twithEvents: d.withEvents,\n\t\t\t\t\t\t\timplicit: false,\n\t\t\t\t\t\t\tslot: m.variables.length,\n\t\t\t\t\t\t\tdeclaration: d,\n\t\t\t\t\t\t\tusage: new UsageFacts(),\n\t\t\t\t\t\t};\n\t\t\t\t\t\tm.variables.push(symbol);\n\t\t\t\t\t\tthis.addMember(m, d.name, symbol);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ConstDeclaration':\n\t\t\t\t\tfor (const d of member.declarators) {\n\t\t\t\t\t\tconst symbol: ConstSymbol = {\n\t\t\t\t\t\t\tkind: 'const',\n\t\t\t\t\t\t\tid: this.ids.take(),\n\t\t\t\t\t\t\tname: d.name.name,\n\t\t\t\t\t\t\tmodule: m.name,\n\t\t\t\t\t\t\tprocedure: null,\n\t\t\t\t\t\t\tisPublic: isPublicScope(member.scope, false) && standard,\n\t\t\t\t\t\t\ttype: d.asClause\n\t\t\t\t\t\t\t\t? this.types.named(d.asClause.type, m, d.asClause.fixedLength)\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t\tvalue: d.value,\n\t\t\t\t\t\t\tdeclaration: member,\n\t\t\t\t\t\t\tnameRef: d.name,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tm.consts.push(symbol);\n\t\t\t\t\t\tthis.addMember(m, d.name, symbol);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'EventDeclaration':\n\t\t\t\t\tm.events.push({\n\t\t\t\t\t\tkind: 'event',\n\t\t\t\t\t\tid: this.ids.take(),\n\t\t\t\t\t\tname: member.name.name,\n\t\t\t\t\t\tmodule: m.name,\n\t\t\t\t\t\tparameters: member.parameters,\n\t\t\t\t\t\tdeclaration: member,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'DeclareStatement': {\n\t\t\t\t\tconst symbol = {\n\t\t\t\t\t\tkind: 'declare' as const,\n\t\t\t\t\t\tid: this.ids.take(),\n\t\t\t\t\t\tname: member.name.name,\n\t\t\t\t\t\tmodule: m.name,\n\t\t\t\t\t\tisPublic: isPublicScope(member.scope, true),\n\t\t\t\t\t\tdeclaration: member,\n\t\t\t\t\t};\n\t\t\t\t\tm.declares.push(symbol);\n\t\t\t\t\tthis.addMember(m, member.name, symbol);\n\t\t\t\t\tthis.diagnostics.add(m.name, 'declare-not-supported', member.span, member.name.name);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'ProcedureDeclaration':\n\t\t\t\t\tthis.declareProcedure(m, member);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ImplementsStatement': {\n\t\t\t\t\tconst name = member.type.parts.at(-1)?.name ?? member.type.name;\n\t\t\t\t\tconst target = this.index.classes.get(name.toLowerCase());\n\t\t\t\t\tif (target) m.implements.push(target);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.diagnostics.add(m.name, 'user-defined-type-not-defined', member.type.span, name);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate udtFields(\n\t\tm: BoundModule,\n\t\tdecl: Extract<ModuleMember, { kind: 'TypeDeclaration' }>,\n\t): void {\n\t\tconst udt = m.udts.find((u) => u.declaration === decl);\n\t\tif (!udt) return;\n\t\tfor (const f of decl.members) {\n\t\t\tconst bounds = f.dimensions?.bounds ?? null;\n\t\t\tudt.fields.push({\n\t\t\t\tname: f.name.name,\n\t\t\t\ttype: this.types.declared(f.name, f.asClause, bounds, m),\n\t\t\t\tbounds,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate declareProcedure(m: BoundModule, decl: ProcedureDeclaration): void {\n\t\tconst returns =\n\t\t\tdecl.procedureKind === 'Function' || decl.procedureKind === 'PropertyGet'\n\t\t\t\t? this.types.declared(decl.name, decl.returnType, null, m)\n\t\t\t\t: null;\n\t\tconst p = new BoundProcedure(this.ids.take(), m, decl, returns);\n\t\tdecl.parameters.forEach((param, i) => p.params.push(this.param(m, param, i)));\n\t\tif (returns) {\n\t\t\tp.result = {\n\t\t\t\tkind: 'variable',\n\t\t\t\tid: this.ids.take(),\n\t\t\t\tname: decl.name.name,\n\t\t\t\tscope: 'result',\n\t\t\t\tmodule: m.name,\n\t\t\t\tisPublic: false,\n\t\t\t\ttype: returns,\n\t\t\t\tbounds: null,\n\t\t\t\tisNew: false,\n\t\t\t\twithEvents: false,\n\t\t\t\timplicit: false,\n\t\t\t\tslot: p.params.length,\n\t\t\t\tdeclaration: null,\n\t\t\t\tusage: new UsageFacts(),\n\t\t\t};\n\t\t}\n\t\tm.procedures.push(p);\n\t\tconst key = decl.name.name.toLowerCase();\n\t\tconst existing = m.members.get(key);\n\t\tlet group = existing instanceof PropertyGroup ? existing : undefined;\n\t\tif (!group) {\n\t\t\tgroup = new PropertyGroup(decl.name.name, m);\n\t\t\tif (existing)\n\t\t\t\tthis.diagnostics.add(m.name, 'duplicate-declaration', decl.name.span, decl.name.name);\n\t\t\telse m.members.set(key, group);\n\t\t\tm.groups.set(key, group);\n\t\t}\n\t\tif (!group.add(p))\n\t\t\tthis.diagnostics.add(m.name, 'ambiguous-name', decl.name.span, decl.name.name);\n\t\tfor (const a of decl.attributes) this.memberAttribute(m, group, a);\n\t}\n\n\tprivate param(m: BoundModule, param: Parameter, index: number): ParamSymbol {\n\t\tconst type = param.paramArray\n\t\t\t? { kind: 'array' as const, element: VARIANT, rank: null, fixed: false }\n\t\t\t: this.types.declared(param.name, param.asClause, null, m, param.isArray);\n\t\treturn {\n\t\t\tkind: 'param',\n\t\t\tid: this.ids.take(),\n\t\t\tname: param.name.name,\n\t\t\tindex,\n\t\t\tslot: index,\n\t\t\tpassing: param.passing === 'ByVal' ? 'ByVal' : 'ByRef',\n\t\t\toptional: param.optional,\n\t\t\tdefaultValue: param.defaultValue,\n\t\t\tparamArray: param.paramArray,\n\t\t\ttype,\n\t\t\tdeclaration: param,\n\t\t\tusage: new UsageFacts(),\n\t\t};\n\t}\n\n\tprivate memberAttribute(m: BoundModule, group: PropertyGroup, a: AttributeStatement): void {\n\t\tif (!a.name.toLowerCase().endsWith('.vb_usermemid')) return;\n\t\tconst v = a.values[0];\n\t\tconst n =\n\t\t\tv?.kind === 'NumberLiteral'\n\t\t\t\t? v.value\n\t\t\t\t: v?.kind === 'Unary' && v.operator === '-' && v.operand.kind === 'NumberLiteral'\n\t\t\t\t\t? -v.operand.value\n\t\t\t\t\t: undefined;\n\t\tif (n === 0) m.defaultMember = group;\n\t\telse if (n === -4) m.newEnum = group;\n\t}\n\n\t/** Records a module-level name, reporting a duplicate. */\n\taddMember(m: BoundModule, name: NameRef, symbol: ModuleMemberSymbol): void {\n\t\tconst key = name.name.toLowerCase();\n\t\tif (m.members.has(key)) this.reportDuplicate(m, name.span, name.name);\n\t\telse m.members.set(key, symbol);\n\t}\n\n\tprivate reportDuplicate(m: BoundModule, span: Span, name: string): void {\n\t\tthis.diagnostics.add(m.name, 'duplicate-declaration', span, name);\n\t}\n}\n\n/** The Long type every Enum member has. */\nexport const ENUM_MEMBER_TYPE = scalarType('Long');\n","// Compile errors the binder finds ([MS-VBAL] 5: name resolution and declaration rules), in the\n// VBA editor's wording. Parse diagnostics from `lang` are carried through with their module.\nimport type { Span, VbaDiagnostic } from '../lang/index';\n\n/** The compile errors the binder reports. `SEMANTIC_MESSAGES` gives each one's wording. */\nexport type SemanticDiagnosticCode =\n\t| 'variable-not-defined'\n\t| 'sub-or-function-not-defined'\n\t| 'duplicate-declaration'\n\t| 'ambiguous-name'\n\t| 'label-not-defined'\n\t| 'byref-argument-type-mismatch'\n\t| 'wrong-number-of-arguments'\n\t| 'argument-not-optional'\n\t| 'named-argument-not-found'\n\t| 'invalid-use-of-me'\n\t| 'user-defined-type-not-defined'\n\t| 'method-or-data-member-not-found'\n\t| 'expected-array'\n\t| 'invalid-qualifier'\n\t| 'constant-expression-required'\n\t| 'declare-not-supported'\n\t| 'exit-not-allowed'\n\t| 'exit-not-in-loop'\n\t| 'only-valid-in-object-module';\n\n/** The message VBA's editor shows for each code. */\nexport const SEMANTIC_MESSAGES: Readonly<Record<SemanticDiagnosticCode, string>> = {\n\t'variable-not-defined': 'Variable not defined',\n\t'sub-or-function-not-defined': 'Sub or Function not defined',\n\t'duplicate-declaration': 'Duplicate declaration in current scope',\n\t'ambiguous-name': 'Ambiguous name detected',\n\t'label-not-defined': 'Label not defined',\n\t'byref-argument-type-mismatch': 'ByRef argument type mismatch',\n\t'wrong-number-of-arguments': 'Wrong number of arguments or invalid property assignment',\n\t'argument-not-optional': 'Argument not optional',\n\t'named-argument-not-found': 'Named argument not found',\n\t'invalid-use-of-me': 'Invalid use of Me keyword',\n\t'user-defined-type-not-defined': 'User-defined type not defined',\n\t'method-or-data-member-not-found': 'Method or data member not found',\n\t'expected-array': 'Expected array',\n\t'invalid-qualifier': 'Invalid qualifier',\n\t'constant-expression-required': 'Constant expression required',\n\t'declare-not-supported': 'Declare statements are not supported in this environment',\n\t'exit-not-allowed': 'Exit {target} not allowed in {others}',\n\t'exit-not-in-loop': 'Exit {target} not within {loop}',\n\t'only-valid-in-object-module': 'Only valid in object module',\n};\n\n/** The runtime error an executor raises if it reaches code with this compile error. */\nexport const SEMANTIC_ERROR_NUMBERS: Readonly<Partial<Record<SemanticDiagnosticCode, number>>> = {\n\t'sub-or-function-not-defined': 35,\n\t'wrong-number-of-arguments': 450,\n\t'argument-not-optional': 449,\n\t'named-argument-not-found': 448,\n\t'method-or-data-member-not-found': 438,\n\t'expected-array': 13,\n\t'declare-not-supported': 445,\n};\n\n/** A diagnostic of the bound program: a parse diagnostic or a semantic one, with its module. */\nexport interface BoundDiagnostic {\n\t/** The name of the module it was found in. */\n\treadonly module: string;\n\t/** The parser's or the binder's code. */\n\treadonly code: VbaDiagnostic['code'] | SemanticDiagnosticCode;\n\t/** The message, in the VBA editor's wording for binder codes. */\n\treadonly message: string;\n\t/** An error stops the module from running; a warning does not. */\n\treadonly severity: 'error' | 'warning';\n\t/** The source the problem covers. */\n\treadonly span: Span;\n}\n\n/** Collects diagnostics, capped so hostile input cannot grow the list without bound. */\nexport class DiagnosticSink {\n\treadonly items: BoundDiagnostic[] = [];\n\tconstructor(private readonly max = 1000) {}\n\n\tadd(module: string, code: SemanticDiagnosticCode, span: Span, detail?: string): void {\n\t\tif (this.items.length >= this.max) return;\n\t\tconst message = messageOf(code, detail);\n\t\tconst severity = code === 'declare-not-supported' ? 'warning' : 'error';\n\t\tthis.items.push({ module, code, message, severity, span });\n\t}\n\n\taddParsed(module: string, diagnostic: VbaDiagnostic): void {\n\t\tif (this.items.length >= this.max) return;\n\t\tthis.items.push({ ...diagnostic, module });\n\t}\n}\n\nconst EXIT_OTHERS: Readonly<Record<string, string>> = {\n\tSub: 'Function or Property',\n\tFunction: 'Sub or Property',\n\tProperty: 'Function or Sub',\n};\n\n/** The editor's message: the code's text, with its detail appended or filled in. */\nfunction messageOf(code: SemanticDiagnosticCode, detail: string | undefined): string {\n\tconst text = SEMANTIC_MESSAGES[code];\n\tif (code === 'exit-not-in-loop' && detail)\n\t\treturn text\n\t\t\t.replace('{target}', detail)\n\t\t\t.replace('{loop}', detail === 'Do' ? 'Do...Loop' : 'For...Next');\n\tif (code === 'exit-not-allowed' && detail)\n\t\treturn text\n\t\t\t.replace('{target}', detail)\n\t\t\t.replace('{others}', EXIT_OTHERS[detail] ?? 'this procedure');\n\treturn text + (detail ? `: ${detail}` : '');\n}\n","// A bound module: its options, module-level symbols, procedures and, for class and document\n// modules, the shape other code sees (public members, default member, events, interfaces).\nimport type { ModuleKind, ModuleNode } from '../lang/index';\nimport type { BoundProcedure, PropertyGroup } from './procedure';\nimport type {\n\tConstSymbol,\n\tDeclareSymbol,\n\tEnumMemberSymbol,\n\tEnumSymbol,\n\tEventSymbol,\n\tUdtSymbol,\n\tVariableSymbol,\n} from './symbols';\nimport type { ScalarTypeName } from './types';\n\n/** The `Option` statements of a module, with VBA's defaults for those not written. */\nexport interface ModuleOptions {\n\t/** `Option Base` (0 or 1): the default lower bound of arrays declared without one. */\n\treadonly base: 0 | 1;\n\t/** `Option Compare Text`. */\n\treadonly compareText: boolean;\n\t/** `Option Explicit`: every variable must be declared. */\n\treadonly explicit: boolean;\n\t/** `Option Private Module`: public members are not visible outside the project. */\n\treadonly privateModule: boolean;\n}\n\n/** A module-level name: what `ModuleScope` finds for it. */\nexport type ModuleMemberSymbol =\n\t| VariableSymbol\n\t| ConstSymbol\n\t| EnumSymbol\n\t| EnumMemberSymbol\n\t| DeclareSymbol\n\t| PropertyGroup;\n\n/**\n * One module of a bound program: its options, module-level symbols and procedures, and for class\n * and document modules the shape other code sees (default member, events, interfaces).\n */\nexport class BoundModule {\n\t/** The module's `Option` statements. */\n\toptions: ModuleOptions = { base: 0, compareText: false, explicit: false, privateModule: false };\n\t/** Module variables (`scope` module) or class instance variables (`scope` instance), by slot. */\n\treadonly variables: VariableSymbol[] = [];\n\t/** Module constants, in an order where each comes after the constants its value uses. */\n\treadonly consts: ConstSymbol[] = [];\n\t/** `Enum` declarations, in source order. */\n\treadonly enums: EnumSymbol[] = [];\n\t/** `Type` declarations (user-defined types), in source order. */\n\treadonly udts: UdtSymbol[] = [];\n\t/** `Event` declarations of a class module, in source order. */\n\treadonly events: EventSymbol[] = [];\n\t/** `Declare` statements (external procedures), in source order. */\n\treadonly declares: DeclareSymbol[] = [];\n\t/** Every procedure (each Property accessor separately), in source order. */\n\treadonly procedures: BoundProcedure[] = [];\n\t/** Procedures by lower-case name. */\n\treadonly groups = new Map<string, PropertyGroup>();\n\t/** Every module-level name (lower case). */\n\treadonly members = new Map<string, ModuleMemberSymbol>();\n\t/** `DefInt A-Z` and friends: the type of each letter (lower case). */\n\treadonly defTypes = new Map<string, ScalarTypeName>();\n\t/** Class modules named by `Implements`. */\n\treadonly implements: BoundModule[] = [];\n\t/** The member with `VB_UserMemId = 0` (class modules). */\n\tdefaultMember: PropertyGroup | null = null;\n\t/** The member with `VB_UserMemId = -4` (`For Each` over an instance). */\n\tnewEnum: PropertyGroup | null = null;\n\t/** `VB_PredeclaredId = True`: the class has a default instance named like the class. */\n\tpredeclared = false;\n\t/** Handlers of `WithEvents` variables: the Sub for each variable and event (lower case). */\n\treadonly eventHandlers = new Map<string, Map<string, BoundProcedure>>();\n\t/** True when a compile error was found in this module; it cannot run. */\n\thasErrors = false;\n\n\tconstructor(\n\t\t/** The module name the host gave. */\n\t\treadonly name: string,\n\t\t/** Standard, class, document or form module. */\n\t\treadonly kind: ModuleKind,\n\t\t/** The parsed module. */\n\t\treadonly ast: ModuleNode,\n\t) {}\n\n\t/** The Sub that handles `<prefix>_<event>` (a document module's `Workbook_Open`). */\n\thandler(prefix: string, event: string): BoundProcedure | null {\n\t\tconst group = this.groups.get(`${prefix}_${event}`.toLowerCase());\n\t\treturn group?.method?.kind === 'Sub' ? group.method : null;\n\t}\n\n\t/** True for modules whose variables live per object (class and form modules). */\n\tget perInstance(): boolean {\n\t\treturn this.kind === 'class' || this.kind === 'form';\n\t}\n\n\t/** True for modules whose code runs with a `Me` (class, form and document modules). */\n\tget hasMe(): boolean {\n\t\treturn this.kind !== 'standard';\n\t}\n}\n","// Facts about operands that every executor needs and that depend only on the bound model.\nimport type { Expression } from '../lang/index';\nimport type { Binding } from './bindings';\nimport { isVariant, type StaticType } from './types';\n\n/** The two lookups the facts read (a `BoundProgram`). */\nexport interface BoundLookup {\n\tbinding(node: Expression): Binding | undefined;\n\ttypeOf(node: Expression): StaticType;\n}\n\n/**\n * Whether an operand counts as declared (typed) for comparisons ([MS-VBAL] 5.6.9.8.1): a variable,\n * parameter or function result declared with a type other than Variant. Literals and constants do\n * not: Excel compares `v < \"9a\"` (v holding 9) as a number against a string, without converting.\n * A Boolean literal does count: `\"True\" = True` converts the string and is True in Excel.\n */\nexport function isTypedOperand(model: BoundLookup, e: Expression): boolean {\n\tswitch (e.kind) {\n\t\tcase 'NumberLiteral':\n\t\tcase 'StringLiteral':\n\t\tcase 'DateLiteral':\n\t\tcase 'EmptyLiteral':\n\t\tcase 'NullLiteral':\n\t\tcase 'NothingLiteral':\n\t\t\treturn false;\n\t\tcase 'Paren':\n\t\t\treturn isTypedOperand(model, e.expression);\n\t\tcase 'Unary':\n\t\t\treturn isTypedOperand(model, e.operand);\n\t\tcase 'Name': {\n\t\t\tconst k = model.binding(e)?.kind;\n\t\t\tif (k === 'const' || k === 'enumMember' || k === 'libraryConstant') return false;\n\t\t\treturn !isVariant(model.typeOf(e));\n\t\t}\n\t\tdefault:\n\t\t\treturn !isVariant(model.typeOf(e));\n\t}\n}\n\n/**\n * `Len(v)` / `LenB(v)` of a variable or parameter declared with a scalar type other than String:\n * the VT whose byte size the call returns instead of the length of the text ([MS-VBAL]\n * 6.1.2.11.1.15), else null.\n */\nexport function typedLengthVt(\n\tmodel: BoundLookup,\n\tname: string,\n\targument: Expression | undefined,\n): number | null {\n\tconst lower = name.toLowerCase();\n\tif ((lower !== 'len' && lower !== 'lenb') || !argument || argument.kind !== 'Name') return null;\n\tconst k = model.binding(argument)?.kind;\n\tif (k !== 'variable' && k !== 'param') return null;\n\tconst t = model.typeOf(argument);\n\treturn t.kind === 'scalar' && t.vt !== 8 ? t.vt : null;\n}\n\n/**\n * Whether a conversion's argument has a type known before it runs: a literal, a constant, or an\n * expression of a declared non-Variant type. Office raises 6 for an out-of-range value of such an\n * argument (`CDate(3000000)`), 13 for one held in a Variant.\n */\nexport function isStaticallyTyped(model: BoundLookup, e: Expression): boolean {\n\tswitch (e.kind) {\n\t\tcase 'NumberLiteral':\n\t\tcase 'StringLiteral':\n\t\tcase 'DateLiteral':\n\t\tcase 'BooleanLiteral':\n\t\t\treturn true;\n\t\tcase 'Paren':\n\t\t\treturn isStaticallyTyped(model, e.expression);\n\t\tcase 'Unary':\n\t\t\treturn isStaticallyTyped(model, e.operand);\n\t\tcase 'Name': {\n\t\t\tconst k = model.binding(e)?.kind;\n\t\t\tif (k === 'const' || k === 'enumMember' || k === 'libraryConstant') return true;\n\t\t\treturn !isVariant(model.typeOf(e));\n\t\t}\n\t\tdefault:\n\t\t\treturn !isVariant(model.typeOf(e));\n\t}\n}\n","// The bound program: the modules with their symbols, and side tables keyed by AST node that say\n// what each name, call and `.member` refers to. It is the one model both executors read: the\n// interpreter walks it, the compiler emits JavaScript from it.\nimport type { Expression, Statement } from '../lang/index';\nimport type { Binding, Invocation, WithBlock } from './bindings';\nimport type { BoundDiagnostic } from './diagnostics';\nimport type { BoundModule } from './module';\nimport type { BoundProcedure, PropertyGroup } from './procedure';\nimport { isTypedOperand } from './operands';\nimport { VARIANT, type StaticType } from './types';\n\n/** The side tables the binder fills; one per program. */\nexport class BindingTable {\n\t/** What each name, `Me`, member access, `!` access or call refers to. */\n\treadonly bindings = new Map<Expression, Binding>();\n\t/** What each call, index or call statement does. */\n\treadonly invocations = new Map<Expression | Statement, Invocation>();\n\t/** The `With` block of each `.member` or `!key` written without an object. */\n\treadonly withRefs = new Map<Expression, WithBlock>();\n\t/** The static type of each expression the binder could type. */\n\treadonly types = new Map<Expression, StaticType>();\n\t/** Values used as objects (Set, Is, a Variant or Object argument): no default member is read. */\n\treadonly objectUses = new Set<Expression>();\n}\n\n/**\n * `BoundProgram.mayCallDefault` over the side tables: a Variant or Object value read for its value,\n * unless it is passed on as an object, is an operator's result, or is the result of a library\n * function that never returns an object (`Len(s)`, `Mid(s, 2)`).\n */\nexport function readMayCall(table: BindingTable, e: Expression): boolean {\n\t// An operator's result is never an object (its operands are reads of their own).\n\tif (e.kind === 'Binary' || e.kind === 'Unary' || e.kind === 'TypeOf') return false;\n\tif (table.objectUses.has(e)) return false;\n\tconst t = table.types.get(e);\n\tif (t !== undefined && t.kind !== 'variant' && t.kind !== 'object') return false;\n\tconst inv = table.invocations.get(e);\n\treturn !(inv?.kind === 'library' && !inv.entry.mayReturnObject);\n}\n\n/**\n * A bound project: what `bindProgram` returns. It holds the bound modules and the compile\n * diagnostics, and answers, for any AST node of the project, what the binder decided about it.\n */\nexport class BoundProgram {\n\tprivate readonly byName = new Map<string, BoundModule>();\n\n\tconstructor(\n\t\t/** The modules, in the order they were given to `bindProgram`. */\n\t\treadonly modules: readonly BoundModule[],\n\t\t/** Parse and compile diagnostics of every module. */\n\t\treadonly diagnostics: readonly BoundDiagnostic[],\n\t\tprivate readonly table: BindingTable,\n\t) {\n\t\tfor (const m of modules) this.byName.set(m.name.toLowerCase(), m);\n\t}\n\n\t/** The module with this name, compared case-insensitively. */\n\tmodule(name: string): BoundModule | undefined {\n\t\treturn this.byName.get(name.toLowerCase());\n\t}\n\n\t/**\n\t * Whether evaluating `e` for its value may run code implicitly: read an object's default member\n\t * (a Variant, Object or class-typed operand of an operator, a Let, Print, a conversion, an\n\t * index), or enumerate it (`For Each`). False for literals, typed scalars, and values passed on\n\t * as objects (Set, Is, TypeOf, a Variant or Object argument). Conservative: true may still not\n\t * call anything.\n\t */\n\tmayCallDefault(e: Expression): boolean {\n\t\treturn readMayCall(this.table, e);\n\t}\n\n\t/** What a `Name`, `Me`, `MemberAccess`, `DictionaryAccess` or `CallOrIndex` refers to. */\n\tbinding(node: Expression): Binding | undefined {\n\t\treturn this.table.bindings.get(node);\n\t}\n\n\t/** What a `CallOrIndex` or call statement does. */\n\tinvocation(node: Expression | Statement): Invocation | undefined {\n\t\treturn this.table.invocations.get(node);\n\t}\n\n\t/** The `With` block a `.member` or `!key` with no object refers to. */\n\twithBlock(node: Expression): WithBlock | undefined {\n\t\treturn this.table.withRefs.get(node);\n\t}\n\n\t/** The static type of an expression (Variant when nothing is known). */\n\ttypeOf(node: Expression): StaticType {\n\t\treturn this.table.types.get(node) ?? VARIANT;\n\t}\n\n\t/** Whether a comparison operand counts as declared (typed); see `isTypedOperand`. */\n\tisTypedOperand(node: Expression): boolean {\n\t\treturn isTypedOperand(this, node);\n\t}\n\n\t/**\n\t * Finds a procedure group by `Module.Name` or by an unambiguous `Name` among the standard\n\t * modules (as `Application.Run` does). Private procedures are found when qualified.\n\t */\n\tfindGroup(name: string): PropertyGroup | 'ambiguous' | undefined {\n\t\tconst dot = name.lastIndexOf('.');\n\t\tif (dot > 0) {\n\t\t\tconst m = this.module(name.slice(0, dot));\n\t\t\treturn m?.groups.get(name.slice(dot + 1).toLowerCase());\n\t\t}\n\t\tconst found: PropertyGroup[] = [];\n\t\tfor (const m of this.modules) {\n\t\t\tconst g = m.groups.get(name.toLowerCase());\n\t\t\tif (g && (m.kind === 'standard' || m.kind === 'document')) found.push(g);\n\t\t}\n\t\tif (found.length > 1) {\n\t\t\tconst standard = found.filter((g) => g.module.kind === 'standard');\n\t\t\treturn standard.length === 1 ? standard[0] : 'ambiguous';\n\t\t}\n\t\treturn found[0];\n\t}\n\n\t/** Every bound procedure of every module. */\n\t*procedures(): IterableIterator<BoundProcedure> {\n\t\tfor (const m of this.modules) yield* m.procedures;\n\t}\n\n\t/** True when any module has a compile error. */\n\tget hasErrors(): boolean {\n\t\treturn this.modules.some((m) => m.hasErrors);\n\t}\n}\n","// VBA's built-in constants ([MS-VBAL] 6.1.1): the vb* enumerations as Long values and the string\n// constants (vbCrLf, vbTab, ...).\nimport { scalarType } from '../types';\nimport type { LibraryConstant } from './entry';\n\nconst LONG = scalarType('Long');\nconst STRING = scalarType('String');\n\nconst NUMERIC: Readonly<Record<string, number>> = {\n\t// VbCompareMethod, VbTriState\n\tvbUseCompareOption: -1,\n\tvbBinaryCompare: 0,\n\tvbTextCompare: 1,\n\tvbDatabaseCompare: 2,\n\tvbTrue: -1,\n\tvbFalse: 0,\n\tvbUseDefault: -2,\n\t// VbVarType\n\tvbEmpty: 0,\n\tvbNull: 1,\n\tvbInteger: 2,\n\tvbLong: 3,\n\tvbSingle: 4,\n\tvbDouble: 5,\n\tvbCurrency: 6,\n\tvbDate: 7,\n\tvbString: 8,\n\tvbObject: 9,\n\tvbError: 10,\n\tvbBoolean: 11,\n\tvbVariant: 12,\n\tvbDataObject: 13,\n\tvbDecimal: 14,\n\tvbByte: 17,\n\tvbLongLong: 20,\n\tvbUserDefinedType: 36,\n\tvbArray: 8192,\n\t// VbDayOfWeek, VbFirstWeekOfYear\n\tvbUseSystemDayOfWeek: 0,\n\tvbSunday: 1,\n\tvbMonday: 2,\n\tvbTuesday: 3,\n\tvbWednesday: 4,\n\tvbThursday: 5,\n\tvbFriday: 6,\n\tvbSaturday: 7,\n\tvbUseSystem: 0,\n\tvbFirstJan1: 1,\n\tvbFirstFourDays: 2,\n\tvbFirstFullWeek: 3,\n\t// VbDateTimeFormat\n\tvbGeneralDate: 0,\n\tvbLongDate: 1,\n\tvbShortDate: 2,\n\tvbLongTime: 3,\n\tvbShortTime: 4,\n\t// VbStrConv\n\tvbUpperCase: 1,\n\tvbLowerCase: 2,\n\tvbProperCase: 3,\n\tvbWide: 4,\n\tvbNarrow: 8,\n\tvbKatakana: 16,\n\tvbHiragana: 32,\n\tvbUnicode: 64,\n\tvbFromUnicode: 128,\n\t// VbMsgBoxStyle, VbMsgBoxResult\n\tvbOKOnly: 0,\n\tvbOKCancel: 1,\n\tvbAbortRetryIgnore: 2,\n\tvbYesNoCancel: 3,\n\tvbYesNo: 4,\n\tvbRetryCancel: 5,\n\tvbCritical: 16,\n\tvbQuestion: 32,\n\tvbExclamation: 48,\n\tvbInformation: 64,\n\tvbDefaultButton1: 0,\n\tvbDefaultButton2: 256,\n\tvbDefaultButton3: 512,\n\tvbDefaultButton4: 768,\n\tvbApplicationModal: 0,\n\tvbSystemModal: 4096,\n\tvbMsgBoxHelpButton: 16384,\n\tvbMsgBoxSetForeground: 65536,\n\tvbMsgBoxRight: 524288,\n\tvbMsgBoxRtlReading: 1048576,\n\tvbOK: 1,\n\tvbCancel: 2,\n\tvbAbort: 3,\n\tvbRetry: 4,\n\tvbIgnore: 5,\n\tvbYes: 6,\n\tvbNo: 7,\n\t// VbCallType\n\tvbMethod: 1,\n\tvbGet: 2,\n\tvbLet: 4,\n\tvbSet: 8,\n\t// VbFileAttribute, VbAppWinStyle\n\tvbNormal: 0,\n\tvbReadOnly: 1,\n\tvbHidden: 2,\n\tvbSystem: 4,\n\tvbVolume: 8,\n\tvbDirectory: 16,\n\tvbArchive: 32,\n\tvbAlias: 64,\n\tvbHide: 0,\n\tvbNormalFocus: 1,\n\tvbMinimizedFocus: 2,\n\tvbMaximizedFocus: 3,\n\tvbNormalNoFocus: 4,\n\tvbMinimizedNoFocus: 6,\n\t// ColorConstants, vbObjectError\n\tvbBlack: 0x0,\n\tvbRed: 0xff,\n\tvbGreen: 0xff00,\n\tvbYellow: 0xffff,\n\tvbBlue: 0xff0000,\n\tvbMagenta: 0xff00ff,\n\tvbCyan: 0xffff00,\n\tvbWhite: 0xffffff,\n\tvbObjectError: -2147221504,\n};\n\nconst TEXT: Readonly<Record<string, string>> = {\n\tvbCr: '\\r',\n\tvbLf: '\\n',\n\tvbCrLf: '\\r\\n',\n\tvbNewLine: '\\r\\n',\n\tvbNullChar: '\\0',\n\tvbNullString: '',\n\tvbTab: '\\t',\n\tvbBack: '\\b',\n\tvbFormFeed: '\\f',\n\tvbVerticalTab: '\\v',\n};\n\n/** Every built-in constant: the `vb` enumeration values as `Long`, the text ones as `String`. */\nexport const LIBRARY_CONSTANTS: readonly LibraryConstant[] = [\n\t...Object.entries(NUMERIC).map(([name, value]): LibraryConstant => ({\n\t\tkind: 'constant',\n\t\tname,\n\t\tvalue,\n\t\ttype: LONG,\n\t})),\n\t...Object.entries(TEXT).map(([name, value]): LibraryConstant => ({\n\t\tkind: 'constant',\n\t\tname,\n\t\tvalue,\n\t\ttype: STRING,\n\t})),\n];\n","// The shape of VBA's standard library as the binder and both executors see it: each entry names\n// the runtime export that implements it and how to call that export, so the interpreter's dispatch\n// table and the compiler's generated calls are built from one list.\nimport { scalarType, VARIANT, type ScalarTypeName, type StaticType } from '../types';\n\n/**\n * How a runtime export is called: `env` (args, env), `conversion` (the one argument, env, typed:\n * whether it is a literal or of a declared non-Variant type, see the invocation's `typedArgument`),\n * `compare` (args, Option Compare mode, env), `session` (session, args), `pure` (args), `list`\n * (args, ParamArray values, env), `special` (the executor implements it).\n */\nexport type LibraryConvention =\n\t| 'env'\n\t| 'conversion'\n\t| 'compare'\n\t| 'session'\n\t| 'pure'\n\t| 'list'\n\t| 'special';\n\n/** A function or statement of VBA's library (`Left`, `MsgBox`, `Randomize`). */\nexport interface LibraryFunction {\n\t/** Marks a function entry. */\n\treadonly kind: 'function';\n\t/** The canonical VBA name, with `$` for the String forms. */\n\treadonly name: string;\n\t/** The runtime export (`leftS`), or null for `special` entries. */\n\treadonly runtime: string | null;\n\t/** How an executor calls the runtime export. */\n\treadonly convention: LibraryConvention;\n\t/** Parameter names in order, for named arguments (`InStr(Start:=2, ...)`). */\n\treadonly params: readonly string[];\n\t/** How many leading parameters are required. */\n\treadonly required: number;\n\t/** The last parameter is a ParamArray. */\n\treadonly paramArray: boolean;\n\t/**\n\t * `InStr`/`InStrB`: the first parameter is optional although it comes first, so a call with\n\t * `required` arguments leaves it out (`InStr(s, \"x\")` is `InStr(, s, \"x\")`).\n\t */\n\treadonly leadingOptional: boolean;\n\t/** The static type of the result: `String` for the `$` forms, Variant unless stated. */\n\treadonly returns: StaticType;\n\t/** May answer with a Promise (MsgBox, InputBox, DoEvents, CallByName on a host object). */\n\treadonly async: boolean;\n\t/** A statement-like procedure called without a result (Randomize). */\n\treadonly statement: boolean;\n\t/**\n\t * May return an object (CallByName, Choose, CreateObject, GetObject, IIf, Switch): using the\n\t * result as a value may read its default member.\n\t */\n\treadonly mayReturnObject: boolean;\n}\n\n/** A built-in constant (`vbCrLf`, `vbTextCompare`). */\nexport interface LibraryConstant {\n\t/** Marks a constant entry. */\n\treadonly kind: 'constant';\n\t/** The constant's name, in its canonical spelling. */\n\treadonly name: string;\n\t/** Its value. */\n\treadonly value: number | string;\n\t/** `Long` for the numeric enum constants, `String` for vbCrLf and the like. */\n\treadonly type: StaticType;\n}\n\n/** The objects VBA's library provides: `Err`, `Debug`, and the `VBA` qualifier itself. */\nexport interface LibraryObject {\n\t/** Marks an object entry. */\n\treadonly kind: 'object';\n\t/** Which object. */\n\treadonly name: 'Err' | 'Debug' | 'VBA';\n}\n\n/** Any entry of VBA's library, told apart by `kind`. */\nexport type LibraryEntry = LibraryFunction | LibraryConstant | LibraryObject;\n\n/** The optional settings of a function entry built with `fn` or `twin`. */\nexport interface FunctionOptions {\n\t/** See {@link LibraryFunction.required}. Defaults to every parameter but a ParamArray. */\n\treadonly required?: number;\n\t/** The result type. Defaults to `String` for a name ending in `$`, else Variant. */\n\treadonly returns?: ScalarTypeName | 'Variant';\n\t/** See {@link LibraryFunction.async}. Defaults to false. */\n\treadonly async?: boolean;\n\t/** See {@link LibraryFunction.statement}. Defaults to false. */\n\treadonly statement?: boolean;\n\t/** See {@link LibraryFunction.leadingOptional}. Defaults to false. */\n\treadonly leadingOptional?: boolean;\n\treadonly mayReturnObject?: boolean;\n}\n\n/**\n * A function entry: `params` is a space-separated list; a trailing `...` marks the last one as a\n * ParamArray. `required` defaults to every parameter but a ParamArray.\n */\nexport function fn(\n\tname: string,\n\truntime: string | null,\n\tconvention: LibraryConvention,\n\tparams: string,\n\toptions: FunctionOptions = {},\n): LibraryFunction {\n\tconst list = params === '' ? [] : params.split(' ');\n\tconst paramArray = list.at(-1)?.endsWith('...') ?? false;\n\tconst names = list.map((p) => p.replace('...', ''));\n\tconst returns =\n\t\toptions.returns === undefined || options.returns === 'Variant'\n\t\t\t? name.endsWith('$')\n\t\t\t\t? scalarType('String')\n\t\t\t\t: VARIANT\n\t\t\t: scalarType(options.returns);\n\treturn Object.freeze({\n\t\tkind: 'function',\n\t\tname,\n\t\truntime,\n\t\tconvention,\n\t\tparams: names,\n\t\trequired: options.required ?? (paramArray ? names.length - 1 : names.length),\n\t\tparamArray,\n\t\tleadingOptional: options.leadingOptional ?? false,\n\t\treturns,\n\t\tasync: options.async ?? false,\n\t\tmayReturnObject: options.mayReturnObject ?? false,\n\t\tstatement: options.statement ?? false,\n\t});\n}\n\n/** A function with a `$` twin that calls a separate runtime export (`Left`/`Left$`). */\nexport function twin(\n\tname: string,\n\truntime: string,\n\truntimeS: string,\n\tconvention: LibraryConvention,\n\tparams: string,\n\toptions: FunctionOptions = {},\n): LibraryFunction[] {\n\treturn [\n\t\tfn(name, runtime, convention, params, options),\n\t\tfn(`${name}$`, runtimeS, convention, params, { ...options, returns: 'String' }),\n\t];\n}\n","// VBA's library functions ([MS-VBAL] 6.1.2): name, runtime export, calling convention and\n// parameters. The parameter names are the documented ones, so named arguments bind.\nimport { fn, twin, type LibraryFunction } from './entry';\n\nconst NUM_FORMAT =\n\t'Expression NumDigitsAfterDecimal IncludeLeadingDigit UseParensForNegativeNumbers GroupDigits';\n\nconst STRINGS: LibraryFunction[] = [\n\tfn('Asc', 'asc', 'env', 'String', { returns: 'Integer' }),\n\tfn('AscB', 'ascB', 'env', 'String', { returns: 'Integer' }),\n\tfn('AscW', 'ascW', 'env', 'String', { returns: 'Integer' }),\n\t...twin('Chr', 'chr', 'chr', 'env', 'CharCode'),\n\t...twin('ChrB', 'chrB', 'chrB', 'env', 'CharCode'),\n\t...twin('ChrW', 'chrW', 'chrW', 'env', 'CharCode'),\n\t...twin(\n\t\t'Format',\n\t\t'format',\n\t\t'formatS',\n\t\t'env',\n\t\t'Expression Format FirstDayOfWeek FirstWeekOfYear',\n\t\t{\n\t\t\trequired: 1,\n\t\t},\n\t),\n\tfn('FormatCurrency', 'formatCurrency', 'env', NUM_FORMAT, { required: 1 }),\n\tfn('FormatNumber', 'formatNumber', 'env', NUM_FORMAT, { required: 1 }),\n\tfn('FormatPercent', 'formatPercent', 'env', NUM_FORMAT, { required: 1 }),\n\tfn('FormatDateTime', 'formatDateTime', 'env', 'Expression NamedFormat', { required: 1 }),\n\tfn('InStr', 'inStr', 'compare', 'Start String1 String2 Compare', {\n\t\trequired: 2,\n\t\tleadingOptional: true,\n\t}),\n\tfn('InStrB', 'inStrB', 'compare', 'Start String1 String2 Compare', {\n\t\trequired: 2,\n\t\tleadingOptional: true,\n\t}),\n\tfn('InStrRev', 'inStrRev', 'compare', 'StringCheck StringMatch Start Compare', { required: 2 }),\n\tfn('Join', 'join', 'env', 'SourceArray Delimiter', { required: 1 }),\n\t...twin('LCase', 'lCase', 'lCaseS', 'env', 'String'),\n\t...twin('UCase', 'uCase', 'uCaseS', 'env', 'String'),\n\t...twin('Left', 'left', 'leftS', 'env', 'String Length'),\n\t...twin('LeftB', 'leftB', 'leftB', 'env', 'String Length'),\n\t...twin('Right', 'right', 'rightS', 'env', 'String Length'),\n\t...twin('RightB', 'rightB', 'rightB', 'env', 'String Length'),\n\t...twin('Mid', 'mid', 'midS', 'env', 'String Start Length', { required: 2 }),\n\t...twin('MidB', 'midB', 'midB', 'env', 'String Start Length', { required: 2 }),\n\tfn('Len', 'len', 'env', 'Expression'),\n\tfn('LenB', 'lenB', 'env', 'Expression'),\n\t...twin('LTrim', 'lTrim', 'lTrimS', 'env', 'String'),\n\t...twin('RTrim', 'rTrim', 'rTrimS', 'env', 'String'),\n\t...twin('Trim', 'trim', 'trimS', 'env', 'String'),\n\tfn('Replace', 'replace', 'compare', 'Expression Find Replace Start Count Compare', {\n\t\trequired: 3,\n\t\treturns: 'String',\n\t}),\n\t...twin('Space', 'space', 'space', 'env', 'Number'),\n\tfn('Split', 'split', 'compare', 'Expression Delimiter Limit Compare', { required: 1 }),\n\tfn('StrComp', 'strComp', 'compare', 'String1 String2 Compare', { required: 2 }),\n\tfn('StrConv', 'strConv', 'env', 'String Conversion'),\n\t...twin('String', 'string', 'stringS', 'env', 'Number Character'),\n\tfn('StrReverse', 'strReverse', 'env', 'Expression', { returns: 'String' }),\n\tfn('Filter', 'filter', 'compare', 'SourceArray Match Include Compare', { required: 2 }),\n\t...twin('Str', 'str', 'strS', 'env', 'Number'),\n\tfn('Val', 'val', 'env', 'String', { returns: 'Double' }),\n\t...twin('Hex', 'hex', 'hexS', 'env', 'Number'),\n\t...twin('Oct', 'oct', 'octS', 'env', 'Number'),\n];\n\nconst CONVERSION: LibraryFunction[] = [\n\tfn('CBool', 'cBool', 'conversion', 'Expression', { returns: 'Boolean' }),\n\tfn('CByte', 'cByte', 'conversion', 'Expression', { returns: 'Byte' }),\n\tfn('CCur', 'cCur', 'conversion', 'Expression', { returns: 'Currency' }),\n\tfn('CDate', 'cDate', 'conversion', 'Expression', { returns: 'Date' }),\n\tfn('CVDate', 'cDate', 'conversion', 'Expression'),\n\tfn('CDbl', 'cDbl', 'conversion', 'Expression', { returns: 'Double' }),\n\tfn('CDec', 'cDec', 'conversion', 'Expression'),\n\tfn('CInt', 'cInt', 'conversion', 'Expression', { returns: 'Integer' }),\n\tfn('CLng', 'cLng', 'conversion', 'Expression', { returns: 'Long' }),\n\tfn('CLngLng', 'cLngLng', 'conversion', 'Expression', { returns: 'LongLong' }),\n\tfn('CLngPtr', 'cLngPtr', 'conversion', 'Expression', { returns: 'LongPtr' }),\n\tfn('CSng', 'cSng', 'conversion', 'Expression', { returns: 'Single' }),\n\tfn('CStr', 'cStr', 'conversion', 'Expression', { returns: 'String' }),\n\tfn('CVar', 'cVar', 'pure', 'Expression'),\n\tfn('CVErr', 'cVErr', 'env', 'Expression'),\n\t// Error without an argument is the message of Err.Number: the executor supplies it.\n\tfn('Error', 'error', 'special', 'ErrorNumber', { required: 0 }),\n\tfn('Error$', 'error', 'special', 'ErrorNumber', { required: 0, returns: 'String' }),\n];\n\nconst MATH: LibraryFunction[] = [\n\tfn('Abs', 'abs', 'env', 'Number'),\n\tfn('Atn', 'atn', 'env', 'Number', { returns: 'Double' }),\n\tfn('Cos', 'cos', 'env', 'Number', { returns: 'Double' }),\n\tfn('Exp', 'exp', 'env', 'Number', { returns: 'Double' }),\n\tfn('Fix', 'fix', 'env', 'Number'),\n\tfn('Int', 'int', 'env', 'Number'),\n\tfn('Log', 'log', 'env', 'Number', { returns: 'Double' }),\n\tfn('Rnd', 'rnd', 'session', 'Number', { required: 0, returns: 'Single' }),\n\tfn('Randomize', 'randomize', 'session', 'Number', { required: 0, statement: true }),\n\tfn('Round', 'round', 'env', 'Number NumDigitsAfterDecimal', { required: 1 }),\n\tfn('Sgn', 'sgn', 'env', 'Number', { returns: 'Integer' }),\n\tfn('Sin', 'sin', 'env', 'Number', { returns: 'Double' }),\n\tfn('Sqr', 'sqr', 'env', 'Number', { returns: 'Double' }),\n\tfn('Tan', 'tan', 'env', 'Number', { returns: 'Double' }),\n];\n\nconst DATES: LibraryFunction[] = [\n\tfn('Date', 'date', 'session', ''),\n\tfn('Date$', 'dateS', 'session', ''),\n\tfn('Now', 'now', 'session', ''),\n\tfn('Time', 'time', 'session', ''),\n\tfn('Time$', 'timeS', 'session', ''),\n\tfn('Timer', 'timer', 'session', '', { returns: 'Single' }),\n\tfn('DateAdd', 'dateAdd', 'env', 'Interval Number Date'),\n\tfn('DateDiff', 'dateDiff', 'env', 'Interval Date1 Date2 FirstDayOfWeek FirstWeekOfYear', {\n\t\trequired: 3,\n\t}),\n\tfn('DatePart', 'datePart', 'env', 'Interval Date FirstDayOfWeek FirstWeekOfYear', {\n\t\trequired: 2,\n\t}),\n\tfn('DateSerial', 'dateSerial', 'env', 'Year Month Day'),\n\tfn('DateValue', 'dateValue', 'env', 'Date'),\n\tfn('TimeSerial', 'timeSerial', 'env', 'Hour Minute Second'),\n\tfn('TimeValue', 'timeValue', 'env', 'Time'),\n\tfn('Day', 'day', 'env', 'Date'),\n\tfn('Month', 'month', 'env', 'Date'),\n\tfn('Year', 'year', 'env', 'Date'),\n\tfn('Hour', 'hour', 'env', 'Time'),\n\tfn('Minute', 'minute', 'env', 'Time'),\n\tfn('Second', 'second', 'env', 'Time'),\n\tfn('Weekday', 'weekday', 'env', 'Date FirstDayOfWeek', { required: 1 }),\n\tfn('WeekdayName', 'weekdayName', 'env', 'Weekday Abbreviate FirstDayOfWeek', { required: 1 }),\n\tfn('MonthName', 'monthName', 'env', 'Month Abbreviate', { required: 1 }),\n];\n\nconst INFORMATION: LibraryFunction[] = [\n\tfn('IsArray', 'isArray', 'pure', 'VarName', { returns: 'Boolean' }),\n\tfn('IsDate', 'isDate', 'env', 'Expression', { returns: 'Boolean' }),\n\tfn('IsEmpty', 'isEmpty', 'pure', 'Expression', { returns: 'Boolean' }),\n\tfn('IsError', 'isError', 'pure', 'Expression', { returns: 'Boolean' }),\n\tfn('IsMissing', 'isMissing', 'pure', 'ArgName', { returns: 'Boolean' }),\n\tfn('IsNull', 'isNull', 'pure', 'Expression', { returns: 'Boolean' }),\n\tfn('IsNumeric', 'isNumeric', 'env', 'Expression', { returns: 'Boolean' }),\n\tfn('IsObject', 'isObject', 'pure', 'Expression', { returns: 'Boolean' }),\n\tfn('TypeName', 'typeName', 'pure', 'VarName', { returns: 'String' }),\n\tfn('VarType', 'varType', 'pure', 'VarName', { returns: 'Integer' }),\n\tfn('QBColor', 'qbColor', 'pure', 'Color', { returns: 'Long' }),\n\tfn('RGB', 'rgb', 'pure', 'Red Green Blue', { returns: 'Long' }),\n\t// Arrays and the error line are kept by the executor.\n\tfn('Array', null, 'special', 'ArgList...'),\n\tfn('LBound', null, 'special', 'ArrayName Dimension', { required: 1, returns: 'Long' }),\n\tfn('UBound', null, 'special', 'ArrayName Dimension', { required: 1, returns: 'Long' }),\n\tfn('Erl', null, 'special', '', { returns: 'Long' }),\n];\n\nconst INTERACTION: LibraryFunction[] = [\n\tfn('Choose', 'choose', 'list', 'Index Choice...', { mayReturnObject: true }),\n\tfn('Switch', 'switchOf', 'list', 'VarExpr...', { mayReturnObject: true }),\n\tfn('IIf', 'iif', 'env', 'Expression TruePart FalsePart', { mayReturnObject: true }),\n\tfn('Partition', 'partition', 'env', 'Number Start Stop Interval'),\n\t...twin('Environ', 'environ', 'environ', 'session', 'Expression'),\n\tfn('MsgBox', 'msgBox', 'session', 'Prompt Buttons Title', { required: 1, async: true }),\n\tfn('InputBox', 'inputBox', 'session', 'Prompt Title Default', { required: 1, async: true }),\n\tfn('DoEvents', 'doEvents', 'pure', '', { async: true, returns: 'Integer' }),\n\tfn('CallByName', 'callByName', 'list', 'Object ProcName CallType Args...', {\n\t\tasync: true,\n\t\tmayReturnObject: true,\n\t}),\n\tfn('Command', 'command', 'pure', ''),\n\tfn('Shell', 'shell', 'pure', 'PathName WindowStyle', { required: 1 }),\n\tfn('SendKeys', 'sendKeys', 'pure', 'String Wait', { required: 1, statement: true }),\n\tfn('AppActivate', 'appActivate', 'pure', 'Title Wait', { required: 1, statement: true }),\n\tfn('CreateObject', 'createObject', 'env', 'Class ServerName', {\n\t\trequired: 1,\n\t\tmayReturnObject: true,\n\t}),\n\tfn('GetObject', 'getObject', 'pure', 'PathName Class', {\n\t\trequired: 0,\n\t\tmayReturnObject: true,\n\t}),\n\tfn('GetSetting', 'getSetting', 'pure', 'AppName Section Key Default', { required: 3 }),\n\tfn('SaveSetting', 'saveSetting', 'pure', 'AppName Section Key Setting', { statement: true }),\n\tfn('DeleteSetting', 'deleteSetting', 'pure', 'AppName Section Key', {\n\t\trequired: 1,\n\t\tstatement: true,\n\t}),\n\tfn('GetAllSettings', 'getAllSettings', 'pure', 'AppName Section'),\n];\n\nconst FINANCIAL: LibraryFunction[] = [\n\tfn('FV', 'fv', 'env', 'Rate NPer Pmt PV Type', { required: 3, returns: 'Double' }),\n\tfn('PV', 'pv', 'env', 'Rate NPer Pmt FV Type', { required: 3, returns: 'Double' }),\n\tfn('Pmt', 'pmt', 'env', 'Rate NPer PV FV Type', { required: 3, returns: 'Double' }),\n\tfn('IPmt', 'ipmt', 'env', 'Rate Per NPer PV FV Type', { required: 4, returns: 'Double' }),\n\tfn('PPmt', 'ppmt', 'env', 'Rate Per NPer PV FV Type', { required: 4, returns: 'Double' }),\n\tfn('NPer', 'nper', 'env', 'Rate Pmt PV FV Type', { required: 3, returns: 'Double' }),\n\tfn('Rate', 'rate', 'env', 'NPer Pmt PV FV Type Guess', { required: 3, returns: 'Double' }),\n\tfn('NPV', 'npv', 'env', 'Rate ValueArray', { returns: 'Double' }),\n\tfn('IRR', 'irr', 'env', 'ValueArray Guess', { required: 1, returns: 'Double' }),\n\tfn('MIRR', 'mirr', 'env', 'ValueArray FinanceRate ReinvestRate', { returns: 'Double' }),\n\tfn('SLN', 'sln', 'env', 'Cost Salvage Life', { returns: 'Double' }),\n\tfn('SYD', 'syd', 'env', 'Cost Salvage Life Period', { returns: 'Double' }),\n\tfn('DDB', 'ddb', 'env', 'Cost Salvage Life Period Factor', { required: 4, returns: 'Double' }),\n];\n\n/** File system functions: the sandbox has no disk, so each raises error 445 naming itself. */\nconst FILES: LibraryFunction[] = [\n\t...['CurDir', 'Dir'].flatMap((n) =>\n\t\ttwin(\n\t\t\tn,\n\t\t\tn === 'Dir' ? 'dir' : 'curDir',\n\t\t\tn === 'Dir' ? 'dir' : 'curDir',\n\t\t\t'pure',\n\t\t\t'Path Attributes',\n\t\t\t{\n\t\t\t\trequired: 0,\n\t\t\t},\n\t\t),\n\t),\n\tfn('EOF', 'eof', 'pure', 'FileNumber'),\n\tfn('FileAttr', 'fileAttr', 'pure', 'FileNumber ReturnType'),\n\tfn('FileDateTime', 'fileDateTime', 'pure', 'PathName'),\n\tfn('FileLen', 'fileLen', 'pure', 'PathName'),\n\tfn('FreeFile', 'freeFile', 'pure', 'RangeNumber', { required: 0 }),\n\tfn('Loc', 'loc', 'pure', 'FileNumber'),\n\tfn('LOF', 'lof', 'pure', 'FileNumber'),\n\tfn('Seek', 'seek', 'pure', 'FileNumber'),\n\tfn('GetAttr', 'getAttr', 'pure', 'PathName'),\n\tfn('ChDir', 'chDir', 'pure', 'Path', { statement: true }),\n\tfn('ChDrive', 'chDrive', 'pure', 'Drive', { statement: true }),\n\tfn('FileCopy', 'fileCopy', 'pure', 'Source Destination', { statement: true }),\n\tfn('Kill', 'kill', 'pure', 'PathName', { statement: true }),\n\tfn('MkDir', 'mkDir', 'pure', 'Path', { statement: true }),\n\tfn('RmDir', 'rmDir', 'pure', 'Path', { statement: true }),\n\tfn('SetAttr', 'setAttr', 'pure', 'PathName Attributes', { statement: true }),\n];\n\n/** Every library function, `$` forms included, as the binder and both executors see them. */\nexport const LIBRARY_FUNCTIONS: readonly LibraryFunction[] = [\n\t...STRINGS,\n\t...CONVERSION,\n\t...MATH,\n\t...DATES,\n\t...INFORMATION,\n\t...INTERACTION,\n\t...FINANCIAL,\n\t...FILES,\n];\n","// The VBA library catalogue: one case-insensitive lookup over functions, constants and objects.\nimport { LIBRARY_CONSTANTS } from './constants';\nimport type { LibraryEntry, LibraryObject } from './entry';\nimport { LIBRARY_FUNCTIONS } from './functions';\n\nexport * from './entry';\nexport { LIBRARY_CONSTANTS } from './constants';\nexport { LIBRARY_FUNCTIONS } from './functions';\n\nconst OBJECTS: readonly LibraryObject[] = [\n\t{ kind: 'object', name: 'Err' },\n\t{ kind: 'object', name: 'Debug' },\n\t{ kind: 'object', name: 'VBA' },\n];\n\nconst TABLE = new Map<string, LibraryEntry>();\nfor (const entry of [...LIBRARY_FUNCTIONS, ...LIBRARY_CONSTANTS, ...OBJECTS])\n\tTABLE.set(entry.name.toLowerCase(), entry);\n\n/** The library entry a name refers to (`Left`, `left$`, `vbCrLf`, `Err`), case-insensitively. */\nexport const libraryEntry = (name: string): LibraryEntry | undefined =>\n\tTABLE.get(name.toLowerCase());\n\n/** Every entry, for executors that build a dispatch table up front. */\nexport const libraryEntries = (): IterableIterator<LibraryEntry> => TABLE.values();\n","// Name lookup ([MS-VBAL] 5.6.10): procedure scope, then the module, then the project (module\n// names, classes, Public members of standard modules, Public enums), then VBA's library, then the\n// host's named globals. What none of them declares is left to the caller (dynamic or implicit).\nimport type { Binding } from './bindings';\nimport { libraryEntry } from './library/index';\nimport type { BoundModule, ModuleMemberSymbol } from './module';\nimport { PropertyGroup } from './procedure';\nimport type { ConstSymbol, ParamSymbol, VariableSymbol } from './symbols';\n\n/** Converts a module-level symbol to the binding a reference to it gets. */\nexport function memberBinding(\n\tsymbol: ModuleMemberSymbol,\n\treceiver: 'none' | 'self' | 'object',\n): Binding {\n\tif (symbol instanceof PropertyGroup) return { kind: 'procedure', group: symbol, receiver };\n\tswitch (symbol.kind) {\n\t\tcase 'variable':\n\t\t\treturn { kind: 'variable', symbol };\n\t\tcase 'const':\n\t\t\treturn { kind: 'const', symbol };\n\t\tcase 'enum':\n\t\t\treturn { kind: 'enum', symbol };\n\t\tcase 'enumMember':\n\t\t\treturn { kind: 'enumMember', symbol };\n\t\tcase 'declare':\n\t\t\treturn { kind: 'declare', symbol };\n\t}\n}\n\n/** Whether a module-level symbol is visible outside its module (Public). */\nexport function isPublicSymbol(symbol: ModuleMemberSymbol): boolean {\n\treturn symbol instanceof PropertyGroup ? symbol.isPublic : symbol.isPublic;\n}\n\n/** Whether module `from` may see `symbol` of module `owner` through a qualifier. */\nexport const isVisible = (\n\tsymbol: ModuleMemberSymbol,\n\towner: BoundModule,\n\tfrom: BoundModule,\n): boolean => owner === from || isPublicSymbol(symbol);\n\nconst isEnumSymbol = (symbol: ModuleMemberSymbol): boolean =>\n\t!(symbol instanceof PropertyGroup) && (symbol.kind === 'enum' || symbol.kind === 'enumMember');\n\nexport interface HostNames {\n\t/** Names of `options.globals`. */\n\treadonly globals: ReadonlySet<string>;\n\t/** True when `options.globalObject` is given: undeclared names may be its members. */\n\treadonly globalObject: boolean;\n\t/** Document modules that have a host object. */\n\treadonly documents: ReadonlySet<string>;\n}\n\n/** The project: module names, classes and the Public members of standard modules. */\nexport class ProjectScope {\n\tprivate readonly modules = new Map<string, BoundModule>();\n\tprivate readonly publics = new Map<\n\t\tstring,\n\t\t{ module: BoundModule; symbol: ModuleMemberSymbol }[]\n\t>();\n\n\tconstructor(\n\t\tmodules: readonly BoundModule[],\n\t\treadonly host: HostNames,\n\t) {\n\t\tfor (const m of modules) {\n\t\t\tthis.modules.set(m.name.toLowerCase(), m);\n\t\t\tfor (const [key, symbol] of m.members) {\n\t\t\t\t// Standard modules export their Public members; every module exports Public Enums.\n\t\t\t\tif (!isPublicSymbol(symbol) || (m.kind !== 'standard' && !isEnumSymbol(symbol))) continue;\n\t\t\t\tconst list = this.publics.get(key);\n\t\t\t\tif (list) list.push({ module: m, symbol });\n\t\t\t\telse this.publics.set(key, [{ module: m, symbol }]);\n\t\t\t}\n\t\t}\n\t}\n\n\tmodule(name: string): BoundModule | undefined {\n\t\treturn this.modules.get(name.toLowerCase());\n\t}\n\n\tprivate implemented: Set<BoundModule> | undefined;\n\n\t/**\n\t * True when some class `Implements` this one: an object declared as it may then be another\n\t * class seen through it, so its members cannot be bound early.\n\t */\n\tisImplemented(m: BoundModule): boolean {\n\t\tif (!this.implemented) {\n\t\t\tthis.implemented = new Set();\n\t\t\tfor (const each of this.modules.values())\n\t\t\t\tfor (const i of each.implements) this.implemented.add(i);\n\t\t}\n\t\treturn this.implemented.has(m);\n\t}\n\n\t/**\n\t * A project-level name: a module (as qualifier, class or document object), else a Public member\n\t * of another module. `'ambiguous'` when two modules export it.\n\t */\n\tlookup(name: string, from: BoundModule): Binding | 'ambiguous' | undefined {\n\t\tconst key = name.toLowerCase();\n\t\tconst m = this.modules.get(key);\n\t\tif (m) {\n\t\t\tif (m.kind === 'class' || m.kind === 'form') return { kind: 'class', module: m };\n\t\t\tif (m.kind === 'document' && this.host.documents.has(key))\n\t\t\t\treturn { kind: 'documentObject', module: m };\n\t\t\treturn { kind: 'module', module: m };\n\t\t}\n\t\tconst found = this.publics.get(key)?.filter((e) => e.module !== from);\n\t\tif (!found || found.length === 0) return undefined;\n\t\tif (found.length > 1) return 'ambiguous';\n\t\tconst only = found[0] as { module: BoundModule; symbol: ModuleMemberSymbol };\n\t\treturn memberBinding(only.symbol, 'none');\n\t}\n}\n\n/** The names a procedure declares: parameters, locals, Static locals and local constants. */\nexport class ProcedureScope {\n\tprivate readonly names = new Map<string, VariableSymbol | ParamSymbol | ConstSymbol>();\n\n\tdeclare(symbol: VariableSymbol | ParamSymbol | ConstSymbol): boolean {\n\t\tconst key = symbol.name.toLowerCase();\n\t\tif (this.names.has(key)) return false;\n\t\tthis.names.set(key, symbol);\n\t\treturn true;\n\t}\n\n\tlookup(name: string): Binding | undefined {\n\t\tconst s = this.names.get(name.toLowerCase());\n\t\tif (!s) return undefined;\n\t\tif (s.kind === 'param') return { kind: 'param', symbol: s };\n\t\tif (s.kind === 'const') return { kind: 'const', symbol: s };\n\t\treturn s.implicit ? { kind: 'implicit', symbol: s } : { kind: 'variable', symbol: s };\n\t}\n}\n\n/**\n * The full lookup chain for one module (and, inside a procedure, its procedure scope). Returns\n * undefined for a name nothing declares.\n */\nexport class ScopeChain {\n\tconstructor(\n\t\treadonly module: BoundModule,\n\t\treadonly project: ProjectScope,\n\t\treadonly procedure: ProcedureScope | null,\n\t) {}\n\n\tlookup(name: string): Binding | 'ambiguous' | undefined {\n\t\tconst local = this.procedure?.lookup(name);\n\t\tif (local) return local;\n\t\tconst own = this.module.members.get(name.toLowerCase());\n\t\tif (own) return memberBinding(own, this.module.perInstance ? 'self' : 'none');\n\t\tconst project = this.project.lookup(name, this.module);\n\t\tif (project) return project;\n\t\tconst entry = libraryEntry(name);\n\t\tif (entry) {\n\t\t\tif (entry.kind === 'function') return { kind: 'libraryFunction', entry };\n\t\t\tif (entry.kind === 'constant') return { kind: 'libraryConstant', entry };\n\t\t\treturn { kind: 'libraryObject', entry };\n\t\t}\n\t\tif (this.project.host.globals.has(name.toLowerCase())) return { kind: 'hostGlobal', name };\n\t\treturn undefined;\n\t}\n\n\t/** True when an undeclared name may still be a member of a host object at run time. */\n\tget hasDynamicScope(): boolean {\n\t\treturn (\n\t\t\tthis.project.host.globalObject ||\n\t\t\t(this.module.kind === 'document' &&\n\t\t\t\tthis.project.host.documents.has(this.module.name.toLowerCase()))\n\t\t);\n\t}\n}\n","// Resolves declared types ([MS-VBAL] 5.2.3.1, 5.6.16.7): `As` clauses, type suffixes and DefType\n// letters to `StaticType`s, against the project's classes, user-defined types and enums.\nimport type { ArrayBound, AsClause, NameRef, TypeRef } from '../lang/index';\nimport type { BoundModule } from './module';\nimport type { EnumSymbol, UdtSymbol } from './symbols';\nimport {\n\tOBJECT,\n\tSUFFIX_TYPES,\n\tVARIANT,\n\tscalarType,\n\ttype ScalarTypeName,\n\ttype StaticType,\n} from './types';\n\n/** The type names of the project: classes, user-defined types and enums by lower-case name. */\nexport class TypeIndex {\n\treadonly classes = new Map<string, BoundModule>();\n\treadonly udts = new Map<string, UdtSymbol[]>();\n\treadonly enums = new Map<string, EnumSymbol[]>();\n\n\taddModule(m: BoundModule): void {\n\t\tif (m.kind === 'class' || m.kind === 'form') this.classes.set(m.name.toLowerCase(), m);\n\t}\n\n\taddUdt(u: UdtSymbol): void {\n\t\tpush(this.udts, u.name, u);\n\t}\n\n\taddEnum(e: EnumSymbol): void {\n\t\tpush(this.enums, e.name, e);\n\t}\n\n\t/** A UDT visible from `from`: its own module's first, then a Public one. */\n\tudt(name: string, from: BoundModule): UdtSymbol | undefined {\n\t\treturn visible(this.udts.get(name.toLowerCase()), from);\n\t}\n\n\tenum(name: string, from: BoundModule): EnumSymbol | undefined {\n\t\treturn visible(this.enums.get(name.toLowerCase()), from);\n\t}\n}\n\nfunction push<T>(map: Map<string, T[]>, name: string, item: T): void {\n\tconst key = name.toLowerCase();\n\tconst list = map.get(key);\n\tif (list) list.push(item);\n\telse map.set(key, [item]);\n}\n\nfunction visible<T extends { module: string; isPublic: boolean }>(\n\tlist: readonly T[] | undefined,\n\tfrom: BoundModule,\n): T | undefined {\n\tif (!list) return undefined;\n\treturn (\n\t\tlist.find((s) => s.module.toLowerCase() === from.name.toLowerCase()) ??\n\t\tlist.find((s) => s.isPublic)\n\t);\n}\n\nconst BUILTIN_SCALARS = new Set<string>([\n\t'Boolean',\n\t'Byte',\n\t'Integer',\n\t'Long',\n\t'LongLong',\n\t'LongPtr',\n\t'Single',\n\t'Double',\n\t'Currency',\n\t'Decimal',\n\t'Date',\n\t'String',\n]);\n\nexport class TypeResolver {\n\tconstructor(private readonly index: TypeIndex) {}\n\n\t/** The type a `TypeRef` names, seen from module `from`; undefined for an unknown UDT name. */\n\tnamed(type: TypeRef, from: BoundModule, fixedLength: AsClause['fixedLength'] = null): StaticType {\n\t\tif (type.builtin) {\n\t\t\tif (type.builtin === 'Variant' || type.builtin === 'Any') return VARIANT;\n\t\t\tif (type.builtin === 'Object') return OBJECT;\n\t\t\treturn scalarType(type.builtin as ScalarTypeName, fixedLength);\n\t\t}\n\t\tconst last = type.parts.at(-1)?.name ?? type.name;\n\t\tconst qualifier = type.parts.length > 1 ? type.parts[0]?.name.toLowerCase() : undefined;\n\t\tif (qualifier === undefined || qualifier !== 'vba') {\n\t\t\tconst udt = this.index.udt(last, from);\n\t\t\tif (udt) return { kind: 'udt', udt };\n\t\t\tconst e = this.index.enum(last, from);\n\t\t\tif (e) return scalarType('Long', null, e.name);\n\t\t\tconst cls = this.index.classes.get(last.toLowerCase());\n\t\t\tif (cls) return { kind: 'object', className: cls.name, classModule: cls.name };\n\t\t}\n\t\tif (qualifier === 'vba' && BUILTIN_SCALARS.has(last)) return scalarType(last as ScalarTypeName);\n\t\treturn { kind: 'object', className: last, classModule: null };\n\t}\n\n\t/**\n\t * The type of a declared name: its `As` clause, else its type suffix, else the module's\n\t * DefType for its first letter, else Variant. `bounds` (non-null) makes it an array.\n\t */\n\tdeclared(\n\t\tname: NameRef,\n\t\tasClause: AsClause | null,\n\t\tbounds: readonly ArrayBound[] | null,\n\t\tfrom: BoundModule,\n\t\tforceArray = false,\n\t): StaticType {\n\t\tlet element: StaticType;\n\t\tif (asClause) element = this.named(asClause.type, from, asClause.fixedLength);\n\t\telse if (name.suffix) element = scalarType(SUFFIX_TYPES[name.suffix] ?? 'Double');\n\t\telse {\n\t\t\tconst def = from.defTypes.get(name.name.charAt(0).toLowerCase());\n\t\t\telement = def ? scalarType(def) : VARIANT;\n\t\t}\n\t\tif (bounds === null && !forceArray && !asClause?.isArray) return element;\n\t\tconst rank = bounds && bounds.length > 0 ? bounds.length : null;\n\t\treturn { kind: 'array', element, rank, fixed: rank !== null };\n\t}\n}\n","// The state the binder carries through one module or procedure: where it is, what it has found\n// so far and where to record results. Expression and statement binders share one context.\nimport type { Expression, NameRef, Span, Statement } from '../../lang/index';\nimport type { Binding, Invocation, WithBlock } from '../bindings';\nimport type { DiagnosticSink, SemanticDiagnosticCode } from '../diagnostics';\nimport type { BoundModule } from '../module';\nimport type { BindingTable } from '../program';\nimport type { BoundProcedure } from '../procedure';\nimport type { ProcedureScope, ScopeChain } from '../scope';\nimport { UsageFacts, type IdSource, type VariableSymbol } from '../symbols';\nimport type { TypeResolver } from '../types-resolve';\nimport type { StaticType } from '../types';\n\nexport class BindContext {\n\t/** The open `With` blocks, innermost last. */\n\treadonly withStack: WithBlock[] = [];\n\t/** Every expression bound for its value in this procedure (for the implicit-call summary). */\n\treadonly reads: Expression[] = [];\n\t/** The loops around the statement being bound (Exit For and Exit Do need theirs). */\n\treadonly loopStack: ('For' | 'Do')[] = [];\n\n\tconstructor(\n\t\treadonly module: BoundModule,\n\t\treadonly procedure: BoundProcedure | null,\n\t\treadonly scope: ScopeChain,\n\t\treadonly procedureScope: ProcedureScope | null,\n\t\treadonly table: BindingTable,\n\t\treadonly diagnostics: DiagnosticSink,\n\t\treadonly ids: IdSource,\n\t\treadonly types: TypeResolver,\n\t) {}\n\n\tbind(node: Expression, binding: Binding): Binding {\n\t\tthis.table.bindings.set(node, binding);\n\t\treturn binding;\n\t}\n\n\tinvoke(node: Expression | Statement, invocation: Invocation): void {\n\t\tthis.table.invocations.set(node, invocation);\n\t}\n\n\ttype(node: Expression, type: StaticType): StaticType {\n\t\tthis.table.types.set(node, type);\n\t\treturn type;\n\t}\n\n\treport(code: SemanticDiagnosticCode, span: Span, detail?: string): void {\n\t\tthis.module.hasErrors ||= code !== 'declare-not-supported';\n\t\tthis.diagnostics.add(this.module.name, code, span, detail);\n\t}\n\n\t/** Marks that the procedure touches something that may answer asynchronously. */\n\tdynamic(): void {\n\t\tif (this.procedure) this.procedure.facts.dynamic = true;\n\t}\n\n\t/** Implicit locals that back undeclared names resolved at run time, by lower-case name. */\n\tprivate readonly fallbacks = new Map<string, VariableSymbol>();\n\n\t/**\n\t * The implicit local behind an undeclared name that may be a host member at run time. It is not\n\t * entered in the procedure scope, so every reference stays dynamic.\n\t */\n\tfallbackLocal(name: NameRef): VariableSymbol | null {\n\t\tconst key = name.name.toLowerCase();\n\t\tconst known = this.fallbacks.get(key);\n\t\tif (known) return known;\n\t\tconst symbol = this.implicitLocal(name, false);\n\t\tif (symbol) this.fallbacks.set(key, symbol);\n\t\treturn symbol;\n\t}\n\n\t/** Declares an implicit local for an undeclared name (no `Option Explicit`). */\n\timplicitLocal(name: NameRef, enterScope = true): VariableSymbol | null {\n\t\tconst p = this.procedure;\n\t\tif (!p || !this.procedureScope) return null;\n\t\tconst symbol: VariableSymbol = {\n\t\t\tkind: 'variable',\n\t\t\tid: this.ids.take(),\n\t\t\tname: name.name,\n\t\t\tscope: p.declaration.isStatic ? 'static' : 'local',\n\t\t\tmodule: this.module.name,\n\t\t\tisPublic: false,\n\t\t\ttype: this.types.declared(name, null, null, this.module),\n\t\t\tbounds: null,\n\t\t\tisNew: false,\n\t\t\twithEvents: false,\n\t\t\timplicit: true,\n\t\t\tslot: p.declaration.isStatic ? p.statics.length : p.params.length + 1 + p.locals.length,\n\t\t\tdeclaration: null,\n\t\t\tusage: new UsageFacts(),\n\t\t};\n\t\t(p.declaration.isStatic ? p.statics : p.locals).push(symbol);\n\t\tif (enterScope) this.procedureScope.declare(symbol);\n\t\treturn symbol;\n\t}\n}\n","// Binding of simple names and member accesses ([MS-VBAL] 5.6.10, 5.6.12): locals, the function\n// result, module and project members, qualifiers (`Module2.X`, `VBA.Left`, `Colors.Red`,\n// `Err.Number`), UDT fields, With members, and what is left to run time.\nimport type { DictionaryAccess, MemberAccess, NameExpression, NameRef } from '../../lang/index';\nimport type { Binding } from '../bindings';\nimport { libraryEntry } from '../library/index';\nimport { PropertyGroup } from '../procedure';\nimport type { ModuleMemberSymbol } from '../module';\nimport { memberBinding, isVisible } from '../scope';\nimport { OBJECT, scalarType, VARIANT, type StaticType } from '../types';\nimport type { BindContext } from './context';\n\n/**\n * How a name is used: read, called as a statement, invoked by an enclosing `(args)` (`callee`),\n * assigned, or written before `.member`.\n */\nexport type NameUse = 'value' | 'call' | 'callee' | 'target' | 'qualifier';\n\n/** The static type a binding gives its node. */\nexport function bindingType(b: Binding): StaticType {\n\tswitch (b.kind) {\n\t\tcase 'variable':\n\t\tcase 'param':\n\t\tcase 'result':\n\t\tcase 'implicit':\n\t\t\treturn b.symbol.type;\n\t\tcase 'const':\n\t\t\treturn b.symbol.type ?? VARIANT;\n\t\tcase 'enumMember':\n\t\t\treturn scalarType('Long');\n\t\tcase 'libraryConstant':\n\t\t\treturn b.entry.type;\n\t\tcase 'libraryFunction':\n\t\t\treturn b.entry.returns;\n\t\tcase 'procedure':\n\t\t\treturn b.group.reader?.returnType ?? VARIANT;\n\t\tcase 'udtField':\n\t\t\treturn b.field.type;\n\t\tcase 'me':\n\t\t\treturn {\n\t\t\t\tkind: 'object',\n\t\t\t\tclassName: b.module.name,\n\t\t\t\tclassModule: b.module.perInstance ? b.module.name : null,\n\t\t\t};\n\t\tcase 'module':\n\t\tcase 'class':\n\t\tcase 'documentObject':\n\t\tcase 'hostGlobal':\n\t\t\treturn OBJECT;\n\t\tdefault:\n\t\t\treturn VARIANT;\n\t}\n}\n\n/** Resolves a simple name; reports what cannot be resolved. */\nexport function bindName(\n\tctx: BindContext,\n\tnode: NameExpression,\n\tuse: NameUse,\n\thasArgs: boolean,\n): Binding {\n\tconst ref = node.name;\n\tconst p = ctx.procedure;\n\tif (\n\t\tp?.result &&\n\t\t!hasArgs &&\n\t\tuse !== 'call' &&\n\t\tuse !== 'callee' &&\n\t\tref.name.toLowerCase() === p.name.toLowerCase()\n\t)\n\t\treturn ctx.bind(node, { kind: 'result', symbol: p.result, procedure: p });\n\tlet found = ctx.scope.lookup(ref.name);\n\t// `Left$` names the String twin of `Left`: the library keeps both under their own names.\n\tif (\n\t\tfound &&\n\t\ttypeof found === 'object' &&\n\t\tfound.kind === 'libraryFunction' &&\n\t\tref.suffix === '$'\n\t) {\n\t\tconst twin = libraryEntry(`${ref.name}$`);\n\t\tif (twin?.kind === 'function') found = { kind: 'libraryFunction', entry: twin };\n\t}\n\tif (found === 'ambiguous') {\n\t\tctx.report('ambiguous-name', ref.span, ref.name);\n\t\treturn ctx.bind(node, { kind: 'unresolved', name: ref.name, number: 35 });\n\t}\n\tif (found) {\n\t\tif (found.kind === 'procedure' || found.kind === 'declare') addCallee(ctx, found);\n\t\tif (found.kind === 'hostGlobal') ctx.dynamic();\n\t\treturn ctx.bind(node, found);\n\t}\n\treturn ctx.bind(node, undeclared(ctx, ref, use, hasArgs));\n}\n\nfunction addCallee(ctx: BindContext, b: Binding): void {\n\tif (b.kind !== 'procedure' || !ctx.procedure) return;\n\tfor (const proc of [b.group.method, b.group.get, b.group.let, b.group.set])\n\t\tif (proc) ctx.procedure.facts.callees.add(proc);\n}\n\n/** A name nothing declares: a host member at run time, an implicit local, or a compile error. */\nfunction undeclared(ctx: BindContext, ref: NameRef, use: NameUse, hasArgs: boolean): Binding {\n\tconst callLike = use === 'call' || use === 'callee' || hasArgs;\n\tconst explicit = ctx.module.options.explicit;\n\tif (ctx.scope.hasDynamicScope) {\n\t\tctx.dynamic();\n\t\tconst fallback = !explicit ? ctx.fallbackLocal(ref) : null;\n\t\treturn {\n\t\t\tkind: 'dynamic',\n\t\t\tname: ref.name,\n\t\t\tdocument: ctx.module.kind === 'document',\n\t\t\tfallback,\n\t\t};\n\t}\n\tif (callLike) {\n\t\tctx.report('sub-or-function-not-defined', ref.span, ref.name);\n\t\treturn { kind: 'unresolved', name: ref.name, number: 35 };\n\t}\n\tif (explicit || !ctx.procedure) {\n\t\tctx.report('variable-not-defined', ref.span, ref.name);\n\t\treturn { kind: 'unresolved', name: ref.name, number: 35 };\n\t}\n\tconst symbol = ctx.implicitLocal(ref);\n\treturn symbol ? { kind: 'implicit', symbol } : { kind: 'unresolved', name: ref.name, number: 35 };\n}\n\n/**\n * Binds `object.member` once the object is bound: a qualified project or library name, a UDT\n * field, or a run-time member.\n */\nexport function bindMember(\n\tctx: BindContext,\n\tnode: MemberAccess,\n\tobjectBinding: Binding | null,\n\tobjectType: StaticType,\n\tuse: NameUse,\n): Binding {\n\tconst name = node.member.name;\n\tconst qualified = objectBinding\n\t\t? qualifiedMember(ctx, objectBinding, node.member, use)\n\t\t: undefined;\n\tif (qualified) return ctx.bind(node, qualified);\n\tif (objectType.kind === 'object' && objectType.classModule) {\n\t\tconst early = classMember(ctx, objectType.classModule, node.member);\n\t\tif (early) return ctx.bind(node, early);\n\t}\n\tif (objectType.kind === 'udt') {\n\t\tconst index = objectType.udt.fields.findIndex(\n\t\t\t(f) => f.name.toLowerCase() === name.toLowerCase(),\n\t\t);\n\t\tconst field = objectType.udt.fields[index];\n\t\tif (!field) {\n\t\t\tctx.report('method-or-data-member-not-found', node.member.span, name);\n\t\t\treturn ctx.bind(node, { kind: 'unresolved', name, number: 438 });\n\t\t}\n\t\treturn ctx.bind(node, { kind: 'udtField', field, index });\n\t}\n\tctx.dynamic();\n\treturn ctx.bind(node, { kind: 'member', name, objectType, dictionary: false });\n}\n\nfunction qualifiedMember(\n\tctx: BindContext,\n\tobject: Binding,\n\tmember: NameRef,\n\tuse: NameUse,\n): Binding | undefined {\n\tconst key = member.name.toLowerCase();\n\tswitch (object.kind) {\n\t\tcase 'module':\n\t\tcase 'documentObject': {\n\t\t\tconst symbol = object.module.members.get(key);\n\t\t\tif (symbol && isVisible(symbol, object.module, ctx.module)) {\n\t\t\t\tconst b = memberBinding(symbol, 'none');\n\t\t\t\taddCallee(ctx, b);\n\t\t\t\treturn b;\n\t\t\t}\n\t\t\tif (object.kind === 'documentObject') return undefined;\n\t\t\tctx.report('method-or-data-member-not-found', member.span, member.name);\n\t\t\treturn { kind: 'unresolved', name: member.name, number: 438 };\n\t\t}\n\t\tcase 'me': {\n\t\t\tconst symbol = object.module.members.get(key);\n\t\t\tif (symbol && !isPublicMember(symbol)) {\n\t\t\t\t// `Me` is the object's public interface: its Private members are not on it.\n\t\t\t\tctx.report('method-or-data-member-not-found', member.span, member.name);\n\t\t\t\treturn { kind: 'unresolved', name: member.name, number: 438 };\n\t\t\t}\n\t\t\tif (symbol) {\n\t\t\t\tconst b = memberBinding(symbol, object.module.perInstance ? 'self' : 'none');\n\t\t\t\taddCallee(ctx, b);\n\t\t\t\treturn b;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t}\n\t\tcase 'enum': {\n\t\t\tconst m = object.symbol.members.find((e) => e.name.toLowerCase() === key);\n\t\t\tif (m) return { kind: 'enumMember', symbol: m };\n\t\t\tctx.report('method-or-data-member-not-found', member.span, member.name);\n\t\t\treturn { kind: 'unresolved', name: member.name, number: 438 };\n\t\t}\n\t\tcase 'libraryObject': {\n\t\t\tif (object.entry.name === 'Err') return { kind: 'errMember', name: member.name };\n\t\t\tif (object.entry.name === 'Debug') return { kind: 'debugMember', name: member.name };\n\t\t\tconst entry = libraryEntry(member.name);\n\t\t\tif (entry?.kind === 'function') return { kind: 'libraryFunction', entry };\n\t\t\tif (entry?.kind === 'constant') return { kind: 'libraryConstant', entry };\n\t\t\tctx.report('method-or-data-member-not-found', member.span, member.name);\n\t\t\treturn { kind: 'unresolved', name: member.name, number: 438 };\n\t\t}\n\t\tdefault:\n\t\t\tvoid use;\n\t\t\treturn undefined;\n\t}\n}\n\n/** `object!key` or `!key`: the default member with the key as a String. */\nexport function bindDictionary(\n\tctx: BindContext,\n\tnode: DictionaryAccess,\n\tobjectType: StaticType,\n): Binding {\n\tctx.dynamic();\n\treturn ctx.bind(node, { kind: 'member', name: node.key.name, objectType, dictionary: true });\n}\n\n/**\n * `obj.Member` where `obj` is declared as a class of the project that no class implements: the\n * object can only be an instance of that class (or Nothing), so a public procedure binds early\n * (receiver `object`), and a public field is a member read that never waits. A name the class does\n * not have is the editor's compile error. Returns undefined to bind the member late.\n */\nfunction classMember(ctx: BindContext, className: string, member: NameRef): Binding | undefined {\n\tconst project = ctx.scope.project;\n\tconst m = project.module(className);\n\tif (!m || m.kind !== 'class') return undefined;\n\tconst symbol = m.members.get(member.name.toLowerCase());\n\tif (!symbol) {\n\t\tctx.report('method-or-data-member-not-found', member.span, member.name);\n\t\treturn { kind: 'unresolved', name: member.name, number: 438 };\n\t}\n\tif (!isPublicMember(symbol)) {\n\t\t// A Private member is not part of the class's interface, even through `Me`.\n\t\tctx.report('method-or-data-member-not-found', member.span, member.name);\n\t\treturn { kind: 'unresolved', name: member.name, number: 438 };\n\t}\n\tif (project.isImplemented(m)) return undefined;\n\tif (symbol instanceof PropertyGroup) {\n\t\tconst procs = [symbol.method, symbol.get, symbol.let, symbol.set].filter((p) => p !== null);\n\t\t// A property with a Private part is bound late (run time raises 438 for that part).\n\t\tif (!procs.every((p) => p.isPublic)) return undefined;\n\t\tconst b: Binding = { kind: 'procedure', group: symbol, receiver: 'object' };\n\t\taddCallee(ctx, b);\n\t\treturn b;\n\t}\n\tif (symbol.kind === 'variable' && symbol.isPublic)\n\t\treturn { kind: 'member', name: member.name, objectType: OBJECT, dictionary: false };\n\treturn undefined;\n}\n\n/** A member on the module's public interface: a non-Private procedure (any part of a property) or variable. */\nfunction isPublicMember(symbol: ModuleMemberSymbol): boolean {\n\treturn symbol instanceof PropertyGroup ? symbol.isPublic : symbol.isPublic;\n}\n","// Calls and indexes ([MS-VBAL] 5.6.13, 5.4.2.2): decides whether `target(args)` is a procedure\n// call, a library call, an array index, a run-time member or a default member, and matches the\n// arguments of compiled procedures and library functions to their parameters.\nimport { isStaticallyTyped, typedLengthVt, type BoundLookup } from '../operands';\nimport type { Argument, Expression, Statement } from '../../lang/index';\nimport type { ArgumentPassing, Binding, BoundArgument, CallSite, Invocation } from '../bindings';\nimport type { LibraryFunction } from '../library/index';\nimport type { BoundProcedure, PropertyGroup } from '../procedure';\nimport type { ParamSymbol } from '../symbols';\nimport { VARIANT, type StaticType } from '../types';\nimport type { BindContext } from './context';\nimport type { ExpressionBinder } from './expressions';\nimport { bindName, bindingType } from './names';\n\n/**\n * Binds `target(args)` (a `CallOrIndex` node, a call statement, or a bare name or member that\n * calls a procedure) and records the invocation on `node`. Returns the result type.\n */\nexport function bindInvocation(\n\tbinder: ExpressionBinder,\n\tnode: Expression | Statement,\n\ttarget: Expression,\n\targs: readonly Argument[],\n\tisStatement: boolean,\n): StaticType {\n\tconst ctx = binder.ctx;\n\tlet b: Binding | undefined;\n\tlet targetType: StaticType = VARIANT;\n\tif (target !== node) {\n\t\tif (target.kind === 'Name') {\n\t\t\tb = bindName(ctx, target, isStatement ? 'call' : 'callee', node.kind === 'CallOrIndex');\n\t\t\ttargetType = ctx.type(target, bindingType(b));\n\t\t} else targetType = binder.bind(target, 'callee');\n\t\tctx.type(target, targetType);\n\t}\n\tb ??= ctx.table.bindings.get(target);\n\tconst invocation = decide(binder, b, target, targetType, args, node.kind === 'CallOrIndex');\n\tctx.invoke(node, invocation);\n\tif (invocation.kind === 'call' && invocation.indexResult) {\n\t\tfor (const a of args) if (a.value) binder.value(a.value);\n\t\treturn VARIANT;\n\t}\n\tif (invocation.kind === 'call' || invocation.kind === 'library') {\n\t\tbindSite(binder, invocation.site, args);\n\t\tif (invocation.kind === 'call') return invocation.group.reader?.returnType ?? VARIANT;\n\t\tconst facts = libraryFacts(ctx, invocation);\n\t\tif (facts) ctx.invoke(node, { ...invocation, ...facts });\n\t\treturn invocation.entry.returns;\n\t}\n\tfor (const a of args)\n\t\tif (a.value) {\n\t\t\tif (invocation.kind === 'index') binder.value(a.value);\n\t\t\telse binder.objectValue(a.value);\n\t\t}\n\tif (invocation.kind === 'index') return invocation.elementType;\n\t// A late-bound member receives its arguments by reference: it may write a variable passed.\n\tfor (const a of args)\n\t\tif (a.value && isReference(binder, a.value)) binder.markWrite(a.value, 'byref');\n\treturn VARIANT;\n}\n\nfunction decide(\n\tbinder: ExpressionBinder,\n\tb: Binding | undefined,\n\ttarget: Expression,\n\ttargetType: StaticType,\n\targs: readonly Argument[],\n\tindexable: boolean,\n): Invocation {\n\tconst ctx = binder.ctx;\n\tswitch (b?.kind) {\n\t\tcase 'procedure': {\n\t\t\tconst proc = b.group.reader ?? b.group.any;\n\t\t\tif (indexable && b.group.reader && proc.params.length === 0 && args.length > 0)\n\t\t\t\treturn { kind: 'call', group: b.group, site: { params: [], rest: [] }, indexResult: true };\n\t\t\treturn { kind: 'call', group: b.group, site: matchArgs(binder, proc.params, args, target) };\n\t\t}\n\t\tcase 'declare':\n\t\t\treturn { kind: 'declare', symbol: b.symbol };\n\t\tcase 'libraryFunction':\n\t\t\tif (ctx.procedure) ctx.procedure.facts.library.add(b.entry);\n\t\t\tif (b.entry.async) ctx.dynamic();\n\t\t\treturn { kind: 'library', entry: b.entry, site: matchLibrary(binder, b.entry, args, target) };\n\t\tcase 'member':\n\t\t\treturn { kind: 'member', name: b.name };\n\t\tcase 'dynamic':\n\t\t\treturn { kind: 'member', name: b.name };\n\t\tcase 'errMember':\n\t\tcase 'debugMember':\n\t\t\treturn { kind: 'member', name: b.name };\n\t\tdefault:\n\t\t\tif (targetType.kind === 'array' && args.length > 0)\n\t\t\t\treturn { kind: 'index', elementType: targetType.element };\n\t\t\tif (targetType.kind === 'object' || targetType.kind === 'variant') ctx.dynamic();\n\t\t\treturn { kind: 'dynamic' };\n\t}\n}\n\nconst omitted = (a: Argument | undefined): boolean => !a || a.value === null;\n\n/** Matches arguments to a compiled procedure's parameters, reporting VBA's compile errors. */\nexport function matchArgs(\n\tbinder: ExpressionBinder,\n\tparams: readonly ParamSymbol[],\n\targs: readonly Argument[],\n\tat: Expression,\n\tdropLast = false,\n): CallSite {\n\tconst ctx = binder.ctx;\n\tconst list = dropLast ? params.slice(0, -1) : params;\n\tconst paramArray = list.at(-1)?.paramArray ? list.length - 1 : -1;\n\tconst slots: (BoundArgument | null)[] = (paramArray >= 0 ? list.slice(0, -1) : list).map(\n\t\t() => null,\n\t);\n\tconst rest: (Expression | null)[] = [];\n\tlet position = 0;\n\tfor (const a of args) {\n\t\tif (a.name) {\n\t\t\tconst i = list.findIndex((p) => p.name.toLowerCase() === a.name?.name.toLowerCase());\n\t\t\tif (i < 0 || i === paramArray) {\n\t\t\t\tctx.report('named-argument-not-found', a.name.span, a.name.name);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tslots[i] = bound(binder, list[i] as ParamSymbol, a.value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (paramArray >= 0 && position >= paramArray) {\n\t\t\trest.push(a.value);\n\t\t\tposition++;\n\t\t\tcontinue;\n\t\t}\n\t\tconst p = list[position];\n\t\tif (!p) {\n\t\t\tctx.report('wrong-number-of-arguments', a.span);\n\t\t\tbreak;\n\t\t}\n\t\tslots[position] = omitted(a) ? null : bound(binder, p, a.value);\n\t\tposition++;\n\t}\n\tlist.forEach((p, i) => {\n\t\tif (!p.optional && !p.paramArray && slots[i] === null && i < slots.length)\n\t\t\tctx.report('argument-not-optional', at.span, p.name);\n\t});\n\treturn { params: slots, rest };\n}\n\n/** The passing form of one argument, marking a variable passed ByRef. */\nfunction bound(\n\tbinder: ExpressionBinder,\n\tp: ParamSymbol,\n\te: Expression | null,\n): BoundArgument | null {\n\tif (!e) return null;\n\t// An object passed to a Variant or Object parameter stays an object; a typed parameter reads\n\t// its default member.\n\tif (p.type.kind === 'variant' || p.type.kind === 'object') binder.objectValue(e);\n\telse binder.value(e);\n\tlet passing: ArgumentPassing = 'value';\n\tif (p.passing === 'ByRef') passing = isReference(binder, e) ? 'ref' : 'temp';\n\tif (passing === 'ref') {\n\t\tbinder.markWrite(e, 'byref');\n\t\tcheckByRefType(binder, p, e);\n\t}\n\treturn { expression: e, passing };\n}\n\n/** True when an argument names storage the callee can write through: a variable, element or field. */\nexport function isReference(binder: ExpressionBinder, e: Expression): boolean {\n\tconst t = binder.ctx.table;\n\tconst b = t.bindings.get(e);\n\tswitch (e.kind) {\n\t\tcase 'Name':\n\t\t\treturn (\n\t\t\t\tb?.kind === 'variable' ||\n\t\t\t\tb?.kind === 'param' ||\n\t\t\t\tb?.kind === 'implicit' ||\n\t\t\t\tb?.kind === 'result' ||\n\t\t\t\t(b?.kind === 'dynamic' && b.fallback !== null)\n\t\t\t);\n\t\tcase 'CallOrIndex': {\n\t\t\tconst inv = t.invocations.get(e);\n\t\t\treturn (inv?.kind === 'index' || inv?.kind === 'dynamic') && isReference(binder, e.target);\n\t\t}\n\t\tcase 'MemberAccess':\n\t\t\treturn b?.kind === 'udtField' && (e.object === null || isReference(binder, e.object));\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction checkByRefType(binder: ExpressionBinder, p: ParamSymbol, e: Expression): void {\n\tif (e.kind !== 'Name' || p.type.kind === 'variant') return;\n\tconst b = binder.ctx.table.bindings.get(e);\n\tif (b?.kind !== 'variable' && b?.kind !== 'param' && b?.kind !== 'implicit') return;\n\tconst a = b.symbol.type;\n\tconst mismatch =\n\t\t(p.type.kind === 'scalar' && (a.kind !== 'scalar' || a.vt !== p.type.vt)) ||\n\t\t(p.type.kind === 'udt' && (a.kind !== 'udt' || a.udt !== p.type.udt)) ||\n\t\t(p.type.kind === 'array' && a.kind !== 'array' && a.kind !== 'variant');\n\tif (mismatch) binder.ctx.report('byref-argument-type-mismatch', e.span, e.name.name);\n}\n\n/** Matches arguments to a library function; every argument is passed by value. */\nfunction matchLibrary(\n\tbinder: ExpressionBinder,\n\tentry: LibraryFunction,\n\targs: readonly Argument[],\n\tat: Expression,\n): CallSite {\n\tconst ctx = binder.ctx;\n\tconst n = entry.params.length;\n\tconst fixed = entry.paramArray ? n - 1 : n;\n\tconst slots: (BoundArgument | null)[] = entry.params.slice(0, fixed).map(() => null);\n\tconst rest: (Expression | null)[] = [];\n\tconst positional = args.filter((a) => !a.name);\n\tconst shift = entry.leadingOptional && positional.length <= entry.required ? 1 : 0;\n\tlet position = shift;\n\tfor (const a of args) {\n\t\tif (a.name) {\n\t\t\tconst i = entry.params.findIndex((p) => p.toLowerCase() === a.name?.name.toLowerCase());\n\t\t\tif (i < 0 || i >= fixed) ctx.report('named-argument-not-found', a.name.span, a.name.name);\n\t\t\telse slots[i] = arg(binder, a.value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (position >= fixed) {\n\t\t\tif (entry.paramArray && a.value) rest.push(a.value);\n\t\t\telse if (!entry.paramArray) ctx.report('wrong-number-of-arguments', a.span, entry.name);\n\t\t\tif (a.value) binder.value(a.value);\n\t\t\tposition++;\n\t\t\tcontinue;\n\t\t}\n\t\tslots[position] = omitted(a) ? null : arg(binder, a.value);\n\t\tposition++;\n\t}\n\tconst given = slots.filter((s) => s !== null).length + rest.length;\n\tconst required = Math.min(entry.required, fixed);\n\tfor (let i = shift; i < required; i++)\n\t\tif (slots[i] === null && given < entry.required) {\n\t\t\tctx.report('argument-not-optional', at.span, entry.params[i]);\n\t\t\tbreak;\n\t\t}\n\treturn { params: slots, rest };\n}\n\nconst arg = (binder: ExpressionBinder, e: Expression | null): BoundArgument | null => {\n\tif (!e) return null;\n\tbinder.value(e);\n\treturn { expression: e, passing: 'value' };\n};\n\n/** Binds the arguments already matched into a site (their expressions were bound by `bound`). */\nfunction bindSite(binder: ExpressionBinder, site: CallSite, args: readonly Argument[]): void {\n\tfor (const e of site.rest) if (e && !binder.ctx.table.types.has(e)) binder.objectValue(e);\n\tvoid args;\n}\n\n/** Binds an assignment to a Property Let/Set with arguments (`Foo(1) = x`, `Module2.P(i) = x`). */\nexport function propertySite(\n\tbinder: ExpressionBinder,\n\tgroup: PropertyGroup,\n\tassignment: 'Let' | 'Set',\n\targs: readonly Argument[],\n\tat: Expression,\n): CallSite | null {\n\tconst proc: BoundProcedure | null = assignment === 'Set' ? group.set : group.let;\n\tif (!proc) return null;\n\treturn matchArgs(binder, proc.params, args, at, true);\n}\n\n/** Facts of a library call that depend on its first argument's type (typed Len, conversions). */\nfunction libraryFacts(\n\tctx: BindContext,\n\tinvocation: Extract<Invocation, { kind: 'library' }>,\n): { typedLength?: number; typedArgument?: boolean } | null {\n\tconst first = invocation.site.params[0]?.expression ?? undefined;\n\tif (!first) return null;\n\tconst model: BoundLookup = {\n\t\tbinding: (e) => ctx.table.bindings.get(e),\n\t\ttypeOf: (e) => ctx.table.types.get(e) ?? VARIANT,\n\t};\n\tif (invocation.entry.convention === 'conversion')\n\t\treturn isStaticallyTyped(model, first) ? { typedArgument: true } : null;\n\tconst sized = typedLengthVt(model, invocation.entry.name, first);\n\treturn sized === null ? null : { typedLength: sized };\n}\n","// Binds expressions: records a binding for every name-like node and a static type for every\n// expression ([MS-VBAL] 5.6). Calls and indexes are delegated to `calls.ts`.\nimport type { Expression, MemberAccess } from '../../lang/index';\nimport type { Binding } from '../bindings';\nimport { OBJECT, VARIANT, isVariant, scalarType, widerScalar, type StaticType } from '../types';\nimport { bindInvocation } from './calls';\nimport type { BindContext } from './context';\nimport { bindDictionary, bindingType, bindMember, bindName, type NameUse } from './names';\n\nconst LITERAL_TYPES = {\n\tInteger: scalarType('Integer'),\n\tLong: scalarType('Long'),\n\tLongLong: scalarType('LongLong'),\n\tSingle: scalarType('Single'),\n\tDouble: scalarType('Double'),\n\tCurrency: scalarType('Currency'),\n} as const;\n\nconst COMPARISONS = new Set(['=', '<>', '<', '>', '<=', '>=', 'Like', 'Is']);\nconst LOGICAL = new Set(['And', 'Or', 'Xor', 'Eqv', 'Imp']);\n\nexport class ExpressionBinder {\n\tconstructor(readonly ctx: BindContext) {}\n\n\t/** Binds an expression that is read for its value. */\n\tvalue(e: Expression): StaticType {\n\t\tthis.ctx.reads.push(e);\n\t\treturn this.ctx.type(e, this.bind(e, 'value'));\n\t}\n\n\t/** Binds a value that is passed on as it is (an object stays an object). */\n\tobjectValue(e: Expression): StaticType {\n\t\tconst t = this.value(e);\n\t\tthis.ctx.table.objectUses.add(e);\n\t\treturn t;\n\t}\n\n\t/** Binds an expression written before `.member` (it may be a module, enum or library name). */\n\tqualifier(e: Expression): { binding: Binding | null; type: StaticType } {\n\t\tconst type = this.ctx.type(e, this.bind(e, 'qualifier'));\n\t\treturn { binding: this.ctx.table.bindings.get(e) ?? null, type };\n\t}\n\n\t/** Binds an assignment target and marks the variable it writes. */\n\ttarget(e: Expression, assignment: 'Let' | 'Set'): StaticType {\n\t\tconst type = this.ctx.type(e, this.bind(e, 'target'));\n\t\tthis.markWrite(e, assignment === 'Set' ? 'set' : 'let');\n\t\treturn type;\n\t}\n\n\t/** Marks the variable an expression stores into (`x`, `a(1)`, `u.f`, `a(1).f`). */\n\tmarkWrite(e: Expression, how: 'let' | 'set' | 'for' | 'redim' | 'string' | 'byref'): void {\n\t\tlet node: Expression = e;\n\t\tlet part = false;\n\t\twhile (node.kind === 'CallOrIndex' || node.kind === 'MemberAccess' || node.kind === 'Paren') {\n\t\t\tif (node.kind === 'Paren') return;\n\t\t\tconst b = this.ctx.table.bindings.get(node);\n\t\t\tif (node.kind === 'MemberAccess' && b?.kind !== 'udtField') return this.sharedWrite();\n\t\t\tconst inv = this.ctx.table.invocations.get(node);\n\t\t\tif (node.kind === 'CallOrIndex' && inv?.kind !== 'index' && inv?.kind !== 'dynamic')\n\t\t\t\treturn this.sharedWrite();\n\t\t\t// `v(1) = 5` on a Variant holding an object Lets the object's default member.\n\t\t\tif (node.kind === 'CallOrIndex' && inv?.kind === 'dynamic') {\n\t\t\t\tthis.sharedWrite();\n\t\t\t\tthis.defaultLet(null);\n\t\t\t}\n\t\t\tif (node.kind === 'MemberAccess' && node.object === null) return this.sharedWrite();\n\t\t\tnode = node.kind === 'CallOrIndex' ? node.target : (node.object as Expression);\n\t\t\tpart = true;\n\t\t}\n\t\tconst b = this.ctx.table.bindings.get(node);\n\t\tif (\n\t\t\t!b ||\n\t\t\t(b.kind !== 'variable' && b.kind !== 'param' && b.kind !== 'implicit' && b.kind !== 'result')\n\t\t)\n\t\t\treturn this.sharedWrite();\n\t\tif (\n\t\t\t// Module and instance fields, and Static locals, outlive this activation.\n\t\t\t(b.kind === 'variable' &&\n\t\t\t\t(b.symbol.scope === 'module' ||\n\t\t\t\t\tb.symbol.scope === 'instance' ||\n\t\t\t\t\tb.symbol.scope === 'static')) ||\n\t\t\t(b.kind === 'param' && b.symbol.passing === 'ByRef') ||\n\t\t\t// Let to an object variable assigns the object's default member.\n\t\t\t(how === 'let' && !part && b.symbol.type.kind === 'object')\n\t\t)\n\t\t\tthis.sharedWrite();\n\t\tif (how === 'let' && !part && b.symbol.type.kind === 'object') this.defaultLet(b.symbol.type);\n\t\tconst u = b.symbol.usage;\n\t\tif (part) u.partWritten = true;\n\t\telse if (how === 'let') u.letWritten = true;\n\t\telse if (how === 'set') u.setWritten = true;\n\t\telse if (how === 'for') u.forCounter = true;\n\t\telse if (how === 'redim') u.redimmed = true;\n\t\telse if (how === 'string') u.stringStatement = true;\n\t\telse u.passedByRef = true;\n\t}\n\n\t/**\n\t * A Let that assigns an object's default member runs code implicitly: the procedure gets\n\t * `implicitCalls`, and a class's default Property Let joins its callees.\n\t */\n\tprivate defaultLet(type: StaticType | null): void {\n\t\tconst p = this.ctx.procedure;\n\t\tif (!p) return;\n\t\tp.facts.implicitCalls = true;\n\t\tif (type?.kind !== 'object' || !type.classModule) return;\n\t\tconst d = this.ctx.scope.project.module(type.classModule)?.defaultMember;\n\t\tconst proc = d ? (d.let ?? d.set) : null;\n\t\tif (proc) p.facts.callees.add(proc);\n\t}\n\n\t/** Records that the procedure writes storage another activation can see. */\n\tprivate sharedWrite(): void {\n\t\tif (this.ctx.procedure) this.ctx.procedure.facts.writesShared = true;\n\t}\n\n\t/** Binds any expression; `use` says how a name at its root is used. */\n\tbind(e: Expression, use: NameUse): StaticType {\n\t\tswitch (e.kind) {\n\t\t\tcase 'NumberLiteral':\n\t\t\t\treturn LITERAL_TYPES[e.literalType];\n\t\t\tcase 'StringLiteral':\n\t\t\t\treturn scalarType('String');\n\t\t\tcase 'DateLiteral':\n\t\t\t\treturn scalarType('Date');\n\t\t\tcase 'BooleanLiteral':\n\t\t\t\treturn scalarType('Boolean');\n\t\t\tcase 'NothingLiteral':\n\t\t\t\treturn OBJECT;\n\t\t\tcase 'EmptyLiteral':\n\t\t\tcase 'NullLiteral':\n\t\t\t\treturn VARIANT;\n\t\t\tcase 'Name': {\n\t\t\t\tconst b = bindName(this.ctx, e, use, false);\n\t\t\t\tthis.markRead(b, use);\n\t\t\t\tif (\n\t\t\t\t\tuse !== 'qualifier' &&\n\t\t\t\t\tuse !== 'target' &&\n\t\t\t\t\t(b.kind === 'procedure' || b.kind === 'libraryFunction' || b.kind === 'declare')\n\t\t\t\t)\n\t\t\t\t\tbindInvocation(this, e, e, [], use === 'call');\n\t\t\t\treturn bindingType(b);\n\t\t\t}\n\t\t\tcase 'Me':\n\t\t\t\tif (!this.ctx.module.hasMe) this.ctx.report('invalid-use-of-me', e.span);\n\t\t\t\treturn bindingType(this.ctx.bind(e, { kind: 'me', module: this.ctx.module }));\n\t\t\tcase 'MemberAccess':\n\t\t\t\treturn this.member(e, use);\n\t\t\tcase 'DictionaryAccess': {\n\t\t\t\tconst objectType = e.object ? this.objectValue(e.object) : this.withSubject(e);\n\t\t\t\treturn bindingType(bindDictionary(this.ctx, e, objectType));\n\t\t\t}\n\t\t\tcase 'CallOrIndex':\n\t\t\t\treturn bindInvocation(this, e, e.target, e.args, use === 'call');\n\t\t\tcase 'Paren':\n\t\t\t\treturn this.value(e.expression);\n\t\t\tcase 'Unary': {\n\t\t\t\tconst t = this.value(e.operand);\n\t\t\t\treturn e.operator === 'Not' || isVariant(t) ? t : t;\n\t\t\t}\n\t\t\tcase 'Binary':\n\t\t\t\tif (e.operator === 'Is')\n\t\t\t\t\treturn this.binary(e.operator, this.objectValue(e.left), this.objectValue(e.right));\n\t\t\t\treturn this.binary(e.operator, this.value(e.left), this.value(e.right));\n\t\t\tcase 'TypeOf':\n\t\t\t\tthis.objectValue(e.expression);\n\t\t\t\treturn scalarType('Boolean');\n\t\t\tcase 'New': {\n\t\t\t\tconst t = this.ctx.types.named(e.type, this.ctx.module);\n\t\t\t\tif (t.kind !== 'object') this.ctx.report('invalid-qualifier', e.type.span, e.type.name);\n\t\t\t\treturn t;\n\t\t\t}\n\t\t\tcase 'AddressOf':\n\t\t\t\treturn scalarType('LongLong');\n\t\t\tcase 'FileNumber':\n\t\t\t\treturn this.value(e.expression);\n\t\t\tcase 'InvalidExpression':\n\t\t\t\treturn VARIANT;\n\t\t}\n\t}\n\n\tprivate markRead(b: Binding, use: NameUse): void {\n\t\tif (use === 'target') return;\n\t\tif (b.kind === 'variable' || b.kind === 'param' || b.kind === 'implicit')\n\t\t\tb.symbol.usage.read = true;\n\t}\n\n\tprivate member(e: MemberAccess, use: NameUse): StaticType {\n\t\tlet objectBinding: Binding | null = null;\n\t\tlet objectType: StaticType;\n\t\tif (e.object) {\n\t\t\tconst q = this.qualifier(e.object);\n\t\t\tobjectBinding = q.binding;\n\t\t\tobjectType = q.type;\n\t\t} else objectType = this.withSubject(e);\n\t\tconst b = bindMember(this.ctx, e, objectBinding, objectType, use);\n\t\tif (\n\t\t\tuse !== 'qualifier' &&\n\t\t\tuse !== 'target' &&\n\t\t\tuse !== 'callee' &&\n\t\t\t(b.kind === 'procedure' || b.kind === 'libraryFunction')\n\t\t)\n\t\t\tbindInvocation(this, e, e, [], use === 'call');\n\t\treturn bindingType(b);\n\t}\n\n\t/** The static type of the innermost With subject, recording the `.member`'s block. */\n\twithSubject(e: Expression): StaticType {\n\t\tconst block = this.ctx.withStack.at(-1);\n\t\tif (!block) {\n\t\t\tthis.ctx.report('invalid-qualifier', e.span);\n\t\t\treturn VARIANT;\n\t\t}\n\t\tthis.ctx.table.withRefs.set(e, block);\n\t\treturn block.subjectType;\n\t}\n\n\tprivate binary(op: string, a: StaticType, b: StaticType): StaticType {\n\t\tif (op === 'Is') return scalarType('Boolean');\n\t\tif (isVariant(a) || isVariant(b) || a.kind !== 'scalar' || b.kind !== 'scalar') return VARIANT;\n\t\tif (COMPARISONS.has(op)) return scalarType('Boolean');\n\t\tif (op === '&') return scalarType('String');\n\t\tif (op === '/' || op === '^') return scalarType('Double');\n\t\tif (LOGICAL.has(op) && a.name === 'Boolean' && b.name === 'Boolean') return a;\n\t\treturn widerScalar(a, b);\n\t}\n}\n","// Procedure-level declarations: parameters, `Dim`/`Static` locals, local constants and labels. A\n// local is visible in the whole procedure, so they are collected before the body is bound.\nimport type {\n\tArrayBound,\n\tAsClause,\n\tConstDeclaration,\n\tConstantDeclarator,\n\tNameRef,\n\tStatement,\n\tVariableDeclarator,\n} from '../../lang/index';\nimport { UsageFacts, type ConstSymbol, type VariableSymbol } from '../symbols';\nimport type { BindContext } from './context';\n\n/** The statement lists nested in a statement (If branches, loop bodies, Case bodies). */\nexport function nestedBodies(s: Statement): (readonly Statement[])[] {\n\tswitch (s.kind) {\n\t\tcase 'If':\n\t\t\treturn [...s.branches.map((b) => b.body), ...(s.elseBody ? [s.elseBody] : [])];\n\t\tcase 'SelectCase':\n\t\t\treturn [...s.cases.map((c) => c.body), ...(s.elseBody ? [s.elseBody] : [])];\n\t\tcase 'For':\n\t\tcase 'ForEach':\n\t\tcase 'DoLoop':\n\t\tcase 'While':\n\t\tcase 'With':\n\t\t\treturn [s.body];\n\t\tdefault:\n\t\t\treturn [];\n\t}\n}\n\n/** Visits every statement of a body, nested ones included, in source order. */\nexport function forEachStatement(body: readonly Statement[], visit: (s: Statement) => void): void {\n\t// Recursion depth is bounded by the parser's nesting limit.\n\tfor (const s of body) {\n\t\tvisit(s);\n\t\tfor (const inner of nestedBodies(s)) forEachStatement(inner, visit);\n\t}\n}\n\n/** Declares a local variable (or Static local), reporting a duplicate. */\nexport function declareLocal(\n\tctx: BindContext,\n\tname: NameRef,\n\tdeclarator: VariableDeclarator | null,\n\tasClause: AsClause | null,\n\tbounds: readonly ArrayBound[] | null,\n\tisStatic: boolean,\n): VariableSymbol | null {\n\tconst p = ctx.procedure;\n\tif (!p || !ctx.procedureScope) return null;\n\tconst staticStore = isStatic || p.declaration.isStatic;\n\tconst symbol: VariableSymbol = {\n\t\tkind: 'variable',\n\t\tid: ctx.ids.take(),\n\t\tname: name.name,\n\t\tscope: staticStore ? 'static' : 'local',\n\t\tmodule: ctx.module.name,\n\t\tisPublic: false,\n\t\ttype: ctx.types.declared(name, asClause, bounds, ctx.module),\n\t\tbounds,\n\t\tisNew: asClause?.isNew ?? false,\n\t\twithEvents: false,\n\t\timplicit: false,\n\t\tslot: staticStore ? p.statics.length : p.params.length + 1 + p.locals.length,\n\t\tdeclaration: declarator,\n\t\tusage: new UsageFacts(),\n\t};\n\tif (!ctx.procedureScope.declare(symbol)) {\n\t\tctx.report('duplicate-declaration', name.span, name.name);\n\t\treturn null;\n\t}\n\t(staticStore ? p.statics : p.locals).push(symbol);\n\treturn symbol;\n}\n\nexport function declareLocalConst(\n\tctx: BindContext,\n\ts: ConstDeclaration,\n\td: ConstantDeclarator,\n): ConstSymbol | null {\n\tconst p = ctx.procedure;\n\tif (!p || !ctx.procedureScope) return null;\n\tconst symbol: ConstSymbol = {\n\t\tkind: 'const',\n\t\tid: ctx.ids.take(),\n\t\tname: d.name.name,\n\t\tmodule: ctx.module.name,\n\t\tprocedure: p.name,\n\t\tisPublic: false,\n\t\ttype: d.asClause ? ctx.types.named(d.asClause.type, ctx.module, d.asClause.fixedLength) : null,\n\t\tvalue: d.value,\n\t\tdeclaration: s,\n\t\tnameRef: d.name,\n\t};\n\tif (!ctx.procedureScope.declare(symbol)) {\n\t\tctx.report('duplicate-declaration', d.name.span, d.name.name);\n\t\treturn null;\n\t}\n\tp.consts.push(symbol);\n\treturn symbol;\n}\n\n/** Collects labels and `Dim`/`Static` locals of a body before it is bound. */\nexport function collectLocals(ctx: BindContext, body: readonly Statement[]): void {\n\tconst p = ctx.procedure;\n\tif (!p) return;\n\tforEachStatement(body, (s) => {\n\t\tif (s.kind === 'Label') {\n\t\t\tconst key = s.label.name.toLowerCase();\n\t\t\tif (p.labels.has(key)) ctx.report('duplicate-declaration', s.label.span, s.label.name);\n\t\t\telse p.labels.set(key, s);\n\t\t\tif (s.label.isLineNumber) p.facts.hasLineNumbers = true;\n\t\t} else if (s.kind === 'VariableDeclaration') {\n\t\t\tfor (const d of s.declarators)\n\t\t\t\tdeclareLocal(\n\t\t\t\t\tctx,\n\t\t\t\t\td.name,\n\t\t\t\t\td,\n\t\t\t\t\td.asClause,\n\t\t\t\t\td.dimensions?.bounds ?? null,\n\t\t\t\t\ts.keyword === 'Static',\n\t\t\t\t);\n\t\t}\n\t});\n}\n","// Binds statements ([MS-VBAL] 5.4): one small handler per statement kind in a dispatch table.\n// Each binds the statement's expressions, marks how variables are written, records With blocks\n// and collects the procedure facts (jumps, error handling, End).\nimport type { Expression, Statement } from '../../lang/index';\nimport { VARIANT } from '../types';\nimport { bindInvocation, isReference, propertySite } from './calls';\nimport type { ExpressionBinder } from './expressions';\nimport { declareLocal, declareLocalConst } from './locals';\n\n/** The statement node of a kind (`GoTo` and `GoSub` share one node type). */\nexport type StatementOf<K, S = Statement> = S extends { readonly kind: infer KK }\n\t? K extends KK\n\t\t? S\n\t\t: never\n\t: never;\ntype Handler<K extends Statement['kind']> = (b: StatementBinder, s: StatementOf<K>) => void;\ntype Table = { readonly [K in Statement['kind']]: Handler<K> };\n\n/** Expression-valued fields of the file statements (which raise error 445 when run). */\nconst FILE_FIELDS = [\n\t'path',\n\t'fileNumber',\n\t'recordLength',\n\t'recordNumber',\n\t'target',\n\t'position',\n\t'from',\n\t'to',\n\t'width',\n];\n\n/** Binds a loop body with the loop on the stack Exit For and Exit Do check. */\nfunction loop(b: StatementBinder, kind: 'For' | 'Do', body: readonly Statement[]): void {\n\tb.expr.ctx.loopStack.push(kind);\n\tb.block(body);\n\tb.expr.ctx.loopStack.pop();\n}\n\nconst HANDLERS: Table = {\n\tLabel: () => undefined,\n\tAttributeStatement: () => undefined,\n\tInvalidStatement: () => undefined,\n\tAssignment: (b, s) => b.assignment(s.target, s.value, s.assignment),\n\tCall: (b, s) => {\n\t\tbindInvocation(b.expr, s, s.callee, s.args, true);\n\t},\n\tIf: (b, s) => {\n\t\tfor (const branch of s.branches) {\n\t\t\tb.expr.value(branch.condition);\n\t\t\tb.block(branch.body);\n\t\t}\n\t\tif (s.elseBody) b.block(s.elseBody);\n\t},\n\tSelectCase: (b, s) => {\n\t\tb.expr.value(s.subject);\n\t\tfor (const c of s.cases) {\n\t\t\tfor (const t of c.tests) {\n\t\t\t\tif (t.kind === 'CaseRange') {\n\t\t\t\t\tb.expr.value(t.from);\n\t\t\t\t\tb.expr.value(t.to);\n\t\t\t\t} else b.expr.value(t.value);\n\t\t\t}\n\t\t\tb.block(c.body);\n\t\t}\n\t\tif (s.elseBody) b.block(s.elseBody);\n\t},\n\tFor: (b, s) => {\n\t\tb.expr.target(s.counter, 'Let');\n\t\tb.expr.markWrite(s.counter, 'for');\n\t\tb.expr.value(s.start);\n\t\tb.expr.value(s.end);\n\t\tif (s.step) b.expr.value(s.step);\n\t\tloop(b, 'For', s.body);\n\t},\n\tForEach: (b, s) => {\n\t\tb.expr.target(s.element, 'Let');\n\t\tb.expr.markWrite(s.element, 'for');\n\t\tb.expr.value(s.collection);\n\t\tloop(b, 'For', s.body);\n\t},\n\tDoLoop: (b, s) => {\n\t\tif (s.condition) b.expr.value(s.condition.expression);\n\t\tloop(b, 'Do', s.body);\n\t},\n\tWhile: (b, s) => {\n\t\tb.expr.value(s.condition);\n\t\tb.block(s.body);\n\t},\n\tWith: (b, s) => {\n\t\tconst subjectType = b.expr.objectValue(s.object);\n\t\tconst ctx = b.expr.ctx;\n\t\tconst id = ctx.procedure?.withBlocks.length ?? 0;\n\t\tconst block = { id, depth: ctx.withStack.length, statement: s, subjectType };\n\t\tctx.procedure?.withBlocks.push(block);\n\t\tctx.withStack.push(block);\n\t\tb.block(s.body);\n\t\tctx.withStack.pop();\n\t},\n\tExit: (b, s) => {\n\t\tconst p = b.expr.ctx.procedure;\n\t\tif (s.target === 'Do' || s.target === 'For') {\n\t\t\tif (!b.expr.ctx.loopStack.includes(s.target))\n\t\t\t\tb.expr.ctx.report('exit-not-in-loop', s.span, s.target);\n\t\t\treturn;\n\t\t}\n\t\tif (!p) return;\n\t\tconst kind = p.declaration.procedureKind;\n\t\tconst fits =\n\t\t\ts.target === 'Sub'\n\t\t\t\t? kind === 'Sub'\n\t\t\t\t: s.target === 'Function'\n\t\t\t\t\t? kind === 'Function'\n\t\t\t\t\t: kind.startsWith('Property');\n\t\tif (!fits) b.expr.ctx.report('exit-not-allowed', s.span, s.target);\n\t},\n\tGoTo: (b, s) => {\n\t\tconst f = b.facts();\n\t\tif (f) {\n\t\t\tif (s.kind === 'GoSub') f.hasGoSub = true;\n\t\t\telse f.hasGoTo = true;\n\t\t}\n\t\tb.label(s.label);\n\t},\n\tGoSub: (b, s) => HANDLERS.GoTo(b, s),\n\tReturn: () => undefined,\n\tStop: (b) => {\n\t\tconst f = b.facts();\n\t\tif (f) f.hasEnd = true;\n\t},\n\tEnd: (b) => {\n\t\tconst f = b.facts();\n\t\tif (f) f.hasEnd = true;\n\t},\n\tOnError: (b, s) => {\n\t\tconst f = b.facts();\n\t\tif (f) f.hasOnError = true;\n\t\tif (s.action === 'goto' && s.label) b.label(s.label);\n\t},\n\tResume: (b, s) => {\n\t\tconst f = b.facts();\n\t\tif (f) f.hasResume = true;\n\t\tif (s.action === 'label' && s.label) b.label(s.label);\n\t},\n\tOnGoTo: (b, s) => {\n\t\tconst f = b.facts();\n\t\tif (f) {\n\t\t\tf.hasOnGoTo = true;\n\t\t\tif (s.gosub) f.hasGoSub = true;\n\t\t}\n\t\tb.expr.value(s.selector);\n\t\tfor (const l of s.labels) b.label(l);\n\t},\n\tReDim: (b, s) => {\n\t\tfor (const clause of s.clauses) {\n\t\t\tif (clause.target.kind === 'Name' && !b.expr.ctx.scope.lookup(clause.target.name.name))\n\t\t\t\tdeclareLocal(b.expr.ctx, clause.target.name, null, clause.asClause, [], false);\n\t\t\tb.expr.target(clause.target, 'Let');\n\t\t\tb.expr.markWrite(clause.target, 'redim');\n\t\t\tfor (const bound of clause.bounds) {\n\t\t\t\tif (bound.lower) b.expr.value(bound.lower);\n\t\t\t\tb.expr.value(bound.upper);\n\t\t\t}\n\t\t}\n\t},\n\tErase: (b, s) => {\n\t\tfor (const t of s.targets) {\n\t\t\tb.expr.target(t, 'Let');\n\t\t\tb.expr.markWrite(t, 'redim');\n\t\t}\n\t},\n\tRaiseEvent: (b, s) => {\n\t\tconst ctx = b.expr.ctx;\n\t\tconst event = ctx.module.events.find((e) => e.name.toLowerCase() === s.name.name.toLowerCase());\n\t\tif (!event) ctx.report('method-or-data-member-not-found', s.name.span, s.name.name);\n\t\tconst f = b.facts();\n\t\tif (f) f.raisesEvents = true;\n\t\tctx.dynamic();\n\t\t// Event parameters are ByRef unless declared ByVal: a handler may write what is passed.\n\t\tfor (const a of s.args)\n\t\t\tif (a.value) {\n\t\t\t\tb.expr.value(a.value);\n\t\t\t\tif (isReference(b.expr, a.value)) b.expr.markWrite(a.value, 'byref');\n\t\t\t}\n\t},\n\tMidAssignment: (b, s) => {\n\t\tb.expr.target(s.target, 'Let');\n\t\tb.expr.markWrite(s.target, 'string');\n\t\tb.expr.value(s.start);\n\t\tif (s.length) b.expr.value(s.length);\n\t\tb.expr.value(s.value);\n\t},\n\tLSet: (b, s) => b.stringStatement(s.target, s.value),\n\tRSet: (b, s) => b.stringStatement(s.target, s.value),\n\tName: (b, s) => {\n\t\tb.expr.value(s.oldPath);\n\t\tb.expr.value(s.newPath);\n\t},\n\tError: (b, s) => {\n\t\tb.expr.value(s.number);\n\t},\n\tPrint: (b, s) => {\n\t\tif (s.fileNumber) b.expr.value(s.fileNumber);\n\t\tfor (const item of s.items) if (item.value) b.expr.value(item.value);\n\t},\n\tOpen: (b, s) => b.fileStatement(s),\n\tClose: (b, s) => b.fileStatement(s),\n\tInput: (b, s) => b.fileStatement(s),\n\tLineInput: (b, s) => b.fileStatement(s),\n\tWrite: (b, s) => b.fileStatement(s),\n\tGet: (b, s) => b.fileStatement(s),\n\tPut: (b, s) => b.fileStatement(s),\n\tSeek: (b, s) => b.fileStatement(s),\n\tLock: (b, s) => b.fileStatement(s),\n\tUnlock: (b, s) => b.fileStatement(s),\n\tWidth: (b, s) => b.fileStatement(s),\n\tVariableDeclaration: (b, s) => {\n\t\tfor (const d of s.declarators) {\n\t\t\tfor (const bound of d.dimensions?.bounds ?? []) {\n\t\t\t\tif (bound.lower) b.expr.value(bound.lower);\n\t\t\t\tb.expr.value(bound.upper);\n\t\t\t}\n\t\t\tif (d.asClause?.fixedLength) b.expr.value(d.asClause.fixedLength);\n\t\t}\n\t},\n\tConstDeclaration: (b, s) => {\n\t\tfor (const d of s.declarators) {\n\t\t\tb.expr.value(d.value);\n\t\t\tdeclareLocalConst(b.expr.ctx, s, d);\n\t\t}\n\t},\n};\n\nexport class StatementBinder {\n\tconstructor(readonly expr: ExpressionBinder) {}\n\n\tblock(body: readonly Statement[]): void {\n\t\tfor (const s of body) this.statement(s);\n\t}\n\n\tstatement(s: Statement): void {\n\t\t(HANDLERS[s.kind] as Handler<Statement['kind']>)(this, s);\n\t}\n\n\tfacts() {\n\t\treturn this.expr.ctx.procedure?.facts;\n\t}\n\n\t/** Reports a jump to a label the procedure does not define. */\n\tlabel(l: {\n\t\treadonly name: string;\n\t\treadonly span: Statement['span'];\n\t\treadonly isLineNumber: boolean;\n\t}): void {\n\t\tconst p = this.expr.ctx.procedure;\n\t\tif (!p) return;\n\t\tif (l.isLineNumber && (l.name === '0' || l.name === '-1')) return;\n\t\tif (!p.labels.has(l.name.toLowerCase()))\n\t\t\tthis.expr.ctx.report('label-not-defined', l.span, l.name);\n\t}\n\n\t/** `target = value` / `Set target = value`, including Property Let/Set targets. */\n\tassignment(target: Expression, value: Expression, assignment: 'Let' | 'Set'): void {\n\t\tif (assignment === 'Set') this.expr.objectValue(value);\n\t\telse this.expr.value(value);\n\t\tconst ctx = this.expr.ctx;\n\t\tconst args = target.kind === 'CallOrIndex' ? target.args : [];\n\t\tconst head = target.kind === 'CallOrIndex' ? target.target : target;\n\t\tthis.expr.target(target, assignment);\n\t\tconst b = ctx.table.bindings.get(head);\n\t\tif (b?.kind === 'procedure' && (head.kind === 'Name' || head.kind === 'MemberAccess')) {\n\t\t\tconst site = propertySite(this.expr, b.group, assignment, args, target);\n\t\t\tif (site) ctx.invoke(target, { kind: 'call', group: b.group, site });\n\t\t\telse ctx.report('wrong-number-of-arguments', target.span, b.group.name);\n\t\t}\n\t}\n\n\tstringStatement(target: Expression, value: Expression): void {\n\t\tthis.expr.target(target, 'Let');\n\t\tthis.expr.markWrite(target, 'string');\n\t\tthis.expr.value(value);\n\t}\n\n\tfileStatement(s: Statement): void {\n\t\tconst record = s as unknown as Record<string, unknown>;\n\t\tfor (const field of FILE_FIELDS) {\n\t\t\tconst v = record[field];\n\t\t\tif (v && typeof v === 'object' && 'kind' in v) this.expr.value(v as Expression);\n\t\t}\n\t\tfor (const field of ['fileNumbers', 'targets']) {\n\t\t\tconst list = record[field];\n\t\t\tif (Array.isArray(list)) for (const e of list) this.expr.value(e as Expression);\n\t\t}\n\t\tconst items = record.items;\n\t\tif (Array.isArray(items))\n\t\t\tfor (const item of items) {\n\t\t\t\tconst v = (item as { value?: Expression | null }).value;\n\t\t\t\tif (v) this.expr.value(v);\n\t\t\t}\n\t\tvoid VARIANT;\n\t}\n}\n","// The binder's entry point: parses every module, declares the project's symbols in two passes and\n// binds each module's constant expressions and procedure bodies into one `BoundProgram`.\nimport {\n\tforEachChild,\n\tparseModule,\n\ttype Expression,\n\ttype ModuleKind,\n\ttype ParseOptions,\n} from '../../lang/index';\nimport { ModuleDeclarer } from '../declare';\nimport { DiagnosticSink } from '../diagnostics';\nimport { BoundModule } from '../module';\nimport { BindingTable, BoundProgram, readMayCall } from '../program';\nimport type { BoundProcedure } from '../procedure';\nimport { ProcedureScope, ProjectScope, ScopeChain, type HostNames } from '../scope';\nimport { IdSource, type ConstSymbol } from '../symbols';\nimport { TypeIndex, TypeResolver } from '../types-resolve';\nimport { BindContext } from './context';\nimport { ExpressionBinder } from './expressions';\nimport { collectLocals } from './locals';\nimport { StatementBinder } from './statements';\n\n/** One module of the project as source text. */\nexport interface SourceModuleInput {\n\t/** The module name. */\n\treadonly name: string;\n\t/** Standard, class, document or form module. */\n\treadonly kind: ModuleKind;\n\t/** The module's source text. */\n\treadonly source: string;\n}\n\n/** What `bindProgram` needs to know about the host and the parser. */\nexport interface BindOptions {\n\t/** `#Const` values for conditional compilation. */\n\treadonly constants?: ParseOptions['constants'];\n\t/** Names of the host's global objects (`Application`, `ThisWorkbook`). */\n\treadonly globals?: Iterable<string>;\n\t/** True when the host gives a global object whose members resolve unqualified. */\n\treadonly globalObject?: boolean;\n\t/** Names of document modules that have a host object. */\n\treadonly documentObjects?: Iterable<string>;\n\t/** Parser limits and the current year for date literals without one. */\n\treadonly parse?: Pick<ParseOptions, 'limits' | 'currentYear'>;\n}\n\n/** Binds a project: every module, every name, call and `With` member. Never throws on bad code. */\nexport function bindProgram(\n\tinputs: readonly SourceModuleInput[],\n\toptions: BindOptions = {},\n): BoundProgram {\n\tconst sink = new DiagnosticSink();\n\tconst ids = new IdSource();\n\tconst index = new TypeIndex();\n\tconst types = new TypeResolver(index);\n\tconst table = new BindingTable();\n\tconst declarer = new ModuleDeclarer(ids, index, types, sink);\n\tconst modules = inputs.map((input) => {\n\t\tconst { module: ast, diagnostics } = parseModule(input.source, {\n\t\t\t...options.parse,\n\t\t\tmoduleKind: input.kind,\n\t\t\t...(options.constants ? { constants: options.constants } : {}),\n\t\t});\n\t\tconst m = new BoundModule(input.name, input.kind, ast);\n\t\tfor (const d of diagnostics) {\n\t\t\tsink.addParsed(m.name, d);\n\t\t\tif (d.severity === 'error') m.hasErrors = true;\n\t\t}\n\t\treturn m;\n\t});\n\tfor (const m of modules) declarer.collectTypes(m);\n\tfor (const m of modules) declarer.declareMembers(m);\n\tconst lower = (names: Iterable<string> | undefined) =>\n\t\tnew Set([...(names ?? [])].map((n) => n.toLowerCase()));\n\tconst host: HostNames = {\n\t\tglobals: lower(options.globals),\n\t\tglobalObject: options.globalObject ?? false,\n\t\tdocuments: lower(options.documentObjects),\n\t};\n\tconst project = new ProjectScope(modules, host);\n\tconst make = (m: BoundModule, p: BoundProcedure | null, scope: ProcedureScope | null) =>\n\t\tnew BindContext(m, p, new ScopeChain(m, project, scope), scope, table, sink, ids, types);\n\tfor (const m of modules) {\n\t\tbindModuleLevel(new ExpressionBinder(make(m, null, null)), m);\n\t\tfor (const p of m.procedures) {\n\t\t\tconst scope = new ProcedureScope();\n\t\t\tfor (const param of p.params) scope.declare(param);\n\t\t\tconst ctx = make(m, p, scope);\n\t\t\tcollectLocals(ctx, p.declaration.body);\n\t\t\tnew StatementBinder(new ExpressionBinder(ctx)).block(p.declaration.body);\n\t\t\tsummarizeImplicitCalls(ctx, p);\n\t\t}\n\t\torderConsts(m, table);\n\t\tconnectHandlers(m, sink);\n\t}\n\tfor (const d of sink.items) {\n\t\tif (d.severity !== 'error') continue;\n\t\tconst m = modules.find((x) => x.name === d.module);\n\t\tif (m) m.hasErrors = true;\n\t}\n\treturn new BoundProgram(modules, sink.items, table);\n}\n\n/** Binds the constant expressions at module level: Const values, Enum values, bounds, defaults. */\nfunction bindModuleLevel(binder: ExpressionBinder, m: BoundModule): void {\n\tfor (const c of m.consts) binder.value(c.value);\n\tfor (const e of m.enums)\n\t\tfor (const member of e.members) if (member.value) binder.value(member.value);\n\tfor (const v of m.variables) {\n\t\tfor (const b of v.bounds ?? []) {\n\t\t\tif (b.lower) binder.value(b.lower);\n\t\t\tbinder.value(b.upper);\n\t\t}\n\t\tconst fixed = v.declaration?.asClause?.fixedLength;\n\t\tif (fixed) binder.value(fixed);\n\t}\n\tfor (const u of m.udts) {\n\t\tfor (const f of u.fields) {\n\t\t\tfor (const b of f.bounds ?? []) {\n\t\t\t\tif (b.lower) binder.value(b.lower);\n\t\t\t\tbinder.value(b.upper);\n\t\t\t}\n\t\t\tif (f.type.kind === 'scalar' && f.type.fixedLength) binder.value(f.type.fixedLength);\n\t\t}\n\t}\n\tfor (const p of m.procedures)\n\t\tfor (const param of p.params) if (param.defaultValue) binder.value(param.defaultValue);\n}\n\n/** Sorts the module's constants so each follows the constants of its own module it uses. */\nfunction orderConsts(m: BoundModule, table: BindingTable): void {\n\tconst done = new Set<ConstSymbol>();\n\tconst sorted: ConstSymbol[] = [];\n\tconst visiting = new Set<ConstSymbol>();\n\tconst uses = (e: Expression, out: ConstSymbol[]): void => {\n\t\tconst b = table.bindings.get(e);\n\t\tif (b?.kind === 'const' && b.symbol.module === m.name && b.symbol.procedure === null)\n\t\t\tout.push(b.symbol);\n\t\tforEachChild(e, (child) => uses(child as Expression, out));\n\t};\n\tconst visit = (c: ConstSymbol): void => {\n\t\tif (done.has(c) || visiting.has(c)) return;\n\t\tvisiting.add(c);\n\t\tconst deps: ConstSymbol[] = [];\n\t\tuses(c.value, deps);\n\t\tfor (const d of deps) visit(d);\n\t\tvisiting.delete(c);\n\t\tdone.add(c);\n\t\tsorted.push(c);\n\t};\n\tfor (const c of m.consts) visit(c);\n\tm.consts.splice(0, m.consts.length, ...sorted);\n}\n\n/** Finds the `<variable>_<event>` handlers of the module's `WithEvents` variables. */\nfunction connectHandlers(m: BoundModule, sink: DiagnosticSink): void {\n\tfor (const v of m.variables) {\n\t\tif (!v.withEvents) continue;\n\t\tif (m.kind === 'standard') {\n\t\t\t// WithEvents needs an object to receive the events: a class or document module.\n\t\t\tconst span = v.declaration?.span;\n\t\t\tif (span) sink.add(m.name, 'only-valid-in-object-module', span);\n\t\t\tcontinue;\n\t\t}\n\t\tconst prefix = `${v.name.toLowerCase()}_`;\n\t\tconst events = new Map<string, BoundProcedure>();\n\t\tfor (const [key, group] of m.groups)\n\t\t\tif (key.startsWith(prefix) && group.method?.kind === 'Sub')\n\t\t\t\tevents.set(key.slice(prefix.length), group.method);\n\t\tm.eventHandlers.set(v.name.toLowerCase(), events);\n\t}\n}\n\n/**\n * `ProcedureFacts.implicitCalls`: the procedure reads a value that may run code implicitly, and the\n * default member of each class-typed operand it reads that way joins its callees.\n */\nfunction summarizeImplicitCalls(ctx: BindContext, p: BoundProcedure): void {\n\tfor (const e of ctx.reads) {\n\t\tif (!readMayCall(ctx.table, e)) continue;\n\t\tp.facts.implicitCalls = true;\n\t\tconst t = ctx.table.types.get(e);\n\t\tif (t?.kind !== 'object' || !t.classModule) continue;\n\t\tconst d = ctx.scope.project.module(t.classModule)?.defaultMember;\n\t\tconst proc = d ? (d.reader ?? d.method ?? d.any) : null;\n\t\tif (proc) p.facts.callees.add(proc);\n\t}\n}\n"],"mappings":";;;AAUA,IAAa,iBAAb,MAA4B;;CAE3B,UAAU;;CAEV,WAAW;;CAEX,YAAY;;CAEZ,aAAa;;CAEb,YAAY;;CAEZ,iBAAiB;;CAEjB,SAAS;;CAEA,0BAAU,IAAI,IAAoB;;CAElC,0BAAU,IAAI,IAAqB;;;;;;CAM5C,UAAU;;;;;;CAMV,eAAe;;CAEf,eAAe;;;;;;CAMf,gBAAgB;AACjB;;;;;AAMA,IAAa,iBAAb,MAA4B;CAoBjB;CAEA;CAEA;CAEA;;CAxBD,SAAwB,CAAC;;CAElC,SAAgC;;CAEvB,SAA2B,CAAC;;CAE5B,UAA4B,CAAC;;CAE7B,SAAwB,CAAC;;CAEzB,yBAAS,IAAI,IAA4B;;CAEzC,aAA0B,CAAC;;CAE3B,QAAQ,IAAI,eAAe;CAEpC,YAEU,IAEA,QAEA,aAEA,YACR;EAPQ,KAAA,KAAA;EAEA,KAAA,SAAA;EAEA,KAAA,cAAA;EAEA,KAAA,aAAA;CACP;;CAGH,IAAI,OAAe;EAClB,OAAO,KAAK,YAAY,KAAK;CAC9B;;CAGA,IAAI,OAAsB;EACzB,OAAO,KAAK,YAAY;CACzB;;CAGA,IAAI,WAAoB;EACvB,OAAO,KAAK,YAAY,UAAU;CACnC;;;;;CAMA,IAAI,aAA8C;EACjD,MAAM,QAAQ,KAAK,YAAY;EAC/B,OAAO,UAAU,YAAY,YAAY,UAAU,WAAW,W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