diff --git a/src/tools/ilasm/README.md b/src/tools/ilasm/README.md index 203eaecda412cf..50431f8124e04c 100644 --- a/src/tools/ilasm/README.md +++ b/src/tools/ilasm/README.md @@ -1,25 +1,123 @@ -# ILAssembler Build Workflow +# ILAssembler -This directory contains the ILAssembler tool and its build instructions. +ILAssembler compiles declarations while ANTLR parses the input. The parser uses +`UnbufferedTokenStream` with parse-tree construction disabled. Namespace, type, top-level, +class-member, method-body and shared-directive structure is action-driven. A complete document, +declaration body or method body is never retained. Rules such as `bytes` stream their content into +an accumulator instead of building a subtree at all. The generator emits neither listeners nor +visitors; parser actions own traversal. -## Build Instructions +## Public contract -### Regular Builds -For everyday development and regular builds, simply run: +`src/ILAssembler/ref/ILAssembler.csproj` defines the supported compiler API as a custom reference +assembly, following the same pattern as Mono.Linker. Project references compile against this +contract by default, while the implementation assembly remains the runtime asset. + +ANTLR-generated parser types and the preprocessing/string helpers used by implementation tests are +intentionally absent from the contract. Tests opt into the implementation assembly with +`SkipUseReferenceAssembly`. + +`GrammarActions` is a single `internal sealed partial class` split across +`src/ILAssembler/Actions/GrammarActions.*.cs`: + +| File | Contents | +| ---- | -------- | +| `GrammarActions.cs` | Per-document lifecycle. | +| `GrammarActions.BuildImage.cs` | PE and portable PDB construction. | +| `GrammarActions.Bytes.cs` | `bytearray` accumulation. | +| `GrammarActions.Conversions.cs` | Diagnostics and shared state. | +| `GrammarActions.CustomAttributes.Actions.cs` | Custom attribute descriptors, declarations and blob lists. | +| `GrammarActions.CustomAttributes.Sequences.cs` | Custom attribute scalar-array sequence synthesis. | +| `GrammarActions.CustomAttributes.Serialization.cs` | Serialized attribute values and field/parameter initializers. | +| `GrammarActions.Data.cs` | Streaming mapped-data declarations, labels and reference fixups. | +| `GrammarActions.Debug.cs` | Direct source-location, document and language directives. | +| `GrammarActions.Declarations.Actions.cs` | Direct top-level declarations and shared-directive dispatch. | +| `GrammarActions.Instructions.cs` | Tree-free value instruction and method-item actions. | +| `GrammarActions.Instructions.References.cs` | Reference and signature instruction actions. | +| `GrammarActions.Literals.cs` | Literals, names and strings. | +| `GrammarActions.Manifest.Assembly.cs` | Assembly definitions, identity, keys, security and attributes. | +| `GrammarActions.Manifest.ExportedTypes.cs` | Exported-type headers, implementations and attributes. | +| `GrammarActions.Manifest.Files.cs` | Assembly file declarations and entry points. | +| `GrammarActions.Manifest.References.cs` | Assembly references, identities, keys and hashes. | +| `GrammarActions.Manifest.Resources.cs` | Embedded and external manifest resources. | +| `GrammarActions.Manifest.Typedefs.cs` | Type, member and custom-attribute aliases. | +| `GrammarActions.Manifest.VTable.cs` | Vtable fixup declarations and flags. | +| `GrammarActions.Marshalling.Actions.cs` | Synthesized native type and marshalling descriptor actions. | +| `GrammarActions.Members.Class.cs` | Class directives, generic parameter annotations and method overrides. | +| `GrammarActions.Members.Fields.cs` | Field declarations, attributes, layout, constants, marshalling and RVA data. | +| `GrammarActions.Members.PropertiesEvents.cs` | Property and event headers, bodies and accessors. | +| `GrammarActions.MethodHeaders.cs` | Method definition and signature materialization. | +| `GrammarActions.MethodHeaders.Actions.cs` | Method header, attribute, P/Invoke and generic parser actions. | +| `GrammarActions.MethodHeaders.Generics.cs` | Generic parameter and constraint synthesis and materialization. | +| `GrammarActions.MethodBodies.cs` | Label validation and method-name parsing. | +| `GrammarActions.MethodBodies.Directives.cs` | Direct method-body directives and parameter ownership. | +| `GrammarActions.MethodBodies.ExceptionHandling.cs` | Lexical scopes and synthesized exception regions. | +| `GrammarActions.Security.cs` | Synthesized declarative-security values and permission sets. | +| `GrammarActions.Signatures.cs` | Member and type signature materialization helpers. | +| `GrammarActions.Signatures.Actions.cs` | Signature grammar actions and typed aggregation helpers. | +| `GrammarActions.Signatures.References.cs` | Member-reference synthesis and materialization. | +| `GrammarActions.Signatures.Types.cs` | Type-signature materialization and encoding. | +| `GrammarActions.Types.cs` | Namespace and type scope ownership and shared type conversion. | +| `GrammarActions.Types.Headers.cs` | Namespace and type-header materialization. | +| `GrammarActions.Types.Headers.Actions.cs` | Namespace, type attribute, base and interface parser actions. | +| `GrammarActions.Types.References.cs` | Type-name synthesis and resolution. | + +The hand-written `public partial CILParser` semantic model is split by feature: + +| File | Contents | +| ---- | -------- | +| `CILParser.SemanticValues.CustomAttributes.cs` | Custom attribute, serialization and initializer values. | +| `CILParser.SemanticValues.Declarations.cs` | Type/member headers and their context-owned builders. | +| `CILParser.SemanticValues.Manifest.cs` | Assembly, file, exported-type, resource and typedef values. | +| `CILParser.SemanticValues.Marshalling.cs` | Native, variant and marshalling values and builders. | +| `CILParser.SemanticValues.MethodBodies.cs` | Debug, data, security, exception and instruction values. | +| `CILParser.SemanticValues.Signatures.cs` | Managed types, signatures, names, owners and member references. | + +These types are public because ANTLR emits public rule-context return and local fields. They are +implementation-only: the explicit reference assembly omits `CILParser`, and its existing CP0001 +suppression covers the nested semantic types as part of that excluded surface. + +## Rules for grammar actions + +Parser actions in `src/ILAssembler/gen/CIL.g4` must remain thin. They pass concrete child-rule +values to `GrammarActions`; mechanical assignments and typed builder additions may happen directly +in the grammar. Compilation orchestration belongs in the `GrammarActions` partial-class files. + +`DocumentCompiler` disables parse-tree construction when it creates the parser, and no parser action +changes that setting. ANTLR generates neither listeners nor visitors. All semantics come from parser +actions and concrete synthesized values. Rule contexts own their typed builders and pass finalized +child values to their parents; parser semantic data is never erased to `object`. + +All namespace, type-header, top-level, type, signature, reference, marshalling, class-member, +method-header, method-body directive, exception-handling, data, security, source, language, +assembly, manifest, vtable and typedef structure is action-driven. `scopeBlock` records offsets +under its context key without inspecting children. `BuildParseTree` remains disabled throughout. + +Rule-local builders are finalized from that rule's `finally` clause when error recovery requires a +value. Semantic roots capture the initial syntax-error count in a context local instead of a global +frame stack. The remaining stacks model active compiler nesting: namespaces, types, declaration +owners and lexical method scopes. Their owning declaration or scope releases them from `finally` +because ANTLR skips `@after` actions after a syntax error. + +Only parser actions process structural rules. There is no parse-tree walker or mode toggling. + +## Build ``` ./dotnet.sh build src/tools/ilasm/src/ILAssembler ``` -### Updating Generated Files -If you modify any `.g4` grammar files (rare), you must regenerate the parser and related files: +On Windows, use `.\dotnet.cmd` instead of `./dotnet.sh`. + +## Updating generated parser files + +After modifying `CIL.g4`, regenerate the checked-in ANTLR output before building ILAssembler: ``` ./dotnet.sh build src/tools/ilasm/src/ILAssembler/gen +./dotnet.sh build src/tools/ilasm/src/ILAssembler ``` -This will update the generated files before building the main project. - ---- - -For more details, see the main repository README or contact the maintainers. +Do not edit generated `CIL*.cs` or `.interp` files manually. +Regeneration produces `CILLexer.cs` and `CILParser.cs`; it does not produce visitor or listener +types. diff --git a/src/tools/ilasm/ilasm.slnx b/src/tools/ilasm/ilasm.slnx index fc6b5afa291976..fba31c6ccf0595 100644 --- a/src/tools/ilasm/ilasm.slnx +++ b/src/tools/ilasm/ilasm.slnx @@ -1,4 +1,7 @@ + + + diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.BuildImage.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.BuildImage.cs new file mode 100644 index 00000000000000..8747f8175447e3 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.BuildImage.cs @@ -0,0 +1,580 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using System.Reflection.PortableExecutable; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using Antlr4.Runtime; +using Antlr4.Runtime.Misc; + +namespace ILAssembler +{ + internal sealed partial class GrammarActions + { + public (ImmutableArray Diagnostics, CompilationResult? Image) BuildImage() + { + // Default module name to output filename if no .module directive was provided + if (_entityRegistry.Module.Name is null && _options.OutputFileName is not null) + { + _entityRegistry.Module.Name = _options.OutputFileName; + } + + // Apply DebuggableAttribute AFTER all source declarations have been processed, + // so that GetCoreLibAssemblyReference() can find the correct corelib assembly ref + // declared in the source (e.g., System.Runtime) instead of creating a fallback mscorlib. + if (_entityRegistry.Assembly is not null && (_options.Debug || _options.DebugMode is not null)) + { + ApplyDebuggableAttribute(); + } + + // Return early if there are structural errors that prevent building valid metadata. + // However, allow errors in method bodies (ILA0016-0019) to pass through so we can + // emit the assembly with the errors reported. + // In error-tolerant mode, continue despite errors. + var structuralErrors = _diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error && !IsRecoverableError(d.Id)); + if (structuralErrors.Any() && !_options.ErrorTolerant) + { + return (_diagnostics.ToImmutable(), null); + } + + // Check for vtable fixups and exports - collect export info + var exports = ImmutableArray.CreateBuilder(); + foreach (EntityRegistry.MethodDefinitionEntity method in GetParsedMethods()) + { + if (method.ExportOrdinal >= 0) + { + exports.Add(new VTableExportPEBuilder.ExportInfo( + method.ExportOrdinal, + method.ExportAlias ?? method.Name, + MetadataTokens.GetToken(method.Handle), + method.VTableEntry, + method.VTableSlot)); + } + } + + BlobBuilder ilStream = new(); + PseudoCustomAttributes.Lower(_entityRegistry, _diagnostics); + Blob mvidFixup = _entityRegistry.WriteContentTo(_metadataBuilder, ilStream, _mappedFieldDataNames, _options.Deterministic); + MetadataRootBuilder rootBuilder = new(_metadataBuilder, _options.MetadataVersion); + + // Compute metadata size from the MetadataSizes + // We need this for data label fixup RVA calculations + var sizes = rootBuilder.Sizes; + int metadataSize = ComputeMetadataSize(sizes); + + // Apply command-line overrides + Subsystem subsystem = _options.Subsystem ?? _subsystem; + int fileAlignment = _options.FileAlignment ?? _alignment; + long imageBase = _options.ImageBase ?? _imageBase; + ushort majorSubsystemVersion = _options.SubsystemVersion?.Major ?? 4; + ushort minorSubsystemVersion = _options.SubsystemVersion?.Minor ?? 0; + Machine machine = _options.Machine ?? Machine.I386; + + // Build DllCharacteristics from options + DllCharacteristics dllCharacteristics = DllCharacteristics.DynamicBase | DllCharacteristics.NxCompatible | DllCharacteristics.NoSeh | DllCharacteristics.TerminalServerAware; + if (_options.AppContainer) + { + dllCharacteristics |= DllCharacteristics.AppContainer; + } + if (_options.HighEntropyVA) + { + dllCharacteristics |= DllCharacteristics.HighEntropyVirtualAddressSpace; + } + if (_options.StripReloc) + { + dllCharacteristics &= ~DllCharacteristics.DynamicBase; + } + + Characteristics imageCharacteristics = Characteristics.ExecutableImage; + if (_options.Dll) + { + imageCharacteristics |= Characteristics.Dll; + } + if (machine is Machine.I386 or Machine.Arm) + { + imageCharacteristics |= Characteristics.Bit32Machine; + } + else if (machine is Machine.Amd64 or Machine.Arm64) + { + imageCharacteristics |= Characteristics.LargeAddressAware; + } + + // Compute stack reserve: command-line option overrides directive, which overrides default + ulong sizeOfStackReserve = (ulong)(_options.StackReserve ?? (_stackReserve != 0 ? _stackReserve : 0x00100000)); + + PEHeaderBuilder header = new( + machine: machine, + fileAlignment: fileAlignment, + imageBase: (ulong)imageBase, + subsystem: subsystem, + majorSubsystemVersion: majorSubsystemVersion, + minorSubsystemVersion: minorSubsystemVersion, + dllCharacteristics: dllCharacteristics, + imageCharacteristics: imageCharacteristics, + sizeOfStackReserve: sizeOfStackReserve); + + MethodDefinitionHandle entryPoint = default; + if (_entityRegistry.EntryPoint is not null) + { + entryPoint = (MethodDefinitionHandle)_entityRegistry.EntryPoint.Handle; + } + + // Build debug directory if we have any debug info + DebugDirectoryBuilder? debugDirectoryBuilder = BuildDebugDirectory(entryPoint, out int debugDataSize); + + // Use custom PE builder if we have vtable fixups, exports, or data label reference fixups + if (_vtableFixups.Count > 0 || exports.Count > 0 || _mappedFieldDataReferenceFixups.Count > 0) + { + var vtableFixupInfos = BuildVTableFixupInfos(); + + // Apply CorFlags from options or directive + CorFlags corFlags = _options.CorFlags ?? _corflags; + if (_options.Prefer32Bit) + { + corFlags |= CorFlags.Prefers32Bit; + } + + VTableExportPEBuilder peBuilder = new( + header, + rootBuilder, + ilStream, + _mappedFieldData, + _manifestResources, + debugDirectoryBuilder: debugDirectoryBuilder, + entryPoint: entryPoint, + flags: corFlags, + vtableFixups: vtableFixupInfos, + exports: exports.ToImmutable(), + mappedFieldDataOffsets: _mappedFieldDataNames, + dataLabelFixups: _mappedFieldDataReferenceFixups, + metadataSize: metadataSize, + debugDataSize: debugDataSize); + + return (_diagnostics.ToImmutable(), new CompilationResult(peBuilder, mvidFixup)); + } + + // Apply CorFlags from options or directive + CorFlags standardCorFlags = _options.CorFlags ?? _corflags; + if (_options.Prefer32Bit) + { + standardCorFlags |= CorFlags.Prefers32Bit; + } + + // Deterministic ID provider for reproducible builds + Func, BlobContentId>? deterministicIdProvider = _options.Deterministic + ? GetDeterministicContentId + : null; + + ManagedPEBuilder standardBuilder = new( + header, + rootBuilder, + ilStream, + _mappedFieldData, + _manifestResources, + flags: standardCorFlags, + entryPoint: entryPoint, + debugDirectoryBuilder: debugDirectoryBuilder, + deterministicIdProvider: deterministicIdProvider); + + return (_diagnostics.ToImmutable(), new CompilationResult(standardBuilder, mvidFixup)); + } + + private static BlobContentId GetDeterministicContentId(IEnumerable content) + { + using IncrementalHash hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA256); + foreach (Blob blob in content) + { + hash.AppendData(blob.GetBytes()); + } + + return BlobContentId.FromHash(hash.GetHashAndReset()); + } + + private ImmutableArray BuildVTableFixupInfos() + { + if (_vtableFixups.Count == 0) + return ImmutableArray.Empty; + + var builder = ImmutableArray.CreateBuilder(_vtableFixups.Count); + + for (int entryIndex = 0; entryIndex < _vtableFixups.Count; entryIndex++) + { + var vtf = _vtableFixups[entryIndex]; + var methodTokens = ImmutableArray.CreateBuilder(vtf.SlotCount); + + // Initialize with zeros + for (int i = 0; i < vtf.SlotCount; i++) + { + methodTokens.Add(0); + } + + // Find methods that reference this vtable entry + foreach (EntityRegistry.MethodDefinitionEntity method in GetParsedMethods()) + { + if (method.VTableEntry == entryIndex + 1 && // 1-based + method.VTableSlot > 0 && + method.VTableSlot <= vtf.SlotCount) + { + methodTokens[method.VTableSlot - 1] = MetadataTokens.GetToken(method.Handle); + } + } + + builder.Add(new VTableExportPEBuilder.VTableFixupInfo( + vtf.DataLabel, + vtf.SlotCount, + vtf.Flags, + methodTokens.ToImmutable())); + } + + return builder.ToImmutable(); + } + + private IEnumerable GetParsedMethods() + { + foreach (EntityRegistry.TypeDefinitionEntity type in _entityRegistry.GetSeenEntities(TableIndex.TypeDef)) + { + foreach (EntityRegistry.MethodDefinitionEntity method in type.Methods) + { + yield return method; + } + } + } + + private DebugDirectoryBuilder? BuildDebugDirectory(MethodDefinitionHandle entryPoint, out int debugDataSize) + { + debugDataSize = 0; + + // Check if we have any methods with debug info + bool hasDebugInfo = false; + foreach (var entity in _entityRegistry.GetSeenEntities(TableIndex.MethodDef)) + { + if (entity is EntityRegistry.MethodDefinitionEntity method && + method.DebugInfo.SequencePoints.Count > 0) + { + hasDebugInfo = true; + break; + } + } + + // Generate PDB if we have debug info OR if --debug/--pdb options are set + bool generatePdb = hasDebugInfo || _options.Debug || _options.Pdb; + if (!generatePdb) + { + return null; + } + + // Build PDB metadata + BuildPdbMetadata(); + + // Get row counts from main metadata for the portable PDB + var typeSystemRowCounts = _metadataBuilder.GetRowCounts(); + + // Create the portable PDB + var pdbBuilder = new PortablePdbBuilder( + _pdbBuilder, + typeSystemRowCounts, + entryPoint, + idProvider: _options.Deterministic ? GetDeterministicContentId : null); + + var pdbBlob = new BlobBuilder(); + var pdbContentId = pdbBuilder.Serialize(pdbBlob); + + // Create debug directory with embedded PDB + var debugDirectoryBuilder = new DebugDirectoryBuilder(); + debugDirectoryBuilder.AddCodeViewEntry( + $"assembly.pdb", + pdbContentId, + pdbBuilder.FormatVersion); + debugDirectoryBuilder.AddEmbeddedPortablePdbEntry(pdbBlob, pdbBuilder.FormatVersion); + + // Calculate debug data size: + // 2 debug directory entries (28 bytes each) + CodeView data (~24 bytes) + Embedded PDB data (compressed pdbBlob + 8 header) + // CodeView entry: signature (4) + guid (16) + age (4) + path (variable, ~12 for "assembly.pdb\0") + const int debugDirEntrySize = 28; + int codeViewDataSize = 4 + 16 + 4 + "assembly.pdb".Length + 1; // signature + guid + age + path + null + int embeddedPdbHeaderSize = 8; // MPDB signature (4) + uncompressed size (4) + // The embedded PDB is compressed, estimate conservatively as same size + int embeddedPdbDataSize = embeddedPdbHeaderSize + pdbBlob.Count; + + debugDataSize = (2 * debugDirEntrySize) + codeViewDataSize + embeddedPdbDataSize; + + return debugDirectoryBuilder; + } + + private void BuildPdbMetadata() + { + // Add documents and sequence points to the PDB metadata builder + foreach (var entity in _entityRegistry.GetSeenEntities(TableIndex.MethodDef)) + { + if (entity is not EntityRegistry.MethodDefinitionEntity method) + { + continue; + } + + var debugInfo = method.DebugInfo; + if (debugInfo.SequencePoints.Count == 0) + { + // Add empty debug info entry for methods without sequence points + _pdbBuilder.AddMethodDebugInformation(default, default); + continue; + } + + // Get or create document handle + DocumentHandle documentHandle = default; + if (debugInfo.DocumentPath is not null) + { + if (!_documentHandles.TryGetValue(debugInfo.DocumentPath, out documentHandle)) + { + var nameHandle = _pdbBuilder.GetOrAddDocumentName(debugInfo.DocumentPath); + var languageGuidHandle = _currentLanguageGuid != Guid.Empty + ? _pdbBuilder.GetOrAddGuid(_currentLanguageGuid) + : default; + documentHandle = _pdbBuilder.AddDocument( + nameHandle, + default, // hash algorithm + default, // hash + languageGuidHandle); + _documentHandles[debugInfo.DocumentPath] = documentHandle; + } + } + + // Encode sequence points + var sequencePointsBlob = EncodeSequencePoints(debugInfo.SequencePoints); + var sequencePointsBlobHandle = _pdbBuilder.GetOrAddBlob(sequencePointsBlob); + + _pdbBuilder.AddMethodDebugInformation(documentHandle, sequencePointsBlobHandle); + } + } + + private static BlobBuilder EncodeSequencePoints(List sequencePoints) + { + var builder = new BlobBuilder(); + + if (sequencePoints.Count == 0) + { + return builder; + } + + // LocalSignature (not used here, write 0) + builder.WriteCompressedInteger(0); + + int previousOffset = 0; + int previousStartLine = -1; + int previousStartColumn = -1; + + foreach (var sp in sequencePoints) + { + // IL offset delta + int offsetDelta = sp.ILOffset - previousOffset; + builder.WriteCompressedInteger(offsetDelta); + previousOffset = sp.ILOffset; + + if (sp.IsHidden) + { + // Hidden sequence point: delta lines = 0, delta columns = 0 + builder.WriteCompressedInteger(0); + builder.WriteCompressedInteger(0); + } + else + { + // Delta lines + int deltaLines = sp.EndLine - sp.StartLine; + builder.WriteCompressedInteger(deltaLines); + + // Delta columns + int deltaColumns = sp.EndColumn - sp.StartColumn; + if (deltaLines == 0) + { + builder.WriteCompressedInteger(deltaColumns); + } + else + { + builder.WriteCompressedSignedInteger(deltaColumns); + } + + // Start line delta (signed) + if (previousStartLine < 0) + { + builder.WriteCompressedInteger(sp.StartLine); + } + else + { + builder.WriteCompressedSignedInteger(sp.StartLine - previousStartLine); + } + + // Start column delta (signed) + if (previousStartColumn < 0) + { + builder.WriteCompressedInteger(sp.StartColumn); + } + else + { + builder.WriteCompressedSignedInteger(sp.StartColumn - previousStartColumn); + } + + previousStartLine = sp.StartLine; + previousStartColumn = sp.StartColumn; + } + } + + return builder; + } + + /// + /// Add DebuggableAttribute to the assembly based on debug options. + /// - /DEBUG: 0x101 = Default | DisableOptimizations + /// - /DEBUG=OPT: 0x03 = Default | IgnoreSymbolStoreSequencePoints + /// - /DEBUG=IMPL: 0x103 = Default | DisableOptimizations | EnableEditAndContinue + /// + private void ApplyDebuggableAttribute() + { + if (_entityRegistry.Assembly is null) + { + return; + } + + // DebuggingModes enum values from System.Diagnostics.DebuggableAttribute: + // None = 0x00, Default = 0x01, IgnoreSymbolStoreSequencePoints = 0x02, + // EnableEditAndContinue = 0x04, DisableOptimizations = 0x100 + const int DebuggingModesDefault = 0x101; // Default | DisableOptimizations + const int DebuggingModesOpt = 0x03; // Default | IgnoreSymbolStoreSequencePoints + const int DebuggingModesImpl = 0x103; // Default | DisableOptimizations | EnableEditAndContinue + + int debuggingModes = _options.DebugMode switch + { + DebugMode.Opt => DebuggingModesOpt, + DebugMode.Impl => DebuggingModesImpl, + _ => DebuggingModesDefault + }; + + // Get reference to core library + var coreAsmRef = _entityRegistry.GetCoreLibAssemblyReference(); + + // Create reference to System.Diagnostics.DebuggableAttribute + var debuggableAttrType = _entityRegistry.GetOrCreateTypeReference( + coreAsmRef, + new TypeName(null, "System.Diagnostics.DebuggableAttribute")); + + // Create reference to nested type DebuggingModes + var debuggingModesType = _entityRegistry.GetOrCreateTypeReference( + debuggableAttrType, + new TypeName(null, "DebuggingModes")); + + // Create constructor signature: .ctor(DebuggingModes) + BlobBuilder ctorSig = new(); + var sigEncoder = new BlobEncoder(ctorSig); + sigEncoder.MethodSignature(SignatureCallingConvention.Default, 0, isInstanceMethod: true) + .Parameters(1, + returnType => returnType.Void(), + parameters => parameters.AddParameter().Type().Type(debuggingModesType.Handle, isValueType: true)); + + var ctor = _entityRegistry.CreateLazilyRecordedMemberReference(debuggableAttrType, ".ctor", ctorSig); + + // Create custom attribute blob: prolog (0x0001) + int32 value + named args count (0x0000) + BlobBuilder attrValue = new(); + attrValue.WriteUInt16(0x0001); // Prolog + attrValue.WriteInt32(debuggingModes); // DebuggingModes value + attrValue.WriteUInt16(0x0000); // No named arguments + + // Create and attach the custom attribute + var customAttr = _entityRegistry.CreateCustomAttribute(ctor, attrValue); + customAttr.Owner = _entityRegistry.Assembly; + } + + /// + /// Computes the total metadata size from MetadataSizes. + /// This replicates the internal MetadataSizes.MetadataSize calculation. + /// + private static int ComputeMetadataSize(MetadataSizes sizes) + { + // Metadata header size (fixed structure): + // - signature (4) + // - major/minor version (4) + // - reserved (4) + // - version string length (4) + // - version string padded to 4 bytes ("v4.0.30319" = 12 bytes padded) + // - storage header (4) + // - 5 stream headers (#~, #Strings, #US, #GUID, #Blob) = 76 bytes + // Total header: ~108 bytes + const int metadataHeaderSize = 108; + + // Stream storage: heaps (#Strings, #US, #GUID, #Blob) - we can get aligned sizes + int heapStorageSize = 0; + heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.String); + heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.UserString); + heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.Guid); + heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.Blob); + + // Table stream (#~): header + table data + // Header: Reserved(4) + Version(2) + HeapSizes(1) + RowIdBitWidth(1) + ValidMask(8) + SortedMask(8) + // + 4 bytes per present table for row counts + int tableStreamSize = 24; // base header + var rowCounts = sizes.RowCounts; + + // Count present tables and add 4 bytes each for row count + for (int i = 0; i < rowCounts.Length; i++) + { + if (rowCounts[i] > 0) + { + tableStreamSize += 4; + } + } + + // Add table data size with estimated row sizes + // Row sizes depend on index sizes (2 or 4 bytes) which we don't have access to + // For small assemblies, all indexes are 2 bytes + tableStreamSize += rowCounts[(int)TableIndex.Module] * 10; // 2+2+2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.TypeRef] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.TypeDef] * 14; // 4+2+2+2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.Field] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.MethodDef] * 14; // 4+2+2+2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.Param] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.InterfaceImpl] * 4; // 2+2 + tableStreamSize += rowCounts[(int)TableIndex.MemberRef] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.Constant] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.CustomAttribute] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.FieldMarshal] * 4; // 2+2 + tableStreamSize += rowCounts[(int)TableIndex.DeclSecurity] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.ClassLayout] * 8; // 2+4+2 + tableStreamSize += rowCounts[(int)TableIndex.FieldLayout] * 6; // 4+2 + tableStreamSize += rowCounts[(int)TableIndex.StandAloneSig] * 2; // 2 + tableStreamSize += rowCounts[(int)TableIndex.EventMap] * 4; // 2+2 + tableStreamSize += rowCounts[(int)TableIndex.Event] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.PropertyMap] * 4; // 2+2 + tableStreamSize += rowCounts[(int)TableIndex.Property] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.MethodSemantics] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.MethodImpl] * 6; // 2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.ModuleRef] * 2; // 2 + tableStreamSize += rowCounts[(int)TableIndex.TypeSpec] * 2; // 2 + tableStreamSize += rowCounts[(int)TableIndex.ImplMap] * 8; // 2+2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.FieldRva] * 6; // 4+2 + tableStreamSize += rowCounts[(int)TableIndex.Assembly] * 22; // 16+2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.AssemblyRef] * 20; // 12+2+2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.File] * 8; // 4+2+2 + tableStreamSize += rowCounts[(int)TableIndex.ExportedType] * 14; // 8+2+2+2 + tableStreamSize += rowCounts[(int)TableIndex.ManifestResource] * 12; // 8+2+2 + tableStreamSize += rowCounts[(int)TableIndex.NestedClass] * 4; // 2+2 + tableStreamSize += rowCounts[(int)TableIndex.GenericParam] * 8; // 4+2+2 + tableStreamSize += rowCounts[(int)TableIndex.MethodSpec] * 4; // 2+2 + tableStreamSize += rowCounts[(int)TableIndex.GenericParamConstraint] * 4; // 2+2 + + // Align table stream to 4 bytes (includes +1 for terminating 0 byte) + tableStreamSize = ((tableStreamSize + 1) + 3) & ~3; + + return metadataHeaderSize + heapStorageSize + tableStreamSize; + } + + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Bytes.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Bytes.cs new file mode 100644 index 00000000000000..42537cf919e7f7 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Bytes.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Globalization; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. + internal ImmutableArray.Builder CreateByteAccumulator() + => ImmutableArray.CreateBuilder(); + + internal void AddByte(ImmutableArray.Builder accumulator, byte value) + => accumulator.Add(value); + + internal ImmutableArray EndBytes(ImmutableArray.Builder accumulator) + => accumulator.DrainToImmutable(); +#pragma warning restore CA1822 + + /// + /// Parses a single hexbyte token. + /// + internal static byte ParseHexbyte(IToken token) + { + // hexbyte can be HEXBYTE, INT32, or ID token (due to lexer ambiguity). + // Validate the text is 1-2 hex characters to avoid FormatException + // from non-hex ID tokens or values > 0xFF from longer INT32 tokens. + string text = token.Text; + if (text.Length <= 2 && byte.TryParse(text, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out byte value)) + { + return value; + } + + // For invalid hex values, mask to byte (matching native ilasm tolerance). + return int.TryParse(text, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out int intValue) + ? (byte)(intValue & 0xFF) + : (byte)0; + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Conversions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Conversions.cs new file mode 100644 index 00000000000000..06111b64304b78 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Conversions.cs @@ -0,0 +1,171 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using System.Reflection.PortableExecutable; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using Antlr4.Runtime; +using Antlr4.Runtime.Misc; + +namespace ILAssembler +{ + internal sealed partial class GrammarActions + { + private readonly ImmutableArray.Builder _diagnostics = ImmutableArray.CreateBuilder(); + private readonly EntityRegistry _entityRegistry = new(); + private readonly IReadOnlyDictionary _documents; + private readonly Options _options; + private readonly MetadataBuilder _metadataBuilder = new(); + private readonly Func _resourceLocator; + + // Record the mapped field data directly into the blob to ensure we preserve ordering + private readonly BlobBuilder _mappedFieldData = new(); + private readonly Dictionary _mappedFieldDataNames = new(); + private readonly Dictionary> _mappedFieldDataReferenceFixups = new(); + private readonly BlobBuilder _manifestResources = new(); + private int _syntaxErrorCount; + + // Debug info tracking + private Guid _currentLanguageGuid = Guid.Empty; + private Guid _currentLanguageVendorGuid = Guid.Empty; + private Guid _currentDocumentTypeGuid = Guid.Empty; + private string? _currentDocumentPath; + private readonly Dictionary _documentHandles = new(); + private readonly MetadataBuilder _pdbBuilder = new(); + + internal GrammarActions(IReadOnlyDictionary documents, Options options, Func resourceLocator) + { + _documents = documents; + _options = options; + _resourceLocator = resourceLocator; + } + private void ReportDiagnostic(DiagnosticSeverity severity, string id, string message, Antlr4.Runtime.ParserRuleContext context) + { + var location = Location.From(context.Start, _documents); + _diagnostics.Add(new Diagnostic(id, severity, message, location)); + } + + private void ReportError(string id, string message, Antlr4.Runtime.ParserRuleContext context) + => ReportDiagnostic(DiagnosticSeverity.Error, id, message, context); + + private void ReportError(string id, string message, IToken token) + { + _diagnostics.Add(new Diagnostic( + id, + DiagnosticSeverity.Error, + message, + Location.From(token, _documents))); + } + + private void ReportWarning(string id, string message, Antlr4.Runtime.ParserRuleContext context) + => ReportDiagnostic(DiagnosticSeverity.Warning, id, message, context); + + private void ReportWarning(string id, string message, IToken token) + { + _diagnostics.Add(new Diagnostic( + id, + DiagnosticSeverity.Warning, + message, + Location.From(token, _documents))); + } + + internal void RecordSyntaxError() => _syntaxErrorCount++; + + internal int SyntaxErrorCount => _syntaxErrorCount; + + internal bool HasSyntaxErrorsSince(int initialSyntaxErrorCount) + => initialSyntaxErrorCount != _syntaxErrorCount; + + private static T ApplyAttribute( + T current, + CILParser.AttributeValue attribute) + where T : struct, Enum + { + if (!attribute.ShouldAppend) + { + return attribute.Value; + } + + int currentValue = Convert.ToInt32(current); + int groupMask = Convert.ToInt32(attribute.GroupMask); + int attributeValue = Convert.ToInt32(attribute.Value); + return (T)Enum.ToObject( + typeof(T), + (currentValue & ~groupMask) | attributeValue); + } + + private static bool IsRecoverableError(string diagnosticId) + { + // Method body and signature diagnostics are recoverable - we emit the assembly but report the error. + // This matches native ilasm behavior where errors during method/field emission don't prevent + // the assembly from being written when the /ERR (OnErrGo) flag is set. + return diagnosticId is DiagnosticIds.ByteArrayTooShort + or DiagnosticIds.ArgumentNotFound + or DiagnosticIds.LocalNotFound + or DiagnosticIds.LabelNotFound + or DiagnosticIds.GenericParameterIndexOutOfRange + or DiagnosticIds.ParameterIndexOutOfRange + or DiagnosticIds.GenericParameterNotFound + or DiagnosticIds.UnknownGenericParameter + or DiagnosticIds.MissingInstanceCallConv; + } + + private sealed class CurrentMethodContext + { + public CurrentMethodContext(EntityRegistry.MethodDefinitionEntity definition) + { + Definition = definition; + // Populate argument names from the method's parameter definitions + foreach (var param in definition.Parameters) + { + if (param.Name is not null && param.Sequence > 0) + { + ArgumentNames[param.Name] = param.Sequence - 1; + } + } + } + + public EntityRegistry.MethodDefinitionEntity Definition { get; } + + public Dictionary Labels { get; } = new(); + + public Dictionary UndefinedLabelReferences { get; } = new(); + + public Dictionary ArgumentNames { get; } = new(); + + public List> LocalsScopes { get; } = new(); + + public List AllLocals { get; } = new(); + } + + private CurrentMethodContext? _currentMethod; + private EntityRegistry.FieldDefinitionEntity? _lastFieldDefinition; + private EntityRegistry.EntityBase? _pendingClassCustomAttributeOwner; + + private const ushort CustomAttributeBlobFormatVersion = 1; + + // These stacks are the active nested compiler scopes, not parser-value accumulators. + private readonly Stack _currentNamespace = new(); + private readonly Stack _currentTypeDefinition = new(); + + private bool _expectInstance; + private Subsystem _subsystem = Subsystem.WindowsCui; + private CorFlags _corflags = CorFlags.ILOnly; + private int _alignment = 0x200; + private long _imageBase = 0x00400000; + private long _stackReserve; + + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Actions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Actions.cs new file mode 100644 index 00000000000000..a7293be4da92bf --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Actions.cs @@ -0,0 +1,224 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal MethodReferenceValue CreateCustomAttributeType(MethodReferenceValue constructor) + => constructor; + + internal CustomAttributeDescriptorValue CreateDefaultCustomAttribute( + MethodReferenceValue constructor) + => CreateCustomAttributeDescriptor( + constructor, + new RawCustomAttributeBlobValue(CreateDefaultCustomAttributeBlob()), + null); + + internal CustomAttributeDescriptorValue CreateStringCustomAttribute( + MethodReferenceValue constructor, + string value) + => CreateCustomAttributeDescriptor( + constructor, + new RawCustomAttributeBlobValue(CreateStringBlob(value)), + null); + + internal CustomAttributeDescriptorValue CreateStructuredCustomAttribute( + MethodReferenceValue constructor, + CustomAttributeBlobValue value) + => CreateCustomAttributeDescriptor( + constructor, + value, + null); + + internal CustomAttributeDescriptorValue CreateRawCustomAttribute( + MethodReferenceValue constructor, + ImmutableArray value) + => CreateCustomAttributeDescriptor( + constructor, + new RawCustomAttributeBlobValue(CreateRawBlob(value)), + null); + + internal CustomAttributeDescriptorValue CreateDefaultOwnedCustomAttribute( + OwnerTypeValue owner, + MethodReferenceValue constructor) + => CreateCustomAttributeDescriptor( + constructor, + new RawCustomAttributeBlobValue(CreateDefaultCustomAttributeBlob()), + owner); + + internal CustomAttributeDescriptorValue CreateStringOwnedCustomAttribute( + OwnerTypeValue owner, + MethodReferenceValue constructor, + string value) + => CreateCustomAttributeDescriptor( + constructor, + new RawCustomAttributeBlobValue(CreateStringBlob(value)), + owner); + + internal CustomAttributeDescriptorValue CreateStructuredOwnedCustomAttribute( + OwnerTypeValue owner, + MethodReferenceValue constructor, + CustomAttributeBlobValue value) + => CreateCustomAttributeDescriptor( + constructor, + value, + owner); + + internal CustomAttributeDescriptorValue CreateRawOwnedCustomAttribute( + OwnerTypeValue owner, + MethodReferenceValue constructor, + ImmutableArray value) + => CreateCustomAttributeDescriptor( + constructor, + new RawCustomAttributeBlobValue(CreateRawBlob(value)), + owner); + + internal CustomAttributeDeclarationValue CreateCustomAttributeDeclaration( + CustomAttributeDescriptorValue value) + => value; + + internal CustomAttributeDeclarationValue CreateCustomAttributeTypedef(string alias) + => new CustomAttributeTypedefValue(alias); + + private static CustomAttributeDescriptorValue CreateCustomAttributeDescriptor( + MethodReferenceValue constructor, + CustomAttributeBlobValue value, + OwnerTypeValue? owner) + => new(constructor, value, owner); + + private static BlobBuilder CreateStringBlob(string value) + { + BlobBuilder blob = new(); + blob.WriteUTF8(value); + return blob; + } + + private static BlobBuilder CreateRawBlob(ImmutableArray value) + { + BlobBuilder blob = new(value.Length); + blob.WriteBytes(value); + return blob; + } + + private static BlobBuilder CreateDefaultCustomAttributeBlob() + { + BlobBuilder value = new(); + value.WriteUInt16(CustomAttributeBlobFormatVersion); + value.WriteUInt16(0); + return value; + } + + internal CustomAttributeBlobValue CreateCustomAttributeBlob( + ImmutableArray arguments, + ImmutableArray namedArguments) + => new StructuredCustomAttributeBlobValue(arguments, namedArguments); + + internal CustomAttributeNamedArgumentValue CreateCustomBlobNamedArgument( + byte kind, + SerializationTypeValue type, + string name, + SerializedInitializerValue value) + => new(kind, type, name, value); + + private BlobBuilder MaterializeCustomAttributeBlob(CustomAttributeBlobValue value) + { + if (value is RawCustomAttributeBlobValue raw) + { + return raw.Value; + } + + if (value is not StructuredCustomAttributeBlobValue structured) + { + return new BlobBuilder(); + } + + BlobBuilder result = new(); + result.WriteUInt16(CustomAttributeBlobFormatVersion); + foreach (SerializedInitializerValue argument in structured.Arguments) + { + MaterializeSerializedInitializer(argument).WriteContentTo(result); + } + + WriteCustomBlobNamedArguments(result, structured.NamedArguments); + return result; + } + + private void WriteCustomBlobNamedArguments( + BlobBuilder result, + ImmutableArray namedArguments) + { + result.WriteInt16((short)namedArguments.Length); + foreach (CustomAttributeNamedArgumentValue argument in namedArguments) + { + result.WriteByte(argument.Kind); + MaterializeSerializationType(argument.Type).WriteContentTo(result); + result.WriteSerializedString(argument.Name); + MaterializeSerializedInitializer(argument.Value).WriteContentTo(result); + } + } + + private EntityRegistry.CustomAttributeEntity MaterializeCustomAttribute( + CustomAttributeDescriptorValue descriptor, + IToken location) + { + EntityRegistry.EntityBase constructor = MaterializeMethodReference(descriptor.Constructor); + BlobBuilder value = MaterializeCustomAttributeBlob(descriptor.Value); + EntityRegistry.CustomAttributeEntity attribute = + _entityRegistry.CreateCustomAttribute(constructor, value); + attribute.Location = Location.From(location, _documents); + if (descriptor.Owner is { } owner) + { + attribute.Owner = MaterializeOwnerType(owner); + } + + return attribute; + } + + private EntityRegistry.CustomAttributeEntity? MaterializeCustomAttributeDeclaration( + CustomAttributeDeclarationValue? value, + IToken location) + { + if (value is CustomAttributeTypedefValue typedef) + { + if (TryResolveTypedefAsCustomAttribute(typedef.Alias) is not { } resolved) + { + return null; + } + + EntityRegistry.CustomAttributeEntity typedefAttribute = + _entityRegistry.CreateCustomAttribute(resolved.Constructor, resolved.Value); + typedefAttribute.Location = Location.From(location, _documents); + return typedefAttribute; + } + + if (value is not CustomAttributeDescriptorValue descriptor) + { + return null; + } + + EntityRegistry.CustomAttributeEntity attribute = MaterializeCustomAttribute(descriptor, location); + return descriptor.Owner is null ? attribute : null; + } + + internal EntityRegistry.CustomAttributeEntity? MaterializeCustomAttributeDeclaration( + CILParser.CustomAttrDeclContext context) + => MaterializeCustomAttributeDeclaration(context.Value, context.Start); + + internal EntityRegistry.CustomAttributeEntity MaterializeCustomAttributeDescriptor( + CILParser.CustomDescrContext context) + => MaterializeCustomAttribute(context.Value, context.Start); + + internal EntityRegistry.CustomAttributeEntity? MaterializeMethodBodyCustomAttributeDeclaration( + CILParser.CustomDescrInMethodBodyContext context) + => MaterializeCustomAttributeDeclaration(context.Value, context.Start); + + internal EntityRegistry.EntityBase MaterializeOwnerType( + CILParser.OwnerTypeContext context) + => MaterializeOwnerType(context.Value); +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Sequences.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Sequences.cs new file mode 100644 index 00000000000000..06c356deb44c33 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Sequences.cs @@ -0,0 +1,100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal void AddFloat32SequenceValue(BlobBuilder builder, double value) + => builder.WriteSingle((float)value); + + internal void AddFloat32SequenceValue(BlobBuilder builder, IToken value) + => builder.WriteSingle(ParseInt32(value)); + + internal void AddFloat64SequenceValue(BlobBuilder builder, double value) + => builder.WriteDouble(value); + + internal void AddFloat64SequenceValue(BlobBuilder builder, IToken value) + => builder.WriteDouble(ParseInt64(value)); + + internal void AddInt64SequenceValue(BlobBuilder builder, IToken value) + => builder.WriteInt64(ParseInt64(value)); + + internal void AddInt32SequenceValue(BlobBuilder builder, IToken value) + => builder.WriteInt32(ParseInt32(value)); + + internal void AddInt16SequenceValue(BlobBuilder builder, IToken value) + => builder.WriteInt16((short)ParseInt32(value)); + + internal void AddInt8SequenceValue(BlobBuilder builder, IToken value) + => builder.WriteByte((byte)ParseInt32(value)); + + internal void AddBooleanSequenceValue(BlobBuilder builder, bool value) + => builder.WriteBoolean(value); + + internal void AddStringSequenceValue(BlobBuilder builder, IToken value) + => builder.WriteSerializedString( + value.Type == CILParser.NULLREF + ? null + : StringHelpers.ParseQuotedString(value.Text)); + + internal ClassSequenceElementValue CreateNullClassSequenceValue() + => new StringClassSequenceElementValue(null); + + internal ClassSequenceElementValue CreateQuotedClassSequenceValue(IToken value) + => new StringClassSequenceElementValue(StringHelpers.ParseQuotedString(value.Text)); + + internal ClassSequenceElementValue CreateClassSequenceValue(ClassNameValue className) + => new TypeClassSequenceElementValue(className); + + private BlobBuilder MaterializeSerializedSequence(SerializedSequenceValue sequence) + { + if (sequence is RawSerializedSequenceValue raw) + { + return raw.Value; + } + + BlobBuilder blob = new(); + switch (sequence) + { + case ClassSerializedSequenceValue classes: + foreach (ClassSequenceElementValue value in classes.Values) + { + MaterializeClassSequenceElement(value).WriteContentTo(blob); + } + break; + case ObjectSerializedSequenceValue objects: + foreach (SerializedInitializerValue value in objects.Values) + { + SerializedInitializerValue initializer = value; + while (initializer is ObjectSerializedInitializerValue boxed) + { + initializer = boxed.Value; + } + + MaterializeSerializationType(initializer.Type).WriteContentTo(blob); + MaterializeSerializedInitializer(initializer).WriteContentTo(blob); + } + break; + } + + return blob; + } + + private BlobBuilder MaterializeClassSequenceElement(ClassSequenceElementValue value) + { + BlobBuilder blob = new(); + blob.WriteSerializedString(value switch + { + StringClassSequenceElementValue text => text.Value, + TypeClassSequenceElementValue type => GetReflectionNotation(type.ClassName), + _ => null + }); + return blob; + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Serialization.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Serialization.cs new file mode 100644 index 00000000000000..415ed45e2d0a11 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.CustomAttributes.Serialization.cs @@ -0,0 +1,403 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection.Metadata; +using System.Text; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal byte GetCustomAttributeNamedArgumentKind(IToken token) + => (byte)(token.Text == "field" + ? CustomAttributeNamedArgumentKind.Field + : CustomAttributeNamedArgumentKind.Property); + + internal SerializationTypeValue CreateSerializationType( + SerializationTypeValue element, + IToken? array) + { + return array is null ? element : new ArraySerializationTypeValue(element); + } + + internal SerializationTypeValue CreatePrimitiveSerializationType(byte type) + => new SimpleSerializationTypeValue((SerializationTypeCode)type); + + internal SerializationTypeValue CreateSerializationTypeTypedef( + CILParser.SerializTypeElementContext context, + string alias) + => new TypedefSerializationTypeValue(context.Start, alias); + + internal SerializationTypeValue CreateSimpleSerializationType(IToken type) + => new SimpleSerializationTypeValue(GetSerializationTypeCode(type.Type)); + + internal SerializationTypeValue CreateEnumSerializationType(IToken name) + => new StringEnumSerializationTypeValue(StringHelpers.ParseQuotedString(name.Text)); + + internal SerializationTypeValue CreateEnumSerializationType(ClassNameValue className) + => new ClassEnumSerializationTypeValue(className); + + internal BlobBuilder CreateFloat32SerializedInitializer( + CILParser.Float64Context context, + double value) + { + float serializedValue = IsPlainInteger(context) && + ParseIntegerValue(context.Start.Text.AsSpan(), out long rawValue) + ? BitConverter.Int32BitsToSingle((int)rawValue) + : (float)value; + BlobBuilder blob = CreateSerializedInitializer(SerializationTypeCode.Single); + blob.WriteSingle(serializedValue); + return blob; + } + + internal BlobBuilder CreateFloat64SerializedInitializer( + CILParser.Float64Context context, + double value) + { + double serializedValue = IsPlainInteger(context) && + ParseIntegerValue(context.Start.Text.AsSpan(), out long rawValue) + ? BitConverter.Int64BitsToDouble(rawValue) + : value; + BlobBuilder blob = CreateSerializedInitializer(SerializationTypeCode.Double); + blob.WriteDouble(serializedValue); + return blob; + } + + private static bool IsPlainInteger(CILParser.Float64Context context) + => context.Start.Type == CILParser.INT32 && + context.Stop is { Type: CILParser.INT32 }; + + internal BlobBuilder CreateFloat32BitsSerializedInitializer(IToken value) + { + BlobBuilder blob = CreateSerializedInitializer(SerializationTypeCode.Single); + blob.WriteSingle(BitConverter.Int32BitsToSingle(ParseInt32(value))); + return blob; + } + + internal BlobBuilder CreateFloat64BitsSerializedInitializer(IToken value) + { + BlobBuilder blob = CreateSerializedInitializer(SerializationTypeCode.Double); + blob.WriteDouble(BitConverter.Int64BitsToDouble(ParseInt64(value))); + return blob; + } + + internal BlobBuilder CreateIntegerSerializedInitializer(IToken type, IToken value) + { + BlobBuilder blob = CreateSerializedInitializer(GetSerializationTypeCode(type.Type)); + switch (type.Type) + { + case CILParser.INT8: + case CILParser.UINT8: + blob.WriteByte((byte)ParseInt32(value)); + break; + case CILParser.CHAR: + case CILParser.INT16: + case CILParser.UINT16: + blob.WriteInt16((short)ParseInt32(value)); + break; + case CILParser.INT32_: + case CILParser.UINT32: + blob.WriteInt32(ParseInt32(value)); + break; + case CILParser.INT64_: + case CILParser.UINT64: + blob.WriteInt64(ParseInt64(value)); + break; + default: + throw new UnreachableException(); + } + + return blob; + } + + internal BlobBuilder CreateBooleanSerializedInitializer(IToken type, bool value) + { + Debug.Assert(type.Type == CILParser.BOOL); + BlobBuilder blob = CreateSerializedInitializer(SerializationTypeCode.Boolean); + blob.WriteBoolean(value); + return blob; + } + + internal BlobBuilder CreateByteArraySerializedInitializer(ImmutableArray value) + { + BlobBuilder blob = CreateSerializedInitializer( + SerializationTypeCode.String, + value.Length + 1); + blob.WriteBytes(value); + return blob; + } + + private static BlobBuilder CreateSerializedInitializer( + SerializationTypeCode type, + int capacity = 9) + { + BlobBuilder blob = new(capacity); + blob.WriteByte((byte)type); + return blob; + } + + internal FieldInitializerValue CreateFieldInitializer(BlobBuilder value) + => new(true, ExtractConstantFromSerInit(value)); + + internal FieldInitializerValue CreateFieldInitializer(string value) + => new(true, value); + + internal FieldInitializerValue CreateNullFieldInitializer() + => new(true, null); + + internal SerializedInitializerValue CreateScalarSerializedValue( + CILParser.SerInitContext context, + CILParser.FieldSerInitContext initializer, + BlobBuilder value) + { + if (initializer.Start.Text == "bytearray") + { + return new InvalidByteArraySerializedInitializerValue(context.Start); + } + + ImmutableArray encodedValue = value.ToImmutableArray(); + BlobBuilder serializedValue = new(Math.Max(0, encodedValue.Length - 1)); + if (encodedValue.Length > 1) + { + serializedValue.WriteBytes(encodedValue.AsSpan().Slice(1).ToArray()); + } + + SerializationTypeValue type = encodedValue.Length == 0 + ? new RawSerializationTypeValue(new BlobBuilder()) + : new SimpleSerializationTypeValue((SerializationTypeCode)encodedValue[0]); + return new RawSerializedInitializerValue(type, serializedValue); + } + + internal SerializedInitializerValue CreateStringSerializedValue() + => CreateSerializedStringValue(SerializationTypeCode.String, null); + + internal SerializedInitializerValue CreateStringSerializedValue(IToken value) + => CreateSerializedStringValue( + SerializationTypeCode.String, + StringHelpers.ParseQuotedString(value.Text)); + + internal SerializedInitializerValue CreateTypeSerializedValue(IToken value) + => CreateSerializedStringValue( + SerializationTypeCode.Type, + StringHelpers.ParseQuotedString(value.Text)); + + internal SerializedInitializerValue CreateTypeSerializedValue(ClassNameValue className) + => new ClassNameSerializedInitializerValue(className); + + internal SerializedInitializerValue CreateNullTypeSerializedValue() + => CreateSerializedStringValue(SerializationTypeCode.Type, null); + + private static RawSerializedInitializerValue CreateSerializedStringValue( + SerializationTypeCode type, + string? value) + { + BlobBuilder serializedValue = new(); + serializedValue.WriteSerializedString(value); + return new RawSerializedInitializerValue( + new SimpleSerializationTypeValue(type), + serializedValue); + } + + internal SerializedInitializerValue CreateObjectSerializedValue( + SerializedInitializerValue value) + => new ObjectSerializedInitializerValue(value); + + internal SerializedInitializerValue CreateArraySerializedValue( + IToken elementType, + IToken length, + SerializedSequenceValue values) + => new ArraySerializedInitializerValue( + new ArraySerializationTypeValue( + new SimpleSerializationTypeValue(GetSerializationTypeCode(elementType.Type))), + ParseInt32(length), + values); + + internal SerializedInitializerValue CreateArraySerializedValue( + IToken elementType, + IToken length, + BlobBuilder values) + => CreateArraySerializedValue( + elementType, + length, + new RawSerializedSequenceValue(values)); + + private BlobBuilder MaterializeSerializationType(SerializationTypeValue value) + { + if (value is RawSerializationTypeValue raw) + { + return raw.Value; + } + + BlobBuilder blob = new(); + switch (value) + { + case SimpleSerializationTypeValue simple: + blob.WriteByte((byte)simple.Type); + break; + case ArraySerializationTypeValue array: + blob.WriteByte((byte)SerializationTypeCode.SZArray); + MaterializeSerializationType(array.ElementType).WriteContentTo(blob); + break; + case StringEnumSerializationTypeValue stringEnum: + blob.WriteByte((byte)SerializationTypeCode.Enum); + blob.WriteSerializedString(stringEnum.Name); + break; + case ClassEnumSerializationTypeValue classEnum: + blob.WriteByte((byte)SerializationTypeCode.Enum); + blob.WriteSerializedString(GetReflectionNotation(classEnum.ClassName)); + break; + case TypedefSerializationTypeValue typedef: + ReportError( + DiagnosticIds.TypedefNotFound, + string.Format(DiagnosticMessageTemplates.TypedefNotFound, typedef.Alias), + typedef.Token); + break; + } + + return blob; + } + + private BlobBuilder MaterializeSerializedInitializer(SerializedInitializerValue value) + { + if (value is RawSerializedInitializerValue raw) + { + return raw.Value; + } + + BlobBuilder blob = new(); + switch (value) + { + case ClassNameSerializedInitializerValue className: + blob.WriteSerializedString(GetReflectionNotation(className.ClassName)); + break; + case ObjectSerializedInitializerValue boxed: + MaterializeSerializationType(boxed.Value.Type).WriteContentTo(blob); + MaterializeSerializedInitializer(boxed.Value).WriteContentTo(blob); + break; + case InvalidByteArraySerializedInitializerValue invalid: + ReportError( + DiagnosticIds.InvalidMetadataToken, + "bytearray is not a valid structured custom attribute value", + invalid.Token); + blob.WriteSerializedString(null); + break; + case ArraySerializedInitializerValue array: + blob.WriteInt32(array.Length); + MaterializeSerializedSequence(array.Values).WriteContentTo(blob); + break; + } + + return blob; + } + + private string GetReflectionNotation(ClassNameValue className) + { + EntityRegistry.TypeEntity type = ResolveClassName(className); + return (type as EntityRegistry.IHasReflectionNotation)?.ReflectionNotation ?? string.Empty; + } + + private static SerializationTypeCode GetSerializationTypeCode(int tokenType) + => tokenType switch + { + CILParser.INT8 => SerializationTypeCode.SByte, + CILParser.UINT8 => SerializationTypeCode.Byte, + CILParser.INT16 => SerializationTypeCode.Int16, + CILParser.UINT16 => SerializationTypeCode.UInt16, + CILParser.INT32_ => SerializationTypeCode.Int32, + CILParser.UINT32 => SerializationTypeCode.UInt32, + CILParser.INT64_ => SerializationTypeCode.Int64, + CILParser.UINT64 => SerializationTypeCode.UInt64, + CILParser.FLOAT32 => SerializationTypeCode.Single, + CILParser.FLOAT64_ => SerializationTypeCode.Double, + CILParser.CHAR => SerializationTypeCode.Char, + CILParser.BOOL => SerializationTypeCode.Boolean, + CILParser.STRING => SerializationTypeCode.String, + CILParser.TYPE => SerializationTypeCode.Type, + CILParser.OBJECT => SerializationTypeCode.TaggedObject, + _ => throw new UnreachableException() + }; + + private static object? ExtractConstantFromSerInit(BlobBuilder blob) + { + ImmutableArray bytes = blob.ToImmutableArray(); + if (bytes.Length == 0) + { + return null; + } + + SerializationTypeCode typeCode = (SerializationTypeCode)bytes[0]; + ReadOnlySpan valueBytes = bytes.AsSpan().Slice(1); + return typeCode switch + { + SerializationTypeCode.Boolean => valueBytes.Length >= 1 && valueBytes[0] != 0, + SerializationTypeCode.Char => valueBytes.Length >= 2 ? BitConverter.ToChar(valueBytes) : '\0', + SerializationTypeCode.SByte => valueBytes.Length >= 1 ? (sbyte)valueBytes[0] : (sbyte)0, + SerializationTypeCode.Byte => valueBytes.Length >= 1 ? valueBytes[0] : (byte)0, + SerializationTypeCode.Int16 => valueBytes.Length >= 2 ? BitConverter.ToInt16(valueBytes) : (short)0, + SerializationTypeCode.UInt16 => valueBytes.Length >= 2 ? BitConverter.ToUInt16(valueBytes) : (ushort)0, + SerializationTypeCode.Int32 => valueBytes.Length >= 4 ? BitConverter.ToInt32(valueBytes) : 0, + SerializationTypeCode.UInt32 => valueBytes.Length >= 4 ? BitConverter.ToUInt32(valueBytes) : 0u, + SerializationTypeCode.Int64 => valueBytes.Length >= 8 ? BitConverter.ToInt64(valueBytes) : 0L, + SerializationTypeCode.UInt64 => valueBytes.Length >= 8 ? BitConverter.ToUInt64(valueBytes) : 0uL, + SerializationTypeCode.Single => valueBytes.Length >= 4 ? BitConverter.ToSingle(valueBytes) : 0f, + SerializationTypeCode.Double => valueBytes.Length >= 8 ? BitConverter.ToDouble(valueBytes) : 0d, + SerializationTypeCode.String => Encoding.Unicode.GetString(valueBytes), + SerializationTypeCode.Type => ExtractSerString(valueBytes), + SerializationTypeCode.SZArray => valueBytes.ToArray(), + SerializationTypeCode.TaggedObject => valueBytes.ToArray(), + SerializationTypeCode.Enum => valueBytes.ToArray(), + _ => bytes.AsSpan().ToArray() + }; + } + + private static string? ExtractSerString(ReadOnlySpan bytes) + { + if (bytes.Length == 0 || bytes[0] == 0xFF) + { + return null; + } + + int length; + int bytesRead; + if ((bytes[0] & 0x80) == 0) + { + length = bytes[0]; + bytesRead = 1; + } + else if ((bytes[0] & 0xC0) == 0x80) + { + if (bytes.Length < 2) + { + return null; + } + + length = ((bytes[0] & 0x3F) << 8) | bytes[1]; + bytesRead = 2; + } + else + { + if (bytes.Length < 4) + { + return null; + } + + length = ((bytes[0] & 0x1F) << 24) | + (bytes[1] << 16) | + (bytes[2] << 8) | + bytes[3]; + bytesRead = 4; + } + + return bytes.Length < bytesRead + length + ? null + : Encoding.UTF8.GetString(bytes.Slice(bytesRead, length)); + } + + internal static FieldInitializerValue GetInitializerValue(CILParser.InitOptContext context) + => context.Value; +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Data.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Data.cs new file mode 100644 index 00000000000000..7d56bb23122772 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Data.cs @@ -0,0 +1,210 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + internal CILParser.DataDeclarationBuilder CreateDataDeclaration( + CILParser.DataDeclContext context) + => new( + context.Parent is not CILParser.MethodDeclContext || + _currentMethod is not null); + + internal void EndDataDeclaration( + CILParser.DataDeclContext context, + CILParser.DataDeclarationBuilder builder, + int initialSyntaxErrorCount) + { + bool hasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + context.HasSyntaxError = hasSyntaxError; + + if (hasSyntaxError || !builder.ShouldCommit) + { + return; + } + + int declarationOffset = _mappedFieldData.Count; + if (builder.Name is not null && !_mappedFieldDataNames.ContainsKey(builder.Name)) + { + _mappedFieldDataNames.Add(builder.Name, declarationOffset); + } + + _mappedFieldData.LinkSuffix(builder.Data); + if (builder.ReferenceFixups is null) + { + return; + } + + foreach ((string target, List declarationFixups) in builder.ReferenceFixups) + { + if (!_mappedFieldDataReferenceFixups.TryGetValue(target, out List? fixups)) + { + _mappedFieldDataReferenceFixups.Add(target, fixups = new()); + } + + fixups.AddRange(declarationFixups); + } + } + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. + internal void SetDataDeclarationHeader( + CILParser.DataDeclarationBuilder builder, + byte section, + IToken name) + { + _ = section; + builder.Name = ParseIdentifier(name); + } + + internal void SetAnonymousDataDeclarationHeader( + CILParser.DataDeclarationBuilder builder, + byte section) + { + _ = builder; + _ = section; + } + + internal byte GetMappedDataSection() => 0; + + internal byte GetTlsDataSection() => 1; + + internal byte GetCilDataSection() => 2; + internal int ParseDataItemCount(IToken token) => ParseInt32(token); + + internal void AddDataString(CILParser.DataDeclarationBuilder builder, string value) + => builder.Data.WriteUTF16(value); + + internal void AddDataReference( + CILParser.DataDeclarationBuilder builder, + IToken targetToken) + { + string target = ParseIdentifier(targetToken); + Dictionary> fixups = + builder.ReferenceFixups ??= new Dictionary>(); + if (!fixups.TryGetValue(target, out List? targetFixups)) + { + fixups.Add(target, targetFixups = new()); + } + + targetFixups.Add(builder.Data.ReserveBytes(sizeof(int))); + } + + internal void AddDataBytes( + CILParser.DataDeclarationBuilder builder, + ImmutableArray value) + => builder.Data.WriteBytes(value); + + internal void AddFloatingPointData( + CILParser.DataDeclarationBuilder builder, + IToken kind, + double value, + int count) + { + if (count <= 0) + { + return; + } + + if (kind.Text == "float32") + { + float single = (float)value; + for (int i = 0; i < count; i++) + { + builder.Data.WriteSingle(single); + } + } + else + { + Debug.Assert(kind.Text == "float64"); + for (int i = 0; i < count; i++) + { + builder.Data.WriteDouble(value); + } + } + } + + internal void AddInt64Data( + CILParser.DataDeclarationBuilder builder, + IToken kind, + IToken value, + int count) + { + Debug.Assert(kind.Text == "int64"); + if (count <= 0) + { + return; + } + + long parsedValue = ParseInt64(value); + for (int i = 0; i < count; i++) + { + builder.Data.WriteInt64(parsedValue); + } + } + + internal void AddIntegerData( + CILParser.DataDeclarationBuilder builder, + IToken kind, + IToken value, + int count) + { + if (count <= 0) + { + return; + } + + int parsedValue = ParseInt32(value); + switch (kind.Text) + { + case "int8": + builder.Data.WriteBytes((byte)parsedValue, count); + break; + case "int16": + for (int i = 0; i < count; i++) + { + builder.Data.WriteInt16((short)parsedValue); + } + break; + default: + Debug.Assert(kind.Text == "int32"); + for (int i = 0; i < count; i++) + { + builder.Data.WriteInt32(parsedValue); + } + break; + } + } + + internal void AddZeroData( + CILParser.DataDeclarationBuilder builder, + IToken kind, + int count) + { + if (count <= 0) + { + return; + } + + int elementSize = kind.Text switch + { + "int8" => sizeof(byte), + "int16" => sizeof(short), + "int32" or "float32" => sizeof(int), + "int64" or "float64" => sizeof(long), + _ => throw new UnreachableException(), + }; + builder.Data.WriteBytes(0, checked(elementSize * count)); + } +#pragma warning restore CA1822 + + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Debug.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Debug.cs new file mode 100644 index 00000000000000..7f86131b9dd8ab --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Debug.cs @@ -0,0 +1,222 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. + internal bool IsAutoIncrementSourceDirective(IToken token) => token.Text == "#line"; +#pragma warning restore CA1822 + + internal SourceDirectiveValue CreateSourceLine( + bool autoIncrement, + IToken line, + IToken? path) + { + int lineNumber = ParseInt32(line); + return CreateSourceDirective(autoIncrement, lineNumber, 0, lineNumber, 0, path); + } + + internal SourceDirectiveValue CreateSourceColumn( + bool autoIncrement, + IToken line, + IToken column, + IToken? path) + { + int lineNumber = ParseInt32(line); + int columnNumber = ParseInt32(column); + return CreateSourceDirective( + autoIncrement, + lineNumber, + columnNumber, + lineNumber, + columnNumber, + path); + } + + internal SourceDirectiveValue CreateSourceColumnRange( + bool autoIncrement, + IToken line, + IToken startColumn, + IToken endColumn, + IToken? path) + { + int lineNumber = ParseInt32(line); + return CreateSourceDirective( + autoIncrement, + lineNumber, + ParseInt32(startColumn), + lineNumber, + ParseInt32(endColumn), + path); + } + + internal SourceDirectiveValue CreateSourceLineRange( + bool autoIncrement, + IToken startLine, + IToken endLine, + IToken column, + IToken? path) + { + int columnNumber = ParseInt32(column); + return CreateSourceDirective( + autoIncrement, + ParseInt32(startLine), + columnNumber, + ParseInt32(endLine), + columnNumber, + path); + } + + internal SourceDirectiveValue CreateSourceRange( + bool autoIncrement, + IToken startLine, + IToken endLine, + IToken startColumn, + IToken endColumn, + IToken? path) + => CreateSourceDirective( + autoIncrement, + ParseInt32(startLine), + ParseInt32(startColumn), + ParseInt32(endLine), + ParseInt32(endColumn), + path); + + private static SourceDirectiveValue CreateSourceDirective( + bool autoIncrement, + int startLine, + int startColumn, + int endLine, + int endColumn, + IToken? path) + => new( + autoIncrement, + startLine, + startColumn, + endLine, + endColumn, + path is null ? null : StringHelpers.ParseQuotedString(path.Text)); + + internal void EndSourceDirective( + CILParser.ExtSourceSpecContext context, + int initialSyntaxErrorCount) + { + context.HasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (context.HasSyntaxError || + context.Value is not { } value || + !CanApplySharedDirective(context)) + { + context.Value = null; + return; + } + + ApplySourceDirective(value); + } + + private void ApplySourceDirective(SourceDirectiveValue value) + { + if (value.DocumentPath is not null) + { + _currentDocumentPath = value.DocumentPath; + } + + if (_currentMethod is null || _currentDocumentPath is null) + { + return; + } + + int ilOffset = _currentMethod.Definition.MethodBody.Offset; + _currentMethod.Definition.DebugInfo.DocumentPath ??= _currentDocumentPath; + + EntityRegistry.SequencePoint sequencePoint; + if (value.StartLine == 0xFEEFEE) + { + sequencePoint = EntityRegistry.SequencePoint.Hidden(ilOffset); + } + else + { + int endColumn = value.EndColumn; + if (value.EndLine == value.StartLine && endColumn == value.StartColumn) + { + endColumn++; + } + + sequencePoint = new EntityRegistry.SequencePoint( + ilOffset, + value.StartLine, + value.StartColumn, + value.EndLine, + endColumn); + } + + List sequencePoints = + _currentMethod.Definition.DebugInfo.SequencePoints; + if (sequencePoints.Count > 0 && sequencePoints[^1].ILOffset == ilOffset) + { + sequencePoints[^1] = sequencePoint; + } + else + { + sequencePoints.Add(sequencePoint); + } + } + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. + internal string ParseLanguageString(IToken token) + => StringHelpers.ParseQuotedString(token.Text); + + internal LanguageDirectiveValue CreateLanguageDirective(string language) + => new LanguageDirectiveValue(language, null, null); + + internal LanguageDirectiveValue CreateLanguageDirective(string language, string vendor) + => new LanguageDirectiveValue(language, vendor, null); + + internal LanguageDirectiveValue CreateLanguageDirective( + string language, + string vendor, + string documentType) + => new LanguageDirectiveValue(language, vendor, documentType); +#pragma warning restore CA1822 + + internal void EndLanguageDirective( + CILParser.LanguageDeclContext context, + int initialSyntaxErrorCount) + { + context.HasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (context.HasSyntaxError || + context.Value is not { } value || + !CanApplySharedDirective(context)) + { + context.Value = null; + return; + } + + if (Guid.TryParse(value.Language, out Guid language)) + { + _currentLanguageGuid = language; + } + if (value.Vendor is not null && Guid.TryParse(value.Vendor, out Guid vendor)) + { + _currentLanguageVendorGuid = vendor; + } + if (value.DocumentType is not null && + Guid.TryParse(value.DocumentType, out Guid documentType)) + { + _currentDocumentTypeGuid = documentType; + } + } + + private bool CanApplySharedDirective(ParserRuleContext context) + => context.Parent is not CILParser.MethodDeclContext || _currentMethod is not null; + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Declarations.Actions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Declarations.Actions.cs new file mode 100644 index 00000000000000..6759a7fa40ce42 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Declarations.Actions.cs @@ -0,0 +1,172 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection.PortableExecutable; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal void BeginTopLevelDirective() => PrepareTopLevelDeclaration(); + + internal void ProcessTopLevelDataDeclaration(CILParser.DataDeclContext context) + => _ = context; + + internal void ProcessTopLevelVTableDeclaration(CILParser.VtableDeclContext context) + { + if (!context.HasSyntaxError) + { + MaterializeVTable(context); + } + } + + internal void ProcessTopLevelVTableFixupDeclaration(CILParser.VtfixupDeclContext context) + { + if (!context.HasSyntaxError) + { + MaterializeVTableFixup(context); + } + } + + internal void ProcessTopLevelSourceDirective(CILParser.ExtSourceSpecContext context) + => _ = context; + + internal void ProcessTopLevelFileDeclaration(CILParser.FileDeclContext context) + { + if (!context.HasSyntaxError) + { + _ = MaterializeFileDeclaration(context); + } + } + + internal void ProcessTopLevelAssembly(CILParser.AssemblyBlockContext context) + { + if (!context.HasSyntaxError) + { + MaterializeAssemblyDefinition(context); + } + } + + internal void ProcessTopLevelAssemblyReference(CILParser.AssemblyRefBlockContext context) + { + if (!context.HasSyntaxError) + { + MaterializeAssemblyReference(context); + } + } + + internal void ProcessTopLevelExportedType(CILParser.ExptypeBlockContext context) + { + if (!context.HasSyntaxError) + { + MaterializeExportedType(context); + } + } + + internal void ProcessTopLevelManifestResource(CILParser.ManifestResBlockContext context) + { + if (!context.HasSyntaxError) + { + MaterializeManifestResource(context); + } + } + + internal void SetModuleHeader( + CILParser.ModuleHeadContext context, + string name, + bool isExternal) + { + context.Value = name; + context.HasName = true; + context.IsExternal = isExternal; + } + + internal void SetEmptyModuleHeader(CILParser.ModuleHeadContext context) + { + context.Value = string.Empty; + context.HasName = false; + context.IsExternal = false; + } + + internal void ProcessTopLevelModule(string? name, bool hasName, bool isExternal) + { + if (!hasName) + { + _entityRegistry.Module.Name = null; + } + else if (isExternal) + { + _entityRegistry.GetOrCreateModuleReference(name ?? string.Empty, _ => { }); + } + else + { + _entityRegistry.Module.Name = name; + } + } + + internal void ProcessTopLevelSecurityDeclaration(CILParser.SecDeclContext context) + { + if (!context.HasSyntaxError) + { + EntityRegistry.DeclarativeSecurityAttributeEntity? security = + MaterializeSecurityDeclaration(context); + security?.Parent = _entityRegistry.Assembly; + } + } + + internal void ProcessTopLevelCustomAttribute(CILParser.CustomAttrDeclContext context) + { + if (!context.HasSyntaxError && + MaterializeCustomAttributeDeclaration(context) is { } customAttribute) + { + customAttribute.Owner = + (EntityRegistry.EntityBase?)_lastFieldDefinition ?? _entityRegistry.Module; + } + } + + internal void ProcessTopLevelSubsystem(IToken value) + { + _subsystem = (Subsystem)ParseInt32(value); + } + + internal void ProcessTopLevelCorFlags(IToken value) + { + _corflags = (CorFlags)ParseInt32(value); + } + + internal void ProcessTopLevelAlignment(IToken value) + { + _alignment = ParseInt32(value); + } + + internal void ProcessTopLevelImageBase(IToken value) + { + _imageBase = ParseInt64(value); + } + + internal void ProcessTopLevelStackReserve(IToken value) + { + _stackReserve = ParseInt64(value); + } + + internal void ProcessTopLevelLanguageDirective(CILParser.LanguageDeclContext context) + => _ = context; + + internal void ProcessTopLevelTypedef(CILParser.TypedefDeclContext context) + { + if (!context.HasSyntaxError) + { + MaterializeTypedef(context); + } + } + + internal void BeginTopLevelTypeList() => PrepareTopLevelDeclaration(); + + internal void ProcessTopLevelTypeListEntry(ClassNameValue value) + => _ = ResolveClassName(value); + + private void PrepareTopLevelDeclaration() => ClearPendingCustomAttributeOwners(); +} +#pragma warning restore CA1822 diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Instructions.References.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Instructions.References.cs new file mode 100644 index 00000000000000..5bda6c6db7710b --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Instructions.References.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + internal void EmitMethodReferenceInstruction(IToken opcodeToken, CILParser.MethodRefContext context) + { + if (StartInstruction(opcodeToken) is not { } instruction || context.HasSyntaxError) + { + return; + } + + ILOpCode opcode = instruction.OpCode; + CurrentMethodContext method = instruction.Method; + bool expectInstance = opcode is ILOpCode.Callvirt or ILOpCode.Newobj; + _expectInstance = expectInstance; + try + { + method.Definition.MethodBody.OpCode(opcode); + WriteInstructionToken(method, MaterializeMethodReference(context)); + } + finally + { + if (expectInstance) + { + _expectInstance = false; + } + } + } + + internal void EmitFieldReferenceInstruction(IToken opcodeToken, CILParser.FieldRefContext context) + { + if (StartInstruction(opcodeToken) is not { } instruction || context.HasSyntaxError) + { + return; + } + + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + WriteInstructionToken(instruction.Method, MaterializeFieldReference(context)); + } + + internal void EmitMetadataTokenInstruction(IToken opcodeToken, CILParser.MdtokenContext context) + { + if (StartInstruction(opcodeToken) is not { } instruction || context.HasSyntaxError) + { + return; + } + + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + WriteInstructionToken(instruction.Method, ResolveMetadataToken(context)); + } + + internal void EmitTypeReferenceInstruction(IToken opcodeToken, CILParser.TypeSpecContext context) + { + if (StartInstruction(opcodeToken) is not { } instruction || context.HasSyntaxError) + { + return; + } + + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + WriteInstructionToken(instruction.Method, ResolveTypeSpecification(context)); + } + + internal void EmitCalliInstruction(IToken opcodeToken, CILParser.CalliSignatureContext context) + { + if (StartInstruction(opcodeToken) is not { } instruction || context.HasSyntaxError) + { + return; + } + + Debug.Assert(instruction.OpCode == ILOpCode.Calli); + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + instruction.Method.Definition.MethodBody.Token( + _entityRegistry.GetOrCreateStandaloneSignature( + MaterializeCalliSignature(context.Value)).Handle); + } + + internal void EmitOwnerTokenInstruction(IToken opcodeToken, CILParser.OwnerTypeContext context) + { + if (StartInstruction(opcodeToken) is not { } instruction || context.HasSyntaxError) + { + return; + } + + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + WriteInstructionToken(instruction.Method, MaterializeOwnerType(context)); + } + + private static void WriteInstructionToken(CurrentMethodContext method, EntityRegistry.EntityBase entity) + { + if (entity is EntityRegistry.TypeReferenceEntity typeReference) + { + typeReference.RecordBlobToWriteResolvedToken( + method.Definition.MethodBody.CodeBuilder.ReserveBytes(sizeof(int))); + } + else if (entity is EntityRegistry.MemberReferenceEntity memberReference) + { + memberReference.RecordBlobToWriteResolvedHandle( + method.Definition.MethodBody.CodeBuilder.ReserveBytes(sizeof(int))); + } + else + { + method.Definition.MethodBody.Token(entity.Handle); + } + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Instructions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Instructions.cs new file mode 100644 index 00000000000000..1d2d368a92034c --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Instructions.cs @@ -0,0 +1,420 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using System.Runtime.InteropServices; +using System.Text; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + internal void EmitNoOperandInstruction(IToken opcodeToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + } + + internal void EmitVariableIndexInstruction(IToken opcodeToken, IToken indexToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + WriteVariableIndex(instruction.Method, instruction.OpCode, ParseInt32(indexToken)); + } + + internal void EmitVariableNameInstruction(IToken opcodeToken, IToken nameToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + CurrentMethodContext method = instruction.Method; + ILOpCode opcode = instruction.OpCode; + string instructionName = opcode.ToString(); + string variableName = ParseIdentifier(nameToken); + int? index = null; + + if (instructionName.Contains("arg", StringComparison.Ordinal)) + { + if (method.ArgumentNames.TryGetValue(variableName, out int argumentIndex)) + { + index = method.Definition.SignatureHeader.IsInstance ? argumentIndex + 1 : argumentIndex; + } + else + { + ReportError( + DiagnosticIds.ArgumentNotFound, + string.Format(DiagnosticMessageTemplates.ArgumentNotFound, variableName), + opcodeToken); + } + } + else + { + for (int i = method.LocalsScopes.Count - 1; i >= 0; i--) + { + if (method.LocalsScopes[i].TryGetValue(variableName, out int localIndex)) + { + index = localIndex; + break; + } + } + + if (index is null) + { + ReportError( + DiagnosticIds.LocalNotFound, + string.Format(DiagnosticMessageTemplates.LocalNotFound, variableName), + opcodeToken); + } + } + + WriteVariableIndex(method, opcode, index ?? -1); + } + + internal void EmitInt32Instruction(IToken opcodeToken, IToken valueToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + int value = ParseInt32(valueToken); + if (instruction.OpCode is ILOpCode.Ldc_i4 or ILOpCode.Ldc_i4_s) + { + instruction.Method.Definition.MethodBody.LoadConstantI4(value); + return; + } + + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + instruction.Method.Definition.MethodBody.CodeBuilder.WriteByte((byte)value); + } + + internal void EmitInt64Instruction(IToken opcodeToken, IToken valueToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + Debug.Assert(instruction.OpCode == ILOpCode.Ldc_i8); + instruction.Method.Definition.MethodBody.LoadConstantI8(ParseInt64(valueToken)); + } + + internal void EmitFloatingInstruction(IToken opcodeToken, double value) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + WriteFloatingInstruction(instruction.Method, instruction.OpCode, value); + } + + internal void EmitFloatingInstruction(IToken opcodeToken, IToken valueToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + WriteFloatingInstruction(instruction.Method, instruction.OpCode, ParseInt64(valueToken)); + } + + internal void EmitBranchOffsetInstruction(IToken opcodeToken, IToken offsetToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + InstructionEncoder body = instruction.Method.Definition.MethodBody; + LabelHandle label = body.DefineLabel(); + body.Branch(instruction.OpCode, label); + body.MarkLabel(label, body.Offset + ParseInt32(offsetToken)); + } + + internal void EmitBranchLabelInstruction(IToken opcodeToken, IToken labelToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + CurrentMethodContext method = instruction.Method; + string labelName = ParseIdentifier(labelToken); + if (!method.Labels.TryGetValue(labelName, out LabelHandle label)) + { + label = method.Definition.MethodBody.DefineLabel(); + method.Labels[labelName] = label; + method.UndefinedLabelReferences.TryAdd(labelName, opcodeToken); + } + + method.Definition.MethodBody.Branch(instruction.OpCode, label); + } + + internal void EmitRawFloatingInstruction( + IToken opcodeToken, + ImmutableArray bytes, + IToken bytesToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + double value; + ReadOnlySpan byteSpan = bytes.AsSpan(); + if (byteSpan.Length >= sizeof(double)) + { + value = BitConverter.ToDouble(byteSpan); + } + else if (byteSpan.Length >= sizeof(float)) + { + value = BitConverter.ToSingle(byteSpan); + } + else + { + ReportError( + DiagnosticIds.ByteArrayTooShort, + DiagnosticMessageTemplates.ByteArrayTooShort, + bytesToken); + value = 0; + } + + WriteFloatingInstruction(instruction.Method, instruction.OpCode, value); + } + + internal void EmitRawStringInstruction(IToken opcodeToken, ImmutableArray bytes) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + string value = MemoryMarshal.Cast(bytes.AsSpan()).ToString(); + instruction.Method.Definition.MethodBody.LoadString(_metadataBuilder.GetOrAddUserString(value)); + } + + internal void EmitStringInstruction(IToken opcodeToken, string value) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + instruction.Method.Definition.MethodBody.LoadString(_metadataBuilder.GetOrAddUserString(value)); + } + + internal void EmitAnsiStringInstruction(IToken opcodeToken, string value) + { + int byteCount = Encoding.UTF8.GetByteCount(value); + if ((byteCount % 2) != 0) + { + byteCount++; + } + + Span utf8Bytes = new byte[byteCount]; + Encoding.UTF8.GetBytes(value, utf8Bytes); + EmitStringInstruction(opcodeToken, new string(MemoryMarshal.Cast(utf8Bytes))); + } + + internal void EmitRawTokenInstruction(IToken opcodeToken, IToken valueToken) + { + if (StartInstruction(opcodeToken) is not { } instruction) + { + return; + } + + instruction.Method.Definition.MethodBody.OpCode(instruction.OpCode); + instruction.Method.Definition.MethodBody.CodeBuilder.WriteInt32(ParseInt32(valueToken)); + } + + internal void EmitByte(IToken valueToken) + { + _currentMethod?.Definition.MethodBody.CodeBuilder.WriteByte((byte)ParseInt32(valueToken)); + } + + internal void SetMaxStack(IToken valueToken) + { + if (_currentMethod is not null) + { + _currentMethod.Definition.MaxStack = ParseInt32(valueToken); + } + } + + internal void SetEntryPoint() + { + if (_currentMethod is not null) + { + _entityRegistry.EntryPoint = _currentMethod.Definition; + } + } + + internal void SetZeroInit() + { + if (_currentMethod is not null) + { + _currentMethod.Definition.BodyAttributes = MethodBodyAttributes.InitLocals; + } + } + + internal void DefineLabel(IToken nameToken) + { + if (_currentMethod is not { } method) + { + return; + } + + string labelName = ParseIdentifier(nameToken); + method.UndefinedLabelReferences.Remove(labelName); + if (!method.Labels.TryGetValue(labelName, out LabelHandle label)) + { + label = method.Definition.MethodBody.DefineLabel(); + method.Labels[labelName] = label; + } + + method.Definition.MethodBody.MarkLabel(label); + } + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. + internal CILParser.SwitchInstructionBuilder CreateSwitchInstruction(IToken opcodeToken) + => new(opcodeToken); + + internal void AddSwitchLabel(CILParser.SwitchInstructionBuilder builder, IToken labelToken) + => builder.Operands.Add((labelToken, false)); + + internal void AddSwitchOffset(CILParser.SwitchInstructionBuilder builder, IToken offsetToken) + => builder.Operands.Add((offsetToken, true)); +#pragma warning restore CA1822 + + internal void CompleteSwitchInstruction(CILParser.SwitchInstructionBuilder? builder) + { + if (builder is null || + StartInstruction(builder.OpcodeToken) is not { } instruction) + { + return; + } + + Debug.Assert(instruction.OpCode == ILOpCode.Switch); + CurrentMethodContext method = instruction.Method; + List<(LabelHandle Label, int? Offset)> labels = new(builder.Operands.Count); + foreach ((IToken token, bool isOffset) in builder.Operands) + { + if (isOffset) + { + labels.Add((method.Definition.MethodBody.DefineLabel(), ParseInt32(token))); + continue; + } + + string labelName = ParseIdentifier(token); + if (!method.Labels.TryGetValue(labelName, out LabelHandle label)) + { + label = method.Definition.MethodBody.DefineLabel(); + method.Labels[labelName] = label; + method.UndefinedLabelReferences.TryAdd(labelName, builder.OpcodeToken); + } + + labels.Add((label, null)); + } + + if (labels.Count > 0) + { + SwitchInstructionEncoder switchEncoder = method.Definition.MethodBody.Switch(labels.Count); + foreach ((LabelHandle label, _) in labels) + { + switchEncoder.Branch(label); + } + } + else + { + method.Definition.MethodBody.OpCode(ILOpCode.Switch); + method.Definition.MethodBody.CodeBuilder.WriteInt32(0); + } + + foreach ((LabelHandle label, int? offset) in labels) + { + if (offset is int value) + { + method.Definition.MethodBody.MarkLabel(label, method.Definition.MethodBody.Offset + value); + } + } + } + + private (CurrentMethodContext Method, ILOpCode OpCode)? StartInstruction(IToken opcodeToken) + { + if (_currentMethod is not { } method) + { + return null; + } + + ILOpCode opcode = ParseOpCodeFromToken(opcodeToken); + if (opcode == ILOpCode.Localloc) + { + method.Definition.HasDynamicStackAllocation = true; + } + + return (method, opcode); + } + + private static void WriteVariableIndex(CurrentMethodContext method, ILOpCode opcode, int index) + { + method.Definition.MethodBody.OpCode(opcode); + if (opcode.ToString().EndsWith("_s", StringComparison.Ordinal)) + { + method.Definition.MethodBody.CodeBuilder.WriteByte((byte)index); + } + else + { + method.Definition.MethodBody.CodeBuilder.WriteInt32(index); + } + } + + private static void WriteFloatingInstruction(CurrentMethodContext method, ILOpCode opcode, double value) + { + if (opcode == ILOpCode.Ldc_r4) + { + method.Definition.MethodBody.LoadConstantR4((float)value); + } + else + { + method.Definition.MethodBody.LoadConstantR8(value); + } + } + + private static ILOpCode ParseOpCodeFromToken(IToken token) + { + string text = token.Text.TrimEnd('.'); + if (text == "unused") + { + return ILOpCode.Unused; + } + + string normalized = text.Replace('.', '_'); + normalized = normalized switch + { + "ldelem_u8" => "ldelem_i8", + "ldind_u8" => "ldind_i8", + "endfault" => "endfinally", + _ => normalized + }; + + return (ILOpCode)Enum.Parse(typeof(ILOpCode), normalized, ignoreCase: true); + } + + internal EntityRegistry.EntityBase ResolveMetadataToken(CILParser.MdtokenContext context) + => ResolveMetadataToken(context.Value); +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Literals.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Literals.cs new file mode 100644 index 00000000000000..e6e2ad26cfd172 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Literals.cs @@ -0,0 +1,196 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using System.Reflection.PortableExecutable; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using Antlr4.Runtime; +using Antlr4.Runtime.Misc; + +namespace ILAssembler +{ +#pragma warning disable CA1822 // Mark members as static + internal sealed partial class GrammarActions + { + internal void AddComposedStringPart(StringBuilder builder, IToken token) + => builder.Append(StringHelpers.ParseQuotedString(token.Text)); + + internal string EndComposedString(StringBuilder builder) + => builder.ToString(); + + internal void AddDottedNamePart(CILParser.DottedNameBuilder builder, string value) + { + if (builder.HasPart) + { + builder.Value.Append('.'); + } + + builder.Value.Append(value); + builder.HasPart = true; + } + + internal void AddDottedNameToken(CILParser.DottedNameBuilder builder, IToken token) + => AddDottedNamePart(builder, ParseIdentifier(token)); + + internal string EndDottedName(CILParser.DottedNameBuilder builder) + => builder.Value.ToString(); + + internal string ParseDottedNamePart(IToken token) + => token.Text.Length >= 2 && token.Text[0] == '\'' + ? StringHelpers.ParseQuotedString(token.Text) + : token.Text; + + internal double ParseFloatingLiteral(IToken token) + { + string text = token.Text; + bool neg = text.StartsWith('-'); + if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out double result)) + { + result = neg ? double.MaxValue : double.MinValue; + } + + return result; + } + + internal double ParseFloatingInteger(IToken token) + { + if (!ParseIntegerValue(token.Text.AsSpan(), out long value)) + { + ReportLiteralOutOfRange(token); + value = 0; + } + + return value; + } + + internal double ParseFloat32Bits(IToken token) + => BitConverter.Int32BitsToSingle(ParseInt32(token)); + + internal double ParseFloat64Bits(IToken token) + => BitConverter.Int64BitsToDouble(ParseInt64(token)); + + internal static string GetIdentifier(CILParser.IdContext context) + => ParseIdentifier(context.Start); + + private static string ParseIdentifier(IToken token) + { + string text = token.Text; + return text.Length >= 2 && text[0] == '\'' + ? text.Substring(1, text.Length - 2) + : text; + } + + private static bool ParseIntegerValue(ReadOnlySpan value, out long result) + { + NumberStyles parseStyle = NumberStyles.None; + bool negate = false; + if (value.StartsWith("-".AsSpan())) + { + negate = true; + value = value.Slice(1); + } + + if (value.StartsWith("0x".AsSpan())) + { + parseStyle = NumberStyles.AllowHexSpecifier; + value = value.Slice(2); + } + else if (value.StartsWith("0".AsSpan())) + { + // Octal support isn't built-in, so we'll do it manually. + result = 0; + for (int i = 0; i < value.Length; i++, result *= 8) + { + int digitValue = value[i] - '0'; + if (digitValue < 0 || digitValue > 7) + { + // COMPAT: native ilasm skips invalid digits silently + continue; + } + result += digitValue; + } + if (negate) result = -result; + return true; + } + + bool success = long.TryParse(value.ToString(), parseStyle, CultureInfo.InvariantCulture, out result); + if (!success) + { + // Try parsing as unsigned — handles values like: + // - Decimal overflow with negation: 9223372036854775808 (= -Int64.MinValue) + // - Large unsigned decimal: 18444492274432737280 + if (ulong.TryParse(value.ToString(), parseStyle, CultureInfo.InvariantCulture, out ulong uresult)) + { + result = unchecked((long)uresult); + if (negate) result = unchecked(-result); + return true; + } + // Handle oversized hex values (>64 bits) by truncating to low 64 bits, + // matching native ilasm behavior for values like 0x94188556b24089e8b90c9c61f9f3088 + if (parseStyle == NumberStyles.AllowHexSpecifier && value.Length > 16) + { + var truncated = value.Slice(value.Length - 16); + if (ulong.TryParse(truncated.ToString(), parseStyle, CultureInfo.InvariantCulture, out uresult)) + { + result = unchecked((long)uresult); + if (negate) result = unchecked(-result); + return true; + } + } + return false; + } + + if (negate) result = -result; + return true; + } + + internal int ParseInt32(IToken token) + { + ReadOnlySpan value = token.Text.AsSpan(); + if (!ParseIntegerValue(value, out long num)) + { + ReportLiteralOutOfRange(token); + return 0; + } + + return (int)num; + } + + + private long ParseInt64(IToken token) + { + ReadOnlySpan value = token.Text.AsSpan(); + if (!ParseIntegerValue(value, out long num)) + { + ReportLiteralOutOfRange(token); + return 0; + } + + return num; + } + + private void ReportLiteralOutOfRange(IToken token) + { + _diagnostics.Add(new Diagnostic( + DiagnosticIds.LiteralOutOfRange, + DiagnosticSeverity.Error, + string.Format(DiagnosticMessageTemplates.LiteralOutOfRange, token.Text), + Location.From(token, _documents))); + } + + internal bool ParseBoolean(IToken token) => bool.Parse(token.Text); + + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Assembly.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Assembly.cs new file mode 100644 index 00000000000000..ddd730e2e7014b --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Assembly.cs @@ -0,0 +1,203 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Immutable; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Reflection.Metadata; +using System.Text; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal void SetAssemblyAttribute(CILParser.AsmAttrAnyContext context) + { + (AssemblyFlags value, AssemblyFlags mask) = context.Start.Text switch + { + "retargetable" => (AssemblyFlags.Retargetable, (AssemblyFlags)0), + "windowsruntime" => (AssemblyFlags.WindowsRuntime, (AssemblyFlags)0), + "noplatform" => (AssemblyFlags.NoPlatform, (AssemblyFlags)0), + "legacy library" => ((AssemblyFlags)0, (AssemblyFlags)0), + "cil" => (GetFlagForArch(ProcessorArchitecture.MSIL), AssemblyFlags.ArchitectureMask), + "x86" => (GetFlagForArch(ProcessorArchitecture.X86), AssemblyFlags.ArchitectureMask), + "amd64" => (GetFlagForArch(ProcessorArchitecture.Amd64), AssemblyFlags.ArchitectureMask), + "arm" => (GetFlagForArch(ProcessorArchitecture.Arm), AssemblyFlags.ArchitectureMask), + "arm64" => (GetFlagForArch((ProcessorArchitecture)6), AssemblyFlags.ArchitectureMask), + _ => throw new UnreachableException() + }; + context.Value = value; + context.Mask = mask; + } + + internal AssemblyFlags AddAssemblyAttribute( + AssemblyFlags attributes, + AssemblyFlags value, + AssemblyFlags mask) + => mask == 0 ? attributes | value : (attributes & ~mask) | value; + + internal AssemblyDefinitionValue CreateAssemblyDefinition( + AssemblyFlags attributes, + string name, + ImmutableArray declarations) + => new(attributes, name, declarations); + + internal AssemblyDeclarationValue CreateAssemblyHashAlgorithmDeclaration(IToken value) + => new AssemblyHashAlgorithmDirectiveValue((AssemblyHashAlgorithm)ParseInt32(value)); + + internal AssemblyDeclarationValue CreateAssemblySecurityDeclaration( + SecurityDeclarationValue? value, + IToken location) + => new AssemblySecurityDirectiveValue(value, location); + + internal AssemblyDeclarationValue CreateAssemblyPublicKeyDeclaration( + ImmutableArray value) + => new AssemblyPublicKeyDirectiveValue(value); + + internal AssemblyDeclarationValue CreateAssemblyVersionDeclaration( + int? major, + int? minor, + int? build, + int? revision) + => new AssemblyVersionDirectiveValue(new( + major ?? 0, + minor ?? 0, + build ?? 0, + revision ?? 0)); + + internal AssemblyDeclarationValue CreateAssemblyLocaleDeclaration(string value) + => new AssemblyLocaleDirectiveValue(value); + + internal AssemblyDeclarationValue CreateAssemblyLocaleDeclaration( + ImmutableArray value) + => new AssemblyLocaleDirectiveValue(Encoding.Unicode.GetString(value.AsSpan())); + + internal AssemblyDeclarationValue CreateAssemblyCustomAttributeDeclaration( + CustomAttributeDeclarationValue? value, + IToken location) + => new AssemblyCustomAttributeDirectiveValue(value, location); + + private static AssemblyFlags GetFlagForArch(ProcessorArchitecture architecture) + => (AssemblyFlags)((int)architecture << 4); + + private static (ProcessorArchitecture Architecture, AssemblyFlags Flags) GetArchAndFlags( + AssemblyFlags flags) + { + ProcessorArchitecture architecture = + (ProcessorArchitecture)(((int)flags & 0xF0) >> 4); + return (architecture, flags & ~GetFlagForArch(architecture)); + } + + private void MaterializeAssemblyDefinition(AssemblyDefinitionValue definition) + { + string assemblyName = _options.AssemblyName ?? definition.Name; + _entityRegistry.Assembly ??= new EntityRegistry.AssemblyEntity(assemblyName); + EntityRegistry.AssemblyEntity assembly = _entityRegistry.Assembly; + (assembly.ProcessorArchitecture, assembly.Flags) = + GetArchAndFlags(definition.Attributes); + + foreach (AssemblyDeclarationValue declaration in definition.Declarations) + { + switch (declaration) + { + case AssemblyHashAlgorithmDirectiveValue hashAlgorithm: + assembly.HashAlgorithm = hashAlgorithm.Value; + break; + case AssemblySecurityDirectiveValue security: + if (security.Value is { } securityValue && + MaterializeSecurityDeclaration(securityValue, security.Location) is { } entity) + { + entity.Parent = assembly; + } + break; + default: + ApplyAssemblyOrReferenceDirective(assembly, declaration); + break; + } + } + + if (_options.KeyFile is not null) + { + ApplyKeyFile(_options.KeyFile); + } + } + + private void ApplyAssemblyOrReferenceDirective( + EntityRegistry.AssemblyOrRefEntity target, + AssemblyDeclarationValue declaration) + { + switch (declaration) + { + case AssemblyPublicKeyDirectiveValue publicKey: + // COMPAT: A reference's public key token wins regardless of declaration order. + if (target is not EntityRegistry.AssemblyReferenceEntity assemblyReference || + assemblyReference.PublicKeyOrToken is null || + assemblyReference.Flags.HasFlag(AssemblyFlags.PublicKey)) + { + target.PublicKeyOrToken = CreateManifestBlob(publicKey.Value); + target.Flags |= AssemblyFlags.PublicKey; + } + break; + case AssemblyVersionDirectiveValue version: + target.Version = version.Value; + break; + case AssemblyLocaleDirectiveValue locale: + target.Culture = locale.Value; + break; + case AssemblyCustomAttributeDirectiveValue customAttribute: + MaterializeCustomAttributeDeclaration( + customAttribute.Value, + customAttribute.Location)?.Owner = target; + break; + } + } + + private static BlobBuilder CreateManifestBlob(ImmutableArray value) + { + BlobBuilder blob = new(value.Length); + blob.WriteBytes(value); + return blob; + } + + private void ApplyKeyFile(string keyFilePath) + { + if (_entityRegistry.Assembly is null) + { + return; + } + + try + { + byte[] keyBytes = File.ReadAllBytes(keyFilePath); + BlobBuilder blob = new(keyBytes.Length); + blob.WriteBytes(keyBytes); + _entityRegistry.Assembly.PublicKeyOrToken = blob; + _entityRegistry.Assembly.Flags |= AssemblyFlags.PublicKey; + } + catch (Exception ex) + { + SourceText? firstDocument = _documents.Values.FirstOrDefault(); + Location location = firstDocument is not null + ? new Location(new SourceSpan(0, 0), firstDocument) + : new Location(new SourceSpan(0, 0), new SourceText(string.Empty, keyFilePath)); + _diagnostics.Add(new Diagnostic( + DiagnosticIds.KeyFileError, + DiagnosticSeverity.Error, + $"Failed to read key file '{keyFilePath}': {ex.Message}", + location)); + } + } + + internal void MaterializeAssemblyDefinition(CILParser.AssemblyBlockContext context) + { + if (context.Value is AssemblyDefinitionValue definition) + { + MaterializeAssemblyDefinition(definition); + } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.ExportedTypes.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.ExportedTypes.cs new file mode 100644 index 00000000000000..16e78893c63015 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.ExportedTypes.cs @@ -0,0 +1,303 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal void SetExportedTypeAttribute(CILParser.ExptAttrContext context) + { + string attribute = context.Start.Text == "nested" + ? $"nested{context.Stop?.Text}" + : context.Start.Text; + (TypeAttributes value, TypeAttributes mask) = attribute switch + { + "private" => (TypeAttributes.NotPublic, TypeAttributes.VisibilityMask), + "public" => (TypeAttributes.Public, TypeAttributes.VisibilityMask), + "forwarder" => (TypeAttributes.Forwarder, (TypeAttributes)0), + "nestedpublic" => (TypeAttributes.NestedPublic, TypeAttributes.VisibilityMask), + "nestedprivate" => (TypeAttributes.NestedPrivate, TypeAttributes.VisibilityMask), + "nestedfamily" => (TypeAttributes.NestedFamily, TypeAttributes.VisibilityMask), + "nestedassembly" => (TypeAttributes.NestedAssembly, TypeAttributes.VisibilityMask), + "nestedfamandassem" => (TypeAttributes.NestedFamANDAssem, TypeAttributes.VisibilityMask), + "nestedfamorassem" => (TypeAttributes.NestedFamORAssem, TypeAttributes.VisibilityMask), + _ => throw new UnreachableException() + }; + context.Value = value; + context.Mask = mask; + } + + internal TypeAttributes AddExportedTypeAttribute( + TypeAttributes attributes, + TypeAttributes value, + TypeAttributes mask) + => mask == 0 ? attributes | value : (attributes & ~mask) | value; + + internal ExportedTypeHeaderValue CreateExportedTypeHeader( + TypeAttributes attributes, + string name, + IToken location) + => new ExportedTypeHeaderValue(true, attributes, name, location); + + internal ExportedTypeValue CreateExportedType( + ExportedTypeHeaderValue header, + ImmutableArray declarations) + => new ExportedTypeValue( + header, + declarations); + + internal ExportedTypeDeclarationValue CreateExportedTypeFileDeclaration( + string name, + IToken location) + => new ExportedTypeFileDirectiveValue(name, location); + + internal ExportedTypeDeclarationValue CreateNestedExportedTypeDeclaration( + TypeName name, + IToken location) + => new NestedExportedTypeDirectiveValue(name, location); + + internal ExportedTypeDeclarationValue CreateExportedTypeAssemblyDeclaration( + string name, + IToken location) + => new ExportedTypeAssemblyDirectiveValue(name, location); + + internal ExportedTypeDeclarationValue CreateExportedTypeMetadataTokenDeclaration( + int token, + IToken location) + => new ExportedTypeMetadataTokenDirectiveValue(token, location); + + internal ExportedTypeDeclarationValue CreateExportedTypeDefinitionIdDeclaration( + IToken value) + => new ExportedTypeDefinitionIdDirectiveValue(ParseInt32(value)); + + internal ExportedTypeDeclarationValue CreateExportedTypeCustomAttributeDeclaration( + CustomAttributeDeclarationValue? value, + IToken location) + => new ExportedTypeCustomAttributeDirectiveValue(value, location); + + private void MaterializeExportedType(ExportedTypeValue value) + { + ExportedTypeHeaderValue header = value.Header; + if (!header.IsValid || + header.Location is not IToken location) + { + return; + } + + (string typeNamespace, string name) = + NameHelpers.SplitDottedNameToNamespaceAndName(header.Name); + ( + EntityRegistry.EntityBase? implementation, + int typeDefinitionId, + ImmutableArray customAttributes + ) = MaterializeExportedTypeDeclarations(value.Declarations); + + if (implementation is null) + { + ReportWarning( + DiagnosticIds.MissingExportedTypeImplementation, + string.Format( + DiagnosticMessageTemplates.MissingExportedTypeImplementation, + header.Name), + location); + return; + } + + EntityRegistry.ExportedTypeEntity exportedType = + _entityRegistry.GetOrCreateExportedType( + implementation, + typeNamespace, + name, + entity => + { + entity.Attributes = header.Attributes; + entity.TypeDefinitionId = typeDefinitionId; + }); + foreach (EntityRegistry.CustomAttributeEntity attribute in customAttributes) + { + attribute.Owner = exportedType; + } + } + + private ( + EntityRegistry.EntityBase? Implementation, + int TypeDefinitionId, + ImmutableArray CustomAttributes + ) MaterializeExportedTypeDeclarations( + ImmutableArray declarations) + { + EntityRegistry.EntityBase? implementation = null; + int typeDefinitionId = 0; + ImmutableArray.Builder customAttributes = + ImmutableArray.CreateBuilder(); + + foreach (ExportedTypeDeclarationValue declaration in declarations) + { + switch (declaration) + { + case ExportedTypeCustomAttributeDirectiveValue customAttribute: + if (MaterializeCustomAttributeDeclaration( + customAttribute.Value, + customAttribute.Location) is { } attribute) + { + customAttributes.Add(attribute); + } + break; + case ExportedTypeMetadataTokenDirectiveValue metadataToken: + EntityRegistry.EntityBase entity = ResolveMetadataToken(metadataToken.Token); + if (entity is EntityRegistry.FakeTypeEntity) + { + ReportError( + DiagnosticIds.InvalidMetadataToken, + DiagnosticMessageTemplates.InvalidMetadataToken, + metadataToken.Location); + } + implementation = ResolveBetterExportedTypeImplementation( + implementation, + entity); + break; + case ExportedTypeFileDirectiveValue file: + implementation = _entityRegistry.FindFile(file.Name); + if (implementation is null) + { + ReportError( + DiagnosticIds.FileNotFound, + string.Format(DiagnosticMessageTemplates.FileNotFound, file.Name), + file.Location); + } + break; + case ExportedTypeAssemblyDirectiveValue assembly: + implementation = _entityRegistry.FindAssemblyReference(assembly.Name); + if (implementation is null) + { + ReportError( + DiagnosticIds.AssemblyNotFound, + string.Format( + DiagnosticMessageTemplates.AssemblyNotFound, + assembly.Name), + assembly.Location); + } + break; + case NestedExportedTypeDirectiveValue nested: + EntityRegistry.ExportedTypeEntity? containingType = + ResolveExportedType(nested.Name, nested.Location); + if (containingType is null) + { + ReportError( + DiagnosticIds.ExportedTypeNotFound, + string.Format( + DiagnosticMessageTemplates.ExportedTypeNotFound, + GetExportedTypeDisplayName(nested.Name)), + nested.Location); + } + else + { + implementation = ResolveBetterExportedTypeImplementation( + implementation, + containingType); + } + break; + case ExportedTypeDefinitionIdDirectiveValue definitionId: + typeDefinitionId = definitionId.Value; + break; + } + } + + return (implementation, typeDefinitionId, customAttributes.ToImmutable()); + } + + private static EntityRegistry.EntityBase? ResolveBetterExportedTypeImplementation( + EntityRegistry.EntityBase? current, + EntityRegistry.EntityBase? candidate) + { + if (candidate is null) + { + return current; + } + + if (current is null) + { + return candidate; + } + + return GetImplementationPriority(candidate) >= GetImplementationPriority(current) + ? candidate + : current; + + static int GetImplementationPriority(EntityRegistry.EntityBase entity) + => entity switch + { + EntityRegistry.FileEntity => 4, + EntityRegistry.AssemblyReferenceEntity => 3, + EntityRegistry.ExportedTypeEntity => 2, + _ => 1 + }; + } + + private EntityRegistry.ExportedTypeEntity? ResolveExportedType( + TypeName typeName, + IToken location) + { + Stack containingTypes = new(); + for (TypeName? containingType = typeName; + containingType is not null; + containingType = containingType.ContainingTypeName) + { + containingTypes.Push(containingType); + } + + EntityRegistry.ExportedTypeEntity? exportedType = null; + while (containingTypes.Count != 0) + { + TypeName containingType = containingTypes.Pop(); + (string typeNamespace, string name) = + NameHelpers.SplitDottedNameToNamespaceAndName(containingType.DottedName); + exportedType = _entityRegistry.FindExportedType( + exportedType, + typeNamespace, + name); + if (exportedType is null) + { + ReportError( + DiagnosticIds.ExportedTypeNotFound, + string.Format( + DiagnosticMessageTemplates.ExportedTypeNotFound, + containingType.DottedName), + location); + return null; + } + } + + return exportedType; + } + + private static string GetExportedTypeDisplayName(TypeName typeName) + { + Stack names = new(); + for (TypeName? current = typeName; + current is not null; + current = current.ContainingTypeName) + { + names.Push(current.DottedName); + } + + return string.Join("/", names); + } + + internal void MaterializeExportedType(CILParser.ExptypeBlockContext context) + { + if (context.Value is ExportedTypeValue value) + { + MaterializeExportedType(value); + } + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Files.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Files.cs new file mode 100644 index 00000000000000..f2bc370670b12a --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Files.cs @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal bool ParseFileAttribute(IToken token) + { + Debug.Assert(token.Text == "nometadata"); + return false; + } + + internal bool ParseFileEntry(IToken token) + { + Debug.Assert(token.Text == ".entrypoint"); + return true; + } + + internal void AddFileAttribute( + CILParser.FileDeclarationBuilder builder, + bool hasMetadata) + => builder.HasMetadata &= hasMetadata; + + internal void SetFileName(CILParser.FileDeclarationBuilder builder, string name) + => builder.Name = name; + + internal void AddFileEntry( + CILParser.FileDeclarationBuilder builder, + bool isEntryPoint) + => builder.IsEntryPoint |= isEntryPoint; + + internal void SetFileHash( + CILParser.FileDeclarationBuilder builder, + ImmutableArray hash) + => builder.Hash = hash; + + internal void EndFileDeclaration( + CILParser.FileDeclContext context, + CILParser.FileDeclarationBuilder builder, + int initialSyntaxErrorCount) + { + context.HasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + context.Value = context.HasSyntaxError + ? null + : new FileDeclarationValue( + builder.Name, + builder.HasMetadata, + builder.IsEntryPoint, + builder.Hash); + } + + private EntityRegistry.FileEntity MaterializeFileDeclaration(FileDeclarationValue declaration) + { + BlobBuilder? hash = declaration.Hash is { } value ? CreateManifestBlob(value) : null; + EntityRegistry.FileEntity entity = + _entityRegistry.GetOrCreateFile(declaration.Name, declaration.HasMetadata, hash); + if (declaration.IsEntryPoint) + { + _entityRegistry.EntryPoint = entity; + } + + return entity; + } + + internal EntityRegistry.FileEntity MaterializeFileDeclaration( + CILParser.FileDeclContext context) + { + Debug.Assert(context.Value is not null); + FileDeclarationValue declaration = + context.Value ?? new(string.Empty, HasMetadata: true, IsEntryPoint: false, Hash: null); + return MaterializeFileDeclaration(declaration); + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.References.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.References.cs new file mode 100644 index 00000000000000..3e9ecb258284ef --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.References.cs @@ -0,0 +1,85 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Reflection; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal AssemblyReferenceHeaderValue CreateAssemblyReferenceHeader( + AssemblyFlags attributes, + string name, + string alias) + => new AssemblyReferenceHeaderValue(true, attributes, name, alias); + + internal AssemblyReferenceValue CreateAssemblyReference( + AssemblyReferenceHeaderValue header, + ImmutableArray declarations) + => new AssemblyReferenceValue( + header, + declarations); + + internal AssemblyDeclarationValue CreateAssemblyReferenceHashDeclaration( + ImmutableArray value) + => new AssemblyReferenceHashDirectiveValue(value); + + internal AssemblyDeclarationValue CreateAssemblyReferencePublicKeyTokenDeclaration( + ImmutableArray value) + => new AssemblyReferencePublicKeyTokenDirectiveValue(value); + + internal AssemblyDeclarationValue? CreateAssemblyReferenceAutoDeclaration() => null; + + private EntityRegistry.AssemblyReferenceEntity MaterializeAssemblyReferenceHeader( + AssemblyReferenceHeaderValue header) + { + (ProcessorArchitecture architecture, AssemblyFlags flags) = + GetArchAndFlags(header.Attributes); + return _entityRegistry.GetOrCreateAssemblyReference( + header.Alias, + assemblyReference => + { + assemblyReference.Name = header.Name; + assemblyReference.Flags = flags; + assemblyReference.ProcessorArchitecture = architecture; + }); + } + + private void MaterializeAssemblyReference(AssemblyReferenceValue reference) + { + if (!reference.Header.IsValid) + { + return; + } + + EntityRegistry.AssemblyReferenceEntity entity = + MaterializeAssemblyReferenceHeader(reference.Header); + foreach (AssemblyDeclarationValue declaration in reference.Declarations) + { + switch (declaration) + { + case AssemblyReferenceHashDirectiveValue hash: + entity.Hash = CreateManifestBlob(hash.Value); + break; + case AssemblyReferencePublicKeyTokenDirectiveValue publicKeyToken: + entity.PublicKeyOrToken = CreateManifestBlob(publicKeyToken.Value); + entity.Flags &= ~AssemblyFlags.PublicKey; + break; + default: + ApplyAssemblyOrReferenceDirective(entity, declaration); + break; + } + } + } + + internal void MaterializeAssemblyReference(CILParser.AssemblyRefBlockContext context) + { + if (context.Value is AssemblyReferenceValue reference) + { + MaterializeAssemblyReference(reference); + } + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Resources.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Resources.cs new file mode 100644 index 00000000000000..b4b87d6503c6c6 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Resources.cs @@ -0,0 +1,159 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal ManifestResourceAttributes AddManifestResourceAttribute( + ManifestResourceAttributes attributes, + ManifestResourceAttributes value) + => attributes | value; + + internal ManifestResourceAttributes ParseManifestResourceAttribute(IToken token) + => token.Text switch + { + "public" => ManifestResourceAttributes.Public, + "private" => ManifestResourceAttributes.Private, + _ => throw new UnreachableException() + }; + + internal ManifestResourceHeaderValue CreateManifestResourceHeader( + ManifestResourceAttributes attributes, + string name, + string alias, + IToken location) + => new ManifestResourceHeaderValue(true, attributes, name, alias, location); + + internal ManifestResourceValue CreateManifestResource( + ManifestResourceHeaderValue header, + ImmutableArray declarations) + => new ManifestResourceValue( + header, + declarations); + + internal ManifestResourceDeclarationValue CreateManifestResourceFileDeclaration( + string name, + IToken offset, + IToken location) + => new ManifestResourceFileDirectiveValue(name, (uint)ParseInt32(offset), location); + + internal ManifestResourceDeclarationValue CreateManifestResourceAssemblyDeclaration( + string name) + => new ManifestResourceAssemblyDirectiveValue(name); + + internal ManifestResourceDeclarationValue CreateManifestResourceCustomAttributeDeclaration( + CustomAttributeDeclarationValue? value, + IToken location) + => new ManifestResourceCustomAttributeDirectiveValue(value, location); + + private void MaterializeManifestResource(ManifestResourceValue value) + { + ManifestResourceHeaderValue header = value.Header; + if (!header.IsValid || + header.Location is not IToken location) + { + return; + } + + ( + EntityRegistry.EntityBase? implementation, + uint offset, + ImmutableArray customAttributes + ) = MaterializeManifestResourceDeclarations(value.Declarations); + + if (implementation is null) + { + offset = (uint)_manifestResources.Count; + byte[] resourceData = _resourceLocator(header.Alias); + if (resourceData is null) + { + ReportError( + DiagnosticIds.FileNotFound, + string.Format( + DiagnosticMessageTemplates.FileNotFound, + header.Alias), + location); + } + else + { + _manifestResources.WriteInt32(resourceData.Length); + _manifestResources.WriteBytes(resourceData); + } + } + + EntityRegistry.ManifestResourceEntity resource = + _entityRegistry.CreateManifestResource(header.Name, offset); + resource.Attributes = header.Attributes; + resource.Implementation = implementation; + foreach (EntityRegistry.CustomAttributeEntity customAttribute in customAttributes) + { + customAttribute.Owner = resource; + } + } + + private ( + EntityRegistry.EntityBase? Implementation, + uint Offset, + ImmutableArray CustomAttributes + ) MaterializeManifestResourceDeclarations( + ImmutableArray declarations) + { + EntityRegistry.EntityBase? implementation = null; + uint offset = 0; + ImmutableArray.Builder customAttributes = + ImmutableArray.CreateBuilder(); + + foreach (ManifestResourceDeclarationValue declaration in declarations) + { + switch (declaration) + { + case ManifestResourceCustomAttributeDirectiveValue customAttribute: + if (MaterializeCustomAttributeDeclaration( + customAttribute.Value, + customAttribute.Location) is { } attribute) + { + customAttributes.Add(attribute); + } + break; + case ManifestResourceFileDirectiveValue file + when implementation is not EntityRegistry.AssemblyReferenceEntity: + EntityRegistry.FileEntity? fileEntity = _entityRegistry.FindFile(file.Name); + if (fileEntity is null) + { + ReportError( + DiagnosticIds.FileNotFound, + string.Format(DiagnosticMessageTemplates.FileNotFound, file.Name), + file.Location); + } + else + { + implementation = fileEntity; + offset = file.Offset; + } + break; + case ManifestResourceAssemblyDirectiveValue assembly: + implementation = + _entityRegistry.GetOrCreateAssemblyReference(assembly.Name, _ => { }); + break; + } + } + + return (implementation, offset, customAttributes.ToImmutable()); + } + + internal void MaterializeManifestResource(CILParser.ManifestResBlockContext context) + { + if (context.Value is ManifestResourceValue value) + { + MaterializeManifestResource(value); + } + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Typedefs.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Typedefs.cs new file mode 100644 index 00000000000000..1aa54aee176ba9 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.Typedefs.cs @@ -0,0 +1,131 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + private readonly Dictionary _typedefs = new(); + + internal TypedefDeclarationValue CreateTypeSignatureTypedef( + TypeValue type, + string alias) + => new TypeSignatureTypedefDeclarationValue(type, alias); + + internal TypedefDeclarationValue CreateClassTypedef( + ClassNameValue type, + string alias) + => new ClassTypedefDeclarationValue(type, alias); + + internal TypedefDeclarationValue CreateMemberTypedef( + MemberReferenceValue member, + string alias) + => new MemberTypedefDeclarationValue(member, alias); + + internal TypedefDeclarationValue CreateCustomAttributeTypedefDeclaration( + CustomAttributeDescriptorValue attribute, + IToken location, + string alias) + => new CustomAttributeTypedefDeclarationValue( + attribute, + location, + alias); + + private void MaterializeTypedef(TypedefDeclarationValue declaration) + { + switch (declaration) + { + case TypeSignatureTypedefDeclarationValue type: + BlobBuilder typeBlob = MaterializeType(type.Type); + BlobBuilder copy = new(typeBlob.Count); + typeBlob.WriteContentTo(copy); + _typedefs[type.Alias] = new TypedefEntry.TypeBlob(copy); + break; + case ClassTypedefDeclarationValue type: + _typedefs[type.Alias] = new TypedefEntry.Type(ResolveClassName(type.Type)); + break; + case MemberTypedefDeclarationValue member: + _typedefs[member.Alias] = + new TypedefEntry.Member(MaterializeMemberReference(member.Member)); + break; + case CustomAttributeTypedefDeclarationValue customAttribute: + EntityRegistry.CustomAttributeEntity attribute = + MaterializeCustomAttribute( + customAttribute.Attribute, + customAttribute.Location); + _typedefs[customAttribute.Alias] = + new TypedefEntry.CustomAttribute(attribute.Constructor, attribute.Value); + break; + } + } + + internal void MaterializeTypedef(CILParser.TypedefDeclContext context) + { + if (context.Value is TypedefDeclarationValue declaration) + { + MaterializeTypedef(declaration); + } + } + + private EntityRegistry.TypeEntity? TryResolveTypedefAsType(string alias) + { + if (_typedefs.TryGetValue(alias, out TypedefEntry? entry) && + entry is TypedefEntry.Type type) + { + return type.Entity; + } + + return null; + } + + private BlobBuilder? TryResolveTypedefAsTypeBlob(string alias) + { + if (!_typedefs.TryGetValue(alias, out TypedefEntry? entry)) + { + return null; + } + + if (entry is TypedefEntry.TypeBlob blob) + { + return blob.Blob; + } + + if (entry is TypedefEntry.Type type) + { + BlobBuilder result = new(5); + result.WriteByte((byte)SignatureTypeKind.Class); + result.WriteTypeEntity(type.Entity); + return result; + } + + return null; + } + + private EntityRegistry.EntityBase? TryResolveTypedefAsMember(string alias) + { + if (_typedefs.TryGetValue(alias, out TypedefEntry? entry) && + entry is TypedefEntry.Member member) + { + return member.Entity; + } + + return null; + } + + private (EntityRegistry.EntityBase Constructor, BlobBuilder Value)? + TryResolveTypedefAsCustomAttribute(string alias) + { + if (_typedefs.TryGetValue(alias, out TypedefEntry? entry) && + entry is TypedefEntry.CustomAttribute customAttribute) + { + return (customAttribute.Constructor, customAttribute.Value); + } + + return null; + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.VTable.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.VTable.cs new file mode 100644 index 00000000000000..8a4f00dba47e65 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Manifest.VTable.cs @@ -0,0 +1,61 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + private readonly List _vtableFixups = new(); + + internal ushort ParseVTableFixupAttribute(IToken token) + => token.Text switch + { + "int32" => VTableFixupSupport.COR_VTABLE_32BIT, + "int64" => VTableFixupSupport.COR_VTABLE_64BIT, + "fromunmanaged" => VTableFixupSupport.COR_VTABLE_FROM_UNMANAGED, + "callmostderived" => VTableFixupSupport.COR_VTABLE_CALL_MOST_DERIVED, + "retainappdomain" => + VTableFixupSupport.COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN, + _ => throw new UnreachableException() + }; + + internal ushort AddVTableFixupAttribute(ushort attributes, ushort value) + => (ushort)(attributes | value); + + internal ushort CompleteVTableFixupAttributes(ushort attributes) + { + const ushort SlotSizeMask = + VTableFixupSupport.COR_VTABLE_32BIT | VTableFixupSupport.COR_VTABLE_64BIT; + return (attributes & SlotSizeMask) == 0 + ? (ushort)(attributes | VTableFixupSupport.COR_VTABLE_32BIT) + : attributes; + } + + internal VTableFixupValue CreateVTableFixup( + IToken slotCount, + ushort flags, + IToken dataLabel) + => new VTableFixupValue(ParseInt32(slotCount), flags, ParseIdentifier(dataLabel)); + + internal RawVTableValue CreateRawVTable(ImmutableArray value) + => new(value); + + internal void MaterializeVTable(CILParser.VtableDeclContext context) + => throw new NotImplementedException( + "raw vtable fixups blob (.vtable) not supported - use .vtfixup instead"); + + internal void MaterializeVTableFixup(CILParser.VtfixupDeclContext context) + { + if (context.Value is VTableFixupValue value) + { + _vtableFixups.Add(new(value.SlotCount, value.Flags, value.DataLabel)); + } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Marshalling.Actions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Marshalling.Actions.cs new file mode 100644 index 00000000000000..f14eccb0e66788 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Marshalling.Actions.cs @@ -0,0 +1,507 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection.Metadata; +using System.Runtime.InteropServices; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + private const byte NativeTypeVoid = 0x01; + private const byte NativeTypeSysChar = 0x0D; + private const byte NativeTypeVariant = 0x0E; + private const byte NativeTypePointer = 0x10; + private const byte NativeTypeDecimal = 0x11; + private const byte NativeTypeDate = 0x12; + private const byte NativeTypeObjectReference = 0x18; + private const byte NativeTypeNestedStruct = 0x21; + private const byte NativeTypeMax = 0x50; + + internal MarshallingDescriptorValue CreateEmptyMarshallingDescriptor() + => MarshallingDescriptorValue.Empty; + + internal MarshallingDescriptorValue CompleteMarshalClause( + MarshallingDescriptorValue value) + => value; + + internal void SetMarshalBlobNativeType( + CILParser.MarshalBlobBuilder builder, + NativeTypeValue value) + => builder.NativeType = value; + + internal void AddMarshalBlobByte(CILParser.MarshalBlobBuilder builder, byte value) + => (builder.RawBytes ??= new BlobBuilder()).WriteByte(value); + + internal MarshallingDescriptorValue CreateMarshallingDescriptor( + CILParser.MarshalBlobBuilder builder) + => new(builder.RawBytes, builder.NativeType); + + internal void SetNativeTypeElement( + CILParser.NativeTypeBuilder builder, + NativeTypeElementValue value) + => builder.Element = value; + + internal void AddNativeTypeArrayPointerInfo( + CILParser.NativeTypeBuilder builder, + NativeTypeArrayPointerInfoValue value) + => (builder.ArrayPointerInfo ??= new List()) + .Add(value); + + internal NativeTypeValue CreateNativeType( + IToken token, + CILParser.NativeTypeBuilder builder) + => new( + token, + builder.Element, + builder.ArrayPointerInfo?.ToImmutableArray() ?? []); + + internal NativeTypeArrayPointerInfoValue CreatePointerNativeType() + => new NativeTypeArrayPointerInfoValue(NativeTypeArrayPointerInfoKind.Pointer); + + internal NativeTypeArrayPointerInfoValue CreatePointerArrayTypeNoSizeData() + => new NativeTypeArrayPointerInfoValue(NativeTypeArrayPointerInfoKind.ArrayNoSizeData); + + internal NativeTypeArrayPointerInfoValue CreatePointerArrayTypeSize(IToken size) + => new NativeTypeArrayPointerInfoValue(NativeTypeArrayPointerInfoKind.ArraySize, Size: size); + + internal NativeTypeArrayPointerInfoValue CreatePointerArrayTypeSizeParamIndex( + IToken size, + IToken parameterIndex) + => new NativeTypeArrayPointerInfoValue( + NativeTypeArrayPointerInfoKind.ArraySizeParamIndex, + size, + parameterIndex); + + internal NativeTypeArrayPointerInfoValue CreatePointerArrayTypeParamIndex( + IToken parameterIndex) + => new NativeTypeArrayPointerInfoValue( + NativeTypeArrayPointerInfoKind.ArrayParamIndex, + ParameterIndex: parameterIndex); + + internal NativeTypeElementValue CreateEmptyNativeType() + => EmptyNativeTypeElementValue.Instance; + + internal NativeTypeElementValue CreateDeprecatedCustomMarshallerNativeType( + CILParser.NativeTypeElementContext context, + string guid, + string nativeTypeName, + string marshallerType, + string cookie) + => new CustomMarshallerNativeTypeElementValue( + context.Start, + guid, + nativeTypeName, + marshallerType, + cookie); + + internal NativeTypeElementValue CreateCustomMarshallerNativeType( + string marshallerType, + string cookie) + => new CustomMarshallerNativeTypeElementValue( + null, + null, + null, + marshallerType, + cookie); + + internal NativeTypeElementValue CreateFixedSysStringNativeType(IToken size) + => new FixedSysStringNativeTypeElementValue(size); + + internal NativeTypeElementValue CreateFixedArrayNativeType( + IToken size, + NativeTypeValue element) + => new FixedArrayNativeTypeElementValue(size, element); + + internal NativeTypeElementValue CreateDeprecatedNativeType( + CILParser.NativeTypeElementContext context, + IToken nativeType) + => new DeprecatedNativeTypeElementValue(context.Start, nativeType.Type); + + internal NativeTypeElementValue CreateSimpleNativeType(IToken nativeType) + => new SimpleNativeTypeElementValue(nativeType.Type); + + internal NativeTypeElementValue CreateIidNativeType( + IToken nativeType, + IidParamIndexValue index) + => new IidNativeTypeElementValue(nativeType.Type, index); + + internal NativeTypeElementValue CreateSafeArrayNativeType( + VariantTypeValue variantType, + string? userDefinedType) + => new SafeArrayNativeTypeElementValue(variantType, userDefinedType); + + internal NativeTypeElementValue CreateUnsignedNativeType(IToken nativeType) + => new UnsignedNativeTypeElementValue(nativeType.Type); + + internal NativeTypeElementValue CreateNestedStructNativeType( + CILParser.NativeTypeElementContext context) + => new NestedStructNativeTypeElementValue(context.Start); + + internal NativeTypeElementValue CreateAnsiBstrNativeType() + => AnsiBstrNativeTypeElementValue.Instance; + + internal NativeTypeElementValue CreateVariantBoolNativeType() + => VariantBoolNativeTypeElementValue.Instance; + + internal NativeTypeElementValue CreateNativeTypeTypedef( + CILParser.NativeTypeElementContext context, + string alias) + => new NativeTypeTypedefValue(context.Start, alias); + + internal IidParamIndexValue GetIidParamIndex(IToken index) + => new(index); + + internal void SetVariantTypeElement( + CILParser.VariantTypeBuilder builder, + VariantTypeElementValue value) + => builder.Element = value; + + internal void AddVariantTypeModifier( + CILParser.VariantTypeBuilder builder, + IToken modifier) + { + builder.Modifiers |= modifier.Type switch + { + CILParser.ARRAY_TYPE_NO_BOUNDS => VarEnum.VT_ARRAY, + CILParser.VECTOR => VarEnum.VT_VECTOR, + CILParser.REF => VarEnum.VT_BYREF, + _ => throw new UnreachableException() + }; + } + + internal VariantTypeValue CreateVariantType(CILParser.VariantTypeBuilder builder) + => new(builder.Element, builder.Modifiers); + + internal VariantTypeElementValue GetVariantTypeElement(IToken variantType) + => new VariantTypeElementValue(variantType.Type); + + private BlobBuilder MaterializeMarshallingDescriptor(MarshallingDescriptorValue? value) + { + if (value?.RawBytes is BlobBuilder rawBytes) + { + return rawBytes; + } + + return MaterializeNativeType(value?.NativeType ?? NativeTypeValue.Empty); + } + + private BlobBuilder MaterializeNativeType(NativeTypeValue value) + { + if (value.Element is null) + { + return new BlobBuilder(); + } + + BlobBuilder element = MaterializeNativeTypeElement(value.Element); + if (value.ArrayPointerInfo.IsDefaultOrEmpty) + { + return element; + } + + BlobBuilder prefix = new(value.ArrayPointerInfo.Length); + BlobBuilder suffix = new(); + + for (int i = value.ArrayPointerInfo.Length - 1; i >= 0; i--) + { + NativeTypeArrayPointerInfoValue info = value.ArrayPointerInfo[i]; + if (info.Kind == NativeTypeArrayPointerInfoKind.Pointer) + { + if (value.Token is IToken token) + { + ReportWarning( + DiagnosticIds.DeprecatedNativeType, + string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "pointer in array"), + token); + } + prefix.WriteByte(NativeTypePointer); + } + else + { + prefix.WriteByte((byte)UnmanagedType.LPArray); + if (element.Count == 0) + { + element.WriteByte(NativeTypeMax); + } + } + } + + foreach (NativeTypeArrayPointerInfoValue info in value.ArrayPointerInfo) + { + switch (info.Kind) + { + case NativeTypeArrayPointerInfoKind.ArraySize: + suffix.WriteCompressedInteger(0); + suffix.WriteCompressedInteger(ParseMarshallingInt32(info.Size)); + suffix.WriteCompressedInteger(0); + break; + case NativeTypeArrayPointerInfoKind.ArraySizeParamIndex: + suffix.WriteCompressedInteger(ParseMarshallingInt32(info.ParameterIndex)); + suffix.WriteCompressedInteger(ParseMarshallingInt32(info.Size)); + suffix.WriteCompressedInteger(1); + break; + case NativeTypeArrayPointerInfoKind.ArrayParamIndex: + suffix.WriteCompressedInteger(ParseMarshallingInt32(info.ParameterIndex)); + break; + } + } + + prefix.LinkSuffix(element); + prefix.LinkSuffix(suffix); + return prefix; + } + + private BlobBuilder MaterializeNativeTypeElement(NativeTypeElementValue value) + { + switch (value) + { + case EmptyNativeTypeElementValue: + return new BlobBuilder(); + case CustomMarshallerNativeTypeElementValue customMarshaller: + return MaterializeCustomMarshallerNativeType(customMarshaller); + case FixedSysStringNativeTypeElementValue fixedSysString: + { + BlobBuilder blob = CreateNativeTypeBlob(UnmanagedType.ByValTStr); + blob.WriteCompressedInteger(ParseInt32(fixedSysString.Size)); + return blob; + } + case FixedArrayNativeTypeElementValue fixedArray: + { + BlobBuilder blob = CreateNativeTypeBlob(UnmanagedType.ByValArray); + blob.WriteCompressedInteger(ParseInt32(fixedArray.Size)); + MaterializeNativeType(fixedArray.Element).WriteContentTo(blob); + return blob; + } + case DeprecatedNativeTypeElementValue deprecated: + return MaterializeDeprecatedNativeType(deprecated); + case SimpleNativeTypeElementValue simple: + return CreateNativeTypeBlob(GetSimpleNativeType(simple.TokenType)); + case IidNativeTypeElementValue iid: + return MaterializeIidNativeType(iid); + case SafeArrayNativeTypeElementValue safeArray: + return MaterializeSafeArrayNativeType(safeArray); + case UnsignedNativeTypeElementValue unsigned: + return CreateNativeTypeBlob(GetUnsignedNativeType(unsigned.TokenType)); + case NestedStructNativeTypeElementValue nestedStruct: + ReportWarning( + DiagnosticIds.DeprecatedNativeType, + string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "NESTEDSTRUCT"), + nestedStruct.Token); + return CreateNativeTypeBlob(NativeTypeNestedStruct); + case AnsiBstrNativeTypeElementValue: +#pragma warning disable CS0618 // Preserve the legacy IL native type spelling. + return CreateNativeTypeBlob(UnmanagedType.AnsiBStr); +#pragma warning restore CS0618 + case VariantBoolNativeTypeElementValue: + return CreateNativeTypeBlob(UnmanagedType.VariantBool); + case NativeTypeTypedefValue typedef: + ReportError( + DiagnosticIds.TypedefNotFound, + string.Format(DiagnosticMessageTemplates.TypedefNotFound, typedef.Alias), + typedef.Token); + return new BlobBuilder(); + default: + throw new UnreachableException(); + } + } + + private BlobBuilder MaterializeCustomMarshallerNativeType( + CustomMarshallerNativeTypeElementValue customMarshaller) + { + BlobBuilder blob = CreateNativeTypeBlob(UnmanagedType.CustomMarshaler); + if (customMarshaller.Guid is not null) + { + if (customMarshaller.Token is IToken token) + { + ReportWarning( + DiagnosticIds.DeprecatedCustomMarshaller, + DiagnosticMessageTemplates.DeprecatedCustomMarshaller, + token); + } + blob.WriteSerializedString(customMarshaller.Guid); + blob.WriteSerializedString(customMarshaller.NativeTypeName); + } + else + { + blob.WriteCompressedInteger(0); + blob.WriteCompressedInteger(0); + } + + blob.WriteSerializedString(customMarshaller.MarshallerType); + blob.WriteSerializedString(customMarshaller.Cookie); + return blob; + } + + private BlobBuilder MaterializeDeprecatedNativeType(DeprecatedNativeTypeElementValue deprecated) + { + (byte value, string name) = deprecated.TokenType switch + { + CILParser.VARIANT => (NativeTypeVariant, "VARIANT"), + CILParser.SYSCHAR => (NativeTypeSysChar, "SYSCHAR"), + CILParser.VOID => (NativeTypeVoid, "VOID"), + CILParser.DECIMAL => (NativeTypeDecimal, "DECIMAL"), + CILParser.DATE => (NativeTypeDate, "DATE"), + CILParser.OBJECTREF => (NativeTypeObjectReference, "OBJECTREF"), + _ => throw new UnreachableException() + }; + + ReportWarning( + DiagnosticIds.DeprecatedNativeType, + string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, name), + deprecated.Token); + return CreateNativeTypeBlob(value); + } + + private BlobBuilder MaterializeIidNativeType(IidNativeTypeElementValue iid) + { + UnmanagedType nativeType = iid.TokenType switch + { + CILParser.IUNKNOWN => UnmanagedType.IUnknown, + CILParser.IDISPATCH => UnmanagedType.IDispatch, + CILParser.INTERFACE => UnmanagedType.Interface, + _ => throw new UnreachableException() + }; + + BlobBuilder blob = CreateNativeTypeBlob(nativeType); + if (MaterializeIidParamIndex(iid.IidParamIndex) is int parameterIndex) + { + blob.WriteCompressedInteger(parameterIndex); + } + return blob; + } + + private BlobBuilder MaterializeSafeArrayNativeType(SafeArrayNativeTypeElementValue safeArray) + { + BlobBuilder blob = CreateNativeTypeBlob(UnmanagedType.SafeArray); + blob.WriteCompressedInteger((int)MaterializeVariantType(safeArray.VariantType)); + if (safeArray.UserDefinedType is null) + { + blob.WriteCompressedInteger(0); + } + else + { + blob.WriteSerializedString(safeArray.UserDefinedType); + } + return blob; + } + + private int? MaterializeIidParamIndex(IidParamIndexValue value) + => value.Index is null ? null : ParseInt32(value.Index); + + private VarEnum MaterializeVariantType(VariantTypeValue value) + => value.Element is null + ? VarEnum.VT_EMPTY + : MaterializeVariantTypeElement(value.Element) | value.Modifiers; + + private static VarEnum MaterializeVariantTypeElement(VariantTypeElementValue value) + => value.TokenType switch + { + CILParser.NULL => VarEnum.VT_EMPTY, + CILParser.VARIANT => VarEnum.VT_VARIANT, + CILParser.CURRENCY => VarEnum.VT_CY, + CILParser.VOID => VarEnum.VT_VOID, + CILParser.BOOL => VarEnum.VT_BOOL, + CILParser.INT8 => VarEnum.VT_I1, + CILParser.INT16 => VarEnum.VT_I2, + CILParser.INT32_ => VarEnum.VT_I4, + CILParser.INT64_ => VarEnum.VT_I8, + CILParser.FLOAT32 => VarEnum.VT_R4, + CILParser.FLOAT64_ => VarEnum.VT_R8, + CILParser.UINT8 => VarEnum.VT_UI1, + CILParser.UINT16 => VarEnum.VT_UI2, + CILParser.UINT32 => VarEnum.VT_UI4, + CILParser.UINT64 => VarEnum.VT_UI8, + CILParser.PTR => VarEnum.VT_PTR, + CILParser.DECIMAL => VarEnum.VT_DECIMAL, + CILParser.DATE => VarEnum.VT_DATE, + CILParser.BSTR => VarEnum.VT_BSTR, + CILParser.LPSTR => VarEnum.VT_LPSTR, + CILParser.LPWSTR => VarEnum.VT_LPWSTR, + CILParser.IUNKNOWN => VarEnum.VT_UNKNOWN, + CILParser.IDISPATCH => VarEnum.VT_DISPATCH, + CILParser.SAFEARRAY => VarEnum.VT_SAFEARRAY, + CILParser.INT => VarEnum.VT_INT, + CILParser.UINT => VarEnum.VT_UINT, + CILParser.ERROR => VarEnum.VT_ERROR, + CILParser.HRESULT => VarEnum.VT_HRESULT, + CILParser.CARRAY => VarEnum.VT_CARRAY, + CILParser.USERDEFINED => VarEnum.VT_USERDEFINED, + CILParser.RECORD => VarEnum.VT_RECORD, + CILParser.FILETIME => VarEnum.VT_FILETIME, + CILParser.BLOB => VarEnum.VT_BLOB, + CILParser.STREAM => VarEnum.VT_STREAM, + CILParser.STORAGE => VarEnum.VT_STORAGE, + CILParser.STREAMED_OBJECT => VarEnum.VT_STREAMED_OBJECT, + CILParser.STORED_OBJECT => VarEnum.VT_STORED_OBJECT, + CILParser.BLOB_OBJECT => VarEnum.VT_BLOB_OBJECT, + CILParser.CF => VarEnum.VT_CF, + CILParser.CLSID => VarEnum.VT_CLSID, + TokenConstants.InvalidType => VarEnum.VT_EMPTY, + _ => throw new UnreachableException() + }; + + private static UnmanagedType GetSimpleNativeType(int tokenType) + { +#pragma warning disable CS0618 // Preserve the legacy IL native type spellings. + return tokenType switch + { + CILParser.CURRENCY => UnmanagedType.Currency, + CILParser.BOOL => UnmanagedType.Bool, + CILParser.INT8 => UnmanagedType.I1, + CILParser.INT16 => UnmanagedType.I2, + CILParser.INT32_ => UnmanagedType.I4, + CILParser.INT64_ => UnmanagedType.I8, + CILParser.FLOAT32 => UnmanagedType.R4, + CILParser.FLOAT64_ => UnmanagedType.R8, + CILParser.ERROR => UnmanagedType.Error, + CILParser.UINT8 => UnmanagedType.U1, + CILParser.UINT16 => UnmanagedType.U2, + CILParser.UINT32 => UnmanagedType.U4, + CILParser.UINT64 => UnmanagedType.U8, + CILParser.BSTR => UnmanagedType.BStr, + CILParser.LPSTR => UnmanagedType.LPStr, + CILParser.LPWSTR => UnmanagedType.LPWStr, + CILParser.LPTSTR => UnmanagedType.LPTStr, + CILParser.STRUCT => UnmanagedType.Struct, + CILParser.INT => UnmanagedType.SysInt, + CILParser.UINT => UnmanagedType.SysUInt, + CILParser.BYVALSTR => UnmanagedType.VBByRefStr, + CILParser.TBSTR => UnmanagedType.TBStr, + CILParser.METHOD => UnmanagedType.FunctionPtr, + CILParser.LPSTRUCT => UnmanagedType.LPStruct, + CILParser.ANY => UnmanagedType.AsAny, + _ => throw new UnreachableException() + }; +#pragma warning restore CS0618 + } + + private static UnmanagedType GetUnsignedNativeType(int tokenType) + => tokenType switch + { + CILParser.INT8 => UnmanagedType.U1, + CILParser.INT16 => UnmanagedType.U2, + CILParser.INT32_ => UnmanagedType.U4, + CILParser.INT64_ => UnmanagedType.U8, + _ => throw new UnreachableException() + }; + + private static BlobBuilder CreateNativeTypeBlob(UnmanagedType value) + => CreateNativeTypeBlob((byte)value); + + private static BlobBuilder CreateNativeTypeBlob(byte value) + { + BlobBuilder blob = new(1); + blob.WriteByte(value); + return blob; + } + + private int ParseMarshallingInt32(IToken? token) + => token is null ? 0 : ParseInt32(token); + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.Class.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.Class.cs new file mode 100644 index 00000000000000..f236a40839d786 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.Class.cs @@ -0,0 +1,488 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + private readonly Dictionary< + EntityRegistry.TypeDefinitionEntity, + List> _pendingClassMethodOverrides = new(); + + private sealed record PendingClassMethodOverride( + EntityRegistry.MemberReferenceEntity Declaration, + EntityRegistry.MemberReferenceEntity? ReferencedBody, + string BodyName, + BlobBuilder BodySignature, + IToken Location); + + private void PrepareClassMember() + { + _pendingClassCustomAttributeOwner = null; + } + + internal void ProcessClassDataDeclaration(CILParser.DataDeclContext context) + { + PrepareClassMember(); + _ = context; + } + + internal void ProcessClassSecurityDeclaration(CILParser.SecDeclContext context) + { + PrepareClassMember(); + if (context.HasSyntaxError) + { + return; + } + + EntityRegistry.DeclarativeSecurityAttributeEntity? security = MaterializeSecurityDeclaration(context); + security?.Parent = _currentTypeDefinition.PeekOrDefault(); + } + + internal void ProcessClassSourceDirective(CILParser.ExtSourceSpecContext context) + { + PrepareClassMember(); + _ = context; + } + + internal void ProcessClassLanguageDirective(CILParser.LanguageDeclContext context) + { + PrepareClassMember(); + _ = context; + } + + internal void ProcessClassCustomAttribute(CILParser.CustomAttrDeclContext context) + { + if (context.HasSyntaxError) + { + return; + } + + if (MaterializeCustomAttributeDeclaration(context) is { } customAttribute) + { + customAttribute.Owner = + _pendingClassCustomAttributeOwner ?? + _currentTypeDefinition.PeekOrDefault(); + } + } + + internal void SetClassSize(IToken token) + { + PrepareClassMember(); + if (_currentTypeDefinition.PeekOrDefault() is { } currentType) + { + currentType.ClassSize = ParseInt32(token); + } + } + + internal void SetClassPackingSize(IToken token) + { + PrepareClassMember(); + if (_currentTypeDefinition.PeekOrDefault() is { } currentType) + { + currentType.PackingSize = ParseInt32(token); + } + } + + internal void ProcessClassExport( + CILParser.ExportHeadContext export, + CILParser.ExptypeDeclsContext declarations) + { + PrepareClassMember(); + _ = export; + _ = declarations; + } + + internal void ProcessClassCompilerControl() + { + PrepareClassMember(); + } + + internal void AddClassMethodOverride( + CILParser.ClassDeclContext context, + TypeSpecificationValue declarationOwner, + string declarationName, + byte bodyCallingConvention, + TypeValue bodyReturnType, + TypeSpecificationValue bodyOwner, + string bodyName, + ImmutableArray bodyArguments) + { + PrepareClassMember(); + AddClassMethodOverrideCore( + context, + bodyCallingConvention, + bodyReturnType, + declarationOwner, + declarationName, + 0, + bodyArguments, + bodyCallingConvention, + bodyReturnType, + bodyOwner, + bodyName, + 0, + bodyArguments); + } + + internal void AddClassMethodOverride( + CILParser.ClassDeclContext context, + byte declarationCallingConvention, + TypeValue declarationReturnType, + TypeSpecificationValue declarationOwner, + string declarationName, + int declarationArity, + ImmutableArray declarationArguments, + byte bodyCallingConvention, + TypeValue bodyReturnType, + TypeSpecificationValue bodyOwner, + string bodyName, + int bodyArity, + ImmutableArray bodyArguments) + { + PrepareClassMember(); + AddClassMethodOverrideCore( + context, + declarationCallingConvention, + declarationReturnType, + declarationOwner, + declarationName, + declarationArity, + declarationArguments, + bodyCallingConvention, + bodyReturnType, + bodyOwner, + bodyName, + bodyArity, + bodyArguments); + } + + private void AddClassMethodOverrideCore( + CILParser.ClassDeclContext context, + byte declarationCallingConvention, + TypeValue declarationReturnType, + TypeSpecificationValue declarationOwner, + string declarationName, + int declarationArity, + ImmutableArray declarationArguments, + byte bodyCallingConvention, + TypeValue bodyReturnType, + TypeSpecificationValue bodyOwner, + string bodyName, + int bodyArity, + ImmutableArray bodyArguments) + { + if (_currentTypeDefinition.PeekOrDefault() is not { } currentType) + { + return; + } + + BlobBuilder declarationSignature = BuildClassMethodOverrideSignature( + declarationCallingConvention, + declarationReturnType, + declarationArguments, + declarationArity); + BlobBuilder bodySignature = BuildClassMethodOverrideSignature( + bodyCallingConvention, + bodyReturnType, + bodyArguments, + bodyArity); + + EntityRegistry.MemberReferenceEntity declaration = + _entityRegistry.CreateLazilyRecordedMemberReference( + ResolveTypeSpecification(declarationOwner), + declarationName, + declarationSignature); + EntityRegistry.TypeEntity resolvedBodyOwner = + ResolveTypeSpecification(bodyOwner); + EntityRegistry.MemberReferenceEntity? referencedBody = + ReferenceEquals(resolvedBodyOwner, currentType) + ? null + : _entityRegistry.CreateLazilyRecordedMemberReference( + resolvedBodyOwner, + bodyName, + bodySignature); + + if (!_pendingClassMethodOverrides.TryGetValue( + currentType, + out List? pendingOverrides)) + { + pendingOverrides = new(); + _pendingClassMethodOverrides.Add(currentType, pendingOverrides); + } + + pendingOverrides.Add( + new( + declaration, + referencedBody, + bodyName, + bodySignature, + context.Start)); + } + + private void CompleteClassMethodOverrides(EntityRegistry.TypeDefinitionEntity type) + { + if (!_pendingClassMethodOverrides.Remove( + type, + out List? pendingOverrides)) + { + return; + } + + foreach (PendingClassMethodOverride pending in pendingOverrides) + { + if (pending.ReferencedBody is { } referencedBody) + { + type.MethodImplementations.Add( + EntityRegistry.CreateUnrecordedMethodImplementation( + type, + referencedBody, + pending.Declaration)); + continue; + } + + EntityRegistry.MethodDefinitionEntity? bodyMethod = null; + bool isAmbiguous = false; + foreach (EntityRegistry.MethodDefinitionEntity candidate in type.Methods) + { + if (candidate.Name != pending.BodyName || + candidate.MethodSignature is null || + !candidate.MethodSignature.ContentEquals(pending.BodySignature)) + { + continue; + } + + if (bodyMethod is not null) + { + isAmbiguous = true; + break; + } + + bodyMethod = candidate; + } + + if (bodyMethod is null || isAmbiguous) + { + ReportError( + DiagnosticIds.InvalidMetadataToken, + $"Override body method '{pending.BodyName}' could not be resolved uniquely", + pending.Location); + continue; + } + + type.MethodImplementations.Add( + EntityRegistry.CreateUnrecordedMethodImplementation( + bodyMethod, + pending.Declaration)); + } + } + + private BlobBuilder BuildClassMethodOverrideSignature( + byte callingConvention, + TypeValue returnType, + ImmutableArray arguments, + int genericArity) + { + BlobBuilder signature = new(); + byte header = callingConvention; + if (genericArity > 0) + { + header |= (byte)SignatureAttributes.Generic; + } + signature.WriteByte(header); + if (genericArity > 0) + { + signature.WriteCompressedInteger(genericArity); + } + + ImmutableArray materializedArguments = + MaterializeSignatureArguments(arguments); + int parameterCount = 0; + foreach (SignatureArg argument in materializedArguments) + { + if (!argument.IsSentinel) + { + parameterCount++; + } + } + signature.WriteCompressedInteger(parameterCount); + MaterializeType(returnType).WriteContentTo(signature); + foreach (SignatureArg argument in materializedArguments) + { + argument.SignatureBlob.WriteContentTo(signature); + } + + return signature; + } + + internal CILParser.CustomAttributeOwnerValue BeginClassGenericParameterDirective( + CILParser.ClassDeclContext context, + IToken index) + { + PrepareClassMember(); + return BeginClassGenericDirective( + FindClassGenericParameter(context, ParseInt32(index))); + } + + internal CILParser.CustomAttributeOwnerValue BeginClassGenericParameterDirective( + string name) + { + PrepareClassMember(); + return BeginClassGenericDirective(FindClassGenericParameter(name)); + } + + internal CILParser.CustomAttributeOwnerValue BeginClassGenericConstraintDirective( + CILParser.ClassDeclContext context, + IToken index, + TypeSpecificationValue constraintType) + { + PrepareClassMember(); + return BeginClassGenericDirective( + FindOrCreateClassGenericConstraint( + FindClassGenericParameter(context, ParseInt32(index)), + constraintType)); + } + + internal CILParser.CustomAttributeOwnerValue BeginClassGenericConstraintDirective( + string name, + TypeSpecificationValue constraintType) + { + PrepareClassMember(); + return BeginClassGenericDirective( + FindOrCreateClassGenericConstraint( + FindClassGenericParameter(name), + constraintType)); + } + + private CILParser.CustomAttributeOwnerValue BeginClassGenericDirective( + EntityRegistry.EntityBase? owner) + { + _pendingClassCustomAttributeOwner = owner; + return new CILParser.CustomAttributeOwnerValue(owner); + } + + internal void AddClassGenericDirectiveAttribute( + CILParser.CustomAttributeOwnerValue ownerValue, + CILParser.CustomAttrDeclContext attribute) + { + if (attribute.HasSyntaxError || + ownerValue.Owner is not { } owner) + { + return; + } + + if (MaterializeCustomAttributeDeclaration(attribute) is { } customAttribute) + { + customAttribute.Owner = owner; + } + } + + private EntityRegistry.GenericParameterEntity? FindClassGenericParameter( + CILParser.ClassDeclContext context, + int index) + { + EntityRegistry.TypeDefinitionEntity? currentType = _currentTypeDefinition.PeekOrDefault(); + if (currentType is not null && + index >= 0 && + index < currentType.GenericParameters.Count) + { + return currentType.GenericParameters[index]; + } + + ReportError( + DiagnosticIds.GenericParameterIndexOutOfRange, + string.Format(DiagnosticMessageTemplates.GenericParameterIndexOutOfRange, index), + context); + return null; + } + + private EntityRegistry.GenericParameterEntity? FindClassGenericParameter(string name) + { + EntityRegistry.TypeDefinitionEntity? currentType = _currentTypeDefinition.PeekOrDefault(); + if (currentType is null) + { + return null; + } + + foreach (EntityRegistry.GenericParameterEntity parameter in currentType.GenericParameters) + { + if (parameter.Name == name) + { + return parameter; + } + } + + return null; + } + + private EntityRegistry.GenericParameterConstraintEntity? FindOrCreateClassGenericConstraint( + EntityRegistry.GenericParameterEntity? parameter, + TypeSpecificationValue constraintType) + { + if (parameter is null || + _currentTypeDefinition.PeekOrDefault() is not { } currentType) + { + return null; + } + + EntityRegistry.TypeEntity baseType = + ResolveTypeSpecification(constraintType); + foreach (EntityRegistry.GenericParameterConstraintEntity constraint in parameter.Constraints) + { + if (constraint.BaseType == baseType) + { + return constraint; + } + } + + EntityRegistry.GenericParameterConstraintEntity newConstraint = + EntityRegistry.CreateGenericConstraint(baseType); + newConstraint.Owner = parameter; + parameter.Constraints.Add(newConstraint); + currentType.GenericParameterConstraints.Add(newConstraint); + return newConstraint; + } + + internal void AddInterfaceImplementationAttribute( + CILParser.ClassDeclContext context, + TypeSpecificationValue interfaceType, + CILParser.CustomDescrContext attribute) + { + PrepareClassMember(); + if (attribute.HasSyntaxError || + _currentTypeDefinition.PeekOrDefault() is not { } currentType) + { + return; + } + + EntityRegistry.TypeEntity resolvedInterface = + ResolveTypeSpecification(interfaceType); + EntityRegistry.InterfaceImplementationEntity? implementation = null; + foreach (EntityRegistry.InterfaceImplementationEntity candidate in currentType.InterfaceImplementations) + { + if (candidate.InterfaceType == resolvedInterface) + { + implementation = candidate; + break; + } + } + + if (implementation is null) + { + implementation = + EntityRegistry.CreateUnrecordedInterfaceImplementation(currentType, resolvedInterface); + currentType.InterfaceImplementations.Add(implementation); + } + + MaterializeCustomAttributeDescriptor(attribute).Owner = implementation; + _ = context; + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.Fields.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.Fields.cs new file mode 100644 index 00000000000000..9324ac304efb38 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.Fields.cs @@ -0,0 +1,166 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Globalization; +using System.Reflection; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal CILParser.FieldDeclarationBuilder PrepareFieldDeclaration() + { + ClearPendingCustomAttributeOwners(); + return new CILParser.FieldDeclarationBuilder(); + } + + internal void AddFieldAttribute( + CILParser.FieldDeclarationBuilder builder, + CILParser.AttributeValue value) + => builder.Attributes = ApplyAttribute(builder.Attributes, value); + + internal void SetFieldMarshalling( + CILParser.FieldDeclarationBuilder builder, + MarshallingDescriptorValue value) + => builder.Marshalling = value; + + internal FieldDeclarationValue CreateFieldDeclaration( + CILParser.FieldDeclContext context, + CILParser.FieldDeclarationBuilder builder, + int initialSyntaxErrorCount, + CILParser.RepeatOptContext offset, + TypeValue fieldType, + string name, + string? dataDeclarationName, + FieldInitializerValue initializer) + { + if (HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null) + { + return FieldDeclarationValue.Error; + } + + FieldAttributes attributes = builder.Attributes; + if (attributes.HasFlag(FieldAttributes.RTSpecialName)) + { + attributes |= FieldAttributes.SpecialName; + } + + return new FieldDeclarationValue( + true, + attributes, + fieldType, + name, + builder.Marshalling, + dataDeclarationName, + offset.HasValue ? offset.Value : null, + initializer); + } + + internal void DefineField( + CILParser.FieldDeclContext context, + FieldDeclarationValue value) + { + _ = context; + if (!value.IsValid) + { + return; + } + + FieldDeclarationValue declaration = value; + + BlobBuilder signature = new(); + _ = new BlobEncoder(signature).Field(); + MaterializeType(declaration.FieldType).WriteContentTo(signature); + + EntityRegistry.FieldDefinitionEntity? field = + EntityRegistry.CreateUnrecordedFieldDefinition( + declaration.Attributes, + _currentTypeDefinition.PeekOrDefault() ?? _entityRegistry.ModuleType, + declaration.Name, + signature); + _lastFieldDefinition = field; + _pendingClassCustomAttributeOwner = field; + + if (field is null) + { + return; + } + + field.MarshallingDescriptor = MaterializeMarshallingDescriptor(declaration.Marshalling); + field.DataDeclarationName = declaration.DataDeclarationName; + field.Offset = declaration.Offset; + if (declaration.Initializer.HasValue) + { + field.ConstantValue = declaration.Initializer.ConstantValue; + field.HasConstant = true; + } + } + + internal CILParser.AttributeValue CreateFieldAttribute(IToken token) + => token.Text switch + { + "static" => new CILParser.AttributeValue(FieldAttributes.Static, 0, true), + "public" => new CILParser.AttributeValue( + FieldAttributes.Public, + FieldAttributes.FieldAccessMask, + true), + "private" => new CILParser.AttributeValue( + FieldAttributes.Private, + FieldAttributes.FieldAccessMask, + true), + "family" => new CILParser.AttributeValue( + FieldAttributes.Family, + FieldAttributes.FieldAccessMask, + true), + "initonly" => new CILParser.AttributeValue(FieldAttributes.InitOnly, 0, true), + "rtspecialname" => new CILParser.AttributeValue(FieldAttributes.RTSpecialName, 0, true), + "specialname" => new CILParser.AttributeValue(FieldAttributes.SpecialName, 0, true), + "assembly" => new CILParser.AttributeValue( + FieldAttributes.Assembly, + FieldAttributes.FieldAccessMask, + true), + "famandassem" => new CILParser.AttributeValue( + FieldAttributes.FamANDAssem, + FieldAttributes.FieldAccessMask, + true), + "famorassem" => new CILParser.AttributeValue( + FieldAttributes.FamORAssem, + FieldAttributes.FieldAccessMask, + true), + "privatescope" => new CILParser.AttributeValue( + FieldAttributes.PrivateScope, + FieldAttributes.FieldAccessMask, + true), + "literal" => new CILParser.AttributeValue(FieldAttributes.Literal, 0, true), +#pragma warning disable SYSLIB0050 + "notserialized" => new CILParser.AttributeValue(FieldAttributes.NotSerialized, 0, true), +#pragma warning restore SYSLIB0050 + "volatile" => new CILParser.AttributeValue(0, 0, true), + _ => throw new UnreachableException(), + }; + + internal CILParser.AttributeValue CreateRawFieldAttribute(IToken token) + => new((FieldAttributes)ParseInt32(token), 0, false); + + internal string GetFieldDataName(IToken token) + => ParseIdentifier(token); + + internal string GetFieldDataOffset(IToken token) + => ParseInt32(token).ToString(CultureInfo.InvariantCulture); + + internal void SetFieldOffset(CILParser.RepeatOptContext context, IToken token) + { + context.Value = ParseInt32(token); + context.HasValue = true; + } + + internal EntityRegistry.EntityBase MaterializeFieldReference( + CILParser.FieldRefContext context) + => MaterializeFieldReference(context.Value); +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.PropertiesEvents.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.PropertiesEvents.cs new file mode 100644 index 00000000000000..a86b8e78b80803 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Members.PropertiesEvents.cs @@ -0,0 +1,254 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Reflection; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal void AddPropertyAttribute( + CILParser.PropertyHeaderBuilder builder, + CILParser.AttributeValue value) + => builder.Attributes = ApplyAttribute(builder.Attributes, value); + + internal PropertyHeaderValue CreatePropertyHeader( + CILParser.PropHeadContext context, + CILParser.PropertyHeaderBuilder builder, + int initialSyntaxErrorCount, + byte callingConvention, + TypeValue propertyType, + string name, + System.Collections.Immutable.ImmutableArray arguments, + FieldInitializerValue initializer) + { + if (HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null) + { + return PropertyHeaderValue.Error; + } + + return new PropertyHeaderValue( + true, + builder.Attributes, + callingConvention, + propertyType, + name, + arguments, + initializer); + } + + internal CILParser.AttributeValue CreatePropertyAttribute(IToken token) + => token.Text switch + { + "specialname" => new CILParser.AttributeValue( + PropertyAttributes.SpecialName, + 0, + true), + "rtspecialname" => new CILParser.AttributeValue(0, 0, true), + _ => throw new UnreachableException(), + }; + + internal CILParser.PropertyBodyValue BeginProperty(PropertyHeaderValue value) + { + PrepareClassMember(); + EntityRegistry.PropertyEntity? property = null; + if (value.IsValid && _currentTypeDefinition.PeekOrDefault() is { } currentType) + { + BlobBuilder signature = new(); + signature.WriteByte( + (byte)(value.CallingConvention | (byte)SignatureKind.Property)); + signature.WriteCompressedInteger(value.Arguments.Length); + MaterializeType(value.PropertyType).WriteContentTo(signature); + foreach (SignatureArgumentValue argument in value.Arguments) + { + MaterializeSignatureArgument(argument).SignatureBlob.WriteContentTo(signature); + } + + property = new EntityRegistry.PropertyEntity(value.Attributes, signature, value.Name); + if (value.Initializer.HasValue) + { + property.ConstantValue = value.Initializer.ConstantValue; + property.HasConstant = true; + property.Attributes |= PropertyAttributes.HasDefault; + } + + currentType.Properties.Add(property); + } + + return new CILParser.PropertyBodyValue(property); + } + + internal void AddPropertySetter( + CILParser.PropertyBodyValue body, + MethodReferenceValue value) + => AddPropertyAccessor(body, MethodSemanticsAttributes.Setter, value); + + internal void AddPropertyGetter( + CILParser.PropertyBodyValue body, + MethodReferenceValue value) + => AddPropertyAccessor(body, MethodSemanticsAttributes.Getter, value); + + internal void AddPropertyOther( + CILParser.PropertyBodyValue body, + MethodReferenceValue value) + => AddPropertyAccessor(body, MethodSemanticsAttributes.Other, value); + + private void AddPropertyAccessor( + CILParser.PropertyBodyValue body, + MethodSemanticsAttributes semantics, + MethodReferenceValue value) + { + if (body.Property is { } property) + { + property.Accessors.Add( + (semantics, MaterializeMethodReference(value))); + } + } + + internal void AddPropertyCustomAttribute( + CILParser.PropertyBodyValue body, + CILParser.CustomAttrDeclContext attribute) + { + if (attribute.HasSyntaxError || + body.Property is not { } property) + { + return; + } + + if (MaterializeCustomAttributeDeclaration(attribute) is { } customAttribute) + { + customAttribute.Owner = property; + } + } + + internal void ProcessPropertySourceDirective( + CILParser.PropertyBodyValue body, + CILParser.ExtSourceSpecContext context) + { + _ = body; + _ = context; + } + + internal void ProcessPropertyLanguageDirective( + CILParser.PropertyBodyValue body, + CILParser.LanguageDeclContext context) + { + _ = body; + _ = context; + } + + internal void AddEventAttribute( + CILParser.EventHeaderBuilder builder, + CILParser.AttributeValue value) + => builder.Attributes = ApplyAttribute(builder.Attributes, value); + + internal EventHeaderValue CreateEventHeader( + CILParser.EventHeadContext context, + CILParser.EventHeaderBuilder builder, + int initialSyntaxErrorCount, + TypeSpecificationValue? eventType, + string name) + { + if (HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null) + { + return EventHeaderValue.Error; + } + + return new EventHeaderValue( + true, + builder.Attributes, + eventType, + name); + } + + internal CILParser.AttributeValue CreateEventAttribute(IToken token) + => token.Text switch + { + "specialname" => new CILParser.AttributeValue( + EventAttributes.SpecialName, + 0, + true), + "rtspecialname" => new CILParser.AttributeValue(0, 0, true), + _ => throw new UnreachableException(), + }; + + internal CILParser.EventBodyValue BeginEvent(EventHeaderValue value) + { + PrepareClassMember(); + EntityRegistry.EventEntity? @event = null; + if (value.IsValid && _currentTypeDefinition.PeekOrDefault() is { } currentType) + { + @event = new EntityRegistry.EventEntity( + value.Attributes, + value.EventType is null + ? null + : ResolveTypeSpecification(value.EventType), + value.Name); + currentType.Events.Add(@event); + } + + return new CILParser.EventBodyValue(@event); + } + + internal void AddEventAdder(CILParser.EventBodyValue body, MethodReferenceValue value) + => AddEventAccessor(body, MethodSemanticsAttributes.Adder, value); + + internal void AddEventRemover(CILParser.EventBodyValue body, MethodReferenceValue value) + => AddEventAccessor(body, MethodSemanticsAttributes.Remover, value); + + internal void AddEventRaiser(CILParser.EventBodyValue body, MethodReferenceValue value) + => AddEventAccessor(body, MethodSemanticsAttributes.Raiser, value); + + internal void AddEventOther(CILParser.EventBodyValue body, MethodReferenceValue value) + => AddEventAccessor(body, MethodSemanticsAttributes.Other, value); + + private void AddEventAccessor( + CILParser.EventBodyValue body, + MethodSemanticsAttributes semantics, + MethodReferenceValue value) + { + if (body.Event is { } @event) + { + @event.Accessors.Add( + (semantics, MaterializeMethodReference(value))); + } + } + + internal void AddEventCustomAttribute( + CILParser.EventBodyValue body, + CILParser.CustomAttrDeclContext attribute) + { + if (attribute.HasSyntaxError || + body.Event is not { } @event) + { + return; + } + + if (MaterializeCustomAttributeDeclaration(attribute) is { } customAttribute) + { + customAttribute.Owner = @event; + } + } + + internal void ProcessEventSourceDirective( + CILParser.EventBodyValue body, + CILParser.ExtSourceSpecContext context) + { + _ = body; + _ = context; + } + + internal void ProcessEventLanguageDirective( + CILParser.EventBodyValue body, + CILParser.LanguageDeclContext context) + { + _ = body; + _ = context; + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.Directives.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.Directives.cs new file mode 100644 index 00000000000000..f6a3e764b447f1 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.Directives.cs @@ -0,0 +1,355 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + internal void EndLocalsDirective( + CILParser.LocalsDeclContext context, + int initialSyntaxErrorCount) + { + bool hasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (hasSyntaxError || _currentMethod is null || context.arguments is null) + { + return; + } + + if (context.initialize is not null) + { + _currentMethod.Definition.BodyAttributes = MethodBodyAttributes.InitLocals; + } + + Dictionary localsScope; + if (_currentMethod.LocalsScopes.Count > 0) + { + localsScope = _currentMethod.LocalsScopes[^1]; + } + else + { + localsScope = new(); + _currentMethod.LocalsScopes.Add(localsScope); + } + + ImmutableArray locals = + MaterializeSignatureArguments(context.arguments.Value); + foreach (SignatureArg local in locals) + { + if (local.Name is not null) + { + localsScope.TryAdd(local.Name, _currentMethod.AllLocals.Count); + } + + _currentMethod.AllLocals.Add(local); + } + } + + internal void EndExportDirective( + CILParser.ExportDeclContext context, + int initialSyntaxErrorCount) + { + bool hasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (hasSyntaxError || _currentMethod is null || context.ordinal is null) + { + return; + } + + _currentMethod.Definition.ExportOrdinal = ParseInt32(context.ordinal.Start); + _currentMethod.Definition.ExportAlias = + context.alias is null ? null : ParseIdentifier(context.alias.Start); + } + + internal void EndVTableEntryDirective( + CILParser.VtentryDeclContext context, + int initialSyntaxErrorCount) + { + bool hasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (hasSyntaxError || _currentMethod is null || context.table is null || context.slot is null) + { + return; + } + + _currentMethod.Definition.VTableEntry = ParseInt32(context.table.Start); + _currentMethod.Definition.VTableSlot = ParseInt32(context.slot.Start); + } + + internal void EndOverrideDirective( + CILParser.OverrideDeclContext context, + int initialSyntaxErrorCount) + { + bool hasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (hasSyntaxError || + _currentMethod is null || + context.owner is null || + context.name is null || + _currentTypeDefinition.PeekOrDefault() is not { } currentType) + { + return; + } + + BlobBuilder signature = _currentMethod.Definition.MethodSignature!; + if (context.convention is not null) + { + if (context.returnType is null || context.arity is null || context.arguments is null) + { + return; + } + + signature = BuildOverrideSignature( + context.convention.Value, + context.returnType.Value, + context.arity.Value, + context.arguments.Value); + } + + EntityRegistry.TypeEntity owner = + ResolveTypeSpecification(context.owner.Value); + EntityRegistry.MemberReferenceEntity declaration = + _entityRegistry.CreateLazilyRecordedMemberReference(owner, context.name.Value, signature); + currentType.MethodImplementations.Add( + EntityRegistry.CreateUnrecordedMethodImplementation(_currentMethod.Definition, declaration)); + } + + private BlobBuilder BuildOverrideSignature( + byte callingConvention, + TypeValue returnType, + int genericArity, + ImmutableArray signatureArguments) + { + BlobBuilder signature = new(); + byte header = callingConvention; + if (genericArity > 0) + { + header |= (byte)SignatureAttributes.Generic; + } + + signature.WriteByte(header); + if (genericArity > 0) + { + signature.WriteCompressedInteger(genericArity); + } + + ImmutableArray arguments = + MaterializeSignatureArguments(signatureArguments); + signature.WriteCompressedInteger(arguments.Length); + MaterializeType(returnType).WriteContentTo(signature); + foreach (SignatureArg argument in arguments) + { + argument.SignatureBlob.WriteContentTo(signature); + } + + return signature; + } + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. + internal void AddCustomAttributeApplication( + ImmutableArray.Builder attributes, + CILParser.CustomAttrDeclContext attribute) + => attributes.Add(new( + attribute.Value, + attribute.Start, + attribute.HasSyntaxError)); +#pragma warning restore CA1822 + + internal void EndParameterDirective( + CILParser.ParameterDeclContext context, + ImmutableArray attributes, + int initialSyntaxErrorCount) + { + bool hasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (hasSyntaxError || _currentMethod is null) + { + return; + } + + if (context.genericIndex is not null || context.genericName is not null) + { + EntityRegistry.GenericParameterEntity? parameter = ResolveMethodGenericParameter( + context.genericIndex, + context.genericName?.Value, + context); + if (parameter is not null) + { + ApplyCustomAttributes(attributes, parameter); + } + + return; + } + + if (context.constraintIndex is not null || context.constraintName is not null) + { + EntityRegistry.GenericParameterEntity? parameter = ResolveMethodGenericParameter( + context.constraintIndex, + context.constraintName?.Value, + context); + if (parameter is null || context.constraintType is null) + { + return; + } + + EntityRegistry.TypeEntity baseType = + ResolveTypeSpecification(context.constraintType.Value); + EntityRegistry.GenericParameterConstraintEntity? constraint = + parameter.Constraints.FirstOrDefault(candidate => candidate.BaseType == baseType); + if (constraint is null) + { + constraint = EntityRegistry.CreateGenericConstraint(baseType); + constraint.Owner = parameter; + parameter.Constraints.Add(constraint); + _currentMethod.Definition.GenericParameterConstraints.Add(constraint); + } + + ApplyCustomAttributes(attributes, constraint); + return; + } + + if (context.parameterIndex is null || context.initializer is null) + { + return; + } + + int index = ParseInt32(context.parameterIndex.Start); + if ((uint)index >= (uint)_currentMethod.Definition.Parameters.Count) + { + ReportError( + DiagnosticIds.ParameterIndexOutOfRange, + string.Format(DiagnosticMessageTemplates.ParameterIndexOutOfRange, index), + context); + return; + } + + EntityRegistry.ParameterEntity parameterEntity = _currentMethod.Definition.Parameters[index]; + FieldInitializerValue initializer = GetInitializerValue(context.initializer); + if (initializer.HasValue) + { + parameterEntity.ConstantValue = initializer.ConstantValue; + parameterEntity.HasConstant = true; + } + + foreach (CustomAttributeApplicationValue application in attributes) + { + if (application.HasSyntaxError) + { + continue; + } + + EntityRegistry.CustomAttributeEntity? attribute = + MaterializeCustomAttributeDeclaration(application.Value, application.Location); + if (attribute is not null) + { + attribute.Owner = parameterEntity; + parameterEntity.HasCustomAttributes = true; + } + } + } + + private EntityRegistry.GenericParameterEntity? ResolveMethodGenericParameter( + CILParser.Int32Context? indexContext, + string? name, + CILParser.ParameterDeclContext diagnosticContext) + { + Debug.Assert(_currentMethod is not null); + if (indexContext is not null) + { + int index = ParseInt32(indexContext.Start); + if ((uint)index >= (uint)_currentMethod.Definition.GenericParameters.Count) + { + ReportError( + DiagnosticIds.GenericParameterIndexOutOfRange, + string.Format(DiagnosticMessageTemplates.GenericParameterIndexOutOfRange, index), + diagnosticContext); + return null; + } + + return _currentMethod.Definition.GenericParameters[index]; + } + + EntityRegistry.GenericParameterEntity? parameter = + _currentMethod.Definition.GenericParameters.FirstOrDefault(candidate => candidate.Name == name); + if (parameter is null) + { + ReportError( + DiagnosticIds.UnknownGenericParameter, + string.Format(DiagnosticMessageTemplates.UnknownGenericParameter, name), + diagnosticContext); + } + + return parameter; + } + + private void ApplyCustomAttributes( + ImmutableArray attributes, + EntityRegistry.EntityBase owner) + { + foreach (CustomAttributeApplicationValue application in attributes) + { + if (application.HasSyntaxError) + { + continue; + } + + EntityRegistry.CustomAttributeEntity? attribute = + MaterializeCustomAttributeDeclaration(application.Value, application.Location); + if (attribute is not null) + { + attribute.Owner = owner; + } + } + } + +#pragma warning disable CA1822 // Parser actions own these directive side effects. + internal void ProcessMethodDataDeclaration(CILParser.DataDeclContext context) + => _ = context; +#pragma warning restore CA1822 + + internal void ProcessMethodSecurityDeclaration(CILParser.SecDeclContext context) + { + if (_currentMethod is null || context.HasSyntaxError) + { + return; + } + + EntityRegistry.DeclarativeSecurityAttributeEntity? security = MaterializeSecurityDeclaration(context); + security?.Parent = _currentMethod.Definition; + } + +#pragma warning disable CA1822 // Parser actions own these directive side effects. + internal void ProcessMethodSourceDirective(CILParser.ExtSourceSpecContext context) + => _ = context; + + internal void ProcessMethodLanguageDirective(CILParser.LanguageDeclContext context) + => _ = context; +#pragma warning restore CA1822 + + internal void ProcessMethodCustomAttribute(CILParser.CustomDescrInMethodBodyContext context) + { + if (_currentMethod is null || context.HasSyntaxError) + { + return; + } + + EntityRegistry.CustomAttributeEntity? attribute = MaterializeMethodBodyCustomAttributeDeclaration(context); + if (attribute is not null) + { + attribute.Owner = _currentMethod.Definition; + } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.ExceptionHandling.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.ExceptionHandling.cs new file mode 100644 index 00000000000000..0eae6e73499c88 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.ExceptionHandling.cs @@ -0,0 +1,277 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + private readonly Dictionary _scopeRanges = new(); + // Method scopes nest while IL and local declarations are emitted, so their live offsets and + // local-scope depth must be restored when each lexical scope exits. + private readonly Stack _scopeStack = new(); + private RuleContext? _methodOwner; + + private void EndMethod() + { + Debug.Assert( + _scopeStack.Count == 0, + "Lexical scope state must be released by its owning rule."); + + _methodOwner = null; + if (_currentMethod is not null) + { + if (_currentMethod.AllLocals.Count > 0) + { + BlobBuilder localsSignature = new(); + BlobEncoder encoder = new(localsSignature); + LocalVariablesEncoder localsEncoder = + encoder.LocalVariableSignature(_currentMethod.AllLocals.Count); + foreach (SignatureArg local in _currentMethod.AllLocals) + { + local.SignatureBlob.WriteContentTo(localsEncoder.AddVariable().Builder); + } + + _currentMethod.Definition.LocalsSignature = + _entityRegistry.GetOrCreateStandaloneSignature(localsSignature); + } + + ValidateLabelReferences(); + _currentMethod = null; + } + + ResetMethodBodyState(); + ClearPendingCustomAttributeOwners(); + } + + private void ResetMethodBodyState() + { + _scopeRanges.Clear(); + _scopeStack.Clear(); + } + + internal void BeginScope(CILParser.ScopeBlockContext context) + { + if (_currentMethod is not null) + { + _scopeStack.Push( + new ScopeFrame(context, CurrentMethodBodyOffset, _currentMethod.LocalsScopes.Count)); + } + } + + internal void EndScope(CILParser.ScopeBlockContext context) + { + if (_scopeStack.Count == 0 || !ReferenceEquals(_scopeStack.Peek().Context, context)) + { + return; + } + + ScopeFrame frame = _scopeStack.Pop(); + if (_currentMethod is not null && frame.LocalsScopeCount < _currentMethod.LocalsScopes.Count) + { + _currentMethod.LocalsScopes.RemoveRange( + frame.LocalsScopeCount, + _currentMethod.LocalsScopes.Count - frame.LocalsScopeCount); + } + + _scopeRanges[context] = (frame.Start, CurrentMethodBodyOffset); + } + + internal void EndExceptionBlock( + CILParser.SehBlockContext context, + int initialSyntaxErrorCount) + { + if (_currentMethod is null || + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null || + context.tryRange is null || + context.clauses is null) + { + return; + } + + ExceptionRangeValue tryRangeValue = context.tryRange.Value; + (LabelHandle Start, LabelHandle End)? tryRange = ResolveExceptionRange(tryRangeValue); + if (tryRange is null) + { + return; + } + + foreach (ExceptionClauseValue clause in context.clauses.Value) + { + (LabelHandle Start, LabelHandle End)? handlerRange = ResolveExceptionRange(clause.Handler); + if (handlerRange is null) + { + continue; + } + + switch (clause) + { + case FinallyExceptionClauseValue: + AddExceptionRegion(new EntityRegistry.ExceptionRegion.FinallyRegion( + tryRange.Value.Start, + tryRange.Value.End, + handlerRange.Value.Start, + handlerRange.Value.End)); + break; + case FaultExceptionClauseValue: + AddExceptionRegion(new EntityRegistry.ExceptionRegion.FaultRegion( + tryRange.Value.Start, + tryRange.Value.End, + handlerRange.Value.Start, + handlerRange.Value.End)); + break; + case CatchExceptionClauseValue { CatchType: { IsValid: true, Type: not null } catchType }: + AddExceptionRegion(new EntityRegistry.ExceptionRegion.CatchRegion( + tryRange.Value.Start, + tryRange.Value.End, + handlerRange.Value.Start, + handlerRange.Value.End, + catchType.Type)); + break; + case FilterExceptionClauseValue filterClause + when ResolveExceptionFilter(filterClause.Filter) is LabelHandle filterStart: + AddExceptionRegion(new EntityRegistry.ExceptionRegion.FilterRegion( + tryRange.Value.Start, + tryRange.Value.End, + handlerRange.Value.Start, + handlerRange.Value.End, + filterStart)); + break; + } + } + } + + internal CatchTypeValue EndCatchClause( + CILParser.CatchClauseContext context, + int initialSyntaxErrorCount) + { + if (_currentMethod is null || + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null || + context.catchType is null || + context.catchType.HasSyntaxError) + { + return CatchTypeValue.Invalid; + } + + EntityRegistry.TypeEntity catchType = + ResolveTypeSpecification(context.catchType.Value); + return new CatchTypeValue(catchType, isValid: true); + } + + internal ExceptionRangeValue CreateScopeExceptionRange(CILParser.ScopeBlockContext scope) + => new ScopeExceptionRangeValue(scope); + + internal ExceptionRangeValue CreateLabelExceptionRange(IToken start, IToken end) + => new LabelExceptionRangeValue(ParseIdentifier(start), ParseIdentifier(end)); + + internal ExceptionRangeValue CreateOffsetExceptionRange(IToken start, IToken end) + => new OffsetExceptionRangeValue(ParseInt32(start), ParseInt32(end)); + + internal ExceptionFilterValue CreateScopeFilter(CILParser.ScopeBlockContext scope) + => new ScopeExceptionFilterValue(scope); + + internal ExceptionFilterValue CreateLabelFilter(IToken label) + => new LabelExceptionFilterValue(ParseIdentifier(label)); + + internal ExceptionFilterValue CreateOffsetFilter(IToken offset) + => new OffsetExceptionFilterValue(ParseInt32(offset)); + + internal ExceptionClauseValue CreateCatchExceptionClause( + CatchTypeValue catchType, + ExceptionRangeValue handler) + => new CatchExceptionClauseValue( + catchType, + handler); + + internal ExceptionClauseValue CreateFilterExceptionClause( + ExceptionFilterValue filter, + ExceptionRangeValue handler) + => new FilterExceptionClauseValue( + filter, + handler); + + internal ExceptionClauseValue CreateFinallyExceptionClause(ExceptionRangeValue handler) + => new FinallyExceptionClauseValue(handler); + + internal ExceptionClauseValue CreateFaultExceptionClause(ExceptionRangeValue handler) + => new FaultExceptionClauseValue(handler); + + private void AddExceptionRegion(EntityRegistry.ExceptionRegion region) + { + Debug.Assert(_currentMethod is not null); + _currentMethod.Definition.ExceptionRegions.Add(region); + } + + private (LabelHandle Start, LabelHandle End)? ResolveExceptionRange(ExceptionRangeValue range) + => range switch + { + ScopeExceptionRangeValue scope => GetScopeRange(scope.Scope), + LabelExceptionRangeValue labels => ( + GetOrCreateMethodLabel(labels.Start), + GetOrCreateMethodLabel(labels.End)), + OffsetExceptionRangeValue offsets => ( + DefineMethodLabelAtOffset(offsets.Start), + DefineMethodLabelAtOffset(offsets.End)), + _ => null, + }; + + private LabelHandle? ResolveExceptionFilter(ExceptionFilterValue filter) + => filter switch + { + ScopeExceptionFilterValue scope => GetScopeRange(scope.Scope).Start, + LabelExceptionFilterValue label => GetOrCreateMethodLabel(label.Label), + OffsetExceptionFilterValue offset => DefineMethodLabelAtOffset(offset.Offset), + _ => null, + }; + + private (LabelHandle Start, LabelHandle End) GetScopeRange(CILParser.ScopeBlockContext context) + { + if (!_scopeRanges.TryGetValue(context, out (int Start, int End) range)) + { + int offset = CurrentMethodBodyOffset; + range = (offset, offset); + } + + return ( + DefineMethodLabelAtOffset(range.Start), + DefineMethodLabelAtOffset(range.End)); + } + + private LabelHandle GetOrCreateMethodLabel(string name) + { + Debug.Assert(_currentMethod is not null); + if (!_currentMethod.Labels.TryGetValue(name, out LabelHandle label)) + { + label = _currentMethod.Definition.MethodBody.DefineLabel(); + _currentMethod.Labels[name] = label; + } + + return label; + } + + private LabelHandle DefineMethodLabelAtOffset(int offset) + { + Debug.Assert(_currentMethod is not null); + LabelHandle label = _currentMethod.Definition.MethodBody.DefineLabel(); + _currentMethod.Definition.MethodBody.MarkLabel(label, offset); + return label; + } + + private int CurrentMethodBodyOffset => _currentMethod?.Definition.MethodBody.Offset ?? 0; + + private readonly record struct ScopeFrame( + CILParser.ScopeBlockContext Context, + int Start, + int LocalsScopeCount); +} +#pragma warning restore CA1822 diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.cs new file mode 100644 index 00000000000000..d5476341f2b4f9 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodBodies.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + private void ValidateLabelReferences() + { + if (_currentMethod is null) + { + return; + } + + // Report errors for any labels that were referenced but never declared + foreach (var undefinedLabel in _currentMethod.UndefinedLabelReferences) + { + ReportError( + DiagnosticIds.LabelNotFound, + string.Format(DiagnosticMessageTemplates.LabelNotFound, undefinedLabel.Key), + undefinedLabel.Value); + } + } + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. + internal string GetMethodName(IToken token) => token.Text; +#pragma warning restore CA1822 +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.Actions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.Actions.cs new file mode 100644 index 00000000000000..f991564482e2be --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.Actions.cs @@ -0,0 +1,307 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal CILParser.MethodHeaderBuilder PrepareMethodHeader() + { + ClearPendingCustomAttributeOwners(); + return new CILParser.MethodHeaderBuilder(); + } + + internal void AddMethodAttribute( + CILParser.MethodHeaderBuilder builder, + CILParser.AttributeValue value) + => builder.Attributes = ApplyAttribute(builder.Attributes, value); + + internal void AddPInvoke(CILParser.MethodHeaderBuilder builder, PInvokeValue value) + => builder.PInvokes.Add(value); + + internal void AddMethodImplementationAttribute( + CILParser.MethodHeaderBuilder builder, + CILParser.AttributeValue value) + => builder.ImplementationAttributes = ApplyAttribute( + builder.ImplementationAttributes, + value); + + internal MethodHeaderValue CreateMethodHeader( + CILParser.MethodHeadContext context, + CILParser.MethodHeaderBuilder builder, + int initialSyntaxErrorCount, + byte callingConvention, + int returnAttributes, + TypeValue returnType, + MarshallingDescriptorValue returnMarshalling, + string name, + ImmutableArray genericParameters, + ImmutableArray arguments) + { + if (HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null) + { + return MethodHeaderValue.Error; + } + + return new MethodHeaderValue( + true, + builder.Attributes, + builder.PInvokes.ToImmutable(), + callingConvention, + returnAttributes, + returnType, + returnMarshalling, + name, + genericParameters, + arguments, + builder.ImplementationAttributes); + } + + internal CILParser.AttributeValue CreateMethodAttribute(IToken token) + => token.Text switch + { + "static" => new CILParser.AttributeValue(MethodAttributes.Static, 0, true), + "public" => new CILParser.AttributeValue( + MethodAttributes.Public, + MethodAttributes.MemberAccessMask, + true), + "private" => new CILParser.AttributeValue( + MethodAttributes.Private, + MethodAttributes.MemberAccessMask, + true), + "family" => new CILParser.AttributeValue( + MethodAttributes.Family, + MethodAttributes.MemberAccessMask, + true), + "final" => new CILParser.AttributeValue(MethodAttributes.Final, 0, true), + "specialname" => new CILParser.AttributeValue(MethodAttributes.SpecialName, 0, true), + "virtual" => new CILParser.AttributeValue(MethodAttributes.Virtual, 0, true), + "strict" => new CILParser.AttributeValue( + MethodAttributes.CheckAccessOnOverride, + 0, + true), + "abstract" => new CILParser.AttributeValue(MethodAttributes.Abstract, 0, true), + "assembly" => new CILParser.AttributeValue( + MethodAttributes.Assembly, + MethodAttributes.MemberAccessMask, + true), + "famandassem" => new CILParser.AttributeValue( + MethodAttributes.FamANDAssem, + MethodAttributes.MemberAccessMask, + true), + "famorassem" => new CILParser.AttributeValue( + MethodAttributes.FamORAssem, + MethodAttributes.MemberAccessMask, + true), + "privatescope" => new CILParser.AttributeValue( + MethodAttributes.PrivateScope, + MethodAttributes.MemberAccessMask, + true), + "hidebysig" => new CILParser.AttributeValue(MethodAttributes.HideBySig, 0, true), + "newslot" => new CILParser.AttributeValue(MethodAttributes.NewSlot, 0, true), + "rtspecialname" => new CILParser.AttributeValue(MethodAttributes.RTSpecialName, 0, true), + "unmanagedexp" => new CILParser.AttributeValue(MethodAttributes.UnmanagedExport, 0, true), + "reqsecobj" => new CILParser.AttributeValue(MethodAttributes.RequireSecObject, 0, true), + _ => throw new UnreachableException(), + }; + + internal CILParser.AttributeValue CreateRawMethodAttribute(IToken token) + => new((MethodAttributes)ParseInt32(token), 0, false); + + internal CILParser.AttributeValue + CreateMethodImplementationAttribute(IToken token) + => token.Text switch + { + "native" => new CILParser.AttributeValue( + MethodImplAttributes.Native, + MethodImplAttributes.CodeTypeMask, + true), + "cil" or "il" => new CILParser.AttributeValue( + MethodImplAttributes.IL, + MethodImplAttributes.CodeTypeMask, + true), + "optil" => new CILParser.AttributeValue( + MethodImplAttributes.OPTIL, + MethodImplAttributes.CodeTypeMask, + true), + "managed" => new CILParser.AttributeValue( + MethodImplAttributes.Managed, + MethodImplAttributes.ManagedMask, + true), + "unmanaged" => new CILParser.AttributeValue( + MethodImplAttributes.Unmanaged, + MethodImplAttributes.ManagedMask, + true), + "forwardref" => new CILParser.AttributeValue(MethodImplAttributes.ForwardRef, 0, true), + "preservesig" => new CILParser.AttributeValue(MethodImplAttributes.PreserveSig, 0, true), + "runtime" => new CILParser.AttributeValue( + MethodImplAttributes.Runtime, + MethodImplAttributes.CodeTypeMask, + true), + "internalcall" => new CILParser.AttributeValue(MethodImplAttributes.InternalCall, 0, true), + "synchronized" => new CILParser.AttributeValue(MethodImplAttributes.Synchronized, 0, true), + "noinlining" => new CILParser.AttributeValue(MethodImplAttributes.NoInlining, 0, true), + "aggressiveinlining" => new CILParser.AttributeValue( + MethodImplAttributes.AggressiveInlining, + 0, + true), + "nooptimization" => new CILParser.AttributeValue(MethodImplAttributes.NoOptimization, 0, true), + "aggressiveoptimization" => new CILParser.AttributeValue( + MethodImplAttributes.AggressiveOptimization, + 0, + true), + "async" => new CILParser.AttributeValue(MethodImplAttributes.Async, 0, true), + _ => throw new UnreachableException(), + }; + + internal CILParser.AttributeValue + CreateRawMethodImplementationAttribute(IToken token) + => new((MethodImplAttributes)ParseInt32(token), 0, false); + + internal void SetPInvokeModule(CILParser.PInvokeBuilder builder, string moduleName) + => builder.ModuleName = moduleName; + + internal void SetPInvokeEntryPoint( + CILParser.PInvokeBuilder builder, + string entryPointName) + => builder.EntryPointName = entryPointName; + + internal void AddPInvokeAttribute( + CILParser.PInvokeBuilder builder, + CILParser.AttributeValue value) + => builder.Attributes = ApplyAttribute(builder.Attributes, value); + + internal PInvokeValue CreatePInvoke(CILParser.PInvokeBuilder builder) + => new(builder.ModuleName, builder.EntryPointName, builder.Attributes); + + internal CILParser.AttributeValue + CreatePInvokeAttribute(IToken token) + => token.Text switch + { + "nomangle" => new CILParser.AttributeValue( + MethodImportAttributes.ExactSpelling, + 0, + true), + "ansi" => new CILParser.AttributeValue( + MethodImportAttributes.CharSetAnsi, + 0, + true), + "unicode" => new CILParser.AttributeValue( + MethodImportAttributes.CharSetUnicode, + 0, + true), + "autochar" => new CILParser.AttributeValue( + MethodImportAttributes.CharSetAuto, + 0, + true), + "lasterr" => new CILParser.AttributeValue( + MethodImportAttributes.SetLastError, + 0, + true), + "winapi" => new CILParser.AttributeValue( + MethodImportAttributes.CallingConventionWinApi, + 0, + true), + "cdecl" => new CILParser.AttributeValue( + MethodImportAttributes.CallingConventionCDecl, + 0, + true), + "stdcall" => new CILParser.AttributeValue( + MethodImportAttributes.CallingConventionStdCall, + 0, + true), + "thiscall" => new CILParser.AttributeValue( + MethodImportAttributes.CallingConventionThisCall, + 0, + true), + "fastcall" => new CILParser.AttributeValue( + MethodImportAttributes.CallingConventionFastCall, + 0, + true), + _ => throw new UnreachableException(), + }; + + internal CILParser.AttributeValue + CreateBestFitPInvokeAttribute(IToken setting) + => new( + setting.Text == "on" + ? MethodImportAttributes.BestFitMappingEnable + : MethodImportAttributes.BestFitMappingDisable, + 0, + true); + + internal CILParser.AttributeValue + CreateCharMapErrorPInvokeAttribute(IToken setting) + => new( + setting.Text == "on" + ? MethodImportAttributes.ThrowOnUnmappableCharEnable + : MethodImportAttributes.ThrowOnUnmappableCharDisable, + 0, + true); + + internal CILParser.AttributeValue + CreateRawPInvokeAttribute(IToken token) + => new( + (MethodImportAttributes)ParseInt32(token), + 0, + false); + + internal CILParser.AttributeValue + CreateGenericParameterAttribute(IToken token) + => token.Text switch + { + "+" => new CILParser.AttributeValue( + GenericParameterAttributes.Covariant, + 0, + true), + "-" => new CILParser.AttributeValue( + GenericParameterAttributes.Contravariant, + 0, + true), + "class" => new CILParser.AttributeValue( + GenericParameterAttributes.ReferenceTypeConstraint, + 0, + true), + "valuetype" => new CILParser.AttributeValue( + GenericParameterAttributes.NotNullableValueTypeConstraint, + 0, + true), + "byreflike" => new CILParser.AttributeValue( + GenericParameterAttributes.AllowByRefLike, + 0, + true), + ".ctor" => new CILParser.AttributeValue( + GenericParameterAttributes.DefaultConstructorConstraint, + 0, + true), + _ => throw new UnreachableException(), + }; + + internal CILParser.AttributeValue + CreateRawGenericParameterAttribute(IToken token) + => new( + (GenericParameterAttributes)ParseInt32(token), + 0, + true); + + internal GenericParameterAttributes AddGenericParameterAttribute( + GenericParameterAttributes attributes, + CILParser.AttributeValue value) + => ApplyAttribute(attributes, value); + + internal GenericParameterDeclarationValue CreateGenericParameterDeclaration( + GenericParameterAttributes attributes, + CILParser.TyBoundContext? constraints, + string name) + => new GenericParameterDeclarationValue( + attributes, + name, + constraints?.Value ?? []); +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.Generics.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.Generics.cs new file mode 100644 index 00000000000000..9a08cd78532d69 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.Generics.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + private static void RegisterGenericParameterNames( + EntityRegistry.EntityBase owner, + NamedElementList parameters, + ImmutableArray declarations) + { + for (int i = 0; i < declarations.Length; i++) + { + GenericParameterDeclarationValue declaration = declarations[i]; + EntityRegistry.GenericParameterEntity parameter = + EntityRegistry.CreateGenericParameter(declaration.Attributes, declaration.Name); + parameter.Owner = owner; + parameter.Index = i; + parameters.Add(parameter); + } + } + private void MaterializeGenericParameterConstraints( + NamedElementList parameters, + List constraints, + ImmutableArray declarations) + { + Debug.Assert(parameters.Count >= declarations.Length); + int count = System.Math.Min(parameters.Count, declarations.Length); + for (int i = 0; i < count; i++) + { + EntityRegistry.GenericParameterEntity parameter = parameters[i]; + foreach (TypeSpecificationValue constraintType in declarations[i].Constraints) + { + EntityRegistry.GenericParameterConstraintEntity constraint = + EntityRegistry.CreateGenericConstraint(ResolveTypeSpecification(constraintType)); + constraint.Owner = parameter; + parameter.Constraints.Add(constraint); + constraints.Add(constraint); + } + } + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.cs new file mode 100644 index 00000000000000..0139a20ae29a97 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.MethodHeaders.cs @@ -0,0 +1,176 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Reflection; +using System.Reflection.Metadata; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + internal void BeginMethod(CILParser.MethodHeadContext context, MethodHeaderValue value) + { + ResetMethodBodyState(); + if (!value.IsValid) + { + return; + } + + MethodHeaderValue header = value; + + EntityRegistry.TypeDefinitionEntity containingType = + _currentTypeDefinition.PeekOrDefault() ?? _entityRegistry.ModuleType; + EntityRegistry.MethodDefinitionEntity methodDefinition = + EntityRegistry.CreateUnrecordedMethodDefinition(containingType, header.Name); + + _currentMethod = new(methodDefinition); + try + { + RegisterGenericParameterNames( + methodDefinition, + methodDefinition.GenericParameters, + header.GenericParameters); + + methodDefinition.MethodAttributes = header.Attributes; + ApplyImplicitMethodAttributes(methodDefinition); + + if (methodDefinition.MethodAttributes.HasFlag(MethodAttributes.Abstract) && + !methodDefinition.ContainingType.Attributes.HasFlag(TypeAttributes.Abstract)) + { + ReportWarning( + DiagnosticIds.AbstractMethodNotInAbstractType, + string.Format( + DiagnosticMessageTemplates.AbstractMethodNotInAbstractType, + methodDefinition.Name), + context); + } + + ApplyPInvokeInformation(methodDefinition, header, context); + + byte signatureHeader = header.CallingConvention; + if (header.GenericParameters.Length != 0) + { + signatureHeader |= (byte)SignatureAttributes.Generic; + } + + SignatureHeader parsedHeader = new(signatureHeader); + if (!methodDefinition.MethodAttributes.HasFlag(MethodAttributes.Static) && + !parsedHeader.IsInstance && + _currentTypeDefinition.Count > 0) + { + signatureHeader |= (byte)SignatureAttributes.Instance; + parsedHeader = new(signatureHeader); + } + if (parsedHeader.HasExplicitThis && !parsedHeader.IsInstance) + { + signatureHeader |= (byte)SignatureAttributes.Instance; + parsedHeader = new(signatureHeader); + } + + BlobBuilder methodSignature = new(); + methodSignature.WriteByte(signatureHeader); + if (header.GenericParameters.Length != 0) + { + methodSignature.WriteCompressedInteger(header.GenericParameters.Length); + } + + MaterializeGenericParameterConstraints( + methodDefinition.GenericParameters, + methodDefinition.GenericParameterConstraints, + header.GenericParameters); + + ImmutableArray arguments = MaterializeSignatureArguments(header.Arguments); + methodSignature.WriteCompressedInteger(arguments.Length); + + SignatureArg returnValue = new( + (ParameterAttributes)header.ReturnAttributes, + MaterializeType(header.ReturnType), + MaterializeMarshallingDescriptor(header.ReturnMarshalling), + null); + returnValue.SignatureBlob.WriteContentTo(methodSignature); + methodDefinition.Parameters.Add( + EntityRegistry.CreateParameter( + returnValue.Attributes, + returnValue.Name, + returnValue.MarshallingDescriptor, + 0)); + + for (int i = 0; i < arguments.Length; i++) + { + SignatureArg argument = arguments[i]; + argument.SignatureBlob.WriteContentTo(methodSignature); + string? parameterName = argument.Name ?? $"A_{i}"; + methodDefinition.Parameters.Add( + EntityRegistry.CreateParameter( + argument.Attributes, + parameterName, + argument.MarshallingDescriptor, + i + 1)); + } + + methodDefinition.SignatureHeader = parsedHeader; + methodDefinition.MethodSignature = methodSignature; + methodDefinition.ImplementationAttributes = header.ImplementationAttributes; + + if (!EntityRegistry.TryAddMethodDefinitionToContainingType(methodDefinition)) + { + ReportError( + DiagnosticIds.DuplicateMethod, + DiagnosticMessageTemplates.DuplicateMethod, + context); + } + + _currentMethod = new(methodDefinition); + _methodOwner = context.Parent; + } + catch + { + _currentMethod = null; + _methodOwner = null; + ResetMethodBodyState(); + throw; + } + } + + private static void ApplyImplicitMethodAttributes(EntityRegistry.MethodDefinitionEntity method) + { + if (method.Name is ".ctor" or ".cctor") + { + method.MethodAttributes |= MethodAttributes.RTSpecialName | MethodAttributes.SpecialName; + } + else if (method.MethodAttributes.HasFlag(MethodAttributes.RTSpecialName)) + { + method.MethodAttributes |= MethodAttributes.SpecialName; + } + } + + private void ApplyPInvokeInformation( + EntityRegistry.MethodDefinitionEntity method, + MethodHeaderValue header, + CILParser.MethodHeadContext context) + { + (EntityRegistry.ModuleReferenceEntity Module, string? EntryPoint, MethodImportAttributes Attributes)? + pInvokeInformation = null; + + foreach (PInvokeValue pInvoke in header.PInvokes) + { + if (pInvoke.ModuleName is null) + { + ReportError( + DiagnosticIds.InvalidPInvokeSignature, + DiagnosticMessageTemplates.InvalidPInvokeSignature, + context); + continue; + } + + pInvokeInformation = ( + _entityRegistry.GetOrCreateModuleReference(pInvoke.ModuleName, _ => { }), + pInvoke.EntryPointName ?? header.Name, + pInvoke.Attributes); + } + + method.MethodImportInformation = pInvokeInformation; + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Security.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Security.cs new file mode 100644 index 00000000000000..ae744749d7459b --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Security.cs @@ -0,0 +1,214 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal DeclarativeSecurityAction ParseSecurityAction(IToken token) + => token.Text switch + { + "request" => DeclarativeSecurityAction.Request, + "demand" => DeclarativeSecurityAction.Demand, + "assert" => DeclarativeSecurityAction.Assert, + "deny" => DeclarativeSecurityAction.Deny, + "permitonly" => DeclarativeSecurityAction.PermitOnly, + "linkcheck" => DeclarativeSecurityAction.LinkDemand, + "inheritcheck" => DeclarativeSecurityAction.InheritanceDemand, + "reqmin" => DeclarativeSecurityAction.RequestMinimum, + "reqopt" => DeclarativeSecurityAction.RequestOptional, + "reqrefuse" => DeclarativeSecurityAction.RequestRefuse, + "prejitgrant" => DeclarativeSecurityAction.PrejitGrant, + "prejitdeny" => DeclarativeSecurityAction.PrejitDeny, + "noncasdemand" => DeclarativeSecurityAction.NonCasDemand, + "noncaslinkdemand" => DeclarativeSecurityAction.NonCasLinkDemand, + "noncasinheritance" => DeclarativeSecurityAction.NonCasInheritanceDemand, + _ => throw new UnreachableException(), + }; + + internal SecurityDeclarationValue CreateNamedPermissionDeclaration( + DeclarativeSecurityAction action, + TypeSpecificationValue permissionType, + ImmutableArray pairs) + => new NamedPermissionDeclarationValue( + action, + permissionType, + pairs); + + internal SecurityDeclarationValue CreateStructuredPermissionDeclaration( + DeclarativeSecurityAction action, + TypeSpecificationValue permissionType, + CustomAttributeBlobValue value) + => new StructuredPermissionDeclarationValue( + action, + permissionType, + value); + + internal SecurityDeclarationValue CreateEmptyPermissionDeclaration( + DeclarativeSecurityAction action, + TypeSpecificationValue permissionType) + => new EmptyPermissionDeclarationValue( + action, + permissionType); + + internal SecurityDeclarationValue CreateRawPermissionSetDeclaration( + DeclarativeSecurityAction action, + ImmutableArray value) + => new RawPermissionSetValue(action, value); + + internal SecurityDeclarationValue CreateStringPermissionSetDeclaration( + DeclarativeSecurityAction action, + string value) + => new StringPermissionSetValue(action, value); + + internal SecurityDeclarationValue CreateAttributePermissionSetDeclaration( + DeclarativeSecurityAction action, + ImmutableArray value) + => new AttributePermissionSetValue(action, value); + + internal void EndSecurityDeclaration( + CILParser.SecDeclContext context, + int initialSyntaxErrorCount) + { + context.HasSyntaxError = + HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null; + if (context.HasSyntaxError) + { + context.Value = null; + } + } + + internal SecurityAttributeValue CreateNamedSecurityAttribute( + IToken name, + ImmutableArray arguments) + => new SecurityAttributeValue( + StringHelpers.ParseQuotedString(name.Text), + null, + arguments); + + internal SecurityAttributeValue CreateTypedSecurityAttribute( + TypeSpecificationValue type, + ImmutableArray arguments) + => new SecurityAttributeValue( + null, + type, + arguments); + + internal SecurityNameValuePairValue CreateSecurityNameValuePair( + string name, + SecurityCaValue value) + => new(name, value); + + internal SecurityCaValue CreateSecurityBooleanValue(bool value) + => new SecurityBooleanValue(value); + + internal SecurityCaValue CreateSecurityInt32Value(IToken value) + => new SecurityInt32Value(ParseInt32(value)); + + internal SecurityCaValue CreateSecurityStringValue(string value) + => new SecurityStringValue(value); + + internal SecurityCaValue CreateSecurityEnumValue( + ClassNameValue type, + IToken kind, + IToken value) + => new SecurityEnumValue( + type, + kind.Text switch + { + "int8" => 1, + "int16" => 2, + "int32" => 4, + _ => throw new UnreachableException(), + }, + ParseInt32(value)); + + internal SecurityCaValue CreateSecurityEnumValue( + ClassNameValue type, + IToken value) + => new SecurityEnumValue(type, 4, ParseInt32(value)); + + private EntityRegistry.DeclarativeSecurityAttributeEntity? MaterializeSecurityDeclaration( + SecurityDeclarationValue value, + IToken location) + { + if (value is PermissionDeclarationValue) + { + ReportError( + DiagnosticIds.UnsupportedSecurityDeclaration, + DiagnosticMessageTemplates.UnsupportedSecurityDeclaration, + location); + return null; + } + + BlobBuilder permissionSet = value switch + { + RawPermissionSetValue raw => CreateRawPermissionSet(raw.Value), + StringPermissionSetValue text => CreateStringPermissionSet(text.Value), + AttributePermissionSetValue attributes => + MaterializeSecurityAttributeSet(attributes.Attributes), + _ => throw new UnreachableException(), + }; + return _entityRegistry.CreateDeclarativeSecurityAttribute(value.Action, permissionSet); + } + + private static BlobBuilder CreateRawPermissionSet(ImmutableArray value) + { + BlobBuilder blob = new(value.Length); + blob.WriteBytes(value); + return blob; + } + + private static BlobBuilder CreateStringPermissionSet(string value) + { + BlobBuilder blob = new(); + blob.WriteUTF16(value); + blob.WriteUTF16("\0"); + return blob; + } + + private BlobBuilder MaterializeSecurityAttributeSet( + ImmutableArray attributes) + { + BlobBuilder blob = new(); + blob.WriteByte((byte)'.'); + blob.WriteCompressedInteger(attributes.Length); + foreach (SecurityAttributeValue attribute in attributes) + { + MaterializeSecurityAttribute(attribute).WriteContentTo(blob); + } + + return blob; + } + + private BlobBuilder MaterializeSecurityAttribute(SecurityAttributeValue attribute) + { + string attributeName = attribute.Name ?? string.Empty; + if (attribute.Type is { } type && + ResolveTypeSpecification(type) is EntityRegistry.IHasReflectionNotation reflectionNotation) + { + attributeName = reflectionNotation.ReflectionNotation; + } + + BlobBuilder blob = new(); + blob.WriteSerializedString(attributeName); + WriteCustomBlobNamedArguments(blob, attribute.Arguments); + return blob; + } + + internal EntityRegistry.DeclarativeSecurityAttributeEntity? MaterializeSecurityDeclaration( + CILParser.SecDeclContext context) + => context.Value is SecurityDeclarationValue value + ? MaterializeSecurityDeclaration(value, context.Start) + : null; + +} +#pragma warning restore CA1822 diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.Actions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.Actions.cs new file mode 100644 index 00000000000000..229b47ae2637f3 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.Actions.cs @@ -0,0 +1,246 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Immutable; +using System.Diagnostics; +using System.Linq; +using System.Reflection; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal byte AddInstanceCallingConvention(byte callingConvention) + => (byte)(callingConvention | (byte)SignatureAttributes.Instance); + + internal byte AddExplicitCallingConvention(byte callingConvention) + => (byte)(callingConvention | (byte)(SignatureAttributes.ExplicitThis | SignatureAttributes.Instance)); + + internal byte GetRawCallingConvention(IToken token) => (byte)ParseInt32(token); + + internal byte GetDefaultCallingConvention() => (byte)SignatureCallingConvention.Default; + + internal byte GetCallingConvention(IToken token) + => (byte)(token.Type switch + { + CILParser.DEFAULT => SignatureCallingConvention.Default, + CILParser.VARARG => SignatureCallingConvention.VarArgs, + CILParser.CDECL => SignatureCallingConvention.CDecl, + CILParser.STDCALL => SignatureCallingConvention.StdCall, + CILParser.THISCALL => SignatureCallingConvention.ThisCall, + CILParser.FASTCALL => SignatureCallingConvention.FastCall, + CILParser.UNMANAGED => SignatureCallingConvention.Unmanaged, + _ => throw new UnreachableException() + }); + + internal void InitializeBound(CILParser.BoundContext context) + { + context.Lower = 0; + context.Upper = 0; + context.HasLower = false; + context.HasUpper = false; + } + + internal void SetBoundSize(CILParser.BoundContext context, IToken sizeToken) + { + context.Lower = 0; + context.Upper = ParseInt32(sizeToken); + context.HasLower = true; + context.HasUpper = true; + } + + internal void SetBoundRange(CILParser.BoundContext context, IToken lowerToken, IToken upperToken) + { + int lower = ParseInt32(lowerToken); + context.Lower = lower; + context.Upper = ParseInt32(upperToken) - lower + 1; + context.HasLower = true; + context.HasUpper = true; + } + + internal void SetBoundLower(CILParser.BoundContext context, IToken lowerToken) + { + context.Lower = ParseInt32(lowerToken); + context.HasLower = true; + } + + internal ArrayBoundValue CreateArrayBound(CILParser.BoundContext bound) + => new( + bound.HasLower ? bound.Lower : null, + bound.HasUpper ? bound.Upper : null); + + internal SignatureArgumentValue CreateSentinelSignatureArgument() + => new SignatureArgumentValue(true, 0, null, null, null); + + internal SignatureArgumentValue CreateSignatureArgument( + int attributes, + TypeValue type, + MarshallingDescriptorValue marshalling, + CILParser.IdContext? name) + => new SignatureArgumentValue( + false, + attributes, + type, + marshalling, + name is null ? null : GetIdentifier(name)); + + internal void SetParameterAttributeElement(CILParser.ParamAttrElementContext context, IToken attribute) + { + context.Value = attribute.Text switch + { + "in" => (int)ParameterAttributes.In, + "out" => (int)ParameterAttributes.Out, + "opt" => (int)ParameterAttributes.Optional, + _ => throw new UnreachableException() + }; + context.ShouldAppend = true; + } + + internal void SetRawParameterAttributeElement(CILParser.ParamAttrElementContext context, IToken token) + { + context.Value = ParseInt32(token) + 1; + context.ShouldAppend = false; + } + + internal int AddParameterAttribute(int attributes, int value, bool shouldAppend) + => shouldAppend ? attributes | value : value; + + internal ElementTypeValue CreateClassElementType(ClassNameValue className, bool isValueType) + => new ClassElementTypeValue(className, isValueType); + + internal ElementTypeValue CreateObjectElementType() + => new PrimitiveElementTypeValue((byte)SignatureTypeCode.Object); + + internal ElementTypeValue CreateTypedReferenceElementType() + => new PrimitiveElementTypeValue((byte)SignatureTypeCode.TypedReference); + + internal ElementTypeValue CreateVoidElementType() + => new PrimitiveElementTypeValue((byte)SignatureTypeCode.Void); + + internal ElementTypeValue CreatePrimitiveElementType(byte typeCode) + => new PrimitiveElementTypeValue(typeCode); + + internal ElementTypeValue CreateFunctionPointerElementType( + byte callingConvention, + TypeValue returnType, + ImmutableArray arguments) + => new FunctionPointerElementTypeValue( + callingConvention, + returnType, + arguments); + + internal ElementTypeValue CreateIndexedGenericParameterElementType( + bool isMethodParameter, + IToken token) + => new IndexedGenericParameterElementTypeValue(isMethodParameter, ParseInt32(token)); + + internal ElementTypeValue CreateNamedGenericParameterElementType( + IToken token, + bool isMethodParameter, + string name) + => new NamedGenericParameterElementTypeValue(token, isMethodParameter, name); + + internal ElementTypeValue CreateTypedefElementType(IToken token, string alias) + => new TypedefElementTypeValue(token, alias); + + internal ElementTypeValue CreateSentinelElementType(TypeValue type) + => new SentinelElementTypeValue(type); + + internal TypeModifierValue CreateSzArrayTypeModifier() + => new SimpleTypeModifierValue(SimpleTypeModifierKind.SzArray); + + internal TypeModifierValue CreateByReferenceTypeModifier() + => new SimpleTypeModifierValue(SimpleTypeModifierKind.ByReference); + + internal TypeModifierValue CreatePointerTypeModifier() + => new SimpleTypeModifierValue(SimpleTypeModifierKind.Pointer); + + internal TypeModifierValue CreatePinnedTypeModifier() + => new SimpleTypeModifierValue(SimpleTypeModifierKind.Pinned); + + internal TypeModifierValue CreateArrayTypeModifier(ImmutableArray bounds) + => new ArrayTypeModifierValue(bounds); + + internal TypeModifierValue CreateCustomTypeModifier( + TypeSpecificationValue type, + bool isRequired) + => new CustomTypeModifierValue(type, isRequired); + + internal TypeModifierValue CreateGenericArgumentsModifier( + ImmutableArray arguments) + => new GenericArgumentsTypeModifierValue(arguments); + + internal byte GetSimpleType(IToken token, bool isUnsigned) + { + SignatureTypeCode typeCode = (token.Type, isUnsigned) switch + { + (CILParser.CHAR, false) => SignatureTypeCode.Char, + (CILParser.STRING, false) => SignatureTypeCode.String, + (CILParser.BOOL, false) => SignatureTypeCode.Boolean, + (CILParser.INT8, false) => SignatureTypeCode.SByte, + (CILParser.INT16, false) => SignatureTypeCode.Int16, + (CILParser.INT32_, false) => SignatureTypeCode.Int32, + (CILParser.INT64_, false) => SignatureTypeCode.Int64, + (CILParser.FLOAT32, false) => SignatureTypeCode.Single, + (CILParser.FLOAT64_, false) => SignatureTypeCode.Double, + (CILParser.UINT8, false) => SignatureTypeCode.Byte, + (CILParser.UINT16, false) => SignatureTypeCode.UInt16, + (CILParser.UINT32, false) => SignatureTypeCode.UInt32, + (CILParser.UINT64, false) => SignatureTypeCode.UInt64, + (CILParser.INT8, true) => SignatureTypeCode.Byte, + (CILParser.INT16, true) => SignatureTypeCode.UInt16, + (CILParser.INT32_, true) => SignatureTypeCode.UInt32, + (CILParser.INT64_, true) => SignatureTypeCode.UInt64, + _ => throw new UnreachableException() + }; + + return (byte)typeCode; + } + + internal byte GetNativeIntType() => (byte)SignatureTypeCode.IntPtr; + + internal byte GetNativeUIntType() => (byte)SignatureTypeCode.UIntPtr; + + internal TypeSpecificationValue CreateClassTypeSpecification(ClassNameValue className) + => new ClassTypeSpecificationValue(className); + + internal TypeSpecificationValue CreateAssemblyTypeSpecification(string assemblyName) + => new AssemblyTypeSpecificationValue(assemblyName); + + internal TypeSpecificationValue CreateModuleTypeSpecification(string moduleName) + => new ModuleTypeSpecificationValue(moduleName); + + internal TypeSpecificationValue CreateSignatureTypeSpecification(TypeValue type) + => new SignatureTypeSpecificationValue(type); + + internal int GetGenericArity(CILParser.GenArityNotEmptyContext? context) + => context?.Value ?? 0; + + internal CalliSignatureValue CreateCalliSignature( + byte callingConvention, + TypeValue returnType, + ImmutableArray arguments) + => new CalliSignatureValue( + callingConvention, + returnType, + arguments); + + private BlobBuilder MaterializeCalliSignature(CalliSignatureValue calliSignature) + { + BlobBuilder signature = new(); + signature.WriteByte(calliSignature.CallingConvention); + ImmutableArray materializedArguments = MaterializeSignatureArguments(calliSignature.Arguments); + signature.WriteCompressedInteger(materializedArguments.Count(argument => !argument.IsSentinel)); + MaterializeType(calliSignature.ReturnType).WriteContentTo(signature); + foreach (SignatureArg argument in materializedArguments) + { + argument.SignatureBlob.WriteContentTo(signature); + } + + return signature; + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.References.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.References.cs new file mode 100644 index 00000000000000..2080f0721e640d --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.References.cs @@ -0,0 +1,212 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Linq; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal MethodReferenceValue CreateMethodReference( + IToken token, + byte callingConvention, + TypeValue returnType, + TypeSpecificationValue? owner, + string name, + ImmutableArray? genericArguments, + int? genericArity, + ImmutableArray arguments) + => new ParsedMethodReferenceValue( + token, + callingConvention, + returnType, + owner, + name, + genericArguments, + genericArity.GetValueOrDefault(), + arguments); + + internal MethodReferenceValue CreateTokenMethodReference(int token) + => new TokenMethodReferenceValue(token); + + internal MethodReferenceValue CreateTypedefMethodReference(IToken token, string alias) + => new TypedefMethodReferenceValue(token, alias); + + internal FieldReferenceValue CreateFieldReference( + TypeValue fieldType, + TypeSpecificationValue? owner, + string name) + => new ParsedFieldReferenceValue( + fieldType, + owner, + name); + + internal FieldReferenceValue CreateTypedefFieldReference(IToken token, string alias) + => new TypedefFieldReferenceValue(token, alias); + + internal MemberReferenceValue CreateMethodMemberReference(MethodReferenceValue method) + => new MethodMemberReferenceValue(method); + + internal MemberReferenceValue CreateFieldMemberReference(FieldReferenceValue field) + => new FieldMemberReferenceValue(field); + + internal MemberReferenceValue CreateTokenMemberReference(int token) + => new TokenMemberReferenceValue(token); + + internal OwnerTypeValue CreateTypeOwner(TypeSpecificationValue type) + => new TypeOwnerValue(type); + + internal OwnerTypeValue CreateMemberOwner(MemberReferenceValue member) + => new MemberOwnerValue(member); + + private EntityRegistry.EntityBase MaterializeMethodReference(MethodReferenceValue methodReference) + { + switch (methodReference) + { + case TokenMethodReferenceValue token: + return ResolveMetadataToken(token.Token); + case TypedefMethodReferenceValue typedef: + if (TryResolveTypedefAsMember(typedef.Alias) is { } resolved) + { + return resolved; + } + ReportError( + DiagnosticIds.TypedefNotFound, + string.Format(DiagnosticMessageTemplates.TypedefNotFound, typedef.Alias), + typedef.Token); + return CreateErrorMethodReference(typedef.Alias); + case ParsedMethodReferenceValue parsed: + return MaterializeParsedMethodReference(parsed); + default: + return CreateErrorMethodReference(""); + } + } + + private EntityRegistry.EntityBase MaterializeParsedMethodReference(ParsedMethodReferenceValue methodReference) + { + byte callingConvention = methodReference.CallingConvention; + EntityRegistry.TypeEntity owner = methodReference.Owner is null + ? _entityRegistry.ModuleType + : ResolveTypeSpecification(methodReference.Owner); + + BlobBuilder? methodSpecificationSignature = null; + int genericArity = methodReference.GenericArity; + if (methodReference.GenericArguments is { } genericArguments) + { + genericArity = genericArguments.Length; + if (genericArity != 0) + { + methodSpecificationSignature = new BlobBuilder(); + methodSpecificationSignature.WriteByte((byte)SignatureKind.MethodSpecification); + MaterializeTypeArguments(genericArguments).WriteContentTo(methodSpecificationSignature); + } + } + + if (genericArity != 0) + { + callingConvention |= (byte)SignatureAttributes.Generic; + } + + if (_expectInstance && (callingConvention & (byte)SignatureAttributes.Instance) == 0) + { + ReportWarning( + DiagnosticIds.MissingInstanceCallConv, + DiagnosticMessageTemplates.MissingInstanceCallConv, + methodReference.Token); + callingConvention |= (byte)SignatureAttributes.Instance; + } + + BlobBuilder signature = new(); + signature.WriteByte(callingConvention); + if (genericArity != 0) + { + signature.WriteCompressedInteger(genericArity); + } + + ImmutableArray arguments = MaterializeSignatureArguments(methodReference.Arguments); + signature.WriteCompressedInteger(arguments.Count(argument => !argument.IsSentinel)); + MaterializeType(methodReference.ReturnType).WriteContentTo(signature); + foreach (SignatureArg argument in arguments) + { + argument.SignatureBlob.WriteContentTo(signature); + } + + EntityRegistry.MemberReferenceEntity memberReference = + _entityRegistry.CreateLazilyRecordedMemberReference(owner, methodReference.Name, signature); + return methodSpecificationSignature is null + ? memberReference + : _entityRegistry.GetOrCreateMethodSpecification(memberReference, methodSpecificationSignature); + } + + private EntityRegistry.EntityBase MaterializeFieldReference(FieldReferenceValue fieldReference) + { + switch (fieldReference) + { + case TypedefFieldReferenceValue typedef: + if (TryResolveTypedefAsMember(typedef.Alias) is { } resolved) + { + return resolved; + } + ReportError( + DiagnosticIds.TypedefNotFound, + string.Format(DiagnosticMessageTemplates.TypedefNotFound, typedef.Alias), + typedef.Token); + return CreateErrorFieldReference(typedef.Alias); + case ParsedFieldReferenceValue parsed: + BlobBuilder fieldType = MaterializeType(parsed.FieldType); + EntityRegistry.TypeEntity owner = parsed.Owner is null + ? _entityRegistry.ModuleType + : ResolveTypeSpecification(parsed.Owner); + BlobBuilder signature = new(fieldType.Count + 1); + signature.WriteByte((byte)SignatureKind.Field); + fieldType.WriteContentTo(signature); + return _entityRegistry.CreateLazilyRecordedMemberReference(owner, parsed.Name, signature); + default: + return CreateErrorFieldReference(""); + } + } + + private EntityRegistry.EntityBase MaterializeMemberReference(MemberReferenceValue memberReference) + => memberReference switch + { + MethodMemberReferenceValue method => MaterializeMethodReference(method.Method), + FieldMemberReferenceValue field => MaterializeFieldReference(field.Field), + TokenMemberReferenceValue token => ResolveMetadataToken(token.Token), + _ => CreateErrorMethodReference("") + }; + + private EntityRegistry.MemberReferenceEntity CreateErrorMethodReference(string name) + { + BlobBuilder signature = new(3); + signature.WriteByte((byte)SignatureCallingConvention.Default); + signature.WriteCompressedInteger(0); + signature.WriteByte((byte)SignatureTypeCode.Void); + return _entityRegistry.CreateLazilyRecordedMemberReference( + _entityRegistry.ModuleType, + name, + signature); + } + + private EntityRegistry.MemberReferenceEntity CreateErrorFieldReference(string name) + { + BlobBuilder signature = new(2); + signature.WriteByte((byte)SignatureKind.Field); + signature.WriteByte((byte)SignatureTypeCode.Object); + return _entityRegistry.CreateLazilyRecordedMemberReference( + _entityRegistry.ModuleType, + name, + signature); + } + + private EntityRegistry.EntityBase MaterializeOwnerType(OwnerTypeValue owner) + => owner switch + { + TypeOwnerValue type => ResolveTypeSpecification(type.Type), + MemberOwnerValue member => MaterializeMemberReference(member.Member), + _ => new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)) + }; +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.Types.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.Types.cs new file mode 100644 index 00000000000000..ca8e52ed1cd849 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.Types.cs @@ -0,0 +1,298 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Immutable; +using System.Linq; +using System.Reflection.Metadata; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + private BlobBuilder MaterializeType(TypeValue type) + { + const int DefaultSignatureElementBlobSize = 10; + + BlobBuilder elementType = MaterializeElementType(type.ElementType); + BlobBuilder prefix = new(DefaultSignatureElementBlobSize); + BlobBuilder suffix = new(DefaultSignatureElementBlobSize); + + for (int i = type.Modifiers.Length - 1; i >= 0; i--) + { + switch (type.Modifiers[i]) + { + case SimpleTypeModifierValue { Kind: SimpleTypeModifierKind.SzArray }: + prefix.WriteByte((byte)SignatureTypeCode.SZArray); + break; + case ArrayTypeModifierValue: + prefix.WriteByte((byte)SignatureTypeCode.Array); + break; + case SimpleTypeModifierValue { Kind: SimpleTypeModifierKind.ByReference }: + prefix.WriteByte((byte)SignatureTypeCode.ByReference); + break; + case SimpleTypeModifierValue { Kind: SimpleTypeModifierKind.Pointer }: + prefix.WriteByte((byte)SignatureTypeCode.Pointer); + break; + case SimpleTypeModifierValue { Kind: SimpleTypeModifierKind.Pinned }: + prefix.WriteByte((byte)SignatureTypeCode.Pinned); + break; + case CustomTypeModifierValue customModifier: + prefix.WriteByte((byte)(customModifier.IsRequired + ? SignatureTypeCode.RequiredModifier + : SignatureTypeCode.OptionalModifier)); + prefix.WriteTypeEntity(ResolveTypeSpecification(customModifier.Type)); + break; + case GenericArgumentsTypeModifierValue: + prefix.WriteByte((byte)SignatureTypeCode.GenericTypeInstance); + break; + } + } + + foreach (TypeModifierValue modifier in type.Modifiers) + { + switch (modifier) + { + case ArrayTypeModifierValue array: + WriteArrayShape(suffix, array.Bounds); + break; + case GenericArgumentsTypeModifierValue genericArguments: + MaterializeTypeArguments(genericArguments.Arguments).WriteContentTo(suffix); + break; + } + } + + // Work around https://github.com/dotnet/runtime/issues/127243 by writing to a separate blob. + BlobBuilder fullBlob = new(elementType.Count + prefix.Count + suffix.Count); + prefix.WriteContentTo(fullBlob); + elementType.WriteContentTo(fullBlob); + suffix.WriteContentTo(fullBlob); + return fullBlob; + } + + private BlobBuilder MaterializeElementType(ElementTypeValue elementType) + { + BlobBuilder blob = new(5); + switch (elementType) + { + case CILParser.ErrorElementTypeValue: + blob.WriteByte((byte)SignatureTypeCode.Object); + break; + case PrimitiveElementTypeValue primitive: + blob.WriteByte(primitive.TypeCode); + break; + case ClassElementTypeValue classType: + EntityRegistry.TypeEntity typeEntity = ResolveClassName(classType.ClassName); + if (TryGetPrimitiveTypeCode(typeEntity, classType.IsValueType) is { } primitiveTypeCode) + { + blob.WriteByte((byte)primitiveTypeCode); + } + else + { + blob.WriteByte((byte)(classType.IsValueType ? SignatureTypeKind.ValueType : SignatureTypeKind.Class)); + blob.WriteTypeEntity(typeEntity); + } + break; + case FunctionPointerElementTypeValue functionPointer: + blob.WriteByte((byte)SignatureTypeCode.FunctionPointer); + blob.WriteByte(functionPointer.CallingConvention); + ImmutableArray arguments = MaterializeSignatureArguments(functionPointer.Arguments); + blob.WriteCompressedInteger(arguments.Count(argument => !argument.IsSentinel)); + blob.LinkSuffix(MaterializeType(functionPointer.ReturnType)); + foreach (SignatureArg argument in arguments) + { + blob.LinkSuffix(argument.SignatureBlob); + } + break; + case IndexedGenericParameterElementTypeValue indexedGenericParameter: + blob.WriteByte((byte)(indexedGenericParameter.IsMethodParameter + ? SignatureTypeCode.GenericMethodParameter + : SignatureTypeCode.GenericTypeParameter)); + // Always emit indexed generic parameters, including intentionally invalid IL. + blob.WriteCompressedInteger(indexedGenericParameter.Index); + break; + case NamedGenericParameterElementTypeValue namedGenericParameter: + WriteNamedGenericParameter(blob, namedGenericParameter); + break; + case TypedefElementTypeValue typedef: + if (TryResolveTypedefAsTypeBlob(typedef.Alias) is { } resolved) + { + resolved.WriteContentTo(blob); + } + else + { + ReportError( + DiagnosticIds.TypedefNotFound, + string.Format(DiagnosticMessageTemplates.TypedefNotFound, typedef.Alias), + typedef.Token); + } + break; + case SentinelElementTypeValue sentinel: + blob.WriteByte((byte)SignatureTypeCode.Sentinel); + blob.LinkSuffix(MaterializeType(sentinel.Type)); + break; + } + + return blob; + } + + private void WriteNamedGenericParameter(BlobBuilder blob, NamedGenericParameterElementTypeValue genericParameter) + { + blob.WriteByte((byte)(genericParameter.IsMethodParameter + ? SignatureTypeCode.GenericMethodParameter + : SignatureTypeCode.GenericTypeParameter)); + + string name = genericParameter.Name; + if (genericParameter.IsMethodParameter) + { + if (_currentMethod is null) + { + ReportError( + DiagnosticIds.MethodTypeParameterOutsideMethod, + string.Format(DiagnosticMessageTemplates.MethodTypeParameterOutsideMethod, name), + genericParameter.Token); + blob.WriteCompressedInteger(0); + return; + } + + for (int i = 0; i < _currentMethod.Definition.GenericParameters.Count; i++) + { + if (_currentMethod.Definition.GenericParameters[i].Name == name) + { + blob.WriteCompressedInteger(i); + return; + } + } + } + else + { + if (_currentTypeDefinition.Count == 0) + { + ReportError( + DiagnosticIds.TypeParameterOutsideType, + string.Format(DiagnosticMessageTemplates.TypeParameterOutsideType, name), + genericParameter.Token); + blob.WriteCompressedInteger(0); + return; + } + + for (int i = 0; i < _currentTypeDefinition.Peek().GenericParameters.Count; i++) + { + if (_currentTypeDefinition.Peek().GenericParameters[i].Name == name) + { + blob.WriteCompressedInteger(i); + return; + } + } + } + + ReportError( + DiagnosticIds.GenericParameterNotFound, + string.Format(DiagnosticMessageTemplates.GenericParameterNotFound, name), + genericParameter.Token); + blob.WriteCompressedInteger(0); + } + + private ImmutableArray MaterializeSignatureArguments(ImmutableArray arguments) + { + ImmutableArray.Builder builder = ImmutableArray.CreateBuilder(arguments.Length); + foreach (SignatureArgumentValue argument in arguments) + { + builder.Add(MaterializeSignatureArgument(argument)); + } + return builder.MoveToImmutable(); + } + + private SignatureArg MaterializeSignatureArgument(SignatureArgumentValue argument) + { + if (argument.IsSentinel) + { + return SignatureArg.CreateSentinelArgument(); + } + + return new SignatureArg( + (System.Reflection.ParameterAttributes)argument.Attributes, + MaterializeType(argument.Type ?? TypeValue.Error), + MaterializeMarshallingDescriptor(argument.Marshalling), + argument.Name); + } + + private BlobBuilder MaterializeTypeArguments(ImmutableArray arguments) + { + BlobBuilder blob = new(4); + blob.WriteCompressedInteger(arguments.Length); + foreach (TypeValue argument in arguments) + { + blob.LinkSuffix(MaterializeType(argument)); + } + return blob; + } + + private static void WriteArrayShape(BlobBuilder suffix, ImmutableArray bounds) + { + suffix.WriteCompressedInteger(bounds.Length); + + int sizeCount = 0; + while (sizeCount < bounds.Length && bounds[sizeCount].Upper is not null) + { + sizeCount++; + } + + suffix.WriteCompressedInteger(sizeCount); + for (int i = 0; i < sizeCount; i++) + { + suffix.WriteCompressedInteger(bounds[i].Upper.GetValueOrDefault()); + } + + int lowerBoundCount = 0; + while (lowerBoundCount < bounds.Length && bounds[lowerBoundCount].Lower is not null) + { + lowerBoundCount++; + } + + suffix.WriteCompressedInteger(lowerBoundCount); + for (int i = 0; i < lowerBoundCount; i++) + { + suffix.WriteCompressedSignedInteger(bounds[i].Lower.GetValueOrDefault()); + } + } + + private static SignatureTypeCode? TryGetPrimitiveTypeCode(EntityRegistry.TypeEntity typeEntity, bool isValueType) + { + if (typeEntity is not EntityRegistry.TypeReferenceEntity typeReference || typeReference.Namespace != "System") + { + return null; + } + + if (isValueType) + { + return typeReference.Name switch + { + "Boolean" => SignatureTypeCode.Boolean, + "Char" => SignatureTypeCode.Char, + "SByte" => SignatureTypeCode.SByte, + "Byte" => SignatureTypeCode.Byte, + "Int16" => SignatureTypeCode.Int16, + "UInt16" => SignatureTypeCode.UInt16, + "Int32" => SignatureTypeCode.Int32, + "UInt32" => SignatureTypeCode.UInt32, + "Int64" => SignatureTypeCode.Int64, + "UInt64" => SignatureTypeCode.UInt64, + "Single" => SignatureTypeCode.Single, + "Double" => SignatureTypeCode.Double, + "IntPtr" => SignatureTypeCode.IntPtr, + "UIntPtr" => SignatureTypeCode.UIntPtr, + "TypedReference" => SignatureTypeCode.TypedReference, + _ => null + }; + } + + return typeReference.Name switch + { + "String" => SignatureTypeCode.String, + "Object" => SignatureTypeCode.Object, + _ => null + }; + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.cs new file mode 100644 index 00000000000000..15fa76626d8694 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Signatures.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + internal EntityRegistry.EntityBase MaterializeMethodReference(CILParser.MethodRefContext context) + => MaterializeMethodReference(context.Value); + + internal EntityRegistry.TypeEntity ResolveTypeSpecification(CILParser.TypeSpecContext context) + => ResolveTypeSpecification(context.Value); +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.Headers.Actions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.Headers.Actions.cs new file mode 100644 index 00000000000000..e066a53daddb23 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.Headers.Actions.cs @@ -0,0 +1,151 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Diagnostics; +using System.Reflection; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal void PrepareNamespaceHeader() + => ClearPendingCustomAttributeOwners(); + + internal CILParser.ClassHeaderBuilder PrepareClassHeader() + { + ClearPendingCustomAttributeOwners(); + return new CILParser.ClassHeaderBuilder(); + } + + internal void AddClassHeaderAttribute( + CILParser.ClassHeaderBuilder builder, + ClassAttributeValue value) + => builder.Attributes.Add(value); + + internal ClassHeaderValue CreateClassHeader( + CILParser.ClassHeadContext context, + CILParser.ClassHeaderBuilder builder, + int initialSyntaxErrorCount, + IToken nameToken, + string fullName, + ImmutableArray genericParameters, + TypeSpecificationValue? baseType, + ImmutableArray interfaces) + { + if (HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null) + { + return ClassHeaderValue.Error; + } + + return new ClassHeaderValue( + true, + nameToken, + fullName, + builder.Attributes.ToImmutable(), + genericParameters, + baseType, + interfaces); + } + + internal ClassAttributeValue CreateClassAttribute(IToken token) + { + return token.Text switch + { + "public" => CreateClassAttribute( + TypeAttributes.Public, + TypeAttributes.VisibilityMask), + "private" => CreateClassAttribute( + TypeAttributes.NotPublic, + TypeAttributes.VisibilityMask), + "value" => CreateClassAttribute( + TypeAttributes.Sealed, + fallbackBase: EntityRegistry.WellKnownBaseType.System_ValueType, + requireSealed: true), + "enum" => CreateClassAttribute( + 0, + fallbackBase: EntityRegistry.WellKnownBaseType.System_Enum), + "interface" => CreateClassAttribute(TypeAttributes.Interface | TypeAttributes.Abstract), + "sealed" => CreateClassAttribute(TypeAttributes.Sealed), + "abstract" => CreateClassAttribute(TypeAttributes.Abstract), + "auto" => CreateClassAttribute(TypeAttributes.AutoLayout, TypeAttributes.LayoutMask), + "sequential" => CreateClassAttribute( + TypeAttributes.SequentialLayout, + TypeAttributes.LayoutMask), + "explicit" => CreateClassAttribute(TypeAttributes.ExplicitLayout), + "extended" => CreateClassAttribute(TypeAttributes.ExtendedLayout, TypeAttributes.LayoutMask), + "ansi" => CreateClassAttribute(TypeAttributes.AnsiClass, TypeAttributes.StringFormatMask), + "unicode" => CreateClassAttribute( + TypeAttributes.UnicodeClass, + TypeAttributes.StringFormatMask), + "autochar" => CreateClassAttribute( + TypeAttributes.AutoClass, + TypeAttributes.StringFormatMask), + "import" => CreateClassAttribute(TypeAttributes.Import), +#pragma warning disable SYSLIB0050 + "serializable" => CreateClassAttribute(TypeAttributes.Serializable), +#pragma warning restore SYSLIB0050 + "windowsruntime" => CreateClassAttribute(TypeAttributes.WindowsRuntime), + "beforefieldinit" => CreateClassAttribute(TypeAttributes.BeforeFieldInit), + "specialname" => CreateClassAttribute(TypeAttributes.SpecialName), + "rtspecialname" => CreateClassAttribute(TypeAttributes.RTSpecialName), + _ => throw new UnreachableException(), + }; + } + + internal ClassAttributeValue CreateNestedClassAttribute(IToken visibility) + { + TypeAttributes attribute = visibility.Text switch + { + "public" => TypeAttributes.NestedPublic, + "private" => TypeAttributes.NestedPrivate, + "family" => TypeAttributes.NestedFamily, + "assembly" => TypeAttributes.NestedAssembly, + "famandassem" => TypeAttributes.NestedFamANDAssem, + "famorassem" => TypeAttributes.NestedFamORAssem, + _ => throw new UnreachableException(), + }; + return CreateClassAttribute(attribute, TypeAttributes.VisibilityMask); + } + + internal ClassAttributeValue CreateRawClassAttribute(IToken token) + { + int value = ParseInt32(token); + bool requireSealed = false; + EntityRegistry.WellKnownBaseType? fallbackBase = null; + if ((value & 0x80000000) != 0) + { + requireSealed = true; + fallbackBase = EntityRegistry.WellKnownBaseType.System_ValueType; + } + if ((value & 0x40000000) != 0) + { + fallbackBase = EntityRegistry.WellKnownBaseType.System_Enum; + } + + value &= unchecked((int)~0xC0000000); + return new ClassAttributeValue( + new((TypeAttributes)value, 0, false), + fallbackBase, + requireSealed); + } + + internal TypeSpecificationValue? CreateEmptyClassBase() => null; + + internal TypeSpecificationValue CreateClassBase(TypeSpecificationValue value) + => value; + + internal ImmutableArray CreateEmptyInterfaceList() + => []; + + private static ClassAttributeValue CreateClassAttribute( + TypeAttributes value, + TypeAttributes groupMask = 0, + EntityRegistry.WellKnownBaseType? fallbackBase = null, + bool requireSealed = false) + => new(new CILParser.AttributeValue(value, groupMask, true), fallbackBase, requireSealed); +} +#pragma warning restore CA1822 diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.Headers.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.Headers.cs new file mode 100644 index 00000000000000..edb5e2b03079f0 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.Headers.cs @@ -0,0 +1,244 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Reflection; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + internal void BeginNamespace( + CILParser.NameSpaceHeadContext context, + string? namespaceName, + int initialSyntaxErrorCount) + { + if (HasSyntaxErrorsSince(initialSyntaxErrorCount) || + context.exception is not null || + namespaceName is null) + { + return; + } + + string? outerNamespace = _currentNamespace.PeekOrDefault(); + _currentNamespace.Push( + string.IsNullOrEmpty(outerNamespace) + ? namespaceName + : $"{outerNamespace}.{namespaceName}"); + _namespaceOwners.Push(context.Parent); + } + + internal void BeginType(CILParser.ClassHeadContext context, ClassHeaderValue value) + { + if (!value.IsValid) + { + return; + } + + EntityRegistry.TypeDefinitionEntity typeDefinition = MaterializeClassHeader(context, value); + _currentTypeDefinition.Push(typeDefinition); + _typeOwners.Push(context.Parent); + } + + private EntityRegistry.TypeDefinitionEntity MaterializeClassHeader( + CILParser.ClassHeadContext context, + ClassHeaderValue header) + { + (string typeNamespace, string typeName) = GetTypeDefinitionName(header.FullName); + bool isNewType = false; + EntityRegistry.TypeDefinitionEntity typeDefinition = + _entityRegistry.GetOrCreateTypeDefinition( + _currentTypeDefinition.PeekOrDefault(), + typeNamespace, + typeName, + newTypeDefinition => + { + isNewType = true; + InitializeTypeDefinition(context, header, newTypeDefinition); + }); + + if (!isNewType) + { + MergeTypeDefinition(header, typeDefinition); + } + + return typeDefinition; + } + + private (string Namespace, string Name) GetTypeDefinitionName(string fullName) + { + int lastDot = fullName.LastIndexOf('.'); + if (lastDot == 0) + { + lastDot = -1; + } + + string typeNamespace; + if (_currentTypeDefinition.Count != 0) + { + typeNamespace = lastDot == -1 ? string.Empty : fullName.Substring(0, lastDot); + } + else if (lastDot == -1) + { + typeNamespace = _currentNamespace.PeekOrDefault() ?? string.Empty; + } + else + { + typeNamespace = + $"{_currentNamespace.PeekOrDefault()}{fullName.Substring(0, lastDot)}"; + } + + return ( + typeNamespace, + lastDot == -1 ? fullName : fullName.Substring(lastDot + 1)); + } + + private void InitializeTypeDefinition( + CILParser.ClassHeadContext context, + ClassHeaderValue header, + EntityRegistry.TypeDefinitionEntity typeDefinition) + { + EntityRegistry.WellKnownBaseType? fallbackBase = + _options.NoAutoInherit ? null : EntityRegistry.WellKnownBaseType.System_Object; + bool requireSealed = false; + TypeAttributes attributes = 0; + foreach (ClassAttributeValue classAttribute in header.Attributes) + { + if (classAttribute.FallbackBase is not null) + { + fallbackBase = classAttribute.FallbackBase; + } + + CILParser.AttributeValue attribute = classAttribute.Attribute; + if (!attribute.ShouldAppend) + { + attributes = attribute.Value; + requireSealed = classAttribute.RequireSealed; + continue; + } + + requireSealed |= classAttribute.RequireSealed; + if (attribute.Value == TypeAttributes.RTSpecialName) + { + continue; + } + + attributes = ApplyAttribute(attributes, attribute); + } + + typeDefinition.Attributes = attributes; + RegisterGenericParameterNames( + typeDefinition, + typeDefinition.GenericParameters, + header.GenericParameters); + + _currentTypeDefinition.Push(typeDefinition); + try + { + MaterializeGenericParameterConstraints( + typeDefinition.GenericParameters, + typeDefinition.GenericParameterConstraints, + header.GenericParameters); + if (header.BaseType is not null) + { + typeDefinition.BaseType = ResolveTypeSpecification(header.BaseType); + } + + AddInterfaceImplementations(typeDefinition, header.Interfaces); + } + finally + { + _currentTypeDefinition.Pop(); + } + + if (typeDefinition.Attributes.HasFlag(TypeAttributes.Interface)) + { + fallbackBase = null; + } + + typeDefinition.BaseType ??= _entityRegistry.ResolveImplicitBaseType(fallbackBase); + if (!typeDefinition.Attributes.HasFlag(TypeAttributes.Sealed) && + (requireSealed || _entityRegistry.SystemValueTypeType.Equals(typeDefinition.BaseType))) + { + IToken location = header.NameToken ?? context.Start; + _diagnostics.Add( + new Diagnostic( + DiagnosticIds.UnsealedValueType, + DiagnosticSeverity.Error, + string.Format(DiagnosticMessageTemplates.UnsealedValueType, typeDefinition.Name), + Location.From(location, _documents))); + typeDefinition.Attributes |= TypeAttributes.Sealed; + } + } + + private void MergeTypeDefinition( + ClassHeaderValue header, + EntityRegistry.TypeDefinitionEntity typeDefinition) + { + TypeAttributes attributes = typeDefinition.Attributes; + foreach (ClassAttributeValue classAttribute in header.Attributes) + { + CILParser.AttributeValue attribute = classAttribute.Attribute; + if (!attribute.ShouldAppend) + { + attributes = attribute.Value; + } + else if ((attribute.Value & TypeAttributes.Interface) != 0) + { + attributes |= TypeAttributes.Interface | TypeAttributes.Abstract; + } + else + { + attributes |= attribute.Value; + } + } + typeDefinition.Attributes = attributes; + + bool materializeConstraints = typeDefinition.GenericParameters.Count == 0; + if (materializeConstraints) + { + RegisterGenericParameterNames( + typeDefinition, + typeDefinition.GenericParameters, + header.GenericParameters); + } + + _currentTypeDefinition.Push(typeDefinition); + try + { + if (materializeConstraints) + { + MaterializeGenericParameterConstraints( + typeDefinition.GenericParameters, + typeDefinition.GenericParameterConstraints, + header.GenericParameters); + } + + if (header.BaseType is not null) + { + EntityRegistry.TypeEntity baseType = ResolveTypeSpecification(header.BaseType); + typeDefinition.BaseType ??= baseType; + } + + AddInterfaceImplementations(typeDefinition, header.Interfaces); + } + finally + { + _currentTypeDefinition.Pop(); + } + } + + private void AddInterfaceImplementations( + EntityRegistry.TypeDefinitionEntity typeDefinition, + ImmutableArray interfaces) + { + foreach (TypeSpecificationValue interfaceType in interfaces) + { + typeDefinition.InterfaceImplementations.Add( + EntityRegistry.CreateUnrecordedInterfaceImplementation( + typeDefinition, + ResolveTypeSpecification(interfaceType))); + } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.References.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.References.cs new file mode 100644 index 00000000000000..021711a9dd2911 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.References.cs @@ -0,0 +1,171 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Reflection.Metadata; +using System.Reflection.Metadata.Ecma335; +using Antlr4.Runtime; + +namespace ILAssembler; + +#pragma warning disable CA1822 // Parser actions are invoked through the per-parser GrammarActions instance. +internal sealed partial class GrammarActions +{ + internal TypeName AddSlashedNamePart(TypeName? containingTypeName, string name) + => new(containingTypeName, name); + + internal ClassNameValue CreateUnqualifiedClassName(TypeName name) + => new UnqualifiedClassNameValue(name); + + internal ClassNameValue CreateAssemblyQualifiedClassName(string assemblyName, TypeName name) + => new AssemblyQualifiedClassNameValue(assemblyName, name); + + internal ClassNameValue CreateModuleQualifiedClassName( + IToken token, + string moduleName, + TypeName name) + => new ModuleQualifiedClassNameValue(token, moduleName, name); + + internal ClassNameValue CreateTokenQualifiedClassName(int scopeToken, TypeName name) + => new TokenQualifiedClassNameValue(scopeToken, name); + + internal ClassNameValue CreatePointerQualifiedClassName(TypeName name) + => new PointerQualifiedClassNameValue(name); + + internal ClassNameValue CreateTokenClassName(int typeToken) + => new TokenClassNameValue(typeToken); + + internal ClassNameValue CreateThisClassName(IToken token) + => new SpecialClassNameValue(token, SpecialClassNameKind.This); + + internal ClassNameValue CreateBaseClassName(IToken token) + => new SpecialClassNameValue(token, SpecialClassNameKind.Base); + + internal ClassNameValue CreateNesterClassName(IToken token) + => new SpecialClassNameValue(token, SpecialClassNameKind.Nester); + + private EntityRegistry.TypeEntity ResolveClassName(ClassNameValue className) + { + switch (className) + { + case SpecialClassNameValue { Kind: SpecialClassNameKind.This } special: + if (_currentTypeDefinition.Count == 0) + { + ReportError(DiagnosticIds.ThisOutsideClass, DiagnosticMessageTemplates.ThisOutsideClass, special.Token); + return new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)); + } + return _currentTypeDefinition.Peek(); + case SpecialClassNameValue { Kind: SpecialClassNameKind.Base } special: + if (_currentTypeDefinition.Count == 0) + { + ReportError(DiagnosticIds.BaseOutsideClass, DiagnosticMessageTemplates.BaseOutsideClass, special.Token); + return new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)); + } + if (_currentTypeDefinition.Peek().BaseType is not { } baseType) + { + ReportError(DiagnosticIds.NoBaseType, DiagnosticMessageTemplates.NoBaseType, special.Token); + return new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)); + } + return baseType; + case SpecialClassNameValue { Kind: SpecialClassNameKind.Nester } special: + if (_currentTypeDefinition.Count < 2) + { + ReportError(DiagnosticIds.NesterOutsideNestedClass, DiagnosticMessageTemplates.NesterOutsideNestedClass, special.Token); + return new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)); + } + return _currentTypeDefinition.Peek().ContainingType!; + case AssemblyQualifiedClassNameValue assembly: + return _entityRegistry.GetOrCreateTypeReference( + _entityRegistry.GetOrCreateAssemblyReference(assembly.AssemblyName, _ => { }), + assembly.Name); + case ModuleQualifiedClassNameValue module: + if (_entityRegistry.FindModuleReference(module.ModuleName) is not { } moduleReference) + { + ReportError( + DiagnosticIds.ModuleNotFound, + string.Format(DiagnosticMessageTemplates.ModuleNotFound, module.ModuleName), + module.Token); + return new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)); + } + return _entityRegistry.GetOrCreateTypeReference(moduleReference, module.Name); + case TokenQualifiedClassNameValue tokenScope: + return _entityRegistry.GetOrCreateTypeReference( + ResolveMetadataToken(tokenScope.Token), + tokenScope.Name); + case PointerQualifiedClassNameValue pointer: + return _entityRegistry.GetOrCreateTypeReference( + new EntityRegistry.FakeTypeEntity(default(ModuleDefinitionHandle)), + pointer.Name); + case UnqualifiedClassNameValue unqualified: + return ResolveUnqualifiedClassName(unqualified.Name); + case TokenClassNameValue typeToken: + EntityRegistry.EntityBase resolvedToken = ResolveMetadataToken(typeToken.Token); + return resolvedToken is EntityRegistry.TypeEntity type + ? type + : new EntityRegistry.FakeTypeEntity(resolvedToken.Handle); + default: + return new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)); + } + } + + private EntityRegistry.TypeEntity ResolveUnqualifiedClassName(TypeName typeName) + { + if (typeName.ContainingTypeName is null && TryResolveTypedefAsType(typeName.DottedName) is { } typedef) + { + return typedef; + } + + if (typeName.ContainingTypeName is null) + { + (string ns, string name) = NameHelpers.SplitDottedNameToNamespaceAndName(typeName.DottedName); + if (ns == "System" && name is "String" or "Object" or "ValueType" or "Enum" + or "Type" or "Array" or "Delegate" or "MulticastDelegate" + or "Exception" or "Attribute") + { + return _entityRegistry.GetOrCreateTypeReference(_entityRegistry.GetCoreLibAssemblyReference(), typeName); + } + } + + Stack containingTypes = new(); + for (TypeName? containingType = typeName; containingType is not null; containingType = containingType.ContainingTypeName) + { + containingTypes.Push(containingType); + } + + EntityRegistry.TypeDefinitionEntity? typeDefinition = null; + while (containingTypes.Count != 0) + { + TypeName containingType = containingTypes.Pop(); + (string ns, string name) = NameHelpers.SplitDottedNameToNamespaceAndName(containingType.DottedName); + typeDefinition = _entityRegistry.GetOrCreateTypeDefinition(typeDefinition, ns, name, _ => { }); + } + + Debug.Assert(typeDefinition is not null); + return typeDefinition; + } + + private EntityRegistry.TypeEntity ResolveTypeSpecification(TypeSpecificationValue typeSpecification) + { + return typeSpecification switch + { + ClassTypeSpecificationValue classType => ResolveClassName(classType.ClassName), + ModuleTypeSpecificationValue module => ResolveModuleTypeSpecification(module.ModuleName), + AssemblyTypeSpecificationValue assembly => new EntityRegistry.FakeTypeEntity( + _entityRegistry.GetOrCreateAssemblyReference(assembly.AssemblyName, _ => { }).Handle), + SignatureTypeSpecificationValue signature => _entityRegistry.GetOrCreateTypeSpec(MaterializeType(signature.Type)), + _ => new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle)) + }; + } + + private EntityRegistry.FakeTypeEntity ResolveModuleTypeSpecification(string moduleName) + { + EntityRegistry.ModuleReferenceEntity? module = _entityRegistry.FindModuleReference(moduleName); + return module is null + ? new EntityRegistry.FakeTypeEntity(MetadataTokens.ModuleReferenceHandle(0)) + : new EntityRegistry.FakeTypeEntity(module.Handle); + } + + private EntityRegistry.EntityBase ResolveMetadataToken(int token) + => _entityRegistry.ResolveHandleToEntity(MetadataTokens.EntityHandle(token)); +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.cs new file mode 100644 index 00000000000000..ed3d3e731a11c7 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.Types.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + // Active namespace and type scopes are paired with their owning declaration so a rule's + // finally block can unwind real compiler state after syntax-error recovery. + private readonly Stack _namespaceOwners = new(); + private readonly Stack _typeOwners = new(); + + /// + /// Releases the namespace, type and method state that a top-level declaration introduced. + /// + /// + /// This runs from the decl rule's finally block so that a syntax error inside the + /// declaration body cannot leak a namespace, type or method scope into the following declarations. + /// + internal void EndDeclaration(CILParser.DeclContext context) + { + EndScopesOwnedBy(context); + } + + /// + /// Releases the type and method state that a class member declaration introduced. + /// + internal void EndClassDeclaration(CILParser.ClassDeclContext context) + { + EndScopesOwnedBy(context); + } + + private void EndScopesOwnedBy(RuleContext owner) + { + if (ReferenceEquals(_methodOwner, owner)) + { + EndMethod(); + } + + if (_typeOwners.Count > 0 && ReferenceEquals(_typeOwners.Peek(), owner)) + { + EndType(); + } + + if (_namespaceOwners.Count > 0 && ReferenceEquals(_namespaceOwners.Peek(), owner)) + { + EndNamespace(); + } + } + + private void EndType() + { + CompleteClassMethodOverrides(_currentTypeDefinition.Peek()); + _typeOwners.Pop(); + _currentTypeDefinition.Pop(); + ClearPendingCustomAttributeOwners(); + } + + private void EndNamespace() + { + _namespaceOwners.Pop(); + _currentNamespace.Pop(); + ClearPendingCustomAttributeOwners(); + } + + private void ResetTypeScopes() + { + _typeOwners.Clear(); + _currentTypeDefinition.Clear(); + _namespaceOwners.Clear(); + _currentNamespace.Clear(); + } + + /// + /// Drops the owners that a trailing .custom directive would bind to. + /// + /// + /// A trailing custom attribute only binds to the preceding field, generic parameter or generic + /// constraint within the same type body, so the pending owners must be dropped whenever a + /// namespace, type or method boundary is crossed. + /// + private void ClearPendingCustomAttributeOwners() + { + _lastFieldDefinition = null; + _pendingClassCustomAttributeOwner = null; + } + +} diff --git a/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.cs b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.cs new file mode 100644 index 00000000000000..e3283f496e8258 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/Actions/GrammarActions.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; + +namespace ILAssembler; + +internal sealed partial class GrammarActions +{ + /// + /// Resets the semantic state that must not flow from one document to the next. + /// + /// + /// The same instance compiles every document of a compilation so + /// that they share an entity registry. Every rule that introduces namespace, type, method or + /// scope state releases it from its own finally block, so this is only a safety net for + /// release builds. + /// + internal void BeginDocument() + { + Debug.Assert( + _currentMethod is null + && _typeOwners.Count == 0 + && _namespaceOwners.Count == 0 + && _scopeStack.Count == 0 + && _pendingClassMethodOverrides.Count == 0, + "Nested compiler state must be released by its owning declaration."); + EndMethod(); + ResetTypeScopes(); + ClearPendingCustomAttributeOwners(); + _pendingClassMethodOverrides.Clear(); + _currentDocumentPath = null; + _syntaxErrorCount = 0; + } +} diff --git a/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValueAliases.cs b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValueAliases.cs new file mode 100644 index 00000000000000..973abd2df5be75 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValueAliases.cs @@ -0,0 +1,176 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +global using AnsiBstrNativeTypeElementValue = ILAssembler.CILParser.AnsiBstrNativeTypeElementValue; +global using ArrayBoundValue = ILAssembler.CILParser.ArrayBoundValue; +global using ArraySerializationTypeValue = ILAssembler.CILParser.ArraySerializationTypeValue; +global using ArraySerializedInitializerValue = ILAssembler.CILParser.ArraySerializedInitializerValue; +global using ArrayTypeModifierValue = ILAssembler.CILParser.ArrayTypeModifierValue; +global using AssemblyCustomAttributeDirectiveValue = ILAssembler.CILParser.AssemblyCustomAttributeDirectiveValue; +global using AssemblyQualifiedClassNameValue = ILAssembler.CILParser.AssemblyQualifiedClassNameValue; +global using AssemblyDeclarationValue = ILAssembler.CILParser.AssemblyDeclarationValue; +global using AssemblyDefinitionValue = ILAssembler.CILParser.AssemblyDefinitionValue; +global using AssemblyHashAlgorithmDirectiveValue = ILAssembler.CILParser.AssemblyHashAlgorithmDirectiveValue; +global using AssemblyLocaleDirectiveValue = ILAssembler.CILParser.AssemblyLocaleDirectiveValue; +global using AssemblyPublicKeyDirectiveValue = ILAssembler.CILParser.AssemblyPublicKeyDirectiveValue; +global using AssemblyReferenceHashDirectiveValue = ILAssembler.CILParser.AssemblyReferenceHashDirectiveValue; +global using AssemblyReferenceHeaderValue = ILAssembler.CILParser.AssemblyReferenceHeaderValue; +global using AssemblyReferencePublicKeyTokenDirectiveValue = ILAssembler.CILParser.AssemblyReferencePublicKeyTokenDirectiveValue; +global using AssemblyReferenceValue = ILAssembler.CILParser.AssemblyReferenceValue; +global using AssemblySecurityDirectiveValue = ILAssembler.CILParser.AssemblySecurityDirectiveValue; +global using AssemblyTypeSpecificationValue = ILAssembler.CILParser.AssemblyTypeSpecificationValue; +global using AssemblyVersionDirectiveValue = ILAssembler.CILParser.AssemblyVersionDirectiveValue; +global using AttributePermissionSetValue = ILAssembler.CILParser.AttributePermissionSetValue; +global using CalliSignatureValue = ILAssembler.CILParser.CalliSignatureValue; +global using CatchExceptionClauseValue = ILAssembler.CILParser.CatchExceptionClauseValue; +global using CatchTypeValue = ILAssembler.CILParser.CatchTypeValue; +global using ClassAttributeValue = ILAssembler.CILParser.ClassAttributeValue; +global using ClassElementTypeValue = ILAssembler.CILParser.ClassElementTypeValue; +global using ClassEnumSerializationTypeValue = ILAssembler.CILParser.ClassEnumSerializationTypeValue; +global using ClassHeaderValue = ILAssembler.CILParser.ClassHeaderValue; +global using ClassNameSerializedInitializerValue = ILAssembler.CILParser.ClassNameSerializedInitializerValue; +global using ClassNameValue = ILAssembler.CILParser.ClassNameValue; +global using ClassSerializedSequenceValue = ILAssembler.CILParser.ClassSerializedSequenceValue; +global using ClassSequenceElementValue = ILAssembler.CILParser.ClassSequenceElementValue; +global using ClassTypeSpecificationValue = ILAssembler.CILParser.ClassTypeSpecificationValue; +global using ClassTypedefDeclarationValue = ILAssembler.CILParser.ClassTypedefDeclarationValue; +global using CustomAttributeApplicationValue = ILAssembler.CILParser.CustomAttributeApplicationValue; +global using CustomAttributeBlobValue = ILAssembler.CILParser.CustomAttributeBlobValue; +global using CustomAttributeDeclarationValue = ILAssembler.CILParser.CustomAttributeDeclarationValue; +global using CustomAttributeDescriptorValue = ILAssembler.CILParser.CustomAttributeDescriptorValue; +global using CustomAttributeNamedArgumentValue = ILAssembler.CILParser.CustomAttributeNamedArgumentValue; +global using CustomAttributeTypedefDeclarationValue = ILAssembler.CILParser.CustomAttributeTypedefDeclarationValue; +global using CustomAttributeTypedefValue = ILAssembler.CILParser.CustomAttributeTypedefValue; +global using CustomMarshallerNativeTypeElementValue = ILAssembler.CILParser.CustomMarshallerNativeTypeElementValue; +global using CustomTypeModifierValue = ILAssembler.CILParser.CustomTypeModifierValue; +global using DataDeclarationBuilder = ILAssembler.CILParser.DataDeclarationBuilder; +global using DeprecatedNativeTypeElementValue = ILAssembler.CILParser.DeprecatedNativeTypeElementValue; +global using ElementTypeValue = ILAssembler.CILParser.ElementTypeValue; +global using EmptyNativeTypeElementValue = ILAssembler.CILParser.EmptyNativeTypeElementValue; +global using EmptyPermissionDeclarationValue = ILAssembler.CILParser.EmptyPermissionDeclarationValue; +global using EventHeaderValue = ILAssembler.CILParser.EventHeaderValue; +global using ExceptionClauseValue = ILAssembler.CILParser.ExceptionClauseValue; +global using ExceptionFilterValue = ILAssembler.CILParser.ExceptionFilterValue; +global using ExceptionRangeValue = ILAssembler.CILParser.ExceptionRangeValue; +global using ExportedTypeAssemblyDirectiveValue = ILAssembler.CILParser.ExportedTypeAssemblyDirectiveValue; +global using ExportedTypeCustomAttributeDirectiveValue = ILAssembler.CILParser.ExportedTypeCustomAttributeDirectiveValue; +global using ExportedTypeDeclarationValue = ILAssembler.CILParser.ExportedTypeDeclarationValue; +global using ExportedTypeDefinitionIdDirectiveValue = ILAssembler.CILParser.ExportedTypeDefinitionIdDirectiveValue; +global using ExportedTypeFileDirectiveValue = ILAssembler.CILParser.ExportedTypeFileDirectiveValue; +global using ExportedTypeHeaderValue = ILAssembler.CILParser.ExportedTypeHeaderValue; +global using ExportedTypeMetadataTokenDirectiveValue = ILAssembler.CILParser.ExportedTypeMetadataTokenDirectiveValue; +global using ExportedTypeValue = ILAssembler.CILParser.ExportedTypeValue; +global using FaultExceptionClauseValue = ILAssembler.CILParser.FaultExceptionClauseValue; +global using FieldDeclarationValue = ILAssembler.CILParser.FieldDeclarationValue; +global using FileDeclarationValue = ILAssembler.CILParser.FileDeclarationValue; +global using FieldInitializerValue = ILAssembler.CILParser.FieldInitializerValue; +global using FieldMemberReferenceValue = ILAssembler.CILParser.FieldMemberReferenceValue; +global using FieldReferenceValue = ILAssembler.CILParser.FieldReferenceValue; +global using FilterExceptionClauseValue = ILAssembler.CILParser.FilterExceptionClauseValue; +global using FinallyExceptionClauseValue = ILAssembler.CILParser.FinallyExceptionClauseValue; +global using FixedArrayNativeTypeElementValue = ILAssembler.CILParser.FixedArrayNativeTypeElementValue; +global using FixedSysStringNativeTypeElementValue = ILAssembler.CILParser.FixedSysStringNativeTypeElementValue; +global using FunctionPointerElementTypeValue = ILAssembler.CILParser.FunctionPointerElementTypeValue; +global using GenericArgumentsTypeModifierValue = ILAssembler.CILParser.GenericArgumentsTypeModifierValue; +global using GenericParameterDeclarationValue = ILAssembler.CILParser.GenericParameterDeclarationValue; +global using IidNativeTypeElementValue = ILAssembler.CILParser.IidNativeTypeElementValue; +global using IidParamIndexValue = ILAssembler.CILParser.IidParamIndexValue; +global using IndexedGenericParameterElementTypeValue = ILAssembler.CILParser.IndexedGenericParameterElementTypeValue; +global using InvalidByteArraySerializedInitializerValue = ILAssembler.CILParser.InvalidByteArraySerializedInitializerValue; +global using LabelExceptionFilterValue = ILAssembler.CILParser.LabelExceptionFilterValue; +global using LabelExceptionRangeValue = ILAssembler.CILParser.LabelExceptionRangeValue; +global using LanguageDirectiveValue = ILAssembler.CILParser.LanguageDirectiveValue; +global using ManifestResourceAssemblyDirectiveValue = ILAssembler.CILParser.ManifestResourceAssemblyDirectiveValue; +global using ManifestResourceCustomAttributeDirectiveValue = ILAssembler.CILParser.ManifestResourceCustomAttributeDirectiveValue; +global using ManifestResourceDeclarationValue = ILAssembler.CILParser.ManifestResourceDeclarationValue; +global using ManifestResourceFileDirectiveValue = ILAssembler.CILParser.ManifestResourceFileDirectiveValue; +global using ManifestResourceHeaderValue = ILAssembler.CILParser.ManifestResourceHeaderValue; +global using ManifestResourceValue = ILAssembler.CILParser.ManifestResourceValue; +global using MarshallingDescriptorValue = ILAssembler.CILParser.MarshallingDescriptorValue; +global using MemberOwnerValue = ILAssembler.CILParser.MemberOwnerValue; +global using MemberReferenceValue = ILAssembler.CILParser.MemberReferenceValue; +global using MemberTypedefDeclarationValue = ILAssembler.CILParser.MemberTypedefDeclarationValue; +global using MethodHeaderValue = ILAssembler.CILParser.MethodHeaderValue; +global using MethodMemberReferenceValue = ILAssembler.CILParser.MethodMemberReferenceValue; +global using MethodReferenceValue = ILAssembler.CILParser.MethodReferenceValue; +global using ModuleQualifiedClassNameValue = ILAssembler.CILParser.ModuleQualifiedClassNameValue; +global using ModuleTypeSpecificationValue = ILAssembler.CILParser.ModuleTypeSpecificationValue; +global using NamedGenericParameterElementTypeValue = ILAssembler.CILParser.NamedGenericParameterElementTypeValue; +global using NamedPermissionDeclarationValue = ILAssembler.CILParser.NamedPermissionDeclarationValue; +global using NativeTypeArrayPointerInfoKind = ILAssembler.CILParser.NativeTypeArrayPointerInfoKind; +global using NativeTypeArrayPointerInfoValue = ILAssembler.CILParser.NativeTypeArrayPointerInfoValue; +global using NativeTypeElementValue = ILAssembler.CILParser.NativeTypeElementValue; +global using NativeTypeTypedefValue = ILAssembler.CILParser.NativeTypeTypedefValue; +global using NativeTypeValue = ILAssembler.CILParser.NativeTypeValue; +global using NestedExportedTypeDirectiveValue = ILAssembler.CILParser.NestedExportedTypeDirectiveValue; +global using NestedStructNativeTypeElementValue = ILAssembler.CILParser.NestedStructNativeTypeElementValue; +global using ObjectSerializedInitializerValue = ILAssembler.CILParser.ObjectSerializedInitializerValue; +global using ObjectSerializedSequenceValue = ILAssembler.CILParser.ObjectSerializedSequenceValue; +global using OffsetExceptionFilterValue = ILAssembler.CILParser.OffsetExceptionFilterValue; +global using OffsetExceptionRangeValue = ILAssembler.CILParser.OffsetExceptionRangeValue; +global using OwnerTypeValue = ILAssembler.CILParser.OwnerTypeValue; +global using ParsedFieldReferenceValue = ILAssembler.CILParser.ParsedFieldReferenceValue; +global using ParsedMethodReferenceValue = ILAssembler.CILParser.ParsedMethodReferenceValue; +global using PermissionDeclarationValue = ILAssembler.CILParser.PermissionDeclarationValue; +global using PInvokeValue = ILAssembler.CILParser.PInvokeValue; +global using PointerQualifiedClassNameValue = ILAssembler.CILParser.PointerQualifiedClassNameValue; +global using PrimitiveElementTypeValue = ILAssembler.CILParser.PrimitiveElementTypeValue; +global using PropertyHeaderValue = ILAssembler.CILParser.PropertyHeaderValue; +global using RawCustomAttributeBlobValue = ILAssembler.CILParser.RawCustomAttributeBlobValue; +global using RawPermissionSetValue = ILAssembler.CILParser.RawPermissionSetValue; +global using RawSerializationTypeValue = ILAssembler.CILParser.RawSerializationTypeValue; +global using RawSerializedInitializerValue = ILAssembler.CILParser.RawSerializedInitializerValue; +global using RawSerializedSequenceValue = ILAssembler.CILParser.RawSerializedSequenceValue; +global using RawVTableValue = ILAssembler.CILParser.RawVTableValue; +global using SafeArrayNativeTypeElementValue = ILAssembler.CILParser.SafeArrayNativeTypeElementValue; +global using ScopeExceptionFilterValue = ILAssembler.CILParser.ScopeExceptionFilterValue; +global using ScopeExceptionRangeValue = ILAssembler.CILParser.ScopeExceptionRangeValue; +global using SecurityAttributeValue = ILAssembler.CILParser.SecurityAttributeValue; +global using SecurityBooleanValue = ILAssembler.CILParser.SecurityBooleanValue; +global using SecurityCaValue = ILAssembler.CILParser.SecurityCaValue; +global using SecurityDeclarationValue = ILAssembler.CILParser.SecurityDeclarationValue; +global using SecurityEnumValue = ILAssembler.CILParser.SecurityEnumValue; +global using SecurityInt32Value = ILAssembler.CILParser.SecurityInt32Value; +global using SecurityNameValuePairValue = ILAssembler.CILParser.SecurityNameValuePairValue; +global using SecurityStringValue = ILAssembler.CILParser.SecurityStringValue; +global using SentinelElementTypeValue = ILAssembler.CILParser.SentinelElementTypeValue; +global using SerializationTypeValue = ILAssembler.CILParser.SerializationTypeValue; +global using SerializedInitializerValue = ILAssembler.CILParser.SerializedInitializerValue; +global using SerializedSequenceValue = ILAssembler.CILParser.SerializedSequenceValue; +global using SignatureArgumentValue = ILAssembler.CILParser.SignatureArgumentValue; +global using SignatureTypeSpecificationValue = ILAssembler.CILParser.SignatureTypeSpecificationValue; +global using SimpleNativeTypeElementValue = ILAssembler.CILParser.SimpleNativeTypeElementValue; +global using SimpleSerializationTypeValue = ILAssembler.CILParser.SimpleSerializationTypeValue; +global using SimpleTypeModifierKind = ILAssembler.CILParser.SimpleTypeModifierKind; +global using SimpleTypeModifierValue = ILAssembler.CILParser.SimpleTypeModifierValue; +global using SourceDirectiveValue = ILAssembler.CILParser.SourceDirectiveValue; +global using SpecialClassNameKind = ILAssembler.CILParser.SpecialClassNameKind; +global using SpecialClassNameValue = ILAssembler.CILParser.SpecialClassNameValue; +global using StringClassSequenceElementValue = ILAssembler.CILParser.StringClassSequenceElementValue; +global using StringEnumSerializationTypeValue = ILAssembler.CILParser.StringEnumSerializationTypeValue; +global using StringPermissionSetValue = ILAssembler.CILParser.StringPermissionSetValue; +global using StructuredCustomAttributeBlobValue = ILAssembler.CILParser.StructuredCustomAttributeBlobValue; +global using StructuredPermissionDeclarationValue = ILAssembler.CILParser.StructuredPermissionDeclarationValue; +global using TokenClassNameValue = ILAssembler.CILParser.TokenClassNameValue; +global using TokenMemberReferenceValue = ILAssembler.CILParser.TokenMemberReferenceValue; +global using TokenMethodReferenceValue = ILAssembler.CILParser.TokenMethodReferenceValue; +global using TokenQualifiedClassNameValue = ILAssembler.CILParser.TokenQualifiedClassNameValue; +global using TypeClassSequenceElementValue = ILAssembler.CILParser.TypeClassSequenceElementValue; +global using TypeModifierValue = ILAssembler.CILParser.TypeModifierValue; +global using TypeName = ILAssembler.CILParser.TypeName; +global using TypeOwnerValue = ILAssembler.CILParser.TypeOwnerValue; +global using TypeSignatureTypedefDeclarationValue = ILAssembler.CILParser.TypeSignatureTypedefDeclarationValue; +global using TypeSpecificationValue = ILAssembler.CILParser.TypeSpecificationValue; +global using TypeValue = ILAssembler.CILParser.TypeValue; +global using TypedefDeclarationValue = ILAssembler.CILParser.TypedefDeclarationValue; +global using TypedefElementTypeValue = ILAssembler.CILParser.TypedefElementTypeValue; +global using TypedefEntry = ILAssembler.CILParser.TypedefEntry; +global using TypedefFieldReferenceValue = ILAssembler.CILParser.TypedefFieldReferenceValue; +global using TypedefMethodReferenceValue = ILAssembler.CILParser.TypedefMethodReferenceValue; +global using TypedefSerializationTypeValue = ILAssembler.CILParser.TypedefSerializationTypeValue; +global using UnqualifiedClassNameValue = ILAssembler.CILParser.UnqualifiedClassNameValue; +global using UnsignedNativeTypeElementValue = ILAssembler.CILParser.UnsignedNativeTypeElementValue; +global using VariantBoolNativeTypeElementValue = ILAssembler.CILParser.VariantBoolNativeTypeElementValue; +global using VariantTypeElementValue = ILAssembler.CILParser.VariantTypeElementValue; +global using VariantTypeValue = ILAssembler.CILParser.VariantTypeValue; +global using VTableFixupValue = ILAssembler.CILParser.VTableFixupValue; diff --git a/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.CustomAttributes.cs b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.CustomAttributes.cs new file mode 100644 index 00000000000000..75c72a98e4f2ff --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.CustomAttributes.cs @@ -0,0 +1,148 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +public partial class CILParser +{ + public abstract record CustomAttributeDeclarationValue + { + public static CustomAttributeDeclarationValue Error { get; } = + new ErrorCustomAttributeDeclarationValue(); + } + + public sealed record ErrorCustomAttributeDeclarationValue : CustomAttributeDeclarationValue; + + public sealed record CustomAttributeDescriptorValue( + MethodReferenceValue Constructor, + CustomAttributeBlobValue Value, + OwnerTypeValue? Owner) : CustomAttributeDeclarationValue + { + public static new CustomAttributeDescriptorValue Error { get; } = + new(MethodReferenceValue.Error, CustomAttributeBlobValue.Error, null); + } + + public sealed record CustomAttributeTypedefValue( + string Alias) : CustomAttributeDeclarationValue; + + public sealed record CustomAttributeApplicationValue( + CustomAttributeDeclarationValue? Value, + IToken Location, + bool HasSyntaxError); + + public abstract record CustomAttributeBlobValue + { + public static CustomAttributeBlobValue Error { get; } = + new ErrorCustomAttributeBlobValue(); + } + + public sealed record ErrorCustomAttributeBlobValue : CustomAttributeBlobValue; + + public sealed record RawCustomAttributeBlobValue( + BlobBuilder Value) : CustomAttributeBlobValue; + + public sealed record StructuredCustomAttributeBlobValue( + ImmutableArray Arguments, + ImmutableArray NamedArguments) + : CustomAttributeBlobValue; + + public sealed record CustomAttributeNamedArgumentValue( + byte Kind, + SerializationTypeValue Type, + string Name, + SerializedInitializerValue Value); + + public abstract record SerializationTypeValue + { + public static SerializationTypeValue Error { get; } = + new ErrorSerializationTypeValue(); + } + + public sealed record ErrorSerializationTypeValue : SerializationTypeValue; + + public sealed record RawSerializationTypeValue( + BlobBuilder Value) : SerializationTypeValue; + + public sealed record SimpleSerializationTypeValue( + SerializationTypeCode Type) : SerializationTypeValue; + + public sealed record ArraySerializationTypeValue( + SerializationTypeValue ElementType) : SerializationTypeValue; + + public sealed record StringEnumSerializationTypeValue( + string Name) : SerializationTypeValue; + + public sealed record ClassEnumSerializationTypeValue( + ClassNameValue ClassName) : SerializationTypeValue; + + public sealed record TypedefSerializationTypeValue( + IToken Token, + string Alias) : SerializationTypeValue; + + public abstract record SerializedInitializerValue(SerializationTypeValue Type) + { + public static SerializedInitializerValue Error { get; } = + new ErrorSerializedInitializerValue(); + } + + public sealed record ErrorSerializedInitializerValue() + : SerializedInitializerValue(SerializationTypeValue.Error); + + public sealed record RawSerializedInitializerValue( + SerializationTypeValue Type, + BlobBuilder Value) : SerializedInitializerValue(Type); + + public sealed record ClassNameSerializedInitializerValue( + ClassNameValue ClassName) + : SerializedInitializerValue( + new SimpleSerializationTypeValue(SerializationTypeCode.Type)); + + public sealed record ObjectSerializedInitializerValue( + SerializedInitializerValue Value) + : SerializedInitializerValue( + new SimpleSerializationTypeValue(SerializationTypeCode.TaggedObject)); + + public sealed record InvalidByteArraySerializedInitializerValue( + IToken Token) + : SerializedInitializerValue( + new SimpleSerializationTypeValue(SerializationTypeCode.String)); + + public sealed record ArraySerializedInitializerValue( + SerializationTypeValue Type, + int Length, + SerializedSequenceValue Values) : SerializedInitializerValue(Type); + + public abstract record SerializedSequenceValue; + + public sealed record RawSerializedSequenceValue( + BlobBuilder Value) : SerializedSequenceValue; + + public sealed record ClassSerializedSequenceValue( + ImmutableArray Values) : SerializedSequenceValue; + + public sealed record ObjectSerializedSequenceValue( + ImmutableArray Values) : SerializedSequenceValue; + + public abstract record ClassSequenceElementValue + { + public static ClassSequenceElementValue Error { get; } = + new ErrorClassSequenceElementValue(); + } + + public sealed record ErrorClassSequenceElementValue : ClassSequenceElementValue; + + public sealed record StringClassSequenceElementValue( + string? Value) : ClassSequenceElementValue; + + public sealed record TypeClassSequenceElementValue( + ClassNameValue ClassName) : ClassSequenceElementValue; + + public sealed record FieldInitializerValue(bool HasValue, object? ConstantValue) + { + public static FieldInitializerValue Empty { get; } = new(false, null); + } +} diff --git a/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Declarations.cs b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Declarations.cs new file mode 100644 index 00000000000000..f8249369b6a00d --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Declarations.cs @@ -0,0 +1,222 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using System.Reflection; +using Antlr4.Runtime; + +namespace ILAssembler; + +public partial class CILParser +{ + public sealed record AttributeValue(T Value, T GroupMask, bool ShouldAppend) + where T : struct, System.Enum + { + public static AttributeValue Empty { get; } = new(default, default, true); + } + + public sealed record PInvokeValue( + string? ModuleName, + string? EntryPointName, + MethodImportAttributes Attributes); + + public sealed record GenericParameterDeclarationValue( + GenericParameterAttributes Attributes, + string Name, + ImmutableArray Constraints) + { + public static GenericParameterDeclarationValue Error { get; } = + new(0, string.Empty, []); + } + + public sealed record MethodHeaderValue( + bool IsValid, + MethodAttributes Attributes, + ImmutableArray PInvokes, + byte CallingConvention, + int ReturnAttributes, + TypeValue ReturnType, + MarshallingDescriptorValue ReturnMarshalling, + string Name, + ImmutableArray GenericParameters, + ImmutableArray Arguments, + MethodImplAttributes ImplementationAttributes) + { + public static MethodHeaderValue Error { get; } = new( + false, + 0, + [], + 0, + 0, + TypeValue.Error, + MarshallingDescriptorValue.Empty, + string.Empty, + [], + [], + 0); + } + + public sealed record FieldDeclarationValue( + bool IsValid, + FieldAttributes Attributes, + TypeValue FieldType, + string Name, + MarshallingDescriptorValue Marshalling, + string? DataDeclarationName, + int? Offset, + FieldInitializerValue Initializer) + { + public static FieldDeclarationValue Error { get; } = new( + false, + 0, + TypeValue.Error, + string.Empty, + MarshallingDescriptorValue.Empty, + null, + null, + FieldInitializerValue.Empty); + } + + public sealed record PropertyHeaderValue( + bool IsValid, + PropertyAttributes Attributes, + byte CallingConvention, + TypeValue PropertyType, + string Name, + ImmutableArray Arguments, + FieldInitializerValue Initializer) + { + public static PropertyHeaderValue Error { get; } = new( + false, + 0, + 0, + TypeValue.Error, + string.Empty, + [], + FieldInitializerValue.Empty); + } + + public sealed record EventHeaderValue( + bool IsValid, + EventAttributes Attributes, + TypeSpecificationValue? EventType, + string Name) + { + public static EventHeaderValue Error { get; } = + new(false, 0, null, string.Empty); + } + + public sealed class ClassAttributeValue + { + public static ClassAttributeValue Empty { get; } = + new(AttributeValue.Empty, null, false); + + internal ClassAttributeValue( + AttributeValue attribute, + EntityRegistry.WellKnownBaseType? fallbackBase, + bool requireSealed) + { + Attribute = attribute; + FallbackBase = fallbackBase; + RequireSealed = requireSealed; + } + + internal AttributeValue Attribute { get; } + + internal EntityRegistry.WellKnownBaseType? FallbackBase { get; } + + internal bool RequireSealed { get; } + } + + public sealed record ClassHeaderValue( + bool IsValid, + IToken? NameToken, + string FullName, + ImmutableArray Attributes, + ImmutableArray GenericParameters, + TypeSpecificationValue? BaseType, + ImmutableArray Interfaces) + { + public static ClassHeaderValue Error { get; } = new( + false, + null, + string.Empty, + [], + [], + null, + []); + } + + public sealed class MethodHeaderBuilder + { + internal MethodAttributes Attributes { get; set; } + + internal ImmutableArray.Builder PInvokes { get; } = + ImmutableArray.CreateBuilder(); + + internal MethodImplAttributes ImplementationAttributes { get; set; } + } + + public sealed class PInvokeBuilder + { + internal string? ModuleName { get; set; } + + internal string? EntryPointName { get; set; } + + internal MethodImportAttributes Attributes { get; set; } + } + + public sealed class FieldDeclarationBuilder + { + internal FieldAttributes Attributes { get; set; } + + internal MarshallingDescriptorValue Marshalling { get; set; } = + MarshallingDescriptorValue.Empty; + } + + public sealed class PropertyHeaderBuilder + { + internal PropertyAttributes Attributes { get; set; } + } + + public sealed class EventHeaderBuilder + { + internal EventAttributes Attributes { get; set; } + } + + public sealed class ClassHeaderBuilder + { + internal ImmutableArray.Builder Attributes { get; } = + ImmutableArray.CreateBuilder(); + } + + public sealed class PropertyBodyValue + { + internal PropertyBodyValue(EntityRegistry.PropertyEntity? property) + { + Property = property; + } + + internal EntityRegistry.PropertyEntity? Property { get; } + } + + public sealed class EventBodyValue + { + internal EventBodyValue(EntityRegistry.EventEntity? @event) + { + Event = @event; + } + + internal EntityRegistry.EventEntity? Event { get; } + } + + public sealed class CustomAttributeOwnerValue + { + internal CustomAttributeOwnerValue(EntityRegistry.EntityBase? owner) + { + Owner = owner; + } + + internal EntityRegistry.EntityBase? Owner { get; } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Manifest.cs b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Manifest.cs new file mode 100644 index 00000000000000..b3e11f6226c8b5 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Manifest.cs @@ -0,0 +1,223 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Immutable; +using System.Reflection; +using System.Reflection.Metadata; +using Antlr4.Runtime; + +namespace ILAssembler; + +public partial class CILParser +{ + public abstract record AssemblyDeclarationValue; + + public sealed record AssemblyDefinitionValue( + AssemblyFlags Attributes, + string Name, + ImmutableArray Declarations); + + public sealed record AssemblyReferenceValue( + AssemblyReferenceHeaderValue Header, + ImmutableArray Declarations); + + public sealed record AssemblyReferenceHeaderValue( + bool IsValid, + AssemblyFlags Attributes, + string Name, + string Alias) + { + public static AssemblyReferenceHeaderValue Error { get; } = + new(false, 0, string.Empty, string.Empty); + } + + public sealed record AssemblyPublicKeyDirectiveValue( + ImmutableArray Value) : AssemblyDeclarationValue; + + public sealed record AssemblyVersionDirectiveValue( + Version Value) : AssemblyDeclarationValue; + + public sealed record AssemblyLocaleDirectiveValue( + string Value) : AssemblyDeclarationValue; + + public sealed record AssemblyCustomAttributeDirectiveValue( + CustomAttributeDeclarationValue? Value, + IToken Location) : AssemblyDeclarationValue; + + public sealed record AssemblyHashAlgorithmDirectiveValue( + AssemblyHashAlgorithm Value) : AssemblyDeclarationValue; + + public sealed record AssemblySecurityDirectiveValue( + SecurityDeclarationValue? Value, + IToken Location) : AssemblyDeclarationValue; + + public sealed record AssemblyReferenceHashDirectiveValue( + ImmutableArray Value) : AssemblyDeclarationValue; + + public sealed record AssemblyReferencePublicKeyTokenDirectiveValue( + ImmutableArray Value) : AssemblyDeclarationValue; + + public sealed record FileDeclarationValue( + string Name, + bool HasMetadata, + bool IsEntryPoint, + ImmutableArray? Hash); + + public sealed class FileDeclarationBuilder + { + internal string Name { get; set; } = string.Empty; + + internal bool HasMetadata { get; set; } = true; + + internal bool IsEntryPoint { get; set; } + + internal ImmutableArray? Hash { get; set; } + } + + public abstract record ExportedTypeDeclarationValue; + + public sealed record ExportedTypeValue( + ExportedTypeHeaderValue Header, + ImmutableArray Declarations); + + public sealed record ExportedTypeHeaderValue( + bool IsValid, + TypeAttributes Attributes, + string Name, + IToken? Location) + { + public static ExportedTypeHeaderValue Error { get; } = + new(false, 0, string.Empty, null); + } + + public sealed record ExportedTypeFileDirectiveValue( + string Name, + IToken Location) : ExportedTypeDeclarationValue; + + public sealed record NestedExportedTypeDirectiveValue( + TypeName Name, + IToken Location) : ExportedTypeDeclarationValue; + + public sealed record ExportedTypeAssemblyDirectiveValue( + string Name, + IToken Location) : ExportedTypeDeclarationValue; + + public sealed record ExportedTypeMetadataTokenDirectiveValue( + int Token, + IToken Location) : ExportedTypeDeclarationValue; + + public sealed record ExportedTypeDefinitionIdDirectiveValue( + int Value) : ExportedTypeDeclarationValue; + + public sealed record ExportedTypeCustomAttributeDirectiveValue( + CustomAttributeDeclarationValue? Value, + IToken Location) : ExportedTypeDeclarationValue; + + public abstract record ManifestResourceDeclarationValue; + + public sealed record ManifestResourceValue( + ManifestResourceHeaderValue Header, + ImmutableArray Declarations); + + public sealed record ManifestResourceHeaderValue( + bool IsValid, + ManifestResourceAttributes Attributes, + string Name, + string Alias, + IToken? Location) + { + public static ManifestResourceHeaderValue Error { get; } = + new(false, 0, string.Empty, string.Empty, null); + } + + public sealed record ManifestResourceFileDirectiveValue( + string Name, + uint Offset, + IToken Location) : ManifestResourceDeclarationValue; + + public sealed record ManifestResourceAssemblyDirectiveValue( + string Name) : ManifestResourceDeclarationValue; + + public sealed record ManifestResourceCustomAttributeDirectiveValue( + CustomAttributeDeclarationValue? Value, + IToken Location) : ManifestResourceDeclarationValue; + + public sealed record RawVTableValue(ImmutableArray Value); + + public sealed record VTableFixupValue(int SlotCount, ushort Flags, string DataLabel); + + public abstract record TypedefDeclarationValue(string Alias) + { + public static TypedefDeclarationValue Error { get; } = + new ErrorTypedefDeclarationValue(); + } + + public sealed record ErrorTypedefDeclarationValue() + : TypedefDeclarationValue(string.Empty); + + public sealed record TypeSignatureTypedefDeclarationValue( + TypeValue Type, + string Alias) : TypedefDeclarationValue(Alias); + + public sealed record ClassTypedefDeclarationValue( + ClassNameValue Type, + string Alias) : TypedefDeclarationValue(Alias); + + public sealed record MemberTypedefDeclarationValue( + MemberReferenceValue Member, + string Alias) : TypedefDeclarationValue(Alias); + + public sealed record CustomAttributeTypedefDeclarationValue( + CustomAttributeDescriptorValue Attribute, + IToken Location, + string Alias) : TypedefDeclarationValue(Alias); + + public abstract class TypedefEntry + { + public sealed class Type : TypedefEntry + { + internal Type(EntityRegistry.TypeEntity entity) + { + Entity = entity; + } + + internal EntityRegistry.TypeEntity Entity { get; } + } + + public sealed class TypeBlob : TypedefEntry + { + internal TypeBlob(BlobBuilder blob) + { + Blob = blob; + } + + internal BlobBuilder Blob { get; } + } + + public sealed class Member : TypedefEntry + { + internal Member(EntityRegistry.EntityBase entity) + { + Entity = entity; + } + + internal EntityRegistry.EntityBase Entity { get; } + } + + public sealed class CustomAttribute : TypedefEntry + { + internal CustomAttribute( + EntityRegistry.EntityBase constructor, + BlobBuilder value) + { + Constructor = constructor; + Value = value; + } + + internal EntityRegistry.EntityBase Constructor { get; } + + internal BlobBuilder Value { get; } + } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Marshalling.cs b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Marshalling.cs new file mode 100644 index 00000000000000..fa0e57c974a4e7 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Marshalling.cs @@ -0,0 +1,138 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Reflection.Metadata; +using System.Runtime.InteropServices; +using Antlr4.Runtime; + +namespace ILAssembler; + +public partial class CILParser +{ + public sealed record MarshallingDescriptorValue( + BlobBuilder? RawBytes, + NativeTypeValue? NativeType) + { + public static MarshallingDescriptorValue Empty { get; } = + new(new BlobBuilder(0), null); + } + + public sealed record NativeTypeValue( + IToken? Token, + NativeTypeElementValue? Element, + ImmutableArray ArrayPointerInfo) + { + public static NativeTypeValue Empty { get; } = new(null, null, []); + } + + public abstract record NativeTypeElementValue; + + public sealed record EmptyNativeTypeElementValue : NativeTypeElementValue + { + public static EmptyNativeTypeElementValue Instance { get; } = new(); + } + + public sealed record CustomMarshallerNativeTypeElementValue( + IToken? Token, + string? Guid, + string? NativeTypeName, + string MarshallerType, + string Cookie) : NativeTypeElementValue; + + public sealed record FixedSysStringNativeTypeElementValue( + IToken Size) : NativeTypeElementValue; + + public sealed record FixedArrayNativeTypeElementValue( + IToken Size, + NativeTypeValue Element) : NativeTypeElementValue; + + public sealed record DeprecatedNativeTypeElementValue( + IToken Token, + int TokenType) : NativeTypeElementValue; + + public sealed record SimpleNativeTypeElementValue( + int TokenType) : NativeTypeElementValue; + + public sealed record IidNativeTypeElementValue( + int TokenType, + IidParamIndexValue IidParamIndex) : NativeTypeElementValue; + + public sealed record SafeArrayNativeTypeElementValue( + VariantTypeValue VariantType, + string? UserDefinedType) : NativeTypeElementValue; + + public sealed record UnsignedNativeTypeElementValue( + int TokenType) : NativeTypeElementValue; + + public sealed record NestedStructNativeTypeElementValue( + IToken Token) : NativeTypeElementValue; + + public sealed record AnsiBstrNativeTypeElementValue : NativeTypeElementValue + { + public static AnsiBstrNativeTypeElementValue Instance { get; } = new(); + } + + public sealed record VariantBoolNativeTypeElementValue : NativeTypeElementValue + { + public static VariantBoolNativeTypeElementValue Instance { get; } = new(); + } + + public sealed record NativeTypeTypedefValue( + IToken Token, + string Alias) : NativeTypeElementValue; + + public enum NativeTypeArrayPointerInfoKind + { + Pointer, + ArrayNoSizeData, + ArraySize, + ArraySizeParamIndex, + ArrayParamIndex + } + + public sealed record NativeTypeArrayPointerInfoValue( + NativeTypeArrayPointerInfoKind Kind, + IToken? Size = null, + IToken? ParameterIndex = null); + + public sealed record IidParamIndexValue(IToken? Index) + { + public static IidParamIndexValue Empty { get; } = new((IToken?)null); + } + + public sealed record VariantTypeValue( + VariantTypeElementValue? Element, + VarEnum Modifiers) + { + public static VariantTypeValue Empty { get; } = new(null, 0); + } + + public sealed record VariantTypeElementValue(int TokenType) + { + public static VariantTypeElementValue Error { get; } = + new(TokenConstants.InvalidType); + } + + public sealed class MarshalBlobBuilder + { + internal NativeTypeValue? NativeType { get; set; } + + internal BlobBuilder? RawBytes { get; set; } + } + + public sealed class NativeTypeBuilder + { + internal NativeTypeElementValue? Element { get; set; } + + internal List? ArrayPointerInfo { get; set; } + } + + public sealed class VariantTypeBuilder + { + internal VariantTypeElementValue? Element { get; set; } + + internal VarEnum Modifiers { get; set; } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.MethodBodies.cs b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.MethodBodies.cs new file mode 100644 index 00000000000000..b11c1c0363797a --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.MethodBodies.cs @@ -0,0 +1,206 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Reflection; +using System.Reflection.Metadata; +using System.Text; +using Antlr4.Runtime; + +namespace ILAssembler; + +public partial class CILParser +{ + public sealed class DottedNameBuilder + { + internal StringBuilder Value { get; } = new(); + + internal bool HasPart { get; set; } + } + + public sealed record SourceDirectiveValue( + bool AutoIncrement, + int StartLine, + int StartColumn, + int EndLine, + int EndColumn, + string? DocumentPath); + + public sealed record LanguageDirectiveValue( + string Language, + string? Vendor, + string? DocumentType); + + public abstract record ExceptionRangeValue + { + public static ExceptionRangeValue Invalid { get; } = + new InvalidExceptionRangeValue(); + } + + public sealed record InvalidExceptionRangeValue : ExceptionRangeValue; + + public sealed record ScopeExceptionRangeValue( + ScopeBlockContext Scope) : ExceptionRangeValue; + + public sealed record LabelExceptionRangeValue( + string Start, + string End) : ExceptionRangeValue; + + public sealed record OffsetExceptionRangeValue( + int Start, + int End) : ExceptionRangeValue; + + public abstract record ExceptionFilterValue + { + public static ExceptionFilterValue Invalid { get; } = + new InvalidExceptionFilterValue(); + } + + public sealed record InvalidExceptionFilterValue : ExceptionFilterValue; + + public sealed record ScopeExceptionFilterValue( + ScopeBlockContext Scope) : ExceptionFilterValue; + + public sealed record LabelExceptionFilterValue( + string Label) : ExceptionFilterValue; + + public sealed record OffsetExceptionFilterValue( + int Offset) : ExceptionFilterValue; + + public sealed class CatchTypeValue + { + internal CatchTypeValue(EntityRegistry.TypeEntity? type, bool isValid) + { + Type = type; + IsValid = isValid; + } + + public static CatchTypeValue Invalid { get; } = new(null, isValid: false); + + internal EntityRegistry.TypeEntity? Type { get; } + + public bool IsValid { get; } + } + + public abstract record ExceptionClauseValue(ExceptionRangeValue Handler) + { + public static ExceptionClauseValue Invalid { get; } = + new InvalidExceptionClauseValue(ExceptionRangeValue.Invalid); + } + + public sealed record InvalidExceptionClauseValue( + ExceptionRangeValue Handler) : ExceptionClauseValue(Handler); + + public sealed record CatchExceptionClauseValue( + CatchTypeValue CatchType, + ExceptionRangeValue Handler) : ExceptionClauseValue(Handler); + + public sealed record FilterExceptionClauseValue( + ExceptionFilterValue Filter, + ExceptionRangeValue Handler) : ExceptionClauseValue(Handler); + + public sealed record FinallyExceptionClauseValue( + ExceptionRangeValue Handler) : ExceptionClauseValue(Handler); + + public sealed record FaultExceptionClauseValue( + ExceptionRangeValue Handler) : ExceptionClauseValue(Handler); + + public abstract record SecurityDeclarationValue(DeclarativeSecurityAction Action); + + public abstract record PermissionDeclarationValue( + DeclarativeSecurityAction Action, + TypeSpecificationValue PermissionType) : SecurityDeclarationValue(Action); + + public sealed record NamedPermissionDeclarationValue( + DeclarativeSecurityAction Action, + TypeSpecificationValue PermissionType, + ImmutableArray Pairs) + : PermissionDeclarationValue(Action, PermissionType); + + public sealed record StructuredPermissionDeclarationValue( + DeclarativeSecurityAction Action, + TypeSpecificationValue PermissionType, + CustomAttributeBlobValue Value) + : PermissionDeclarationValue(Action, PermissionType); + + public sealed record EmptyPermissionDeclarationValue( + DeclarativeSecurityAction Action, + TypeSpecificationValue PermissionType) + : PermissionDeclarationValue(Action, PermissionType); + + public sealed record RawPermissionSetValue( + DeclarativeSecurityAction Action, + ImmutableArray Value) : SecurityDeclarationValue(Action); + + public sealed record StringPermissionSetValue( + DeclarativeSecurityAction Action, + string Value) : SecurityDeclarationValue(Action); + + public sealed record AttributePermissionSetValue( + DeclarativeSecurityAction Action, + ImmutableArray Attributes) : SecurityDeclarationValue(Action); + + public sealed record SecurityAttributeValue( + string? Name, + TypeSpecificationValue? Type, + ImmutableArray Arguments) + { + public static SecurityAttributeValue Error { get; } = + new(null, null, []); + } + + public sealed record SecurityNameValuePairValue( + string Name, + SecurityCaValue Value) + { + public static SecurityNameValuePairValue Error { get; } = + new(string.Empty, SecurityCaValue.Error); + } + + public abstract record SecurityCaValue + { + public static SecurityCaValue Error { get; } = new ErrorSecurityCaValue(); + } + + public sealed record ErrorSecurityCaValue : SecurityCaValue; + + public sealed record SecurityBooleanValue(bool Value) : SecurityCaValue; + + public sealed record SecurityInt32Value(int Value) : SecurityCaValue; + + public sealed record SecurityStringValue(string Value) : SecurityCaValue; + + public sealed record SecurityEnumValue( + ClassNameValue Type, + byte Size, + int Value) : SecurityCaValue; + + public sealed class DataDeclarationBuilder + { + internal DataDeclarationBuilder(bool shouldCommit) + { + ShouldCommit = shouldCommit; + } + + internal bool ShouldCommit { get; } + + internal BlobBuilder Data { get; } = new(); + + internal Dictionary>? ReferenceFixups { get; set; } + + internal string? Name { get; set; } + } + + public sealed class SwitchInstructionBuilder + { + internal SwitchInstructionBuilder(IToken opcodeToken) + { + OpcodeToken = opcodeToken; + } + + internal IToken OpcodeToken { get; } + + internal List<(IToken Token, bool IsOffset)> Operands { get; } = new(); + } +} diff --git a/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Signatures.cs b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Signatures.cs new file mode 100644 index 00000000000000..d5b0b627a2fff7 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CILParser.SemanticValues.Signatures.cs @@ -0,0 +1,218 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Immutable; +using Antlr4.Runtime; + +namespace ILAssembler; + +public partial class CILParser +{ + public sealed record TypeName(TypeName? ContainingTypeName, string DottedName); + + public sealed record ArrayBoundValue(int? Lower, int? Upper); + + public abstract record ElementTypeValue + { + public static ElementTypeValue Error { get; } = new ErrorElementTypeValue(); + } + + public sealed record ErrorElementTypeValue : ElementTypeValue; + + public sealed record PrimitiveElementTypeValue(byte TypeCode) : ElementTypeValue; + + public sealed record ClassElementTypeValue(ClassNameValue ClassName, bool IsValueType) : ElementTypeValue; + + public sealed record FunctionPointerElementTypeValue( + byte CallingConvention, + TypeValue ReturnType, + ImmutableArray Arguments) : ElementTypeValue; + + public abstract record GenericParameterElementTypeValue(bool IsMethodParameter) : ElementTypeValue; + + public sealed record IndexedGenericParameterElementTypeValue(bool IsMethodParameter, int Index) + : GenericParameterElementTypeValue(IsMethodParameter); + + public sealed record NamedGenericParameterElementTypeValue( + IToken Token, + bool IsMethodParameter, + string Name) : GenericParameterElementTypeValue(IsMethodParameter); + + public sealed record TypedefElementTypeValue(IToken Token, string Alias) : ElementTypeValue; + + public sealed record SentinelElementTypeValue(TypeValue Type) : ElementTypeValue; + + public sealed record TypeValue( + ElementTypeValue ElementType, + ImmutableArray Modifiers) + { + public static TypeValue Error { get; } = new(ElementTypeValue.Error, []); + } + + public abstract record TypeModifierValue + { + public static TypeModifierValue Error { get; } = new ErrorTypeModifierValue(); + } + + public sealed record ErrorTypeModifierValue : TypeModifierValue; + + public enum SimpleTypeModifierKind + { + SzArray, + ByReference, + Pointer, + Pinned + } + + public sealed record SimpleTypeModifierValue(SimpleTypeModifierKind Kind) : TypeModifierValue; + + public sealed record ArrayTypeModifierValue(ImmutableArray Bounds) : TypeModifierValue; + + public sealed record CustomTypeModifierValue( + TypeSpecificationValue Type, + bool IsRequired) : TypeModifierValue; + + public sealed record GenericArgumentsTypeModifierValue( + ImmutableArray Arguments) : TypeModifierValue; + + public sealed record SignatureArgumentValue( + bool IsSentinel, + int Attributes, + TypeValue? Type, + MarshallingDescriptorValue? Marshalling, + string? Name) + { + public static SignatureArgumentValue Error { get; } = + new(false, 0, TypeValue.Error, null, null); + } + + public sealed record CalliSignatureValue( + byte CallingConvention, + TypeValue ReturnType, + ImmutableArray Arguments) + { + public static CalliSignatureValue Error { get; } = new(0, TypeValue.Error, []); + } + + public abstract record ClassNameValue + { + public static ClassNameValue Error { get; } = new ErrorClassNameValue(); + } + + public sealed record ErrorClassNameValue : ClassNameValue; + + public sealed record UnqualifiedClassNameValue(TypeName Name) : ClassNameValue; + + public sealed record AssemblyQualifiedClassNameValue( + string AssemblyName, + TypeName Name) : ClassNameValue; + + public sealed record ModuleQualifiedClassNameValue( + IToken Token, + string ModuleName, + TypeName Name) : ClassNameValue; + + public sealed record TokenQualifiedClassNameValue( + int Token, + TypeName Name) : ClassNameValue; + + public sealed record PointerQualifiedClassNameValue(TypeName Name) : ClassNameValue; + + public sealed record TokenClassNameValue(int Token) : ClassNameValue; + + public enum SpecialClassNameKind + { + This, + Base, + Nester + } + + public sealed record SpecialClassNameValue( + IToken Token, + SpecialClassNameKind Kind) : ClassNameValue; + + public abstract record TypeSpecificationValue + { + public static TypeSpecificationValue Error { get; } = + new ErrorTypeSpecificationValue(); + } + + public sealed record ErrorTypeSpecificationValue : TypeSpecificationValue; + + public sealed record ClassTypeSpecificationValue( + ClassNameValue ClassName) : TypeSpecificationValue; + + public sealed record AssemblyTypeSpecificationValue( + string AssemblyName) : TypeSpecificationValue; + + public sealed record ModuleTypeSpecificationValue( + string ModuleName) : TypeSpecificationValue; + + public sealed record SignatureTypeSpecificationValue( + TypeValue Type) : TypeSpecificationValue; + + public abstract record MethodReferenceValue + { + public static MethodReferenceValue Error { get; } = new ErrorMethodReferenceValue(); + } + + public sealed record ErrorMethodReferenceValue : MethodReferenceValue; + + public sealed record TokenMethodReferenceValue(int Token) : MethodReferenceValue; + + public sealed record TypedefMethodReferenceValue( + IToken Token, + string Alias) : MethodReferenceValue; + + public sealed record ParsedMethodReferenceValue( + IToken Token, + byte CallingConvention, + TypeValue ReturnType, + TypeSpecificationValue? Owner, + string Name, + ImmutableArray? GenericArguments, + int GenericArity, + ImmutableArray Arguments) : MethodReferenceValue; + + public abstract record FieldReferenceValue + { + public static FieldReferenceValue Error { get; } = new ErrorFieldReferenceValue(); + } + + public sealed record ErrorFieldReferenceValue : FieldReferenceValue; + + public sealed record TypedefFieldReferenceValue( + IToken Token, + string Alias) : FieldReferenceValue; + + public sealed record ParsedFieldReferenceValue( + TypeValue FieldType, + TypeSpecificationValue? Owner, + string Name) : FieldReferenceValue; + + public abstract record MemberReferenceValue + { + public static MemberReferenceValue Error { get; } = new ErrorMemberReferenceValue(); + } + + public sealed record ErrorMemberReferenceValue : MemberReferenceValue; + + public sealed record MethodMemberReferenceValue( + MethodReferenceValue Method) : MemberReferenceValue; + + public sealed record FieldMemberReferenceValue( + FieldReferenceValue Field) : MemberReferenceValue; + + public sealed record TokenMemberReferenceValue(int Token) : MemberReferenceValue; + + public abstract record OwnerTypeValue + { + public static OwnerTypeValue Error { get; } = new ErrorOwnerTypeValue(); + } + + public sealed record ErrorOwnerTypeValue : OwnerTypeValue; + + public sealed record TypeOwnerValue(TypeSpecificationValue Type) : OwnerTypeValue; + + public sealed record MemberOwnerValue(MemberReferenceValue Member) : OwnerTypeValue; +} diff --git a/src/tools/ilasm/src/ILAssembler/CompatibilitySuppressions.xml b/src/tools/ilasm/src/ILAssembler/CompatibilitySuppressions.xml new file mode 100644 index 00000000000000..5b82f9b865e369 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/CompatibilitySuppressions.xml @@ -0,0 +1,23 @@ + + + + + + CP0001 + T:ILAssembler.CILLexer + + + CP0001 + T:ILAssembler.CILParser + + + + CP0001 + T:ILAssembler.PreprocessedTokenSource + + + + CP0001 + T:ILAssembler.StringHelpers + + diff --git a/src/tools/ilasm/src/ILAssembler/DocumentCompiler.cs b/src/tools/ilasm/src/ILAssembler/DocumentCompiler.cs index f499c616e418e2..2ee8588cd425f8 100644 --- a/src/tools/ilasm/src/ILAssembler/DocumentCompiler.cs +++ b/src/tools/ilasm/src/ILAssembler/DocumentCompiler.cs @@ -22,28 +22,22 @@ public sealed class DocumentCompiler Dictionary loadedDocuments = new(); ImmutableArray.Builder diagnostics = ImmutableArray.CreateBuilder(); - GrammarVisitor? visitor = null; + GrammarActions? actions = null; IReadOnlyDictionary? definedVariables = null; foreach (var document in documents) { loadedDocuments[document.Path!] = document; - var inputSource = new AntlrInputStream(document.Text) - { - name = document.Path - }; + StringCharStream inputSource = new(document.Text, document.Path); CILLexer lexer = new(inputSource); PreprocessedTokenSource preprocessor = new(lexer, path => { - var includedDocument = includedDocumentLoader(path); - var includedSource = new AntlrInputStream(includedDocument.Text) - { - name = includedDocument.Path - }; + SourceText includedDocument = includedDocumentLoader(path); + StringCharStream includedSource = new(includedDocument.Text, includedDocument.Path); loadedDocuments[includedDocument.Path!] = includedDocument; return new CILLexer(includedSource); - }, text => new CILLexer(new AntlrInputStream(text)), definedVariables); + }, text => new CILLexer(new StringCharStream(text)), definedVariables); preprocessor.OnPreprocessorSyntaxError += (source, start, length, msg) => { @@ -57,29 +51,32 @@ public sealed class DocumentCompiler } }; - CILParser parser = new(new CommonTokenStream(preprocessor)); + actions ??= new GrammarActions(loadedDocuments, options, resourceLocator); + actions.BeginDocument(); + + CILParser parser = new(new UnbufferedTokenStream(preprocessor)) + { + Actions = actions, + BuildParseTree = false + }; parser.RemoveErrorListeners(); - var parserDiagnostics = ImmutableArray.CreateBuilder(); - parser.AddErrorListener(new ParserErrorListener(parserDiagnostics, loadedDocuments)); - var result = parser.decls(); + ImmutableArray.Builder parserDiagnostics = ImmutableArray.CreateBuilder(); + parser.AddErrorListener(new ParserErrorListener(parserDiagnostics, loadedDocuments, actions.RecordSyntaxError)); + _ = parser.decls(); // Add parser diagnostics to the main list diagnostics.AddRange(parserDiagnostics); - visitor ??= new GrammarVisitor(loadedDocuments, options, resourceLocator); - - _ = result.Accept(visitor); - // Transfer defined constants to the next document definedVariables = preprocessor.DefinedVariables; } - if (visitor is null) + if (actions is null) { return (diagnostics.ToImmutable(), null); } - var image = visitor.BuildImage(); + var image = actions.BuildImage(); bool anyErrors = diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); anyErrors |= image.Diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); @@ -96,15 +93,21 @@ internal sealed class ParserErrorListener : Antlr4.Runtime.IAntlrErrorListener.Builder _diagnostics; private readonly Dictionary _loadedDocuments; + private readonly Action _recordSyntaxError; - public ParserErrorListener(ImmutableArray.Builder diagnostics, Dictionary loadedDocuments) + public ParserErrorListener( + ImmutableArray.Builder diagnostics, + Dictionary loadedDocuments, + Action recordSyntaxError) { _diagnostics = diagnostics; _loadedDocuments = loadedDocuments; + _recordSyntaxError = recordSyntaxError; } public void SyntaxError(TextWriter output, IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e) { + _recordSyntaxError(); var sourceName = offendingSymbol?.TokenSource?.SourceName ?? ""; var span = new SourceSpan(offendingSymbol?.StartIndex ?? 0, offendingSymbol is null ? 0 : offendingSymbol.StopIndex - offendingSymbol.StartIndex + 1); if (_loadedDocuments.TryGetValue(sourceName, out var sourceText)) diff --git a/src/tools/ilasm/src/ILAssembler/EntityRegistry.cs b/src/tools/ilasm/src/ILAssembler/EntityRegistry.cs index f87536cfef6199..e765adddb2c262 100644 --- a/src/tools/ilasm/src/ILAssembler/EntityRegistry.cs +++ b/src/tools/ilasm/src/ILAssembler/EntityRegistry.cs @@ -572,7 +572,7 @@ public Blob WriteContentTo(MetadataBuilder builder, BlobBuilder ilStream, IReadO builder.AddEvent( evt.Attributes, builder.GetOrAddString(evt.Name), - evt.Type.Handle); + evt.Type?.Handle ?? default(TypeDefinitionHandle)); foreach (var accessor in evt.Accessors) { @@ -2174,10 +2174,10 @@ public sealed class InterfaceImplementationEntity(TypeDefinitionEntity type, Typ public TypeEntity InterfaceType { get; } = interfaceType; } - public sealed class EventEntity(EventAttributes attributes, TypeEntity type, string name) : EntityBase + public sealed class EventEntity(EventAttributes attributes, TypeEntity? type, string name) : EntityBase { public EventAttributes Attributes { get; set; } = attributes; - public TypeEntity Type { get; } = type; + public TypeEntity? Type { get; } = type; public string Name { get; } = name; public List<(MethodSemanticsAttributes Semantic, EntityBase Method)> Accessors { get; } = new(); diff --git a/src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs b/src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs deleted file mode 100644 index 58808cd5be510e..00000000000000 --- a/src/tools/ilasm/src/ILAssembler/GrammarVisitor.cs +++ /dev/null @@ -1,6618 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Buffers.Binary; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Reflection.Metadata; -using System.Reflection.Metadata.Ecma335; -using System.Reflection.PortableExecutable; -using System.Runtime.InteropServices; -using System.Security.Cryptography; -using System.Text; -using Antlr4.Runtime; -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; - -namespace ILAssembler -{ - internal abstract record GrammarResult - { - protected GrammarResult() { } - - public sealed record String(string Value) : GrammarResult; - - public sealed record Literal(T Value) : GrammarResult; - - public sealed record Sequence(ImmutableArray Value) : GrammarResult; - - /// - /// A formatted blob of bytes. - /// - /// The bytes of the blob. - public sealed record FormattedBlob(BlobBuilder Value) : GrammarResult; - - public sealed record SentinelValue - { - public static SentinelValue Instance { get; } = new(); - - public static Literal Result { get; } = new(Instance); - } - - public sealed record Flag(T Value, bool ShouldAppend = true) : GrammarResult - where T : struct, Enum - { - private readonly T _groupMask; - public Flag(T value, bool shouldAppend, T groupMask) - : this(value, shouldAppend) - { - _groupMask = groupMask; - } - public Flag(T value, T groupMask) - : this(value) - { - _groupMask = groupMask; - } - - public static T operator |(T lhs, Flag rhs) - { - if (!rhs.ShouldAppend) - { - return rhs.Value; - } - int lhsInt = Convert.ToInt32(lhs); - int maskInt = Convert.ToInt32(rhs._groupMask); - int valueInt = Convert.ToInt32(rhs.Value); - return (T)Enum.ToObject(typeof(T), (lhsInt & ~maskInt) | valueInt); - } - } - } - -#pragma warning disable CA1822 // Mark members as static - internal sealed class GrammarVisitor : ICILVisitor - { - private const string NodeShouldNeverBeDirectlyVisited = "This node should never be directly visited. It should be directly processed by its parent node."; - private readonly ImmutableArray.Builder _diagnostics = ImmutableArray.CreateBuilder(); - private readonly EntityRegistry _entityRegistry = new(); - private readonly IReadOnlyDictionary _documents; - private readonly Options _options; - private readonly MetadataBuilder _metadataBuilder = new(); - private readonly Func _resourceLocator; - - // Record the mapped field data directly into the blob to ensure we preserve ordering - private readonly BlobBuilder _mappedFieldData = new(); - private readonly Dictionary _mappedFieldDataNames = new(); - private readonly Dictionary> _mappedFieldDataReferenceFixups = new(); - private readonly BlobBuilder _manifestResources = new(); - - // Typedef aliases - maps alias name to the resolved entity - private readonly Dictionary _typedefs = new(); - - // Debug info tracking - private Guid _currentLanguageGuid = Guid.Empty; - private Guid _currentLanguageVendorGuid = Guid.Empty; - private Guid _currentDocumentTypeGuid = Guid.Empty; - private string? _currentDocumentPath; - private readonly Dictionary _documentHandles = new(); - private readonly MetadataBuilder _pdbBuilder = new(); - - // VTable fixup tracking - uses types from VTableFixupSupport - private readonly List _vtableFixups = new(); - - public GrammarVisitor(IReadOnlyDictionary documents, Options options, Func resourceLocator) - { - _documents = documents; - _options = options; - _resourceLocator = resourceLocator; - } - /// - /// Represents a typedef alias entry. - /// - private abstract record TypedefEntry - { - public sealed record Type(EntityRegistry.TypeEntity Entity) : TypedefEntry; - public sealed record TypeBlob(BlobBuilder Blob) : TypedefEntry; - public sealed record Member(EntityRegistry.EntityBase Entity) : TypedefEntry; - public sealed record CustomAttribute(EntityRegistry.EntityBase Constructor, BlobBuilder Value) : TypedefEntry; - } - - private void ReportDiagnostic(DiagnosticSeverity severity, string id, string message, Antlr4.Runtime.ParserRuleContext context) - { - var location = Location.From(context.Start, _documents); - _diagnostics.Add(new Diagnostic(id, severity, message, location)); - } - - private void ReportError(string id, string message, Antlr4.Runtime.ParserRuleContext context) - => ReportDiagnostic(DiagnosticSeverity.Error, id, message, context); - - private void ReportWarning(string id, string message, Antlr4.Runtime.ParserRuleContext context) - => ReportDiagnostic(DiagnosticSeverity.Warning, id, message, context); - - public (ImmutableArray Diagnostics, CompilationResult? Image) BuildImage() - { - // Default module name to output filename if no .module directive was provided - if (_entityRegistry.Module.Name is null && _options.OutputFileName is not null) - { - _entityRegistry.Module.Name = _options.OutputFileName; - } - - // Apply DebuggableAttribute AFTER all source declarations have been processed, - // so that GetCoreLibAssemblyReference() can find the correct corelib assembly ref - // declared in the source (e.g., System.Runtime) instead of creating a fallback mscorlib. - if (_entityRegistry.Assembly is not null && (_options.Debug || _options.DebugMode is not null)) - { - ApplyDebuggableAttribute(); - } - - // Return early if there are structural errors that prevent building valid metadata. - // However, allow errors in method bodies (ILA0016-0019) to pass through so we can - // emit the assembly with the errors reported. - // In error-tolerant mode, continue despite errors. - var structuralErrors = _diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error && !IsRecoverableError(d.Id)); - if (structuralErrors.Any() && !_options.ErrorTolerant) - { - return (_diagnostics.ToImmutable(), null); - } - - // Check for vtable fixups and exports - collect export info - var exports = ImmutableArray.CreateBuilder(); - foreach (EntityRegistry.MethodDefinitionEntity method in GetParsedMethods()) - { - if (method.ExportOrdinal >= 0) - { - exports.Add(new VTableExportPEBuilder.ExportInfo( - method.ExportOrdinal, - method.ExportAlias ?? method.Name, - MetadataTokens.GetToken(method.Handle), - method.VTableEntry, - method.VTableSlot)); - } - } - - BlobBuilder ilStream = new(); - PseudoCustomAttributes.Lower(_entityRegistry, _diagnostics); - Blob mvidFixup = _entityRegistry.WriteContentTo(_metadataBuilder, ilStream, _mappedFieldDataNames, _options.Deterministic); - MetadataRootBuilder rootBuilder = new(_metadataBuilder, _options.MetadataVersion); - - // Compute metadata size from the MetadataSizes - // We need this for data label fixup RVA calculations - var sizes = rootBuilder.Sizes; - int metadataSize = ComputeMetadataSize(sizes); - - // Apply command-line overrides - Subsystem subsystem = _options.Subsystem ?? _subsystem; - int fileAlignment = _options.FileAlignment ?? _alignment; - long imageBase = _options.ImageBase ?? _imageBase; - ushort majorSubsystemVersion = _options.SubsystemVersion?.Major ?? 4; - ushort minorSubsystemVersion = _options.SubsystemVersion?.Minor ?? 0; - Machine machine = _options.Machine ?? Machine.I386; - - // Build DllCharacteristics from options - DllCharacteristics dllCharacteristics = DllCharacteristics.DynamicBase | DllCharacteristics.NxCompatible | DllCharacteristics.NoSeh | DllCharacteristics.TerminalServerAware; - if (_options.AppContainer) - { - dllCharacteristics |= DllCharacteristics.AppContainer; - } - if (_options.HighEntropyVA) - { - dllCharacteristics |= DllCharacteristics.HighEntropyVirtualAddressSpace; - } - if (_options.StripReloc) - { - dllCharacteristics &= ~DllCharacteristics.DynamicBase; - } - - Characteristics imageCharacteristics = Characteristics.ExecutableImage; - if (_options.Dll) - { - imageCharacteristics |= Characteristics.Dll; - } - if (machine is Machine.I386 or Machine.Arm) - { - imageCharacteristics |= Characteristics.Bit32Machine; - } - else if (machine is Machine.Amd64 or Machine.Arm64) - { - imageCharacteristics |= Characteristics.LargeAddressAware; - } - - // Compute stack reserve: command-line option overrides directive, which overrides default - ulong sizeOfStackReserve = (ulong)(_options.StackReserve ?? (_stackReserve != 0 ? _stackReserve : 0x00100000)); - - PEHeaderBuilder header = new( - machine: machine, - fileAlignment: fileAlignment, - imageBase: (ulong)imageBase, - subsystem: subsystem, - majorSubsystemVersion: majorSubsystemVersion, - minorSubsystemVersion: minorSubsystemVersion, - dllCharacteristics: dllCharacteristics, - imageCharacteristics: imageCharacteristics, - sizeOfStackReserve: sizeOfStackReserve); - - MethodDefinitionHandle entryPoint = default; - if (_entityRegistry.EntryPoint is not null) - { - entryPoint = (MethodDefinitionHandle)_entityRegistry.EntryPoint.Handle; - } - - // Build debug directory if we have any debug info - DebugDirectoryBuilder? debugDirectoryBuilder = BuildDebugDirectory(entryPoint, out int debugDataSize); - - // Use custom PE builder if we have vtable fixups, exports, or data label reference fixups - if (_vtableFixups.Count > 0 || exports.Count > 0 || _mappedFieldDataReferenceFixups.Count > 0) - { - var vtableFixupInfos = BuildVTableFixupInfos(); - - // Apply CorFlags from options or directive - CorFlags corFlags = _options.CorFlags ?? _corflags; - if (_options.Prefer32Bit) - { - corFlags |= CorFlags.Prefers32Bit; - } - - VTableExportPEBuilder peBuilder = new( - header, - rootBuilder, - ilStream, - _mappedFieldData, - _manifestResources, - debugDirectoryBuilder: debugDirectoryBuilder, - entryPoint: entryPoint, - flags: corFlags, - vtableFixups: vtableFixupInfos, - exports: exports.ToImmutable(), - mappedFieldDataOffsets: _mappedFieldDataNames, - dataLabelFixups: _mappedFieldDataReferenceFixups, - metadataSize: metadataSize, - debugDataSize: debugDataSize); - - return (_diagnostics.ToImmutable(), new CompilationResult(peBuilder, mvidFixup)); - } - - // Apply CorFlags from options or directive - CorFlags standardCorFlags = _options.CorFlags ?? _corflags; - if (_options.Prefer32Bit) - { - standardCorFlags |= CorFlags.Prefers32Bit; - } - - // Deterministic ID provider for reproducible builds - Func, BlobContentId>? deterministicIdProvider = _options.Deterministic - ? GetDeterministicContentId - : null; - - ManagedPEBuilder standardBuilder = new( - header, - rootBuilder, - ilStream, - _mappedFieldData, - _manifestResources, - flags: standardCorFlags, - entryPoint: entryPoint, - debugDirectoryBuilder: debugDirectoryBuilder, - deterministicIdProvider: deterministicIdProvider); - - return (_diagnostics.ToImmutable(), new CompilationResult(standardBuilder, mvidFixup)); - } - - private static BlobContentId GetDeterministicContentId(IEnumerable content) - { - using IncrementalHash hash = IncrementalHash.CreateHash(HashAlgorithmName.SHA256); - foreach (Blob blob in content) - { - hash.AppendData(blob.GetBytes()); - } - - return BlobContentId.FromHash(hash.GetHashAndReset()); - } - - private ImmutableArray BuildVTableFixupInfos() - { - if (_vtableFixups.Count == 0) - return ImmutableArray.Empty; - - var builder = ImmutableArray.CreateBuilder(_vtableFixups.Count); - - for (int entryIndex = 0; entryIndex < _vtableFixups.Count; entryIndex++) - { - var vtf = _vtableFixups[entryIndex]; - var methodTokens = ImmutableArray.CreateBuilder(vtf.SlotCount); - - // Initialize with zeros - for (int i = 0; i < vtf.SlotCount; i++) - { - methodTokens.Add(0); - } - - // Find methods that reference this vtable entry - foreach (EntityRegistry.MethodDefinitionEntity method in GetParsedMethods()) - { - if (method.VTableEntry == entryIndex + 1 && // 1-based - method.VTableSlot > 0 && - method.VTableSlot <= vtf.SlotCount) - { - methodTokens[method.VTableSlot - 1] = MetadataTokens.GetToken(method.Handle); - } - } - - builder.Add(new VTableExportPEBuilder.VTableFixupInfo( - vtf.DataLabel, - vtf.SlotCount, - vtf.Flags, - methodTokens.ToImmutable())); - } - - return builder.ToImmutable(); - } - - private IEnumerable GetParsedMethods() - { - foreach (EntityRegistry.TypeDefinitionEntity type in _entityRegistry.GetSeenEntities(TableIndex.TypeDef)) - { - foreach (EntityRegistry.MethodDefinitionEntity method in type.Methods) - { - yield return method; - } - } - } - - private DebugDirectoryBuilder? BuildDebugDirectory(MethodDefinitionHandle entryPoint, out int debugDataSize) - { - debugDataSize = 0; - - // Check if we have any methods with debug info - bool hasDebugInfo = false; - foreach (var entity in _entityRegistry.GetSeenEntities(TableIndex.MethodDef)) - { - if (entity is EntityRegistry.MethodDefinitionEntity method && - method.DebugInfo.SequencePoints.Count > 0) - { - hasDebugInfo = true; - break; - } - } - - // Generate PDB if we have debug info OR if --debug/--pdb options are set - bool generatePdb = hasDebugInfo || _options.Debug || _options.Pdb; - if (!generatePdb) - { - return null; - } - - // Build PDB metadata - BuildPdbMetadata(); - - // Get row counts from main metadata for the portable PDB - var typeSystemRowCounts = _metadataBuilder.GetRowCounts(); - - // Create the portable PDB - var pdbBuilder = new PortablePdbBuilder( - _pdbBuilder, - typeSystemRowCounts, - entryPoint, - idProvider: _options.Deterministic ? GetDeterministicContentId : null); - - var pdbBlob = new BlobBuilder(); - var pdbContentId = pdbBuilder.Serialize(pdbBlob); - - // Create debug directory with embedded PDB - var debugDirectoryBuilder = new DebugDirectoryBuilder(); - debugDirectoryBuilder.AddCodeViewEntry( - $"assembly.pdb", - pdbContentId, - pdbBuilder.FormatVersion); - debugDirectoryBuilder.AddEmbeddedPortablePdbEntry(pdbBlob, pdbBuilder.FormatVersion); - - // Calculate debug data size: - // 2 debug directory entries (28 bytes each) + CodeView data (~24 bytes) + Embedded PDB data (compressed pdbBlob + 8 header) - // CodeView entry: signature (4) + guid (16) + age (4) + path (variable, ~12 for "assembly.pdb\0") - const int debugDirEntrySize = 28; - int codeViewDataSize = 4 + 16 + 4 + "assembly.pdb".Length + 1; // signature + guid + age + path + null - int embeddedPdbHeaderSize = 8; // MPDB signature (4) + uncompressed size (4) - // The embedded PDB is compressed, estimate conservatively as same size - int embeddedPdbDataSize = embeddedPdbHeaderSize + pdbBlob.Count; - - debugDataSize = (2 * debugDirEntrySize) + codeViewDataSize + embeddedPdbDataSize; - - return debugDirectoryBuilder; - } - - private void BuildPdbMetadata() - { - // Add documents and sequence points to the PDB metadata builder - foreach (var entity in _entityRegistry.GetSeenEntities(TableIndex.MethodDef)) - { - if (entity is not EntityRegistry.MethodDefinitionEntity method) - { - continue; - } - - var debugInfo = method.DebugInfo; - if (debugInfo.SequencePoints.Count == 0) - { - // Add empty debug info entry for methods without sequence points - _pdbBuilder.AddMethodDebugInformation(default, default); - continue; - } - - // Get or create document handle - DocumentHandle documentHandle = default; - if (debugInfo.DocumentPath is not null) - { - if (!_documentHandles.TryGetValue(debugInfo.DocumentPath, out documentHandle)) - { - var nameHandle = _pdbBuilder.GetOrAddDocumentName(debugInfo.DocumentPath); - var languageGuidHandle = _currentLanguageGuid != Guid.Empty - ? _pdbBuilder.GetOrAddGuid(_currentLanguageGuid) - : default; - documentHandle = _pdbBuilder.AddDocument( - nameHandle, - default, // hash algorithm - default, // hash - languageGuidHandle); - _documentHandles[debugInfo.DocumentPath] = documentHandle; - } - } - - // Encode sequence points - var sequencePointsBlob = EncodeSequencePoints(debugInfo.SequencePoints); - var sequencePointsBlobHandle = _pdbBuilder.GetOrAddBlob(sequencePointsBlob); - - _pdbBuilder.AddMethodDebugInformation(documentHandle, sequencePointsBlobHandle); - } - } - - private static BlobBuilder EncodeSequencePoints(List sequencePoints) - { - var builder = new BlobBuilder(); - - if (sequencePoints.Count == 0) - { - return builder; - } - - // LocalSignature (not used here, write 0) - builder.WriteCompressedInteger(0); - - int previousOffset = 0; - int previousStartLine = -1; - int previousStartColumn = -1; - - foreach (var sp in sequencePoints) - { - // IL offset delta - int offsetDelta = sp.ILOffset - previousOffset; - builder.WriteCompressedInteger(offsetDelta); - previousOffset = sp.ILOffset; - - if (sp.IsHidden) - { - // Hidden sequence point: delta lines = 0, delta columns = 0 - builder.WriteCompressedInteger(0); - builder.WriteCompressedInteger(0); - } - else - { - // Delta lines - int deltaLines = sp.EndLine - sp.StartLine; - builder.WriteCompressedInteger(deltaLines); - - // Delta columns - int deltaColumns = sp.EndColumn - sp.StartColumn; - if (deltaLines == 0) - { - builder.WriteCompressedInteger(deltaColumns); - } - else - { - builder.WriteCompressedSignedInteger(deltaColumns); - } - - // Start line delta (signed) - if (previousStartLine < 0) - { - builder.WriteCompressedInteger(sp.StartLine); - } - else - { - builder.WriteCompressedSignedInteger(sp.StartLine - previousStartLine); - } - - // Start column delta (signed) - if (previousStartColumn < 0) - { - builder.WriteCompressedInteger(sp.StartColumn); - } - else - { - builder.WriteCompressedSignedInteger(sp.StartColumn - previousStartColumn); - } - - previousStartLine = sp.StartLine; - previousStartColumn = sp.StartColumn; - } - } - - return builder; - } - - private static bool IsRecoverableError(string diagnosticId) - { - // Method body and signature diagnostics are recoverable - we emit the assembly but report the error. - // This matches native ilasm behavior where errors during method/field emission don't prevent - // the assembly from being written when the /ERR (OnErrGo) flag is set. - return diagnosticId is DiagnosticIds.ByteArrayTooShort - or DiagnosticIds.ArgumentNotFound - or DiagnosticIds.LocalNotFound - or DiagnosticIds.LabelNotFound - or DiagnosticIds.GenericParameterIndexOutOfRange - or DiagnosticIds.ParameterIndexOutOfRange - or DiagnosticIds.GenericParameterNotFound - or DiagnosticIds.UnknownGenericParameter - or DiagnosticIds.MissingInstanceCallConv; - } - - public GrammarResult Visit(IParseTree tree) => tree.Accept(this); - - GrammarResult ICILVisitor.VisitAlignment(CILParser.AlignmentContext context) => VisitAlignment(context); - public GrammarResult.Literal VisitAlignment(CILParser.AlignmentContext context) - { - return VisitInt32(context.int32()); - } - - GrammarResult ICILVisitor.VisitAsmAttr(CILParser.AsmAttrContext context) => VisitAsmAttr(context); - public GrammarResult.Literal VisitAsmAttr(CILParser.AsmAttrContext context) - => new(context.asmAttrAny().Select(VisitAsmAttrAny).Aggregate((AssemblyFlags)0, (lhs, rhs) => lhs | rhs)); - GrammarResult ICILVisitor.VisitAsmAttrAny(CILParser.AsmAttrAnyContext context) => VisitAsmAttrAny(context); - public GrammarResult.Flag VisitAsmAttrAny(CILParser.AsmAttrAnyContext context) - { - return context.GetText() switch - { - "retargetable" => new(AssemblyFlags.Retargetable), - "windowsruntime" => new(AssemblyFlags.WindowsRuntime), - "noplatform" => new(AssemblyFlags.NoPlatform), - "legacy library" => new(0), - "cil" => new(GetFlagForArch(ProcessorArchitecture.MSIL), AssemblyFlags.ArchitectureMask), - "x86" => new(GetFlagForArch(ProcessorArchitecture.X86), AssemblyFlags.ArchitectureMask), - "amd64" => new(GetFlagForArch(ProcessorArchitecture.Amd64), AssemblyFlags.ArchitectureMask), - "arm" => new(GetFlagForArch(ProcessorArchitecture.Arm), AssemblyFlags.ArchitectureMask), - "arm64" => new(GetFlagForArch((ProcessorArchitecture)6), AssemblyFlags.ArchitectureMask), - _ => throw new UnreachableException() - }; - } - - private static AssemblyFlags GetFlagForArch(ProcessorArchitecture arch) - { - return (AssemblyFlags)((int)arch << 4); - } - - private static (ProcessorArchitecture, AssemblyFlags) GetArchAndFlags(AssemblyFlags flags) - { - var arch = (ProcessorArchitecture)(((int)flags & 0xF0) >> 4); - var newFlags = flags & ~((AssemblyFlags)((int)arch << 4)); - return (arch, newFlags); - } - - private EntityRegistry.AssemblyOrRefEntity? _currentAssemblyOrRef; - public GrammarResult VisitAsmOrRefDecl(CILParser.AsmOrRefDeclContext context) - { - Debug.Assert(_currentAssemblyOrRef is not null); - - if (context.customAttrDecl() is { } attr) - { - var customAttr = VisitCustomAttrDecl(attr).Value; - customAttr?.Owner = _currentAssemblyOrRef; - return GrammarResult.SentinelValue.Result; - } - - string decl = context.GetChild(0).GetText(); - if (decl is ".publickey" or ".publicKey") - { - BlobBuilder blob = new(); - blob.WriteBytes(VisitBytes(context.bytes()).Value); - // COMPAT: Native ilasm gives a public key token precedence regardless of declaration order. - if (_currentAssemblyOrRef is not EntityRegistry.AssemblyReferenceEntity assemblyReference - || assemblyReference.PublicKeyOrToken is null - || assemblyReference.Flags.HasFlag(AssemblyFlags.PublicKey)) - { - _currentAssemblyOrRef!.PublicKeyOrToken = blob; - _currentAssemblyOrRef.Flags |= AssemblyFlags.PublicKey; - } - } - else if (decl == ".ver") - { - var versionComponents = context.intOrWildcard(); - _currentAssemblyOrRef!.Version = new Version( - VisitIntOrWildcard(versionComponents[0]).Value ?? 0, - VisitIntOrWildcard(versionComponents[1]).Value ?? 0, - VisitIntOrWildcard(versionComponents[2]).Value ?? 0, - VisitIntOrWildcard(versionComponents[3]).Value ?? 0); - } - else if (decl == ".locale") - { - _currentAssemblyOrRef!.Culture = context.compQstring() is { } compQstring - ? VisitCompQstring(compQstring).Value - : Encoding.Unicode.GetString([.. VisitBytes(context.bytes()).Value]); - } - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitAssemblyBlock(CILParser.AssemblyBlockContext context) => VisitAssemblyBlock(context); - public GrammarResult VisitAssemblyBlock(CILParser.AssemblyBlockContext context) - { - // Use command-line override if specified, otherwise use the name from the .assembly directive - string assemblyName = _options.AssemblyName ?? VisitDottedName(context.dottedName()).Value; - _entityRegistry.Assembly ??= new EntityRegistry.AssemblyEntity(assemblyName); - var attr = VisitAsmAttr(context.asmAttr()).Value; - (_entityRegistry.Assembly.ProcessorArchitecture, _entityRegistry.Assembly.Flags) = GetArchAndFlags(attr); - foreach (var decl in context.assemblyDecls().assemblyDecl()) - { - VisitAssemblyDecl(decl); - } - - // Apply command-line key file override (overrides .publickey directive) - if (_options.KeyFile is not null) - { - ApplyKeyFile(_options.KeyFile); - } - - // DebuggableAttribute is applied in BuildImage() after all source declarations - // have been processed, so the correct corelib assembly ref can be found. - - return GrammarResult.SentinelValue.Result; - } - - /// - /// Add DebuggableAttribute to the assembly based on debug options. - /// - /DEBUG: 0x101 = Default | DisableOptimizations - /// - /DEBUG=OPT: 0x03 = Default | IgnoreSymbolStoreSequencePoints - /// - /DEBUG=IMPL: 0x103 = Default | DisableOptimizations | EnableEditAndContinue - /// - private void ApplyDebuggableAttribute() - { - if (_entityRegistry.Assembly is null) - { - return; - } - - // DebuggingModes enum values from System.Diagnostics.DebuggableAttribute: - // None = 0x00, Default = 0x01, IgnoreSymbolStoreSequencePoints = 0x02, - // EnableEditAndContinue = 0x04, DisableOptimizations = 0x100 - const int DebuggingModesDefault = 0x101; // Default | DisableOptimizations - const int DebuggingModesOpt = 0x03; // Default | IgnoreSymbolStoreSequencePoints - const int DebuggingModesImpl = 0x103; // Default | DisableOptimizations | EnableEditAndContinue - - int debuggingModes = _options.DebugMode switch - { - DebugMode.Opt => DebuggingModesOpt, - DebugMode.Impl => DebuggingModesImpl, - _ => DebuggingModesDefault - }; - - // Get reference to core library - var coreAsmRef = _entityRegistry.GetCoreLibAssemblyReference(); - - // Create reference to System.Diagnostics.DebuggableAttribute - var debuggableAttrType = _entityRegistry.GetOrCreateTypeReference( - coreAsmRef, - new TypeName(null, "System.Diagnostics.DebuggableAttribute")); - - // Create reference to nested type DebuggingModes - var debuggingModesType = _entityRegistry.GetOrCreateTypeReference( - debuggableAttrType, - new TypeName(null, "DebuggingModes")); - - // Create constructor signature: .ctor(DebuggingModes) - BlobBuilder ctorSig = new(); - var sigEncoder = new BlobEncoder(ctorSig); - sigEncoder.MethodSignature(SignatureCallingConvention.Default, 0, isInstanceMethod: true) - .Parameters(1, - returnType => returnType.Void(), - parameters => parameters.AddParameter().Type().Type(debuggingModesType.Handle, isValueType: true)); - - var ctor = _entityRegistry.CreateLazilyRecordedMemberReference(debuggableAttrType, ".ctor", ctorSig); - - // Create custom attribute blob: prolog (0x0001) + int32 value + named args count (0x0000) - BlobBuilder attrValue = new(); - attrValue.WriteUInt16(0x0001); // Prolog - attrValue.WriteInt32(debuggingModes); // DebuggingModes value - attrValue.WriteUInt16(0x0000); // No named arguments - - // Create and attach the custom attribute - var customAttr = _entityRegistry.CreateCustomAttribute(ctor, attrValue); - customAttr.Owner = _entityRegistry.Assembly; - } - - private void ApplyKeyFile(string keyFilePath) - { - if (_entityRegistry.Assembly is null) - { - return; - } - - try - { - byte[] keyBytes = File.ReadAllBytes(keyFilePath); - BlobBuilder blob = new(); - blob.WriteBytes(keyBytes); - _entityRegistry.Assembly.PublicKeyOrToken = blob; - _entityRegistry.Assembly.Flags |= AssemblyFlags.PublicKey; - } - catch (Exception ex) - { - // Create a location pointing to the first document (if available) - var firstDoc = _documents.Values.FirstOrDefault(); - var location = firstDoc is not null - ? new Location(new SourceSpan(0, 0), firstDoc) - : new Location(new SourceSpan(0, 0), new SourceText(string.Empty, keyFilePath)); - _diagnostics.Add(new Diagnostic(DiagnosticIds.KeyFileError, DiagnosticSeverity.Error, $"Failed to read key file '{keyFilePath}': {ex.Message}", location)); - } - } - - GrammarResult ICILVisitor.VisitAssemblyDecl(CILParser.AssemblyDeclContext context) => VisitAssemblyDecl(context); - public GrammarResult VisitAssemblyDecl(CILParser.AssemblyDeclContext context) - { - if (context.secDecl() is { } secDecl) - { - var declarativeSecurity = VisitSecDecl(secDecl); - if (declarativeSecurity.Value is { } sec) - { - sec.Parent = _entityRegistry.Assembly; - } - } - else if (context.int32() is { } hashAlg) - { - _entityRegistry.Assembly!.HashAlgorithm = (AssemblyHashAlgorithm)VisitInt32(hashAlg).Value; - } - else if (context.asmOrRefDecl() is { } asmOrRef) - { - _currentAssemblyOrRef = _entityRegistry.Assembly; - VisitAsmOrRefDecl(asmOrRef); - _currentAssemblyOrRef = null; - } - return GrammarResult.SentinelValue.Result; - } - public GrammarResult VisitAssemblyDecls(CILParser.AssemblyDeclsContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - public GrammarResult VisitAssemblyRefDecl(CILParser.AssemblyRefDeclContext context) - { - if (context.asmOrRefDecl() is { } asmOrRef) - { - VisitAsmOrRefDecl(asmOrRef); - } - string decl = context.GetChild(0).GetText(); - if (decl == ".hash") - { - var blob = new BlobBuilder(); - blob.WriteBytes(VisitBytes(context.bytes()).Value); - ((EntityRegistry.AssemblyReferenceEntity)_currentAssemblyOrRef!).Hash = blob; - } - if (decl == ".publickeytoken") - { - var blob = new BlobBuilder(); - blob.WriteBytes(VisitBytes(context.bytes()).Value); - _currentAssemblyOrRef!.PublicKeyOrToken = blob; - _currentAssemblyOrRef.Flags &= ~AssemblyFlags.PublicKey; - } - return GrammarResult.SentinelValue.Result; - } - public GrammarResult VisitAssemblyRefDecls(CILParser.AssemblyRefDeclsContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitAssemblyRefHead(CILParser.AssemblyRefHeadContext context) => VisitAssemblyRefHead(context); - public GrammarResult.Literal VisitAssemblyRefHead(CILParser.AssemblyRefHeadContext context) - { - var (arch, flags) = GetArchAndFlags(VisitAsmAttr(context.asmAttr()).Value); - var dottedNames = context.dottedName(); - string name = VisitDottedName(dottedNames[0]).Value; - string alias = name; - if (dottedNames.Length > 1) - { - alias = VisitDottedName(dottedNames[1]).Value; - } - return new(_entityRegistry.GetOrCreateAssemblyReference(alias, asmref => - { - asmref.Name = name; - asmref.Flags = flags; - asmref.ProcessorArchitecture = arch; - })); - } - - GrammarResult ICILVisitor.VisitAtOpt(CILParser.AtOptContext context) => VisitAtOpt(context); - public GrammarResult.Literal VisitAtOpt(CILParser.AtOptContext context) - => context.id() is { } id ? new(VisitId(id).Value) - : context.int32() is { } i ? new(VisitInt32(i).Value.ToString()) - : new(null); - - GrammarResult ICILVisitor.VisitBoolSeq(CILParser.BoolSeqContext context) => VisitBoolSeq(context); - public static GrammarResult.FormattedBlob VisitBoolSeq(CILParser.BoolSeqContext context) - { - var builder = ImmutableArray.CreateBuilder(); - - foreach (var item in context.truefalse()) - { - builder.AddRange(VisitTruefalse(item).Value); - } - - return new(builder.ToImmutable().SerializeSequence()); - } - GrammarResult ICILVisitor.VisitBound(CILParser.BoundContext context) => VisitBound(context); - public GrammarResult.Literal<(int? Lower, int? Upper)> VisitBound(CILParser.BoundContext context) - { - bool hasEllipsis = context.ELLIPSIS() is not null; - var indices = context.int32(); - - if (indices.Length == 0) - { - // Empty or standalone "..." - return new((null, null)); - } - - int firstValue = VisitInt32(indices[0]).Value; - - return (indices.Length, hasEllipsis) switch - { - (1, false) => new((0, firstValue)), - (1, true) => new((firstValue, null)), - (2, _) => new((firstValue, VisitInt32(indices[1]).Value - firstValue + 1)), - _ => throw new UnreachableException() - }; - } - - GrammarResult ICILVisitor.VisitBounds(CILParser.BoundsContext context) => VisitBounds(context); - public GrammarResult.Sequence<(int? Lower, int? Upper)> VisitBounds(CILParser.BoundsContext context) - { - return new(context.bound().Select(bound => VisitBound(bound).Value).ToImmutableArray()); - } - - GrammarResult ICILVisitor.VisitBytes(CILParser.BytesContext context) => VisitBytes(context); - public static GrammarResult.Sequence VisitBytes(CILParser.BytesContext context) - { - var builder = ImmutableArray.CreateBuilder(); - - foreach (var item in context.hexbyte()) - { - builder.Add(VisitHexbyte(item)); - } - - return new(builder.ToImmutable()); - } - GrammarResult ICILVisitor.VisitCallConv(CILParser.CallConvContext context) => VisitCallConv(context); - public GrammarResult.Literal VisitCallConv(CILParser.CallConvContext context) - { - if (context.callKind() is CILParser.CallKindContext callKind) - { - return new((byte)VisitCallKind(callKind).Value); - } - else if (context.int32() is CILParser.Int32Context int32) - { - return new((byte)VisitInt32(int32).Value); - } - else if (context.INSTANCE() is not null) - { - return new((byte)(VisitCallConv(context.callConv()).Value | (byte)SignatureAttributes.Instance)); - } - else if (context.EXPLICIT() is not null) - { - return new((byte)( - VisitCallConv(context.callConv()).Value | - (byte)(SignatureAttributes.ExplicitThis | SignatureAttributes.Instance))); - } - return new(0); - } - GrammarResult ICILVisitor.VisitCallKind(CILParser.CallKindContext context) => VisitCallKind(context); - public GrammarResult.Literal VisitCallKind(CILParser.CallKindContext context) - { - // callKind can be empty (/* EMPTY */) - return Default in that case - if (context.ChildCount == 0) - { - return new(SignatureCallingConvention.Default); - } - int childType = context.GetChild(context.ChildCount - 1).Symbol.Type; - return new(childType switch - { - CILParser.DEFAULT => SignatureCallingConvention.Default, - CILParser.VARARG => SignatureCallingConvention.VarArgs, - CILParser.CDECL => SignatureCallingConvention.CDecl, - CILParser.STDCALL => SignatureCallingConvention.StdCall, - CILParser.THISCALL => SignatureCallingConvention.ThisCall, - CILParser.FASTCALL => SignatureCallingConvention.FastCall, - CILParser.UNMANAGED => SignatureCallingConvention.Unmanaged, - _ => throw new UnreachableException() - }); - } - - GrammarResult ICILVisitor.VisitCatchClause(CILParser.CatchClauseContext context) => VisitCatchClause(context); - public GrammarResult.Literal VisitCatchClause(CILParser.CatchClauseContext context) => VisitTypeSpec(context.typeSpec()); - - GrammarResult ICILVisitor.VisitCaValue(CILParser.CaValueContext context) => VisitCaValue(context); - public GrammarResult.FormattedBlob VisitCaValue(CILParser.CaValueContext context) - { - BlobBuilder blob = new(); - if (context.truefalse() is CILParser.TruefalseContext truefalse) - { - blob.WriteByte((byte)SerializationTypeCode.Boolean); - blob.WriteBoolean(VisitTruefalse(truefalse).Value); - } - else if (context.compQstring() is CILParser.CompQstringContext str) - { - blob.WriteUTF8(VisitCompQstring(str).Value); - blob.WriteByte(0); - } - else if (context.className() is CILParser.ClassNameContext className) - { - var name = VisitClassName(className).Value; - blob.WriteByte((byte)SerializationTypeCode.Enum); - blob.WriteUTF8((name as EntityRegistry.IHasReflectionNotation)?.ReflectionNotation ?? ""); - blob.WriteByte(0); - byte size = 4; - if (context.INT8() is not null) - { - size = 1; - } - else if (context.INT16() is not null) - { - size = 2; - } - blob.WriteByte(size); - blob.WriteInt32(VisitInt32(context.int32()).Value); - } - else - { - blob.WriteByte((byte)SerializationTypeCode.Int32); - blob.WriteInt32(VisitInt32(context.int32()).Value); - } - return new(blob); - } - - public GrammarResult VisitChildren(IRuleNode node) - { - for (int i = 0; i < node.ChildCount; i++) - { - node.GetChild(i).Accept(this); - } - return GrammarResult.SentinelValue.Result; - } - GrammarResult ICILVisitor.VisitClassAttr(CILParser.ClassAttrContext context) => VisitClassAttr(context); - - public GrammarResult.Literal<(GrammarResult.Flag Attribute, EntityRegistry.WellKnownBaseType? FallbackBase, bool RequireSealed)> VisitClassAttr(CILParser.ClassAttrContext context) - { - if (context.int32() is CILParser.Int32Context int32) - { - int value = VisitInt32(int32).Value; - // COMPAT: The VALUE and ENUM keywords use sentinel values to pass through the fallback base type - // in ILASM. These sentinel values can be provided through the "pass the value of the flag" feature, - // so we detect those old flags here and provide the correct fallback type. - bool requireSealed = false; - EntityRegistry.WellKnownBaseType? fallbackBase = null; - if ((value & 0x80000000) != 0) - { - requireSealed = true; - fallbackBase = EntityRegistry.WellKnownBaseType.System_ValueType; - } - if ((value & 0x40000000) != 0) - { - fallbackBase = EntityRegistry.WellKnownBaseType.System_Enum; - } - // Mask off the sentinel bits - value &= unchecked((int)~0xC0000000); - // COMPAT: When explicit flags are provided they always supercede previously set flags - // (other than the sentinel values) - return new((new((TypeAttributes)value, ShouldAppend: false), fallbackBase, requireSealed)); - } - - if (context.ENUM() is not null) - { - // COMPAT: ilasm implies the Sealed flag when using the 'value' keyword in a type declaration - // even when the 'enum' keyword is used. - return new((new(context.VALUE() is not null ? TypeAttributes.Sealed : 0), EntityRegistry.WellKnownBaseType.System_Enum, false)); - } - else if (context.VALUE() is not null) - { - // COMPAT: ilasm implies the Sealed flag when using the 'value' keyword in a type declaration - return new((new(TypeAttributes.Sealed), EntityRegistry.WellKnownBaseType.System_ValueType, true)); - } - else if (context.EXPLICIT() is not null) - { - return new((new(TypeAttributes.ExplicitLayout), null, false)); - } - else if (context.INTERFACE() is not null) - { - // COMPAT: interface implies abstract - return new((new(TypeAttributes.Interface | TypeAttributes.Abstract), null, false)); - } - - switch (context.GetText()) - { - case "public": - return new((new(TypeAttributes.Public, TypeAttributes.VisibilityMask), null, false)); - case "private": - return new((new(TypeAttributes.NotPublic, TypeAttributes.VisibilityMask), null, false)); - case "nestedpublic": - return new((new(TypeAttributes.NestedPublic, TypeAttributes.VisibilityMask), null, false)); - case "nestedprivate": - return new((new(TypeAttributes.NestedPrivate, TypeAttributes.VisibilityMask), null, false)); - case "nestedfamily": - return new((new(TypeAttributes.NestedFamily, TypeAttributes.VisibilityMask), null, false)); - case "nestedassembly": - return new((new(TypeAttributes.NestedAssembly, TypeAttributes.VisibilityMask), null, false)); - case "nestedfamandassem": - return new((new(TypeAttributes.NestedFamANDAssem, TypeAttributes.VisibilityMask), null, false)); - case "nestedfamorassem": - return new((new(TypeAttributes.NestedFamORAssem, TypeAttributes.VisibilityMask), null, false)); - case "ansi": - return new((new(TypeAttributes.AnsiClass, TypeAttributes.StringFormatMask), null, false)); - case "autochar": - return new((new(TypeAttributes.AutoClass, TypeAttributes.StringFormatMask), null, false)); - case "unicode": - return new((new(TypeAttributes.UnicodeClass, TypeAttributes.StringFormatMask), null, false)); - case "auto": - return new((new(TypeAttributes.AutoLayout, TypeAttributes.LayoutMask), null, false)); - case "sequential": - return new((new(TypeAttributes.SequentialLayout, TypeAttributes.LayoutMask), null, false)); - case "extended": - return new((new(TypeAttributes.ExtendedLayout, TypeAttributes.LayoutMask), null, false)); - case "sealed": - return new((new(TypeAttributes.Sealed), null, false)); - case "abstract": - return new((new(TypeAttributes.Abstract), null, false)); - case "import": - return new((new(TypeAttributes.Import), null, false)); - case "serializable": -#pragma warning disable SYSLIB0050 - return new((new(TypeAttributes.Serializable), null, false)); -#pragma warning restore SYSLIB0050 - case "windowsruntime": - return new((new(TypeAttributes.WindowsRuntime), null, false)); - case "beforefieldinit": - return new((new(TypeAttributes.BeforeFieldInit), null, false)); - case "specialname": - return new((new(TypeAttributes.SpecialName), null, false)); - case "rtspecialname": - return new((new(TypeAttributes.RTSpecialName), null, false)); - default: - return new((new((TypeAttributes)Enum.Parse(typeof(TypeAttributes), context.GetText(), true)), null, false)); - } - } - - private sealed class CurrentMethodContext - { - public CurrentMethodContext(EntityRegistry.MethodDefinitionEntity definition) - { - Definition = definition; - // Populate argument names from the method's parameter definitions - foreach (var param in definition.Parameters) - { - if (param.Name is not null && param.Sequence > 0) - { - ArgumentNames[param.Name] = param.Sequence - 1; - } - } - } - - public EntityRegistry.MethodDefinitionEntity Definition { get; } - - public Dictionary Labels { get; } = new(); - - public HashSet DeclaredLabels { get; } = new(); - - public Dictionary UndefinedLabelReferences { get; } = new(); - - public Dictionary ArgumentNames { get; } = new(); - - public List> LocalsScopes { get; } = new(); - - public List AllLocals { get; } = new(); - } - - private CurrentMethodContext? _currentMethod; - private EntityRegistry.EntityBase? _pendingClassCustomAttributeOwner; - - public GrammarResult VisitClassDecl(CILParser.ClassDeclContext context) - { - bool isStandaloneCustomAttribute = - context.customAttrDecl().Length == 1 && - context.PARAM() is null; - bool isTrailingCustomAttribute = - isStandaloneCustomAttribute && - context.customAttrDecl()[0].dottedName() is null; - if (!isTrailingCustomAttribute) - { - _pendingClassCustomAttributeOwner = null; - } - - if (context.classHead() is CILParser.ClassHeadContext classHead) - { - _currentTypeDefinition.Push(VisitClassHead(classHead).Value); - VisitClassDecls(context.classDecls()); - _currentTypeDefinition.Pop(); - _pendingClassCustomAttributeOwner = null; - } - else if (context.methodHead() is CILParser.MethodHeadContext methodHead) - { - _currentMethod = new(VisitMethodHead(methodHead).Value); - VisitMethodDecls(context.methodDecls()); - // Build the locals signature from parsed local variable declarations - if (_currentMethod.AllLocals.Count > 0) - { - var localsSig = new BlobBuilder(); - var encoder = new BlobEncoder(localsSig); - var localsEncoder = encoder.LocalVariableSignature(_currentMethod.AllLocals.Count); - foreach (var local in _currentMethod.AllLocals) - { - local.SignatureBlob.WriteContentTo(localsEncoder.AddVariable().Builder); - } - _currentMethod.Definition.LocalsSignature = _entityRegistry.GetOrCreateStandaloneSignature(localsSig); - } - // Validate that all referenced labels were declared - ValidateLabelReferences(); - _currentMethod = null; - } - else if (context.secDecl() is {} secDecl) - { - var declarativeSecurity = VisitSecDecl(secDecl).Value; - declarativeSecurity?.Parent = _currentTypeDefinition.PeekOrDefault(); - } - else if (context.TYPE() is not null && - context.typeSpec().Length == 1 && - context.customDescr() is { } interfaceAttribute) - { - var currentType = _currentTypeDefinition.PeekOrDefault(); - if (currentType is not null) - { - EntityRegistry.TypeEntity interfaceType = VisitTypeSpec(context.typeSpec()[0]).Value; - EntityRegistry.InterfaceImplementationEntity? implementation = - currentType.InterfaceImplementations.FirstOrDefault( - candidate => candidate.InterfaceType == interfaceType); - if (implementation is null) - { - implementation = - EntityRegistry.CreateUnrecordedInterfaceImplementation(currentType, interfaceType); - currentType.InterfaceImplementations.Add(implementation); - } - - VisitCustomDescr(interfaceAttribute).Value.Owner = implementation; - } - } - else if (context.fieldDecl() is {} fieldDecl) - { - _ = VisitFieldDecl(fieldDecl); - } - else if (context.dataDecl() is { } dataDecl) - { - _ = VisitDataDecl(dataDecl); - } - else if (context.extSourceSpec() is { } extSourceSpec) - { - _ = VisitExtSourceSpec(extSourceSpec); - } - else if (context.languageDecl() is { } languageDecl) - { - _ = VisitLanguageDecl(languageDecl); - } - else if (context.OVERRIDE() is not null) - { - var currentType = _currentTypeDefinition.PeekOrDefault(); - if (currentType is not null) - { - var typeSpecs = context.typeSpec(); - var methodNames = context.methodName(); - var callConventions = context.callConv(); - var returnTypes = context.type(); - var signatureArguments = context.sigArgs(); - var genericArities = context.genArity(); - - int bodySignatureIndex = context.METHOD().Length == 0 ? 0 : 1; - BlobBuilder declarationSignature = BuildMethodReferenceSignature( - callConventions[0], - returnTypes[0], - signatureArguments[0], - genericArities.Length > 0 ? VisitGenArity(genericArities[0]).Value : 0); - BlobBuilder bodySignature = context.METHOD().Length == 0 - ? declarationSignature - : BuildMethodReferenceSignature( - callConventions[bodySignatureIndex], - returnTypes[bodySignatureIndex], - signatureArguments[bodySignatureIndex], - genericArities.Length > bodySignatureIndex - ? VisitGenArity(genericArities[bodySignatureIndex]).Value - : 0); - - EntityRegistry.TypeEntity bodyOwner = VisitTypeSpec(typeSpecs[1]).Value; - string bodyName = VisitMethodName(methodNames[1]).Value; - EntityRegistry.MemberReferenceEntity declaration = - _entityRegistry.CreateLazilyRecordedMemberReference( - VisitTypeSpec(typeSpecs[0]).Value, - VisitMethodName(methodNames[0]).Value, - declarationSignature); - - if (ReferenceEquals(bodyOwner, currentType)) - { - EntityRegistry.MethodDefinitionEntity[] bodyMethods = currentType.Methods - .Where(method => - method.Name == bodyName && - method.MethodSignature is not null && - method.MethodSignature.ContentEquals(bodySignature)) - .Take(2) - .ToArray(); - if (bodyMethods.Length != 1) - { - ReportError( - DiagnosticIds.InvalidMetadataToken, - $"Override body method '{bodyName}' could not be resolved uniquely", - context); - return GrammarResult.SentinelValue.Result; - } - - currentType.MethodImplementations.Add( - EntityRegistry.CreateUnrecordedMethodImplementation(bodyMethods[0], declaration)); - } - else - { - EntityRegistry.MemberReferenceEntity body = - _entityRegistry.CreateLazilyRecordedMemberReference( - bodyOwner, - bodyName, - bodySignature); - currentType.MethodImplementations.Add( - EntityRegistry.CreateUnrecordedMethodImplementation(currentType, body, declaration)); - } - } - } - else if (context.int32() is {} int32) - { - // .pack or .size - string keyword = context.GetChild(0).GetText(); - int value = VisitInt32(int32).Value; - var currentType = _currentTypeDefinition.PeekOrDefault(); - if (currentType is not null) - { - if (keyword == ".pack") - { - currentType.PackingSize = value; - } - else if (keyword == ".size") - { - currentType.ClassSize = value; - } - } - } - else if (context.propHead() is CILParser.PropHeadContext propHead) - { - var property = VisitPropHead(propHead).Value; - var currentType = _currentTypeDefinition.PeekOrDefault(); - if (currentType is not null) - { - currentType.Properties.Add(property); - foreach (var propDecl in context.propDecls().propDecl()) - { - if (propDecl.customAttrDecl() is { } customAttrDecl) - { - var customAttr = VisitCustomAttrDecl(customAttrDecl).Value; - if (customAttr is not null) - { - customAttr.Owner = property; - } - } - else if (VisitPropDecl(propDecl).Value is { } accessor) - { - property.Accessors.Add(accessor); - } - } - } - } - else if (context.eventHead() is CILParser.EventHeadContext eventHead) - { - var evt = VisitEventHead(eventHead).Value; - var currentType = _currentTypeDefinition.PeekOrDefault(); - if (currentType is not null) - { - currentType.Events.Add(evt); - foreach (var eventDecl in context.eventDecls().eventDecl()) - { - if (eventDecl.customAttrDecl() is { } customAttrDecl) - { - var customAttr = VisitCustomAttrDecl(customAttrDecl).Value; - if (customAttr is not null) - { - customAttr.Owner = evt; - } - } - else if (VisitEventDecl(eventDecl).Value is { } accessor) - { - evt.Accessors.Add(accessor); - } - } - } - } - else if (context.OVERRIDE() is not null) - { - var currentType = _currentTypeDefinition.PeekOrDefault(); - if (currentType is null) - { - throw new UnreachableException(); - } - - CILParser.CallConvContext[] callConvs = context.callConv(); - CILParser.TypeContext[] returnTypes = context.type(); - CILParser.TypeSpecContext[] owners = context.typeSpec(); - CILParser.MethodNameContext[] methodNames = context.methodName(); - CILParser.GenArityContext[] genericArities = context.genArity(); - CILParser.SigArgsContext[] parameterLists = context.sigArgs(); - - EntityRegistry.MemberReferenceEntity declaration; - EntityRegistry.MemberReferenceEntity body; - if (callConvs.Length == 2) - { - declaration = CreateExplicitMethodReference( - callConvs[0], returnTypes[0], owners[0], methodNames[0], genericArities[0], parameterLists[0]); - body = CreateExplicitMethodReference( - callConvs[1], returnTypes[1], owners[1], methodNames[1], genericArities[1], parameterLists[1]); - } - else - { - EntityRegistry.TypeEntity declarationOwner = VisitTypeSpec(owners[0]).Value; - string declarationName = VisitMethodName(methodNames[0]).Value; - EntityRegistry.TypeEntity bodyOwner = VisitTypeSpec(owners[1]).Value; - string bodyName = VisitMethodName(methodNames[1]).Value; - BlobBuilder bodySignature = CreateExplicitMethodSignature( - callConvs[0], returnTypes[0], genericArity: null, parameterLists[0]); - BlobBuilder declarationSignature = new(); - bodySignature.WriteContentTo(declarationSignature); - declaration = _entityRegistry.CreateLazilyRecordedMemberReference( - declarationOwner, declarationName, declarationSignature); - body = _entityRegistry.CreateLazilyRecordedMemberReference( - bodyOwner, bodyName, bodySignature); - } - - currentType.MethodImplementations.Add(EntityRegistry.CreateUnrecordedMethodImplementation(currentType, body, declaration)); - } - else if (isStandaloneCustomAttribute) - { - if (VisitCustomAttrDecl(context.customAttrDecl()[0]).Value is { } customAttr) - { - customAttr.Owner = - _pendingClassCustomAttributeOwner ?? - _currentTypeDefinition.PeekOrDefault(); - } - } - else if (context.PARAM() is not null) - { - var customAttrDeclarations = context.customAttrDecl(); - var currentType = _currentTypeDefinition.PeekOrDefault(); - if (currentType is not null && context.TYPE() is not null) - { - EntityRegistry.GenericParameterEntity? param = null; - if (context.int32() is { } int32ctx) - { - int index = VisitInt32(int32ctx).Value; - if (index >= 0 && index < currentType.GenericParameters.Count) - { - param = currentType.GenericParameters[index]; - } - else - { - ReportError( - DiagnosticIds.GenericParameterIndexOutOfRange, - string.Format(DiagnosticMessageTemplates.GenericParameterIndexOutOfRange, index), - context); - } - } - else if (context.dottedName() is { } dn) - { - string name = VisitDottedName(dn).Value; - foreach (var genericParam in currentType.GenericParameters) - { - if (genericParam.Name == name) - { - param = genericParam; - break; - } - } - } - if (param is not null) - { - foreach (var attr in customAttrDeclarations ?? Array.Empty()) - { - var customAttrDecl = VisitCustomAttrDecl(attr).Value; - customAttrDecl?.Owner = param; - } - _pendingClassCustomAttributeOwner = param; - } - } - else if (currentType is not null && context.CONSTRAINT() is not null) - { - EntityRegistry.GenericParameterEntity? param = null; - if (context.int32() is { } int32ctx) - { - int index = VisitInt32(int32ctx).Value; - if (index >= 0 && index < currentType.GenericParameters.Count) - { - param = currentType.GenericParameters[index]; - } - else - { - ReportError( - DiagnosticIds.GenericParameterIndexOutOfRange, - string.Format(DiagnosticMessageTemplates.GenericParameterIndexOutOfRange, index), - context); - } - } - else if (context.dottedName() is { } dn) - { - string name = VisitDottedName(dn).Value; - foreach (var genericParam in currentType.GenericParameters) - { - if (genericParam.Name == name) - { - param = genericParam; - break; - } - } - } - if (param is not null) - { - var baseType = VisitTypeSpec(context.typeSpec()[0]).Value; - EntityRegistry.GenericParameterConstraintEntity? constraint = - param.Constraints.FirstOrDefault(entity => entity.BaseType == baseType); - if (constraint is null) - { - constraint = EntityRegistry.CreateGenericConstraint(baseType); - constraint.Owner = param; - param.Constraints.Add(constraint); - currentType.GenericParameterConstraints.Add(constraint); - } - foreach (var attr in customAttrDeclarations ?? Array.Empty()) - { - var customAttrDecl = VisitCustomAttrDecl(attr).Value; - customAttrDecl?.Owner = constraint; - } - _pendingClassCustomAttributeOwner = constraint; - } - } - } - - return GrammarResult.SentinelValue.Result; - } - - private BlobBuilder BuildMethodReferenceSignature( - CILParser.CallConvContext callConvention, - CILParser.TypeContext returnType, - CILParser.SigArgsContext signatureArguments, - int genericArity) - { - var signature = new BlobBuilder(); - byte header = VisitCallConv(callConvention).Value; - if (genericArity > 0) - { - header |= (byte)SignatureAttributes.Generic; - } - - signature.WriteByte(header); - if (genericArity > 0) - { - signature.WriteCompressedInteger(genericArity); - } - - ImmutableArray arguments = VisitSigArgs(signatureArguments).Value; - signature.WriteCompressedInteger(arguments.Count(argument => !argument.IsSentinel)); - VisitType(returnType).Value.WriteContentTo(signature); - foreach (SignatureArg argument in arguments) - { - argument.SignatureBlob.WriteContentTo(signature); - } - - return signature; - } - - public GrammarResult VisitClassDecls(CILParser.ClassDeclsContext context) - { - CILParser.ClassDeclContext[] declarations = context.classDecl(); - foreach (CILParser.ClassDeclContext declaration in declarations) - { - if (declaration.OVERRIDE() is null) - { - VisitClassDecl(declaration); - } - else - { - _pendingClassCustomAttributeOwner = null; - } - } - - foreach (CILParser.ClassDeclContext declaration in declarations) - { - if (declaration.OVERRIDE() is not null) - { - VisitClassDecl(declaration); - } - } - - return GrammarResult.SentinelValue.Result; - } - - - GrammarResult ICILVisitor.VisitClassHead(CILParser.ClassHeadContext context) => VisitClassHead(context); - public GrammarResult.Literal VisitClassHead(CILParser.ClassHeadContext context) - { - string typeFullName = VisitDottedName(context.dottedName()).Value; - int typeFullNameLastDot = typeFullName.LastIndexOf('.'); - // A dot at position 0 is part of the name (e.g., ".GlobalStruct"), not a namespace separator - if (typeFullNameLastDot == 0) - { - typeFullNameLastDot = -1; - } - string typeNS; - if (_currentTypeDefinition.Count != 0) - { - if (typeFullNameLastDot == -1) - { - typeNS = string.Empty; - } - else - { - typeNS = typeFullName.Substring(0, typeFullNameLastDot); - } - } - else - { - if (typeFullNameLastDot == -1) - { - typeNS = _currentNamespace.PeekOrDefault() ?? string.Empty; - } - else - { - typeNS = $"{_currentNamespace.PeekOrDefault()}{typeFullName.Substring(0, typeFullNameLastDot)}"; - } - } - - bool isNewType = false; - - var typeDefinition = _entityRegistry.GetOrCreateTypeDefinition( - _currentTypeDefinition.PeekOrDefault(), - typeNS, - typeFullNameLastDot != -1 - ? typeFullName.Substring(typeFullNameLastDot + 1) - : typeFullName, - (newTypeDef) => - { - isNewType = true; - EntityRegistry.WellKnownBaseType? fallbackBase = _options.NoAutoInherit ? null : EntityRegistry.WellKnownBaseType.System_Object; - bool requireSealed = false; - var classAttrs = context.classAttr(); - newTypeDef.Attributes = classAttrs.Select(VisitClassAttr).Aggregate( - (TypeAttributes)0, - (acc, result) => - { - var (attribute, implicitBase, attrRequireSealed) = result.Value; - if (implicitBase is not null) - { - fallbackBase = implicitBase; - } - if (!attribute.ShouldAppend) - { - requireSealed = attrRequireSealed; - return attribute.Value; - } - requireSealed |= attrRequireSealed; - if (attribute.Value == TypeAttributes.RTSpecialName) - { - // COMPAT: ILASM ignores the rtspecialname directive on a type. - return acc; - } - if ((attribute.Value & TypeAttributes.Interface) != 0) - { - // COMPAT: interface implies abstract - return acc | TypeAttributes.Interface | TypeAttributes.Abstract; - } - // Use the Flag's | operator which handles group masks - // (visibility, layout, string format) correctly. - return acc | attribute; - }); - - - // Two-pass generic parameter processing: - // Pass 1: Register all parameter names (without resolving constraints) - var typarContexts = context.typarsClause()?.typars()?.typar() ?? Array.Empty(); - for (int i = 0; i < typarContexts.Length; i++) - { - var attributes = VisitTyparAttribs(typarContexts[i].typarAttribs()).Value; - var param = EntityRegistry.CreateGenericParameter(attributes, VisitDottedName(typarContexts[i].dottedName()).Value); - param.Owner = newTypeDef; - param.Index = i; - newTypeDef.GenericParameters.Add(param); - } - - // Push the type so that !T references in constraints, extends, and implements can resolve - _currentTypeDefinition.Push(newTypeDef); - - // Pass 2: Resolve constraints (now all params are registered and type is on stack) - for (int i = 0; i < typarContexts.Length; i++) - { - var param = newTypeDef.GenericParameters[i]; - foreach (var constraint in VisitTyBound(typarContexts[i].tyBound()).Value) - { - constraint.Owner = param; - param.Constraints.Add(constraint); - newTypeDef.GenericParameterConstraints.Add(constraint); - } - } - - if (context.extendsClause() is CILParser.ExtendsClauseContext extends) - { - newTypeDef.BaseType = VisitExtendsClause(context.extendsClause()).Value; - } - - if (context.implClause() is CILParser.ImplClauseContext impl) - { - newTypeDef.InterfaceImplementations.AddRange(VisitImplClause(context.implClause()).Value); - } - - _currentTypeDefinition.Pop(); - - // Interfaces should not have an implicit base type - if (newTypeDef.Attributes.HasFlag(TypeAttributes.Interface)) - { - fallbackBase = null; - } - - newTypeDef.BaseType ??= _entityRegistry.ResolveImplicitBaseType(fallbackBase); - - // When the user has provided a type definition for a type that directly inherits - // System.ValueType but has not sealed it, emit a warning and add the 'sealed' modifier. - if (!newTypeDef.Attributes.HasFlag(TypeAttributes.Sealed) && - (requireSealed // COMPAT: when both the sentinel values for 'value' and 'enum' are explicitly - // specified, the sealed modifier is required even though - // the base type isn't System.ValueType. - || _entityRegistry.SystemValueTypeType.Equals(newTypeDef.BaseType))) - { - _diagnostics.Add( - new Diagnostic( - DiagnosticIds.UnsealedValueType, - DiagnosticSeverity.Error, - string.Format(DiagnosticMessageTemplates.UnsealedValueType, newTypeDef.Name), - Location.From(context.dottedName().Stop, _documents))); - newTypeDef.Attributes |= TypeAttributes.Sealed; - } - }); - - if (!isNewType) - { - // Type was forward-referenced. Apply attributes, generic params, - // base type, and interface implementations that were deferred. - var classAttrs = context.classAttr(); - typeDefinition.Attributes = classAttrs.Select(VisitClassAttr).Aggregate( - typeDefinition.Attributes, - (acc, result) => - { - var (attribute, _, _) = result.Value; - if (!attribute.ShouldAppend) - return attribute.Value; - if ((attribute.Value & TypeAttributes.Interface) != 0) - return acc | TypeAttributes.Interface | TypeAttributes.Abstract; - return acc | attribute.Value; - }); - - if (typeDefinition.GenericParameters.Count == 0) - { - // Two-pass generic parameter processing for forward-referenced types - var typarContexts = context.typarsClause()?.typars()?.typar() ?? Array.Empty(); - for (int i = 0; i < typarContexts.Length; i++) - { - var attributes = VisitTyparAttribs(typarContexts[i].typarAttribs()).Value; - var param = EntityRegistry.CreateGenericParameter(attributes, VisitDottedName(typarContexts[i].dottedName()).Value); - param.Owner = typeDefinition; - param.Index = i; - typeDefinition.GenericParameters.Add(param); - } - - _currentTypeDefinition.Push(typeDefinition); - - // Pass 2: Resolve constraints - for (int i = 0; i < typarContexts.Length; i++) - { - var param = typeDefinition.GenericParameters[i]; - foreach (var constraint in VisitTyBound(typarContexts[i].tyBound()).Value) - { - constraint.Owner = param; - param.Constraints.Add(constraint); - typeDefinition.GenericParameterConstraints.Add(constraint); - } - } - } - else - { - _ = context.typarsClause().Accept(this); - _currentTypeDefinition.Push(typeDefinition); - } - - if (context.extendsClause() is CILParser.ExtendsClauseContext extends && typeDefinition.BaseType is null) - { - typeDefinition.BaseType = VisitExtendsClause(extends).Value; - } - else - { - _ = context.extendsClause()?.Accept(this); - } - - if (context.implClause() is CILParser.ImplClauseContext impl) - { - typeDefinition.InterfaceImplementations.AddRange(VisitImplClause(impl).Value); - } - - _currentTypeDefinition.Pop(); - } - - return new(typeDefinition); - } - - GrammarResult ICILVisitor.VisitClassName(CILParser.ClassNameContext context) => VisitClassName(context); - public GrammarResult.Literal VisitClassName(CILParser.ClassNameContext context) - { - if (context.THIS() is not null) - { - if (_currentTypeDefinition.Count == 0) - { - ReportError(DiagnosticIds.ThisOutsideClass, DiagnosticMessageTemplates.ThisOutsideClass, context); - return new(new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle))); - } - var thisType = _currentTypeDefinition.Peek(); - return new(thisType); - } - else if (context.BASE() is not null) - { - if (_currentTypeDefinition.Count == 0) - { - ReportError(DiagnosticIds.BaseOutsideClass, DiagnosticMessageTemplates.BaseOutsideClass, context); - return new(new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle))); - } - var baseType = _currentTypeDefinition.Peek().BaseType; - if (baseType is null) - { - ReportError(DiagnosticIds.NoBaseType, DiagnosticMessageTemplates.NoBaseType, context); - return new(new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle))); - } - return new(baseType); - } - else if (context.NESTER() is not null) - { - if (_currentTypeDefinition.Count < 2) - { - ReportError(DiagnosticIds.NesterOutsideNestedClass, DiagnosticMessageTemplates.NesterOutsideNestedClass, context); - return new(new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle))); - } - var nesterType = _currentTypeDefinition.Peek().ContainingType!; - return new(nesterType); - } - else if (context.slashedName() is CILParser.SlashedNameContext slashedName) - { - EntityRegistry.EntityBase? resolutionContext = null; - if (context.dottedName() is CILParser.DottedNameContext dottedAssemblyOrModuleName) - { - if (context.MODULE() is not null) - { - string moduleName = VisitDottedName(dottedAssemblyOrModuleName).Value; - resolutionContext = _entityRegistry.FindModuleReference(moduleName); - if (resolutionContext is null) - { - ReportError(DiagnosticIds.ModuleNotFound, string.Format(DiagnosticMessageTemplates.ModuleNotFound, moduleName), context); - return new(new EntityRegistry.FakeTypeEntity(default(TypeDefinitionHandle))); - } - } - else - { - resolutionContext = _entityRegistry.GetOrCreateAssemblyReference(VisitDottedName(dottedAssemblyOrModuleName).Value, newRef => { }); - } - } - else if (context.mdtoken() is CILParser.MdtokenContext typeRefScope) - { - resolutionContext = VisitMdtoken(typeRefScope).Value; - } - else if (context.PTR() is not null) - { - resolutionContext = new EntityRegistry.FakeTypeEntity(default(ModuleDefinitionHandle)); - } - - if (resolutionContext is not null) - { - EntityRegistry.TypeReferenceEntity typeRef = _entityRegistry.GetOrCreateTypeReference(resolutionContext, VisitSlashedName(slashedName).Value); - return new(typeRef); - } - - Debug.Assert(resolutionContext is null); - - return new(ResolveTypeDef()); - - // Resolve typedef references - EntityRegistry.TypeEntity ResolveTypeDef() - { - TypeName typeName = VisitSlashedName(slashedName).Value; - if (typeName.ContainingTypeName is null) - { - // Check for typedef. - var typedefResult = TryResolveTypedefAsType(typeName.DottedName); - if (typedefResult is not null) - { - return typedefResult; - } - } - - // COMPAT: Before creating a forward-reference TypeDef, check if the type - // matches a well-known corelib type. Native ilasm resolves unqualified - // references to types like System.String as TypeRefs from the corelib. - if (typeName.ContainingTypeName is null) - { - var (ns, nm) = NameHelpers.SplitDottedNameToNamespaceAndName(typeName.DottedName); - if (ns == "System" && nm is "String" or "Object" or "ValueType" or "Enum" - or "Type" or "Array" or "Delegate" or "MulticastDelegate" - or "Exception" or "Attribute") - { - var coreLib = _entityRegistry.GetCoreLibAssemblyReference(); - return _entityRegistry.GetOrCreateTypeReference(coreLib, typeName); - } - } - - Stack containingTypes = new(); - for (TypeName? containingType = typeName; containingType is not null; containingType = containingType.ContainingTypeName) - { - containingTypes.Push(containingType); - } - EntityRegistry.TypeDefinitionEntity? typeDef = null; - while (containingTypes.Count != 0) - { - TypeName containingType = containingTypes.Pop(); - - (string ns, string name) = NameHelpers.SplitDottedNameToNamespaceAndName(containingType.DottedName); - - typeDef = _entityRegistry.GetOrCreateTypeDefinition( - typeDef, - ns, - name, - _ => { }); - } - - return typeDef!; - } - } - else if (context.mdtoken() is CILParser.MdtokenContext typeToken) - { - EntityRegistry.EntityBase resolvedToken = VisitMdtoken(typeToken).Value; - - if (resolvedToken is not EntityRegistry.TypeEntity type) - { - return new(new EntityRegistry.FakeTypeEntity(resolvedToken.Handle)); - } - return new(type); - } - - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitClassSeq(CILParser.ClassSeqContext context) => VisitClassSeq(context); - public GrammarResult.FormattedBlob VisitClassSeq(CILParser.ClassSeqContext context) - { - BlobBuilder objSeqBlob = new(0); - foreach (var item in context.classSeqElement()) - { - objSeqBlob.LinkSuffix(VisitClassSeqElement(item).Value); - } - return new(objSeqBlob); - } - - GrammarResult ICILVisitor.VisitClassSeqElement(CILParser.ClassSeqElementContext context) => VisitClassSeqElement(context); - - public GrammarResult.FormattedBlob VisitClassSeqElement(CILParser.ClassSeqElementContext context) - { - BlobBuilder blob = new(); - if (context.className() is CILParser.ClassNameContext className) - { - if (VisitClassName(className).Value is EntityRegistry.IHasReflectionNotation notation) - { - blob.WriteSerializedString(notation.ReflectionNotation); - } - else - { - blob.WriteSerializedString(""); - } - return new(blob); - } - - blob.WriteSerializedString( - context.SQSTRING() is { } stringNode - ? StringHelpers.ParseQuotedString(stringNode.Symbol.Text) - : null); - return new(blob); - } - public GrammarResult VisitCompControl(CILParser.CompControlContext context) - { - // All compilation control directives that need special handling will be handled - // directly in the token stream before parsing. - // Any that reach here can be ignored. - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitCompQstring(CILParser.CompQstringContext context) - { - return VisitCompQstring(context); - } - - private static GrammarResult.String VisitCompQstring(CILParser.CompQstringContext context) - { - StringBuilder builder = new(); - foreach (var item in context.QSTRING()) - { - builder.Append(StringHelpers.ParseQuotedString(item.Symbol.Text)); - } - return new(builder.ToString()); - } - - GrammarResult ICILVisitor.VisitCorflags(CILParser.CorflagsContext context) => VisitCorflags(context); - public GrammarResult.Literal VisitCorflags(CILParser.CorflagsContext context) => VisitInt32(context.int32()); - - GrammarResult ICILVisitor.VisitCustomAttrDecl(CILParser.CustomAttrDeclContext context) => VisitCustomAttrDecl(context); - public GrammarResult.Literal VisitCustomAttrDecl(CILParser.CustomAttrDeclContext context) - { - if (context.dottedName() is { } dottedName) - { - // This is a typedef reference for a custom attribute - string alias = VisitDottedName(dottedName).Value; - var resolved = TryResolveTypedefAsCustomAttribute(alias); - if (resolved is not null) - { - var typedefAttribute = _entityRegistry.CreateCustomAttribute(resolved.Value.Constructor, resolved.Value.Value); - typedefAttribute.Location = Location.From(context.Start, _documents); - return new(typedefAttribute); - } - // Typedef not found - could report diagnostic here - return new(null); - } - if (context.customDescrWithOwner() is {} descrWithOwner) - { - // Visit the custom attribute descriptor to record it, - // but don't return it as it will already have its owner recorded. - _ = VisitCustomDescrWithOwner(descrWithOwner); - return new(null); - } - if (context.customDescr() is {} descr) - { -#nullable disable // Disable nullability to work around lack of variance. - return VisitCustomDescr(descr); -#nullable restore - } - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitCustomDescrInMethodBody(CILParser.CustomDescrInMethodBodyContext context) => VisitCustomDescrInMethodBody(context); - public GrammarResult.Literal VisitCustomDescrInMethodBody(CILParser.CustomDescrInMethodBodyContext context) - { - if (context.customDescrWithOwner() is {} descrWithOwner) - { - // Visit the custom attribute descriptor to record it, - // but don't return it as it will already have its owner recorded. - _ = VisitCustomDescrWithOwner(descrWithOwner); - return new(null); - } - if (context.customDescr() is {} descr) - { -#nullable disable // Disable nullability to work around lack of variance. - return VisitCustomDescr(descr); -#nullable restore - } - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitCustomBlobArgs(CILParser.CustomBlobArgsContext context) => VisitCustomBlobArgs(context); - public GrammarResult.FormattedBlob VisitCustomBlobArgs(CILParser.CustomBlobArgsContext context) - { - BlobBuilder blob = new(); - foreach (var item in context.serInit()) - { - VisitSerInit(item).Value.WriteContentTo(blob); - } - return new(blob); - } - - private const ushort CustomAttributeBlobFormatVersion = 1; - - GrammarResult ICILVisitor.VisitCustomBlobDescr(CILParser.CustomBlobDescrContext context) => VisitCustomBlobDescr(context); - public GrammarResult.FormattedBlob VisitCustomBlobDescr(CILParser.CustomBlobDescrContext context) - { - var blob = new BlobBuilder(); - // Custom attribute blob prolog is a 2-byte unsigned integer (ECMA-335 II.23.3) - blob.WriteUInt16(CustomAttributeBlobFormatVersion); - VisitCustomBlobArgs(context.customBlobArgs()).Value.WriteContentTo(blob); - VisitCustomBlobNVPairs(context.customBlobNVPairs()).Value.WriteContentTo(blob); - return new(blob); - } - - GrammarResult ICILVisitor.VisitCustomBlobNVPairs(CILParser.CustomBlobNVPairsContext context) => VisitCustomBlobNVPairs(context); - public GrammarResult.FormattedBlob VisitCustomBlobNVPairs(CILParser.CustomBlobNVPairsContext context) - { - var blob = new BlobBuilder(); - var fieldOrProps = context.fieldOrProp(); - var types = context.serializType(); - var names = context.dottedName(); - var values = context.serInit(); - - blob.WriteInt16((short)fieldOrProps.Length); - - for (int i = 0; i < fieldOrProps.Length; i++) - { - var fieldOrProp = fieldOrProps[i].GetText() == "field" ? CustomAttributeNamedArgumentKind.Field : CustomAttributeNamedArgumentKind.Property; - var type = VisitSerializType(types[i]).Value; - var name = VisitDottedName(names[i]).Value; - var value = VisitSerInit(values[i]).Value; - blob.WriteByte((byte)fieldOrProp); - type.WriteContentTo(blob); - blob.WriteSerializedString(name); - value.WriteContentTo(blob); - } - return new(blob); - } - - GrammarResult ICILVisitor.VisitCustomDescr(CILParser.CustomDescrContext context) => VisitCustomDescr(context); - public GrammarResult.Literal VisitCustomDescr(CILParser.CustomDescrContext context) - { - var ctor = VisitCustomType(context.customType()).Value; - BlobBuilder value; - if (context.customBlobDescr() is {} customBlobDescr) - { - value = VisitCustomBlobDescr(customBlobDescr).Value; - } - else if (context.bytes() is {} bytes) - { - value = new(); - value.WriteBytes(VisitBytes(bytes).Value); - } - else if (context.compQstring() is {} str) - { - value = new(); - value.WriteUTF8(VisitCompQstring(str).Value); - // COMPAT: We treat this string as a string-reprensentation of a blob, - // so we don't emit the null terminator. - } - else - { - value = new(); - value.WriteUInt16(CustomAttributeBlobFormatVersion); - value.WriteUInt16(0); - } - - var attribute = _entityRegistry.CreateCustomAttribute(ctor, value); - attribute.Location = Location.From(context.Start, _documents); - return new(attribute); - } - - GrammarResult ICILVisitor.VisitCustomDescrWithOwner(CILParser.CustomDescrWithOwnerContext context) => VisitCustomDescrWithOwner(context); - - public GrammarResult.Literal VisitCustomDescrWithOwner(CILParser.CustomDescrWithOwnerContext context) - { - var ctor = VisitCustomType(context.customType()).Value; - BlobBuilder value; - if (context.customBlobDescr() is {} customBlobDescr) - { - value = VisitCustomBlobDescr(customBlobDescr).Value; - } - else if (context.bytes() is {} bytes) - { - value = new(); - value.WriteBytes(VisitBytes(bytes).Value); - } - else if (context.compQstring() is {} str) - { - value = new(); - value.WriteUTF8(VisitCompQstring(str).Value); - // COMPAT: We treat this string as a string-reprensentation of a blob, - // so we don't emit the null terminator. - } - else - { - value = new(); - value.WriteUInt16(CustomAttributeBlobFormatVersion); - value.WriteUInt16(0); - } - - var attr = _entityRegistry.CreateCustomAttribute(ctor, value); - - attr.Location = Location.From(context.Start, _documents); - attr.Owner = VisitOwnerType(context.ownerType()).Value; - - return new(attr); - } - - GrammarResult ICILVisitor.VisitCustomType(CILParser.CustomTypeContext context) => VisitCustomType(context); - public GrammarResult.Literal VisitCustomType(CILParser.CustomTypeContext context) => VisitMethodRef(context.methodRef()); - - public GrammarResult VisitDataDecl(CILParser.DataDeclContext context) - { - _ = VisitDdHead(context.ddHead()); - _ = VisitDdBody(context.ddBody()); - return GrammarResult.SentinelValue.Result; - } - public GrammarResult VisitDdBody(CILParser.DdBodyContext context) - { - if (context.ddItemList() is CILParser.DdItemListContext ddItemList) - { - _ = VisitDdItemList(ddItemList); - } - else - { - foreach (var item in context.ddItem()) - { - _ = VisitDdItem(item); - } - } - return GrammarResult.SentinelValue.Result; - } - public GrammarResult VisitDdHead(CILParser.DdHeadContext context) - { - if (context.id() is CILParser.IdContext id) - { - string name = VisitId(id).Value; - if (!_mappedFieldDataNames.ContainsKey(name)) - { - _mappedFieldDataNames.Add(name, _mappedFieldData.Count); - } - } - return GrammarResult.SentinelValue.Result; - } - public GrammarResult VisitDdItem(CILParser.DdItemContext context) - { - if (context.compQstring() is CILParser.CompQstringContext str) - { - var value = VisitCompQstring(str).Value; - _mappedFieldData.WriteUTF16(value); - return GrammarResult.SentinelValue.Result; - } - else if (context.id() is CILParser.IdContext id) - { - // Reference to another data label - this will be patched with the target's RVA - // during PE serialization by VTableExportPEBuilder.ApplyDataLabelFixups() - string name = VisitId(id).Value; - if (!_mappedFieldDataReferenceFixups.TryGetValue(name, out var fixups)) - { - _mappedFieldDataReferenceFixups[name] = fixups = new(); - } - - // Reserve 4 bytes for the RVA that will be patched later - fixups.Add(_mappedFieldData.ReserveBytes(4)); - return GrammarResult.SentinelValue.Result; - } - else if (context.bytes() is CILParser.BytesContext bytes) - { - _mappedFieldData.WriteBytes(VisitBytes(bytes).Value); - return GrammarResult.SentinelValue.Result; - } - - int itemCount = VisitDdItemCount(context.ddItemCount()).Value; - - if (context.INT8() is not null) - { - _mappedFieldData.WriteBytes(context.int32() is CILParser.Int32Context int32 ? (byte)VisitInt32(int32).Value : (byte)0, itemCount); - } - else if (context.INT16() is not null) - { - for (int i = 0; i < itemCount; i++) - { - _mappedFieldData.WriteInt16(context.int32() is CILParser.Int32Context int32 ? (short)VisitInt32(int32).Value : (short)0); - } - } - else if (context.INT32_() is not null) - { - for (int i = 0; i < itemCount; i++) - { - _mappedFieldData.WriteInt32(context.int32() is CILParser.Int32Context int32 ? VisitInt32(int32).Value : 0); - } - } - else if (context.INT64_() is not null) - { - for (int i = 0; i < itemCount; i++) - { - _mappedFieldData.WriteInt64(context.int64() is CILParser.Int64Context int64 ? VisitInt64(int64).Value : 0); - } - } - else if (context.FLOAT32() is not null) - { - for (int i = 0; i < itemCount; i++) - { - _mappedFieldData.WriteSingle(context.float64() is CILParser.Float64Context float64 ? (float)VisitFloat64(float64).Value : 0); - } - } - else if (context.FLOAT64_() is not null) - { - for (int i = 0; i < itemCount; i++) - { - _mappedFieldData.WriteDouble(context.float64() is CILParser.Float64Context float64 ? VisitFloat64(float64).Value : 0); - } - } - return GrammarResult.SentinelValue.Result; - } - GrammarResult ICILVisitor.VisitDdItemCount(CILParser.DdItemCountContext context) => VisitDdItemCount(context); - public GrammarResult.Literal VisitDdItemCount(CILParser.DdItemCountContext context) => new(context.int32() is CILParser.Int32Context ? VisitInt32(context.int32()).Value : 1); - public GrammarResult VisitDdItemList(CILParser.DdItemListContext context) - { - foreach (var item in context.ddItem()) - { - VisitDdItem(item); - } - return GrammarResult.SentinelValue.Result; - } - - private readonly Stack _currentNamespace = new(); - - private readonly Stack _currentTypeDefinition = new(); - - public GrammarResult VisitDecl(CILParser.DeclContext context) - { - bool isTrailingCustomAttribute = - context.customAttrDecl() is { } customAttribute && - customAttribute.dottedName() is null; - if (context.fieldDecl() is null && !isTrailingCustomAttribute) - { - _pendingClassCustomAttributeOwner = null; - } - - if (context.nameSpaceHead() is CILParser.NameSpaceHeadContext ns) - { - string namespaceName = VisitNameSpaceHead(ns).Value; - string? outer = _currentNamespace.PeekOrDefault(); - _currentNamespace.Push(string.IsNullOrEmpty(outer) ? namespaceName : $"{outer}.{namespaceName}"); - VisitDecls(context.decls()); - _currentNamespace.Pop(); - _pendingClassCustomAttributeOwner = null; - return GrammarResult.SentinelValue.Result; - } - if (context.classHead() is CILParser.ClassHeadContext classHead) - { - _currentTypeDefinition.Push(VisitClassHead(classHead).Value); - VisitClassDecls(context.classDecls()); - _currentTypeDefinition.Pop(); - _pendingClassCustomAttributeOwner = null; - return GrammarResult.SentinelValue.Result; - } - if (context.methodHead() is CILParser.MethodHeadContext methodHead) - { - _currentMethod = new(VisitMethodHead(methodHead).Value); - VisitMethodDecls(context.methodDecls()); - if (_currentMethod.AllLocals.Count > 0) - { - var localsSig = new BlobBuilder(); - var encoder = new BlobEncoder(localsSig); - var localsEncoder = encoder.LocalVariableSignature(_currentMethod.AllLocals.Count); - foreach (var local in _currentMethod.AllLocals) - { - local.SignatureBlob.WriteContentTo(localsEncoder.AddVariable().Builder); - } - _currentMethod.Definition.LocalsSignature = _entityRegistry.GetOrCreateStandaloneSignature(localsSig); - } - _currentMethod = null; - return GrammarResult.SentinelValue.Result; - } - if (context.fieldDecl() is { } fieldDecl) - { - _ = VisitFieldDecl(fieldDecl); - return GrammarResult.SentinelValue.Result; - } - if (context.dataDecl() is { } dataDecl) - { - _ = VisitDataDecl(dataDecl); - return GrammarResult.SentinelValue.Result; - } - if (context.vtableDecl() is { } vtable) - { - _ = VisitVtableDecl(vtable); - return GrammarResult.SentinelValue.Result; - } - if (context.vtfixupDecl() is { } vtFixup) - { - _ = VisitVtfixupDecl(vtFixup); - return GrammarResult.SentinelValue.Result; - } - if (context.extSourceSpec() is { } extSourceSpec) - { - _ = VisitExtSourceSpec(extSourceSpec); - return GrammarResult.SentinelValue.Result; - } - if (context.fileDecl() is { } fileDecl) - { - _ = VisitFileDecl(fileDecl); - return GrammarResult.SentinelValue.Result; - } - if (context.assemblyBlock() is { } assemblyBlock) - { - _ = VisitAssemblyBlock(assemblyBlock); - return GrammarResult.SentinelValue.Result; - } - if (context.assemblyRefHead() is { } assemblyRef) - { - var asmRef = VisitAssemblyRefHead(assemblyRef).Value; - _currentAssemblyOrRef = asmRef; - foreach (var decl in context.assemblyRefDecls().assemblyRefDecl()) - { - _ = VisitAssemblyRefDecl(decl); - } - _currentAssemblyOrRef = null; - } - if (context.exptypeHead() is { } exptypeHead) - { - var (attrs, dottedName) = VisitExptypeHead(exptypeHead).Value; - (string typeNamespace, string name) = NameHelpers.SplitDottedNameToNamespaceAndName(dottedName); - var (impl, typeDefId, customAttrs) = VisitExptypeDecls(context.exptypeDecls()).Value; - if (impl is null) - { - // COMPAT: Like native ilasm, warn and skip the exported type when implementation is not specified - ReportWarning(DiagnosticIds.MissingExportedTypeImplementation, - string.Format(DiagnosticMessageTemplates.MissingExportedTypeImplementation, dottedName), - exptypeHead); - return GrammarResult.SentinelValue.Result; - } - var exp = _entityRegistry.GetOrCreateExportedType(impl, typeNamespace, name, exp => - { - exp.Attributes = attrs; - exp.TypeDefinitionId = typeDefId; - }); - foreach (var attr in customAttrs) - { - attr.Owner = exp; - } - return GrammarResult.SentinelValue.Result; - } - if (context.manifestResHead() is { } manifestResHead) - { - var (name, alias, flags) = VisitManifestResHead(manifestResHead).Value; - var (implementation, offset, attrs) = VisitManifestResDecls(context.manifestResDecls()).Value; - if (implementation is null) - { - offset = (uint)_manifestResources.Count; - byte[] resourceData = _resourceLocator(alias); - if (resourceData is null) - { - ReportError(DiagnosticIds.FileNotFound, - string.Format(DiagnosticMessageTemplates.FileNotFound, alias), - context); - } - else - { - // ECMA-335: Each resource is prefixed with a 4-byte length - _manifestResources.WriteInt32(resourceData.Length); - _manifestResources.WriteBytes(resourceData); - } - } - var res = _entityRegistry.CreateManifestResource(name, offset); - res.Attributes = flags; - res.Implementation = implementation; - foreach (var attr in attrs) - { - attr.Owner = res; - } - return GrammarResult.SentinelValue.Result; - } - if (context.moduleHead() is { } moduleHead) - { - if (moduleHead.dottedName() is null) - { - _entityRegistry.Module.Name = null; - } - else if (moduleHead.ChildCount == 2) - { - _entityRegistry.Module.Name = VisitDottedName(moduleHead.dottedName()).Value; - } - else - { - var name = VisitDottedName(moduleHead.dottedName()).Value; - _entityRegistry.GetOrCreateModuleReference(name, _ => { }); - } - return GrammarResult.SentinelValue.Result; - } - if (context.subsystem() is { } subsystem) - { - _subsystem = (Subsystem)VisitSubsystem(subsystem).Value; - } - if (context.corflags() is { } corflags) - { - _corflags = (CorFlags)VisitCorflags(corflags).Value; - } - if (context.alignment() is { } alignment) - { - _alignment = VisitAlignment(alignment).Value; - } - if (context.imagebase() is { } imagebase) - { - _imageBase = VisitImagebase(imagebase).Value; - } - if (context.stackreserve() is { } stackreserve) - { - _stackReserve = VisitStackreserve(stackreserve).Value; - } - if (context.languageDecl() is { } languageDecl) - { - VisitLanguageDecl(languageDecl); - } - if (context.customAttrDecl() is { } topLevelCustomAttr) - { - if (VisitCustomAttrDecl(topLevelCustomAttr).Value is { } customAttr) - { - customAttr.Owner = (EntityRegistry.EntityBase?)_pendingClassCustomAttributeOwner ?? _entityRegistry.Module; - } - } - if (context.secDecl() is { } topSecDecl) - { - var declarativeSecurity = VisitSecDecl(topSecDecl).Value; - declarativeSecurity?.Parent = _entityRegistry.Assembly; - } - if (context.typedefDecl() is { } typedefDecl) - { - VisitTypedefDecl(typedefDecl); - } - if (context.typelist() is { } typelist) - { - foreach (var name in typelist.className()) - { - _ = VisitClassName(name); - } - } - if (context.mscorlib() is { } mscorlib) - { - VisitMscorlib(mscorlib); - } - return GrammarResult.SentinelValue.Result; - } - - public GrammarResult VisitDecls(CILParser.DeclsContext context) - { - foreach (var decl in context.decl()) - { - _ = VisitDecl(decl); - } - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitDottedName(CILParser.DottedNameContext context) - { - return VisitDottedName(context); - } - - public static GrammarResult.String VisitDottedName(CILParser.DottedNameContext context) - { - CILParser.DottedNamePartContext[] parts = context.dottedNamePart(); - if (parts.Length > 0) - { - StringBuilder builder = new(); - for (int i = 0; i < parts.Length; i++) - { - if (i > 0) - { - builder.Append('.'); - } - - CILParser.DottedNamePartContext part = parts[i]; - builder.Append(part.SQSTRING() is { } quotedPart - ? StringHelpers.ParseQuotedString(quotedPart.GetText()) - : part.GetText()); - } - - return new(builder.ToString()); - } - - string text = context.GetText(); - if (context.SQSTRING() is not null && text.Length >= 2 && text[0] == '\'') - { - text = text.Substring(1, text.Length - 2); - } - return new(text); - } - - GrammarResult ICILVisitor.VisitDottedNamePart(CILParser.DottedNamePartContext context) => throw new UnreachableException(); - GrammarResult ICILVisitor.VisitElementType(CILParser.ElementTypeContext context) => VisitElementType(context); - public GrammarResult.FormattedBlob VisitElementType(CILParser.ElementTypeContext context) - { - BlobBuilder blob = new(5); - if (context.OBJECT() is not null) - { - blob.WriteByte((byte)SignatureTypeCode.Object); - } - else if (context.className() is CILParser.ClassNameContext className) - { - EntityRegistry.TypeEntity typeEntity = VisitClassName(className).Value; - if (context.VALUE() is not null || context.VALUETYPE() is not null) - { - // Check for well-known value types that should use primitive type codes - if (TryGetPrimitiveTypeCode(typeEntity, isValueType: true) is { } vtPrimCode) - { - blob.WriteByte((byte)vtPrimCode); - } - else - { - blob.WriteByte((byte)SignatureTypeKind.ValueType); - blob.WriteTypeEntity(typeEntity); - } - } - else - { - // Check for well-known class types that should use primitive type codes - if (TryGetPrimitiveTypeCode(typeEntity, isValueType: false) is { } clsPrimCode) - { - blob.WriteByte((byte)clsPrimCode); - } - else - { - blob.WriteByte((byte)SignatureTypeKind.Class); - blob.WriteTypeEntity(typeEntity); - } - } - } - else if (context.callConv() is CILParser.CallConvContext callConv) - { - // Emit function pointer signature. - blob.WriteByte((byte)SignatureTypeCode.FunctionPointer); - byte sigCallConv = VisitCallConv(callConv).Value; - blob.WriteByte(sigCallConv); - var signatureArgs = VisitSigArgs(context.sigArgs()).Value; - int numArgs = signatureArgs.Count(arg => !arg.IsSentinel); - blob.WriteCompressedInteger(numArgs); - blob.LinkSuffix(VisitType(context.type()).Value); - foreach (var arg in signatureArgs) - { - blob.LinkSuffix(arg.SignatureBlob); - } - } - else if (context.ELLIPSIS() is not null) - { - blob.WriteByte((byte)SignatureTypeCode.Sentinel); - blob.LinkSuffix(VisitType(context.type()).Value); - } - else if (context.METHOD_TYPE_PARAMETER() is not null) - { - if (context.int32() is CILParser.Int32Context int32) - { - // COMPAT: Always write a reference to a generic method parameter by index - // even if we aren't in a method or the index is out of range. We want to be able to write invalid IL like this. - blob.WriteByte((byte)SignatureTypeCode.GenericMethodParameter); - blob.WriteCompressedInteger(VisitInt32(int32).Value); - } - else - { - string dottedName = VisitDottedName(context.dottedName()).Value; - if (_currentMethod is null) - { - ReportError(DiagnosticIds.MethodTypeParameterOutsideMethod, string.Format(DiagnosticMessageTemplates.MethodTypeParameterOutsideMethod, dottedName), context); - blob.WriteByte((byte)SignatureTypeCode.GenericMethodParameter); - blob.WriteCompressedInteger(0); - } - else - { - blob.WriteByte((byte)SignatureTypeCode.GenericMethodParameter); - bool foundParameter = false; - for (int i = 0; i < _currentMethod.Definition.GenericParameters.Count; i++) - { - EntityRegistry.GenericParameterEntity? genericParameter = _currentMethod.Definition.GenericParameters[i]; - if (genericParameter.Name == dottedName) - { - foundParameter = true; - blob.WriteCompressedInteger(i); - break; - } - } - if (!foundParameter) - { - // BREAK-COMPAT: ILASM would silently emit an invalid signature when a method uses an invalid method type parameter but doesn't have method type parameters. - // The signature used completely invalid undocumented codes (that were really sentinel values for how ilasm later detected errors due to how the parsing model worked with a YACC-based parser) - // and when a method had no type parameters, it didn't run the code to process out these values and emit errors. - // This seems like a scenario that doesn't need to be brought forward. - // Instead, we'll just emit a reference to "generic method parameter" 0 and report an error. - - ReportError(DiagnosticIds.GenericParameterNotFound, string.Format(DiagnosticMessageTemplates.GenericParameterNotFound, dottedName), context); - blob.WriteCompressedInteger(0); - } - } - } - } - else if (context.TYPE_PARAMETER() is not null) - { - if (context.int32() is CILParser.Int32Context int32) - { - // COMPAT: Always write a reference to a generic type parameter by index - // even if we aren't in a type or the index is out of range. We want to be able to write invalid IL like this. - blob.WriteByte((byte)SignatureTypeCode.GenericTypeParameter); - blob.WriteCompressedInteger(VisitInt32(int32).Value); - } - else - { - string dottedName = VisitDottedName(context.dottedName()).Value; - if (_currentTypeDefinition.Count == 0) - { - ReportError(DiagnosticIds.TypeParameterOutsideType, string.Format(DiagnosticMessageTemplates.TypeParameterOutsideType, dottedName), context); - blob.WriteByte((byte)SignatureTypeCode.GenericTypeParameter); - blob.WriteCompressedInteger(0); - } - else - { - blob.WriteByte((byte)SignatureTypeCode.GenericTypeParameter); - bool foundParameter = false; - for (int i = 0; i < _currentTypeDefinition.Peek().GenericParameters.Count; i++) - { - EntityRegistry.GenericParameterEntity? genericParameter = _currentTypeDefinition.Peek().GenericParameters[i]; - if (genericParameter.Name == dottedName) - { - foundParameter = true; - blob.WriteCompressedInteger(i); - break; - } - } - if (!foundParameter) - { - // BREAK-COMPAT: ILASM would silently emit an invalid signature when a type uses an invalid method type parameter but doesn't have any type parameters. - // The signature used completely invalid undocumented codes (that were really sentinel values for how ilasm later detected errors due to how the parsing model worked with a YACC-based parser) - // and when a method had no type parameters, it didn't run the code to process out these values and emit errors. - // This seems like a scenario that doesn't need to be brought forward. - // Instead, we'll just emit a reference to "generic method parameter" 0 and report an error. - - ReportError(DiagnosticIds.GenericParameterNotFound, string.Format(DiagnosticMessageTemplates.GenericParameterNotFound, dottedName), context); - blob.WriteCompressedInteger(0); - } - } - } - } - else if (context.TYPEDREF() is not null) - { - blob.WriteByte((byte)SignatureTypeCode.TypedReference); - } - else if (context.VOID() is not null) - { - blob.WriteByte((byte)SignatureTypeCode.Void); - } - else if (context.nativeInt() is not null) - { - blob.WriteByte((byte)SignatureTypeCode.IntPtr); - } - else if (context.nativeUint() is not null) - { - blob.WriteByte((byte)SignatureTypeCode.UIntPtr); - } - else if (context.simpleType() is CILParser.SimpleTypeContext simpleType) - { - blob.WriteByte((byte)VisitSimpleType(simpleType).Value); - } - else if (context.dottedName() is CILParser.DottedNameContext dottedName) - { - // Typedef reference - resolve and write the type blob - string alias = VisitDottedName(dottedName).Value; - var resolved = TryResolveTypedefAsTypeBlob(alias); - if (resolved is not null) - { - // Copy the content to avoid modifying the stored blob - resolved.WriteContentTo(blob); - } - else - { - ReportError(DiagnosticIds.TypedefNotFound, string.Format(DiagnosticMessageTemplates.TypedefNotFound, alias), context); - } - } - else - { - throw new UnreachableException(); - } - return new(blob); - } - - public GrammarResult VisitErrorNode(IErrorNode node) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - - // esHead is '.line' or '#line' - this is just the keyword, actual parsing is in VisitExtSourceSpec. - public GrammarResult VisitEsHead(CILParser.EsHeadContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - - GrammarResult ICILVisitor.VisitEventAttr(CILParser.EventAttrContext context) => VisitEventAttr(context); - public GrammarResult.Flag VisitEventAttr(CILParser.EventAttrContext context) - { - return context.GetText() switch - { - "specialname" => new(EventAttributes.SpecialName), - "rtspecialname" => new(0), // COMPAT: Ignore - _ => throw new UnreachableException(), - }; - } - - GrammarResult ICILVisitor.VisitEventDecl(CILParser.EventDeclContext context) => VisitEventDecl(context); - public GrammarResult.Literal<(MethodSemanticsAttributes, EntityRegistry.EntityBase)?> VisitEventDecl(CILParser.EventDeclContext context) - { - if (context.ChildCount != 2) - { - return new(null); - } - string accessor = context.GetChild(0).GetText(); - EntityRegistry.EntityBase memberReference = VisitMethodRef(context.methodRef()).Value; - MethodSemanticsAttributes methodSemanticsAttributes = accessor switch - { - ".addon" => MethodSemanticsAttributes.Adder, - ".removeon" => MethodSemanticsAttributes.Remover, - ".fire" => MethodSemanticsAttributes.Raiser, - ".other" => MethodSemanticsAttributes.Other, - _ => throw new UnreachableException(), - }; - return new((methodSemanticsAttributes, memberReference)); - } - - GrammarResult ICILVisitor.VisitEventDecls(CILParser.EventDeclsContext context) => VisitEventDecls(context); - public GrammarResult.Sequence<(MethodSemanticsAttributes, EntityRegistry.EntityBase)> VisitEventDecls(CILParser.EventDeclsContext context) - => new( - context.eventDecl() - .Select(decl => VisitEventDecl(decl).Value) - .Where(decl => decl is not null) - .Select(decl => decl!.Value).ToImmutableArray()); - - GrammarResult ICILVisitor.VisitEventHead(CILParser.EventHeadContext context) => VisitEventHead(context); - public GrammarResult.Literal VisitEventHead(CILParser.EventHeadContext context) - { - string name = VisitDottedName(context.dottedName()).Value; - EventAttributes eventAttributes = context.eventAttr().Select(attr => VisitEventAttr(attr).Value).Aggregate((EventAttributes)0, (a, b) => a | b); - return new(new EntityRegistry.EventEntity(eventAttributes, VisitTypeSpec(context.typeSpec()).Value, name)); - } - - public GrammarResult VisitExportHead(CILParser.ExportHeadContext context) => throw new NotImplementedException("Obsolete syntax"); - GrammarResult ICILVisitor.VisitExptAttr(CILParser.ExptAttrContext context) => VisitExptAttr(context); - public static GrammarResult.Flag VisitExptAttr(CILParser.ExptAttrContext context) - { - return context.GetText() switch - { - "private" => new(TypeAttributes.NotPublic, TypeAttributes.VisibilityMask), - "public" => new(TypeAttributes.Public, TypeAttributes.VisibilityMask), - "forwarder" => new(TypeAttributes.Forwarder), - "nestedpublic" => new(TypeAttributes.NestedPublic, TypeAttributes.VisibilityMask), - "nestedprivate" => new(TypeAttributes.NestedPrivate, TypeAttributes.VisibilityMask), - "nestedfamily" => new(TypeAttributes.NestedFamily, TypeAttributes.VisibilityMask), - "nestedassembly" => new(TypeAttributes.NestedAssembly, TypeAttributes.VisibilityMask), - "nestedfamandassem" => new(TypeAttributes.NestedFamANDAssem, TypeAttributes.VisibilityMask), - "nestedfamorassem" => new(TypeAttributes.NestedFamORAssem, TypeAttributes.VisibilityMask), - _ => throw new UnreachableException(), - }; - } - - // Type exports and forwarders are implemented via VisitExptypeDecls - public GrammarResult VisitExptypeDecl(CILParser.ExptypeDeclContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - - GrammarResult ICILVisitor.VisitExptypeDecls(CILParser.ExptypeDeclsContext context) => VisitExptypeDecls(context); - public GrammarResult.Literal<(EntityRegistry.EntityBase? implementation, int typedefId, ImmutableArray attrs)> VisitExptypeDecls(CILParser.ExptypeDeclsContext context) - { - // COMPAT: The following order specifies the precedence of the various export kinds. - // File, Assembly, Class (enclosing type), invalid token. - // We'll process through all of the options here and then return the one that is valid. - // We'll also record custom attributes here. - EntityRegistry.EntityBase? implementationEntity = null; - int typedefId = 0; - var attrs = ImmutableArray.CreateBuilder(); - var declarations = context.exptypeDecl(); - for (int i = 0; i < declarations.Length; i++) - { - if (declarations[i].customAttrDecl() is { } attr) - { - if (VisitCustomAttrDecl(attr).Value is EntityRegistry.CustomAttributeEntity customAttribute) - { - attrs.Add(customAttribute); - } - continue; - } - if (declarations[i].mdtoken() is { } mdToken) - { - var entity = VisitMdtoken(mdToken).Value; - if (entity is null or EntityRegistry.FakeTypeEntity) - { - ReportError(DiagnosticIds.InvalidMetadataToken, DiagnosticMessageTemplates.InvalidMetadataToken, declarations[i]); - } - implementationEntity = ResolveBetterEntity(entity); - continue; - } - string kind = declarations[i].GetText(); - if (kind.StartsWith(".file")) - { - string fileName = VisitDottedName(declarations[i].dottedName()).Value; - implementationEntity = _entityRegistry.FindFile(fileName); - if (implementationEntity is null) - { - ReportError(DiagnosticIds.FileNotFound, string.Format(DiagnosticMessageTemplates.FileNotFound, fileName), declarations[i]); - } - } - else if (kind.StartsWith(".assembly")) - { - string assemblyName = VisitDottedName(declarations[i].dottedName()).Value; - implementationEntity = _entityRegistry.FindAssemblyReference(assemblyName); - if (implementationEntity is null) - { - ReportError(DiagnosticIds.AssemblyNotFound, string.Format(DiagnosticMessageTemplates.AssemblyNotFound, assemblyName), declarations[i]); - } - } - else if (kind.StartsWith(".class")) - { - if (declarations[i].int32() is CILParser.Int32Context int32) - { - typedefId = VisitInt32(int32).Value; - } - else - { - _ = VisitSlashedName(declarations[i].slashedName()); - var containing = ResolveExportedType(declarations[i].slashedName()); - if (containing is null) - { - ReportError(DiagnosticIds.ExportedTypeNotFound, string.Format(DiagnosticMessageTemplates.ExportedTypeNotFound, declarations[i].slashedName().GetText()), declarations[i]); - } - else - { - implementationEntity = ResolveBetterEntity(containing); - } - } - } - } - - return new((implementationEntity, typedefId, attrs.ToImmutable())); - - EntityRegistry.EntityBase? ResolveBetterEntity(EntityRegistry.EntityBase? newImplementation) - { - return (implementationEntity, newImplementation) switch - { - (null, _) => newImplementation, - (_, null) => implementationEntity, - (_, EntityRegistry.FileEntity) => newImplementation, - (EntityRegistry.FileEntity, _) => implementationEntity, - (_, EntityRegistry.AssemblyEntity) => newImplementation, - (EntityRegistry.AssemblyEntity, _) => implementationEntity, - (_, EntityRegistry.TypeEntity) => newImplementation, - (EntityRegistry.TypeEntity, _) => implementationEntity, - _ => throw new UnreachableException(), - }; - } - - // Resolve ExportedType reference - EntityRegistry.ExportedTypeEntity? ResolveExportedType(CILParser.SlashedNameContext slashedName) - { - TypeName typeName = VisitSlashedName(slashedName).Value; - if (typeName.ContainingTypeName is null) - { - // Check for typedef - typedefs resolve to TypeEntity, not ExportedTypeEntity - // so we skip the typedef check for exported type resolution - } - Stack containingTypes = new(); - for (TypeName? containingType = typeName; containingType is not null; containingType = containingType.ContainingTypeName) - { - containingTypes.Push(containingType); - } - EntityRegistry.ExportedTypeEntity? exportedType = null; - while (containingTypes.Count != 0) - { - TypeName containingType = containingTypes.Pop(); - - (string ns, string name) = NameHelpers.SplitDottedNameToNamespaceAndName(containingType.DottedName); - - exportedType = _entityRegistry.FindExportedType( - exportedType, - ns, - name); - - if (exportedType is null) - { - ReportError(DiagnosticIds.ExportedTypeNotFound, string.Format(DiagnosticMessageTemplates.ExportedTypeNotFound, containingType.DottedName), slashedName); - return null; - } - } - - return exportedType!; - } - } - GrammarResult ICILVisitor.VisitExptypeHead(CILParser.ExptypeHeadContext context) => VisitExptypeHead(context); - public GrammarResult.Literal<(TypeAttributes attrs, string dottedName)> VisitExptypeHead(CILParser.ExptypeHeadContext context) - { - var attrs = context.exptAttr().Select(VisitExptAttr).Aggregate((TypeAttributes)0, (a, b) => a | b); - return new((attrs, VisitDottedName(context.dottedName()).Value)); - } - GrammarResult ICILVisitor.VisitExtendsClause(CILParser.ExtendsClauseContext context) => VisitExtendsClause(context); - - public GrammarResult.Literal VisitExtendsClause(CILParser.ExtendsClauseContext context) - { - if (context.typeSpec() is CILParser.TypeSpecContext typeSpec) - { - return new(VisitTypeSpec(typeSpec).Value); - } - else - { - return new(null); - } - } - - public GrammarResult VisitExtSourceSpec(CILParser.ExtSourceSpecContext context) - { - // Parse .line directive to extract source location info - // Grammar: esHead int32 (',' int32)? (':' int32 (',' int32)?)? (SQSTRING | QSTRING)? - var int32s = context.int32(); - var sqstring = context.SQSTRING(); - var qstring = context.QSTRING(); - - // Extract line/column info based on number of int32s - int startLine = 0, endLine = 0, startColumn = 0, endColumn = 0; - - if (int32s.Length >= 1) - { - startLine = VisitInt32(int32s[0]).Value; - endLine = startLine; - } - if (int32s.Length >= 2) - { - // Could be endLine or startColumn depending on separator - string contextText = context.GetText(); - if (contextText.Contains(',') && contextText.IndexOf(',') < contextText.IndexOf(':')) - { - // Format: startLine,endLine:... - endLine = VisitInt32(int32s[1]).Value; - } - else - { - // Format: line:column... - startColumn = VisitInt32(int32s[1]).Value; - endColumn = startColumn; - } - } - if (int32s.Length >= 3) - { - startColumn = VisitInt32(int32s[2]).Value; - endColumn = startColumn; - } - if (int32s.Length >= 4) - { - endColumn = VisitInt32(int32s[3]).Value; - } - - // Extract filename if present - string? filePath = null; - if (sqstring is not null) - { - filePath = StringHelpers.ParseQuotedString(sqstring.GetText()); - } - else if (qstring is not null) - { - filePath = StringHelpers.ParseQuotedString(qstring.GetText()); - } - - // Update current document path if specified - if (filePath is not null) - { - _currentDocumentPath = filePath; - } - - // If we're in a method, record the sequence point - if (_currentMethod is not null && _currentDocumentPath is not null) - { - int ilOffset = _currentMethod.Definition.MethodBody.Offset; - _currentMethod.Definition.DebugInfo.DocumentPath ??= _currentDocumentPath; - - // 0xFEEFEE indicates a hidden sequence point - if (startLine == 0xFEEFEE) - { - AddSequencePoint(EntityRegistry.SequencePoint.Hidden(ilOffset)); - } - else - { - if (endLine == startLine && endColumn == startColumn) - { - endColumn++; - } - - AddSequencePoint( - new EntityRegistry.SequencePoint( - ilOffset, - startLine, - startColumn, - endLine, - endColumn)); - } - - void AddSequencePoint(EntityRegistry.SequencePoint sequencePoint) - { - List sequencePoints = - _currentMethod.Definition.DebugInfo.SequencePoints; - if (sequencePoints.Count > 0 && sequencePoints[^1].ILOffset == ilOffset) - { - sequencePoints[^1] = sequencePoint; - } - else - { - sequencePoints.Add(sequencePoint); - } - } - } - - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitF32seq(CILParser.F32seqContext context) => VisitF32seq(context); - public GrammarResult.FormattedBlob VisitF32seq(CILParser.F32seqContext context) - { - var builder = ImmutableArray.CreateBuilder(context.ChildCount); - - foreach (var item in context.children ?? []) - { - builder.Add((float)(item switch - { - CILParser.Int32Context int32 => VisitInt32(int32).Value, - CILParser.Float64Context float64 => VisitFloat64(float64).Value, - _ => throw new UnreachableException() - })); - } - return new(builder.ToImmutable().SerializeSequence()); - } - GrammarResult ICILVisitor.VisitF64seq(CILParser.F64seqContext context) => VisitF64seq(context); - public GrammarResult.FormattedBlob VisitF64seq(CILParser.F64seqContext context) - { - var builder = ImmutableArray.CreateBuilder(context.ChildCount); - - foreach (var item in context.children ?? []) - { - builder.Add((double)(item switch - { - CILParser.Int64Context int64 => VisitInt64(int64).Value, - CILParser.Float64Context float64 => VisitFloat64(float64).Value, - _ => throw new UnreachableException() - })); - } - return new(builder.ToImmutable().SerializeSequence()); - } - - public GrammarResult VisitFaultClause(CILParser.FaultClauseContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - - GrammarResult ICILVisitor.VisitFieldAttr(CILParser.FieldAttrContext context) => VisitFieldAttr(context); - public GrammarResult.Flag VisitFieldAttr(CILParser.FieldAttrContext context) - { - if (context.int32() is { } int32) - { - return new((FieldAttributes)VisitInt32(int32).Value, ShouldAppend: false); - } - - return context.GetText() switch - { - "static" => new(FieldAttributes.Static), - "public" => new(FieldAttributes.Public, FieldAttributes.FieldAccessMask), - "private" => new(FieldAttributes.Private, FieldAttributes.FieldAccessMask), - "family" => new(FieldAttributes.Family, FieldAttributes.FieldAccessMask), - "initonly" => new(FieldAttributes.InitOnly), - "rtspecialname" => new(FieldAttributes.RTSpecialName), - "specialname" => new(FieldAttributes.SpecialName), - "assembly" => new(FieldAttributes.Assembly, FieldAttributes.FieldAccessMask), - "famandassem" => new(FieldAttributes.FamANDAssem, FieldAttributes.FieldAccessMask), - "famorassem" => new(FieldAttributes.FamORAssem, FieldAttributes.FieldAccessMask), - "privatescope" => new(FieldAttributes.PrivateScope, FieldAttributes.FieldAccessMask), - "literal" => new(FieldAttributes.Literal), -#pragma warning disable SYSLIB0050 // FieldAttributes.NotSeralized is obsolete - "notserialized" => new(FieldAttributes.NotSerialized), -#pragma warning restore SYSLIB0050 // FieldAttributes.NotSeralized is obsolete - "volatile" => new(0), // COMPAT: volatile is not a field attribute; accepted for compatibility - _ => throw new UnreachableException() - }; - } - GrammarResult ICILVisitor.VisitFieldDecl(CILParser.FieldDeclContext context) => VisitFieldDecl(context); - public GrammarResult VisitFieldDecl(CILParser.FieldDeclContext context) - { - var fieldAttrs = context.fieldAttr().Select(VisitFieldAttr).Aggregate((FieldAttributes)0, (a, b) => a | b); - // COMPAT: Native ilasm implicitly adds SpecialName when RTSpecialName is set - if (fieldAttrs.HasFlag(FieldAttributes.RTSpecialName)) - { - fieldAttrs |= FieldAttributes.SpecialName; - } - var fieldType = VisitType(context.type()).Value; - var marshalBlobs = context.marshalBlob(); - var marshalBlob = marshalBlobs.Length > 0 ? VisitMarshalBlob(marshalBlobs[marshalBlobs.Length - 1]).Value : null; - string name = VisitDottedName(context.dottedName()).Value; - var rvaOffset = VisitAtOpt(context.atOpt()).Value; - var fieldOffset = VisitRepeatOpt(context.repeatOpt()).Value; - var constantValue = VisitInitOpt(context.initOpt()).Value; - - var signature = new BlobEncoder(new BlobBuilder()); - _ = signature.Field(); - fieldType.WriteContentTo(signature.Builder); - - var field = EntityRegistry.CreateUnrecordedFieldDefinition(fieldAttrs, _currentTypeDefinition.PeekOrDefault() ?? _entityRegistry.ModuleType, name, signature.Builder); - _pendingClassCustomAttributeOwner = field; - - if (field is not null) - { - field.MarshallingDescriptor = marshalBlob; - field.DataDeclarationName = rvaOffset; - field.Offset = fieldOffset; - if (constantValue is not NoConstantSentinel) - { - field.ConstantValue = constantValue; - field.HasConstant = true; - } - } - - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitFieldInit(CILParser.FieldInitContext context) => VisitFieldInit(context); - public GrammarResult.Literal VisitFieldInit(CILParser.FieldInitContext context) - { - // fieldInit: fieldSerInit | compQstring | NULLREF; - if (context.NULLREF() is not null) - { - return new(null); - } - if (context.compQstring() is CILParser.CompQstringContext compQstring) - { - return new(VisitCompQstring(compQstring).Value); - } - if (context.fieldSerInit() is CILParser.FieldSerInitContext fieldSerInit) - { - // fieldSerInit returns a blob with type byte prefix - extract the actual value - var blob = VisitFieldSerInit(fieldSerInit).Value; - return new(ExtractConstantFromSerInit(blob)); - } - return new(null); - } - - private static object? ExtractConstantFromSerInit(BlobBuilder blob) - { - var bytes = blob.ToImmutableArray(); - if (bytes.Length == 0) - { - return null; - } - - var typeCode = (SerializationTypeCode)bytes[0]; - var valueBytes = bytes.AsSpan().Slice(1); - - return typeCode switch - { - SerializationTypeCode.Boolean => valueBytes.Length >= 1 && valueBytes[0] != 0, - SerializationTypeCode.Char => valueBytes.Length >= 2 ? BitConverter.ToChar(valueBytes) : '\0', - SerializationTypeCode.SByte => valueBytes.Length >= 1 ? (sbyte)valueBytes[0] : (sbyte)0, - SerializationTypeCode.Byte => valueBytes.Length >= 1 ? valueBytes[0] : (byte)0, - SerializationTypeCode.Int16 => valueBytes.Length >= 2 ? BitConverter.ToInt16(valueBytes) : (short)0, - SerializationTypeCode.UInt16 => valueBytes.Length >= 2 ? BitConverter.ToUInt16(valueBytes) : (ushort)0, - SerializationTypeCode.Int32 => valueBytes.Length >= 4 ? BitConverter.ToInt32(valueBytes) : 0, - SerializationTypeCode.UInt32 => valueBytes.Length >= 4 ? BitConverter.ToUInt32(valueBytes) : 0u, - SerializationTypeCode.Int64 => valueBytes.Length >= 8 ? BitConverter.ToInt64(valueBytes) : 0L, - SerializationTypeCode.UInt64 => valueBytes.Length >= 8 ? BitConverter.ToUInt64(valueBytes) : 0uL, - SerializationTypeCode.Single => valueBytes.Length >= 4 ? BitConverter.ToSingle(valueBytes) : 0f, - SerializationTypeCode.Double => valueBytes.Length >= 8 ? BitConverter.ToDouble(valueBytes) : 0d, - SerializationTypeCode.String => Encoding.Unicode.GetString(valueBytes), - // Type is encoded as a SerString (compressed length followed by UTF-8 type name) - SerializationTypeCode.Type => ExtractSerString(valueBytes), - // SZArray: element type followed by element count followed by elements - // Return the raw bytes for arrays since we can't easily represent them - SerializationTypeCode.SZArray => valueBytes.ToArray(), - // TaggedObject: type tag followed by value - return raw bytes - SerializationTypeCode.TaggedObject => valueBytes.ToArray(), - // Enum: type name (SerString) followed by underlying value - return raw bytes - SerializationTypeCode.Enum => valueBytes.ToArray(), - // For unknown/future type codes, return the raw bytes to preserve the data - _ => bytes.AsSpan().ToArray() - }; - } - - /// - /// Extracts a SerString (compressed length + UTF-8 string) from the given bytes. - /// Returns null if the first byte is 0xFF (null string marker). - /// - private static string? ExtractSerString(ReadOnlySpan bytes) - { - if (bytes.Length == 0) - { - return null; - } - // 0xFF indicates null string - if (bytes[0] == 0xFF) - { - return null; - } - // Decode compressed length - int length; - int bytesRead; - if ((bytes[0] & 0x80) == 0) - { - // 1-byte length - length = bytes[0]; - bytesRead = 1; - } - else if ((bytes[0] & 0xC0) == 0x80) - { - // 2-byte length - if (bytes.Length < 2) return null; - length = ((bytes[0] & 0x3F) << 8) | bytes[1]; - bytesRead = 2; - } - else - { - // 4-byte length - if (bytes.Length < 4) return null; - length = ((bytes[0] & 0x1F) << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3]; - bytesRead = 4; - } - if (bytes.Length < bytesRead + length) - { - return null; - } - return Encoding.UTF8.GetString(bytes.Slice(bytesRead, length)); - } - - public GrammarResult VisitFieldOrProp(CILParser.FieldOrPropContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - - GrammarResult ICILVisitor.VisitFieldRef(CILParser.FieldRefContext context) => VisitFieldRef(context); - public GrammarResult.Literal VisitFieldRef(CILParser.FieldRefContext context) - { - if (context.type() is not CILParser.TypeContext type) - { - // This is a typedef reference for a field member - string alias = VisitDottedName(context.dottedName()).Value; - var resolved = TryResolveTypedefAsMember(alias); - if (resolved is not null) - { - return new(resolved); - } - ReportError(DiagnosticIds.TypedefNotFound, string.Format(DiagnosticMessageTemplates.TypedefNotFound, alias), context); - return new(_entityRegistry.CreateLazilyRecordedMemberReference(_entityRegistry.ModuleType, alias, new BlobBuilder())); - } - - var fieldTypeSig = VisitType(type).Value; - EntityRegistry.TypeEntity definingType = _entityRegistry.ModuleType; - if (context.typeSpec() is CILParser.TypeSpecContext typeSpec) - { - definingType = VisitTypeSpec(typeSpec).Value; - } - - string name = VisitDottedName(context.dottedName()).Value; - - var fieldSig = new BlobBuilder(fieldTypeSig.Count + 1); - fieldSig.WriteByte((byte)SignatureKind.Field); - fieldTypeSig.WriteContentTo(fieldSig); - return new(_entityRegistry.CreateLazilyRecordedMemberReference(definingType, name, fieldSig)); - } - - GrammarResult ICILVisitor.VisitFieldSerInit(CILParser.FieldSerInitContext context) => VisitFieldSerInit(context); - public GrammarResult.FormattedBlob VisitFieldSerInit(CILParser.FieldSerInitContext context) - { - // The max length for the majority of the blobs is 9 bytes. 1 for the type of blob, 8 for the max 64-bit value. - // Byte arrays can be larger, so we handle that case separately. - const int CommonMaxBlobLength = 9; - BlobBuilder builder; - var bytesNode = context.bytes(); - if (bytesNode is not null) - { - var bytesResult = VisitBytes(bytesNode); - // Our blob length is the number of bytes in the byte array + the code for the byte array. - builder = new BlobBuilder(bytesResult.Value.Length + 1); - builder.WriteByte((byte)SerializationTypeCode.String); - builder.WriteBytes(bytesResult.Value); - return new(builder); - } - builder = new BlobBuilder(CommonMaxBlobLength); - - int tokenType = ((ITerminalNode)context.GetChild(0)).Symbol.Type; - - builder.WriteByte((byte)GetTypeCodeForToken(tokenType)); - - switch (tokenType) - { - case CILParser.BOOL: - builder.WriteBoolean(VisitTruefalse(context.truefalse()).Value); - break; - case CILParser.INT8: - case CILParser.UINT8: - builder.WriteByte((byte)VisitInt32(context.int32()).Value); - break; - case CILParser.CHAR: - case CILParser.INT16: - case CILParser.UINT16: - builder.WriteInt16((short)VisitInt32(context.int32()).Value); - break; - case CILParser.INT32_: - case CILParser.UINT32: - builder.WriteInt32(VisitInt32(context.int32()).Value); - break; - case CILParser.INT64_: - case CILParser.UINT64: - builder.WriteInt64(VisitInt64(context.int64()).Value); - break; - case CILParser.FLOAT32: - { - if (context.float64() is CILParser.Float64Context float64) - { - string text = float64.GetText(); - if (!text.Contains('.') && - text.IndexOf('e') < 0 && - text.IndexOf('E') < 0 && - ParseIntegerValue(text.AsSpan(), out long rawValue)) - { - builder.WriteSingle(BitConverter.Int32BitsToSingle((int)rawValue)); - } - else - { - builder.WriteSingle((float)VisitFloat64(float64).Value); - } - } - if (context.int32() is CILParser.Int32Context int32) - { - int value = VisitInt32(int32).Value; - builder.WriteSingle(BitConverter.Int32BitsToSingle(value)); - } - break; - } - case CILParser.FLOAT64_: - { - if (context.float64() is CILParser.Float64Context float64) - { - string text = float64.GetText(); - if (!text.Contains('.') && - text.IndexOf('e') < 0 && - text.IndexOf('E') < 0 && - ParseIntegerValue(text.AsSpan(), out long rawValue)) - { - builder.WriteDouble(BitConverter.Int64BitsToDouble(rawValue)); - } - else - { - builder.WriteDouble(VisitFloat64(float64).Value); - } - } - if (context.int64() is CILParser.Int64Context int64) - { - long value = VisitInt64(int64).Value; - builder.WriteDouble(BitConverter.Int64BitsToDouble(value)); - } - break; - } - } - - return new(builder); - } - - GrammarResult ICILVisitor.VisitFileAttr(CILParser.FileAttrContext context) => VisitFileAttr(context); - public GrammarResult.Literal VisitFileAttr(CILParser.FileAttrContext context) - => context.ChildCount != 0 ? new(false) : new(true); - GrammarResult ICILVisitor.VisitFileDecl(CILParser.FileDeclContext context) => VisitFileDecl(context); - public GrammarResult.Literal VisitFileDecl(CILParser.FileDeclContext context) - { - string dottedName = VisitDottedName(context.dottedName()).Value; - ImmutableArray? hash = context.HASH() is not null ? VisitBytes(context.bytes()).Value : null; - var hashBlob = hash is not null ? new BlobBuilder() : null; - hashBlob?.WriteBytes(hash!.Value); - - bool hasMetadata = context.fileAttr().Aggregate(true, (acc, attr) => acc && VisitFileAttr(attr).Value); - bool isEntrypoint = context.fileEntry().Aggregate(false, (acc, attr) => acc || VisitFileEntry(attr).Value); - var entity = _entityRegistry.GetOrCreateFile(dottedName, hasMetadata, hashBlob); - if (isEntrypoint) - { - _entityRegistry.EntryPoint = entity; - } - return new(entity); - } - GrammarResult ICILVisitor.VisitFileEntry(CILParser.FileEntryContext context) => VisitFileEntry(context); - public GrammarResult.Literal VisitFileEntry(CILParser.FileEntryContext context) - => context.ChildCount != 0 ? new(true) : new(false); - - GrammarResult ICILVisitor.VisitFilterClause(CILParser.FilterClauseContext context) => VisitFilterClause(context); - public GrammarResult.Literal VisitFilterClause(CILParser.FilterClauseContext context) - { - if (context.scopeBlock() is CILParser.ScopeBlockContext scopeBlock) - { - LabelHandle start = _currentMethod!.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(start); - _ = VisitScopeBlock(scopeBlock); - return new(start); - } - if (context.id() is CILParser.IdContext id) - { - var start = _currentMethod!.Labels.TryGetValue(VisitId(id).Value, out LabelHandle startLabel) ? startLabel : _currentMethod.Labels[VisitId(id).Value] = _currentMethod.Definition.MethodBody.DefineLabel(); - return new(start); - } - if (context.int32() is CILParser.Int32Context offset) - { - var start = _currentMethod!.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(start, VisitInt32(offset).Value); - return new(start); - } - throw new UnreachableException(); - } - - public GrammarResult VisitFinallyClause(CILParser.FinallyClauseContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - - GrammarResult ICILVisitor.VisitFloat64(CILParser.Float64Context context) => VisitFloat64(context); - public GrammarResult.Literal VisitFloat64(CILParser.Float64Context context) - { - if (context.FLOAT64() is ITerminalNode float64) - { - string text = float64.Symbol.Text; - bool neg = text.StartsWith('-'); - if (!double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out double result)) - { - result = neg ? double.MaxValue : double.MinValue; - } - return new(result); - } - else if (context.int32() is CILParser.Int32Context int32) - { - IToken node = int32.INT32().Symbol; - if (!ParseIntegerValue(node.Text.AsSpan(), out long intValue)) - { - _diagnostics.Add(new Diagnostic( - DiagnosticIds.LiteralOutOfRange, - DiagnosticSeverity.Error, - string.Format(DiagnosticMessageTemplates.LiteralOutOfRange, node.Text), - Location.From(node, _documents))); - intValue = 0; - } - - if (context.FLOAT32() is not null) - { - // FLOAT32 '(' int32 ')' — hex bits reinterpreted as float32 - return new(BitConverter.Int32BitsToSingle((int)intValue)); - } - // int32 or int32 '.' — plain integer or trailing-dot float - return new((double)intValue); - } - else if (context.int64() is CILParser.Int64Context int64) - { - // FLOAT64_ '(' int64 ')' — hex bits reinterpreted as float64 - long value = VisitInt64(int64).Value; - return new(BitConverter.Int64BitsToDouble(value)); - } - throw new UnreachableException(); - } - GrammarResult ICILVisitor.VisitGenArity(CILParser.GenArityContext context) => VisitGenArity(context); - public GrammarResult.Literal VisitGenArity(CILParser.GenArityContext context) - => context.genArityNotEmpty() is CILParser.GenArityNotEmptyContext genArity ? VisitGenArityNotEmpty(genArity) : new(0); - - GrammarResult ICILVisitor.VisitGenArityNotEmpty(CILParser.GenArityNotEmptyContext context) => VisitGenArityNotEmpty(context); - public GrammarResult.Literal VisitGenArityNotEmpty(CILParser.GenArityNotEmptyContext context) => VisitInt32(context.int32()); - - GrammarResult ICILVisitor.VisitHandlerBlock(CILParser.HandlerBlockContext context) => VisitHandlerBlock(context); - - public GrammarResult.Literal<(LabelHandle Start, LabelHandle End)> VisitHandlerBlock(CILParser.HandlerBlockContext context) - { - if (context.scopeBlock() is CILParser.ScopeBlockContext scopeBlock) - { - LabelHandle start = _currentMethod!.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(start); - _ = VisitScopeBlock(scopeBlock); - LabelHandle end = _currentMethod.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(end); - return new((start, end)); - } - var ids = context.id(); - if (ids.Length == 2) - { - var start = _currentMethod!.Labels.TryGetValue(VisitId(ids[0]).Value, out LabelHandle startLabel) ? startLabel : _currentMethod.Labels[VisitId(ids[0]).Value] = _currentMethod.Definition.MethodBody.DefineLabel(); - var end = _currentMethod!.Labels.TryGetValue(VisitId(ids[1]).Value, out LabelHandle endLabel) ? endLabel : _currentMethod.Labels[VisitId(ids[1]).Value] = _currentMethod.Definition.MethodBody.DefineLabel(); - return new((start, end)); - } - var offsets = context.int32(); - if (offsets.Length == 2) - { - var start = _currentMethod!.Definition.MethodBody.DefineLabel(); - var end = _currentMethod.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(start, VisitInt32(offsets[0]).Value); - _currentMethod.Definition.MethodBody.MarkLabel(end, VisitInt32(offsets[1]).Value); - return new((start, end)); - } - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitHexbyte(CILParser.HexbyteContext context) - { - return new GrammarResult.Literal(VisitHexbyte(context)); - } - - public static byte VisitHexbyte(CILParser.HexbyteContext context) - { - // hexbyte can be HEXBYTE, INT32, or ID token (due to lexer ambiguity). - // Validate the text is 1-2 hex characters to avoid FormatException - // from non-hex ID tokens or values > 0xFF from longer INT32 tokens. - string text = context.GetText(); - if (text.Length <= 2 && byte.TryParse(text, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out byte value)) - { - return value; - } - // For invalid hex values, mask to byte (matching native ilasm tolerance). - if (int.TryParse(text, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out int intValue)) - { - return (byte)(intValue & 0xFF); - } - return 0; - } - - GrammarResult ICILVisitor.VisitNativeInt(CILParser.NativeIntContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitNativeUint(CILParser.NativeUintContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitI16seq(CILParser.I16seqContext context) => VisitI16seq(context); - public GrammarResult.FormattedBlob VisitI16seq(CILParser.I16seqContext context) - { - var values = context.int32(); - var builder = ImmutableArray.CreateBuilder(values.Length); - foreach (var value in values) - { - builder.Add((short)VisitInt32(value).Value); - } - return new(builder.MoveToImmutable().SerializeSequence()); - } - GrammarResult ICILVisitor.VisitI32seq(CILParser.I32seqContext context) => VisitI32seq(context); - public GrammarResult.FormattedBlob VisitI32seq(CILParser.I32seqContext context) - { - var values = context.int32(); - var builder = ImmutableArray.CreateBuilder(values.Length); - foreach (var value in values) - { - builder.Add(VisitInt32(value).Value); - } - return new(builder.MoveToImmutable().SerializeSequence()); - } - - GrammarResult ICILVisitor.VisitI8seq(CILParser.I8seqContext context) => VisitI8seq(context); - public GrammarResult.FormattedBlob VisitI8seq(CILParser.I8seqContext context) - { - var values = context.int32(); - var builder = ImmutableArray.CreateBuilder(values.Length); - foreach (var value in values) - { - builder.Add((byte)VisitInt32(value).Value); - } - return new(builder.MoveToImmutable().SerializeSequence()); - } - - GrammarResult ICILVisitor.VisitI64seq(CILParser.I64seqContext context) => VisitI64seq(context); - public GrammarResult.FormattedBlob VisitI64seq(CILParser.I64seqContext context) - { - var values = context.int64(); - var builder = ImmutableArray.CreateBuilder(values.Length); - foreach (var value in values) - { - builder.Add(VisitInt64(value).Value); - } - return new(builder.MoveToImmutable().SerializeSequence()); - } - GrammarResult ICILVisitor.VisitId(CILParser.IdContext context) => VisitId(context); - public static GrammarResult.String VisitId(CILParser.IdContext context) - { - string text = context.GetText(); - if (context.SQSTRING() is not null && text.Length >= 2 && text[0] == '\'') - { - text = text.Substring(1, text.Length - 2); - } - return new GrammarResult.String(text); - } - - GrammarResult ICILVisitor.VisitIidParamIndex(CILParser.IidParamIndexContext context) => VisitIidParamIndex(context); - public GrammarResult.Literal VisitIidParamIndex(CILParser.IidParamIndexContext context) - => context.int32() is CILParser.Int32Context int32 ? new(VisitInt32(int32).Value) : new(null); - - GrammarResult ICILVisitor.VisitImagebase(CILParser.ImagebaseContext context) => VisitImagebase(context); - public GrammarResult.Literal VisitImagebase(CILParser.ImagebaseContext context) => VisitInt64(context.int64()); - - GrammarResult ICILVisitor.VisitImplAttr(ILAssembler.CILParser.ImplAttrContext context) => VisitImplAttr(context); - public GrammarResult.Flag VisitImplAttr(CILParser.ImplAttrContext context) - { - if (context.int32() is CILParser.Int32Context int32) - { - return new((MethodImplAttributes)VisitInt32(int32).Value, ShouldAppend: false); - } - string attribute = context.GetText(); - return attribute switch - { - "native" => new(MethodImplAttributes.Native, MethodImplAttributes.CodeTypeMask), - "cil" or "il" => new(MethodImplAttributes.IL, MethodImplAttributes.CodeTypeMask), - "optil" => new(MethodImplAttributes.OPTIL, MethodImplAttributes.CodeTypeMask), - "managed" => new(MethodImplAttributes.Managed, MethodImplAttributes.ManagedMask), - "unmanaged" => new(MethodImplAttributes.Unmanaged, MethodImplAttributes.ManagedMask), - "forwardref" => new(MethodImplAttributes.ForwardRef), - "preservesig" => new(MethodImplAttributes.PreserveSig), - "runtime" => new(MethodImplAttributes.Runtime, MethodImplAttributes.CodeTypeMask), - "internalcall" => new(MethodImplAttributes.InternalCall), - "synchronized" => new(MethodImplAttributes.Synchronized), - "noinlining" => new(MethodImplAttributes.NoInlining), - "aggressiveinlining" => new(MethodImplAttributes.AggressiveInlining), - "nooptimization" => new(MethodImplAttributes.NoOptimization), - "aggressiveoptimization" => new(MethodImplAttributes.AggressiveOptimization), - "async" => new(MethodImplAttributes.Async), - _ => throw new UnreachableException(), - }; - } - - GrammarResult ICILVisitor.VisitImplClause(CILParser.ImplClauseContext context) => VisitImplClause(context); - public GrammarResult.Sequence VisitImplClause(CILParser.ImplClauseContext context) => context.implList() is {} implList ? VisitImplList(implList) : new(ImmutableArray.Empty); - - GrammarResult ICILVisitor.VisitImplList(CILParser.ImplListContext context) => VisitImplList(context); - public GrammarResult.Sequence VisitImplList(CILParser.ImplListContext context) - { - var builder = ImmutableArray.CreateBuilder(); - foreach (var impl in context.typeSpec()) - { - builder.Add(EntityRegistry.CreateUnrecordedInterfaceImplementation(_currentTypeDefinition.PeekOrDefault()!, VisitTypeSpec(impl).Value)); - } - return new(builder.ToImmutable()); - } - - GrammarResult ICILVisitor.VisitInitOpt(CILParser.InitOptContext context) => VisitInitOpt(context); - public GrammarResult.Literal VisitInitOpt(CILParser.InitOptContext context) - { - if (context.fieldInit() is CILParser.FieldInitContext fieldInit) - { - return VisitFieldInit(fieldInit); - } - // No initializer - return a sentinel indicating no constant - return new(NoConstantSentinel.Instance); - } - - // Sentinel to distinguish "no constant" from "constant is null" - private sealed class NoConstantSentinel - { - public static readonly NoConstantSentinel Instance = new(); - private NoConstantSentinel() { } - } - - public GrammarResult VisitInstr(CILParser.InstrContext context) - { - var instrContext = context.GetRuleContext(0); - ILOpCode opcode = ((GrammarResult.Literal)instrContext.Accept(this)).Value; - if (opcode == ILOpCode.Localloc) - { - _currentMethod!.Definition.HasDynamicStackAllocation = true; - } - switch (instrContext.RuleIndex) - { - case CILParser.RULE_instr_brtarget: - { - ParserRuleContext argument = context.GetRuleContext(1); - if (argument is CILParser.IdContext id) - { - string label = VisitId(id).Value; - if (!_currentMethod!.Labels.TryGetValue(label, out var handle)) - { - handle = _currentMethod.Definition.MethodBody.DefineLabel(); - _currentMethod.Labels[label] = handle; - // Track undefined label references for later validation - if (!_currentMethod.UndefinedLabelReferences.ContainsKey(label)) - { - _currentMethod.UndefinedLabelReferences[label] = context; - } - } - _currentMethod.Definition.MethodBody.Branch(opcode, handle); - } - if (argument is CILParser.Int32Context int32) - { - int offset = VisitInt32(int32).Value; - LabelHandle label = _currentMethod!.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.Branch(opcode, label); - _currentMethod.Definition.MethodBody.MarkLabel(label, _currentMethod.Definition.MethodBody.Offset + offset); - } - } - break; - case CILParser.RULE_instr_field: - { - _currentMethod!.Definition.MethodBody.OpCode(opcode); - if (context.mdtoken() is CILParser.MdtokenContext mdtoken) - { - var entity = VisitMdtoken(mdtoken).Value; - if (entity is EntityRegistry.TypeReferenceEntity mdTokenTypeRef) - { - mdTokenTypeRef.RecordBlobToWriteResolvedToken(_currentMethod.Definition.MethodBody.CodeBuilder.ReserveBytes(4)); - } - else - { - _currentMethod.Definition.MethodBody.Token(entity.Handle); - } - } - else - { - var fieldRef = VisitFieldRef(context.fieldRef()).Value; - if (fieldRef is EntityRegistry.MemberReferenceEntity memberRef) - { - memberRef.RecordBlobToWriteResolvedHandle(_currentMethod.Definition.MethodBody.CodeBuilder.ReserveBytes(4)); - } - else - { - _currentMethod.Definition.MethodBody.Token(fieldRef.Handle); - } - } - } - break; - case CILParser.RULE_instr_i: - { - int arg = VisitInt32(context.int32()).Value; - if (opcode == ILOpCode.Ldc_i4 || opcode == ILOpCode.Ldc_i4_s) - { - _currentMethod!.Definition.MethodBody.LoadConstantI4(arg); - } - else - { - _currentMethod!.Definition.MethodBody.OpCode(opcode); - _currentMethod.Definition.MethodBody.CodeBuilder.WriteByte((byte)arg); - } - } - break; - case CILParser.RULE_instr_i8: - Debug.Assert(opcode == ILOpCode.Ldc_i8); - _currentMethod!.Definition.MethodBody.LoadConstantI8(VisitInt64(context.int64()).Value); - break; - case CILParser.RULE_instr_method: - { - if (opcode == ILOpCode.Callvirt || opcode == ILOpCode.Newobj) - { - _expectInstance = true; - } - _currentMethod!.Definition.MethodBody.OpCode(opcode); - var methodRef = VisitMethodRef(context.methodRef()).Value; - if (methodRef is EntityRegistry.MemberReferenceEntity memberRef) - { - memberRef.RecordBlobToWriteResolvedHandle(_currentMethod.Definition.MethodBody.CodeBuilder.ReserveBytes(4)); - } - else - { - _currentMethod.Definition.MethodBody.Token(methodRef.Handle); - } - // Reset the instance flag for the next instruction. - if (opcode == ILOpCode.Callvirt || opcode == ILOpCode.Newobj) - { - _expectInstance = false; - } - } - break; - case CILParser.RULE_instr_none: - _currentMethod!.Definition.MethodBody.OpCode(opcode); - break; - case CILParser.RULE_instr_r: - { - double value; - ParserRuleContext argument = context.GetRuleContext(1); - if (argument is CILParser.Float64Context float64) - { - value = VisitFloat64(float64).Value; - } - else if (argument is CILParser.Int64Context int64) - { - long intValue = VisitInt64(int64).Value; - value = intValue; - } - else if (argument is CILParser.BytesContext bytesContext) - { - var bytes = VisitBytes(bytesContext).Value.ToArray(); - if (bytes.Length >= 8) - { - value = BitConverter.ToDouble(bytes, 0); - } - else if (bytes.Length >= 4) - { - value = BitConverter.ToSingle(bytes, 0); - } - else - { - ReportError(DiagnosticIds.ByteArrayTooShort, DiagnosticMessageTemplates.ByteArrayTooShort, bytesContext); - value = 0.0d; - } - } - else - { - throw new UnreachableException(); - } - if (opcode == ILOpCode.Ldc_r4) - { - _currentMethod!.Definition.MethodBody.LoadConstantR4((float)value); - } - else - { - _currentMethod!.Definition.MethodBody.LoadConstantR8(value); - } - } - break; - case CILParser.RULE_instr_sig: - { - Debug.Assert(opcode == ILOpCode.Calli); - BlobBuilder signature = new(); - byte callConv = VisitCallConv(context.callConv()).Value; - signature.WriteByte(callConv); - var args = VisitSigArgs(context.sigArgs()).Value; - signature.WriteCompressedInteger(args.Count(arg => !arg.IsSentinel)); - // Write return type - VisitType(context.type()).Value.WriteContentTo(signature); - // Write arg signatures - foreach (var arg in args) - { - arg.SignatureBlob.WriteContentTo(signature); - } - _currentMethod!.Definition.MethodBody.OpCode(opcode); - _currentMethod!.Definition.MethodBody.Token(_entityRegistry.GetOrCreateStandaloneSignature(signature).Handle); - } - break; - case CILParser.RULE_instr_string: - Debug.Assert(opcode == ILOpCode.Ldstr); - string str; - if (context.bytes() is CILParser.BytesContext rawBytes) - { - ReadOnlySpan bytes = VisitBytes(rawBytes).Value.AsSpan(); - ReadOnlySpan bytesAsChars = MemoryMarshal.Cast(bytes); - if (!BitConverter.IsLittleEndian) - { - for (int i = 0; i < bytesAsChars.Length; i++) - { - BinaryPrimitives.ReverseEndianness(bytesAsChars[i]); - } - } - str = bytesAsChars.ToString(); - } - else - { - var userString = context.compQstring(); - Debug.Assert(userString is not null); - str = VisitCompQstring(userString!).Value; - if (context.ANSI() is not null) - { - // Emit the string not as a UTF-16 string (as per the spec), but directly as an ANSI string. - // Although the string is marked as ANSI, this always used the UTF-8 code page - // so we can emit this as UTF-8 bytes. - int byteCount = Encoding.UTF8.GetByteCount(str); - // Ensure we have an even number of bytes. - if ((byteCount % 1) != 0) - { - byteCount++; - } - - Span utf8Bytes = new byte[byteCount]; - Encoding.UTF8.GetBytes(str, utf8Bytes); - - str = new string(MemoryMarshal.Cast(utf8Bytes)); - } - } - _currentMethod!.Definition.MethodBody.LoadString(_metadataBuilder.GetOrAddUserString(str)); - break; - case CILParser.RULE_instr_switch: - { - var labels = new List<(LabelHandle Label, int? Offset)>(); - if (context.labels()?.children is { } labelChildren) - { - foreach (var label in labelChildren) - { - if (label is CILParser.IdContext id) - { - string labelName = VisitId(id).Value; - if (!_currentMethod!.Labels.TryGetValue(labelName, out var handle)) - { - handle = _currentMethod.Definition.MethodBody.DefineLabel(); - _currentMethod.Labels[labelName] = handle; - // Track undefined label references for later validation - if (!_currentMethod.UndefinedLabelReferences.ContainsKey(labelName)) - { - _currentMethod.UndefinedLabelReferences[labelName] = context; - } - } - labels.Add((handle, null)); - } - else if (label is CILParser.Int32Context int32) - { - int offset = VisitInt32(int32).Value; - LabelHandle labelHandle = _currentMethod!.Definition.MethodBody.DefineLabel(); - labels.Add((labelHandle, offset)); - } - } - } - if (labels.Count > 0) - { - var switchEncoder = _currentMethod!.Definition.MethodBody.Switch(labels.Count); - foreach (var label in labels) - { - switchEncoder.Branch(label.Label); - } - } - else - { - // Empty switch: emit opcode + 0 count manually - _currentMethod!.Definition.MethodBody.OpCode(ILOpCode.Switch); - _currentMethod.Definition.MethodBody.CodeBuilder.WriteInt32(0); - } - // Now that we've emitted the switch instruction, we can go back and mark the offset-based target labels - foreach (var label in labels) - { - if (label.Offset is int offset) - { - _currentMethod.Definition.MethodBody.MarkLabel(label.Label, _currentMethod.Definition.MethodBody.Offset + offset); - } - } - } - break; - case CILParser.RULE_instr_tok: - _currentMethod!.Definition.MethodBody.OpCode(opcode); - if (context.int32() is { } tokenValue) - { - _currentMethod.Definition.MethodBody.CodeBuilder.WriteInt32(VisitInt32(tokenValue).Value); - break; - } - - var tok = VisitOwnerType(context.ownerType()).Value; - if (tok is EntityRegistry.TypeReferenceEntity tokTypeRef) - { - tokTypeRef.RecordBlobToWriteResolvedToken(_currentMethod.Definition.MethodBody.CodeBuilder.ReserveBytes(4)); - } - else if (tok is EntityRegistry.MemberReferenceEntity tokMemberRef) - { - tokMemberRef.RecordBlobToWriteResolvedHandle(_currentMethod.Definition.MethodBody.CodeBuilder.ReserveBytes(4)); - } - else - { - _currentMethod.Definition.MethodBody.Token(tok.Handle); - } - break; - case CILParser.RULE_instr_type: - { - var arg = VisitTypeSpec(context.typeSpec()).Value; - _currentMethod!.Definition.MethodBody.OpCode(opcode); - if (arg is EntityRegistry.TypeReferenceEntity argTypeRef) - { - argTypeRef.RecordBlobToWriteResolvedToken(_currentMethod.Definition.MethodBody.CodeBuilder.ReserveBytes(4)); - } - else - { - _currentMethod.Definition.MethodBody.Token(arg.Handle); - } - } - break; - case CILParser.RULE_instr_var: - { - string instrName = opcode.ToString(); - bool isShortForm = instrName.EndsWith("_s"); - _currentMethod!.Definition.MethodBody.OpCode(opcode); - if (context.int32() is CILParser.Int32Context int32) - { - int value = VisitInt32(int32).Value; - if (isShortForm) - { - // Emit a byte instead of the int for the short form - _currentMethod.Definition.MethodBody.CodeBuilder.WriteByte((byte)value); - } - else - { - _currentMethod.Definition.MethodBody.CodeBuilder.WriteInt32(value); - } - } - else - { - Debug.Assert(context.id() is not null); - string varName = VisitId(context.id()!).Value; - int? index = null; - if (instrName.Contains("arg")) - { - if (_currentMethod!.ArgumentNames.TryGetValue(varName, out var argIndex)) - { - index = argIndex; - - if (_currentMethod.Definition.SignatureHeader.IsInstance) - { - index++; - } - } - else - { - ReportError(DiagnosticIds.ArgumentNotFound, string.Format(DiagnosticMessageTemplates.ArgumentNotFound, varName), context); - } - } - else - { - for (int i = _currentMethod!.LocalsScopes.Count - 1; i >= 0 ; i--) - { - if (_currentMethod.LocalsScopes[i].TryGetValue(varName, out var localIndex)) - { - index = localIndex; - break; - } - } - if (index is null) - { - ReportError(DiagnosticIds.LocalNotFound, string.Format(DiagnosticMessageTemplates.LocalNotFound, varName), context); - } - } - - index ??= -1; - - if (isShortForm) - { - // Emit a byte instead of the int for the short form - _currentMethod.Definition.MethodBody.CodeBuilder.WriteByte((byte)index.Value); - } - else - { - _currentMethod.Definition.MethodBody.CodeBuilder.WriteInt32(index.Value); - } - } - } - break; - } - return GrammarResult.SentinelValue.Result; - } - - public GrammarResult.Literal VisitInstr_brtarget(CILParser.Instr_brtargetContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_field(CILParser.Instr_fieldContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_i(CILParser.Instr_iContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_i8(CILParser.Instr_i8Context context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_method(CILParser.Instr_methodContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_none(CILParser.Instr_noneContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_r(CILParser.Instr_rContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_sig(CILParser.Instr_sigContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_string(CILParser.Instr_stringContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_switch(CILParser.Instr_switchContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_tok(CILParser.Instr_tokContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_type(CILParser.Instr_typeContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - public GrammarResult.Literal VisitInstr_var(CILParser.Instr_varContext context) => new(ParseOpCodeFromToken(((ITerminalNode)context.children[0]).Symbol)); - private static ILOpCode ParseOpCodeFromToken(IToken token) - { - string text = token.Text.TrimEnd('.'); - if (text == "unused") - { - // Native ilasm's keyword index uses the last matching opcode.def entry, CEE_UNUSED70. - return ILOpCode.Unused; - } - - string normalized = text.Replace('.', '_'); - - // Handle instruction aliases that don't directly map to ILOpCode enum names - normalized = normalized switch - { - "ldelem_u8" => "ldelem_i8", - "ldind_u8" => "ldind_i8", - "endfault" => "endfinally", - _ => normalized - }; - - return (ILOpCode)Enum.Parse(typeof(ILOpCode), normalized, ignoreCase: true); - } - - GrammarResult ICILVisitor.VisitInstr(CILParser.InstrContext context) => VisitInstr(context); - GrammarResult ICILVisitor.VisitInstr_brtarget(CILParser.Instr_brtargetContext context) => VisitInstr_brtarget(context); - GrammarResult ICILVisitor.VisitInstr_field(CILParser.Instr_fieldContext context) => VisitInstr_field(context); - GrammarResult ICILVisitor.VisitInstr_i(CILParser.Instr_iContext context) => VisitInstr_i(context); - GrammarResult ICILVisitor.VisitInstr_i8(CILParser.Instr_i8Context context) => VisitInstr_i8(context); - GrammarResult ICILVisitor.VisitInstr_method(CILParser.Instr_methodContext context) => VisitInstr_method(context); - GrammarResult ICILVisitor.VisitInstr_none(CILParser.Instr_noneContext context) => VisitInstr_none(context); - GrammarResult ICILVisitor.VisitInstr_r(CILParser.Instr_rContext context) => VisitInstr_r(context); - GrammarResult ICILVisitor.VisitInstr_sig(CILParser.Instr_sigContext context) => VisitInstr_sig(context); - GrammarResult ICILVisitor.VisitInstr_string(CILParser.Instr_stringContext context) => VisitInstr_string(context); - GrammarResult ICILVisitor.VisitInstr_switch(CILParser.Instr_switchContext context) => VisitInstr_switch(context); - GrammarResult ICILVisitor.VisitInstr_tok(CILParser.Instr_tokContext context) => VisitInstr_tok(context); - GrammarResult ICILVisitor.VisitInstr_type(CILParser.Instr_typeContext context) => VisitInstr_type(context); - GrammarResult ICILVisitor.VisitInstr_var(CILParser.Instr_varContext context) => VisitInstr_var(context); - - private static bool ParseIntegerValue(ReadOnlySpan value, out long result) - { - NumberStyles parseStyle = NumberStyles.None; - bool negate = false; - if (value.StartsWith("-".AsSpan())) - { - negate = true; - value = value.Slice(1); - } - - if (value.StartsWith("0x".AsSpan())) - { - parseStyle = NumberStyles.AllowHexSpecifier; - value = value.Slice(2); - } - else if (value.StartsWith("0".AsSpan())) - { - // Octal support isn't built-in, so we'll do it manually. - result = 0; - for (int i = 0; i < value.Length; i++, result *= 8) - { - int digitValue = value[i] - '0'; - if (digitValue < 0 || digitValue > 7) - { - // COMPAT: native ilasm skips invalid digits silently - continue; - } - result += digitValue; - } - if (negate) result = -result; - return true; - } - - bool success = long.TryParse(value.ToString(), parseStyle, CultureInfo.InvariantCulture, out result); - if (!success) - { - // Try parsing as unsigned — handles values like: - // - Decimal overflow with negation: 9223372036854775808 (= -Int64.MinValue) - // - Large unsigned decimal: 18444492274432737280 - if (ulong.TryParse(value.ToString(), parseStyle, CultureInfo.InvariantCulture, out ulong uresult)) - { - result = unchecked((long)uresult); - if (negate) result = unchecked(-result); - return true; - } - // Handle oversized hex values (>64 bits) by truncating to low 64 bits, - // matching native ilasm behavior for values like 0x94188556b24089e8b90c9c61f9f3088 - if (parseStyle == NumberStyles.AllowHexSpecifier && value.Length > 16) - { - var truncated = value.Slice(value.Length - 16); - if (ulong.TryParse(truncated.ToString(), parseStyle, CultureInfo.InvariantCulture, out uresult)) - { - result = unchecked((long)uresult); - if (negate) result = unchecked(-result); - return true; - } - } - return false; - } - - if (negate) result = -result; - return true; - } - - GrammarResult ICILVisitor.VisitInt32(CILParser.Int32Context context) - { - return VisitInt32(context); - } - - public GrammarResult.Literal VisitInt32(CILParser.Int32Context context) - { - IToken node = context.INT32().Symbol; - - ReadOnlySpan value = node.Text.AsSpan(); - - if (!ParseIntegerValue(value, out long num)) - { - _diagnostics.Add(new Diagnostic( - DiagnosticIds.LiteralOutOfRange, - DiagnosticSeverity.Error, - string.Format(DiagnosticMessageTemplates.LiteralOutOfRange, node.Text), - Location.From(node, _documents))); - return new GrammarResult.Literal(0); - } - - return new GrammarResult.Literal((int)num); - } - - - GrammarResult ICILVisitor.VisitInt64(CILParser.Int64Context context) - { - return VisitInt64(context); - } - - public GrammarResult.Literal VisitInt64(CILParser.Int64Context context) - { - IToken node = context.GetChild(0).Symbol; - - ReadOnlySpan value = node.Text.AsSpan(); - - if (!ParseIntegerValue(value, out long num)) - { - _diagnostics.Add(new Diagnostic( - DiagnosticIds.LiteralOutOfRange, - DiagnosticSeverity.Error, - string.Format(DiagnosticMessageTemplates.LiteralOutOfRange, node.Text), - Location.From(node, _documents))); - return new GrammarResult.Literal(0); - } - - return new GrammarResult.Literal(num); - } - - GrammarResult ICILVisitor.VisitIntOrWildcard(CILParser.IntOrWildcardContext context) => VisitIntOrWildcard(context); - public GrammarResult.Literal VisitIntOrWildcard(CILParser.IntOrWildcardContext context) => context.int32() is {} int32 ? new(VisitInt32(int32).Value) : new(null); - - private void ValidateLabelReferences() - { - if (_currentMethod is null) - { - return; - } - - // Report errors for any labels that were referenced but never declared - foreach (var undefinedLabel in _currentMethod.UndefinedLabelReferences) - { - string labelName = undefinedLabel.Key; - ParserRuleContext context = undefinedLabel.Value; - - // Only report if the label was never declared - if (!_currentMethod.DeclaredLabels.Contains(labelName)) - { - ReportError(DiagnosticIds.LabelNotFound, - string.Format(DiagnosticMessageTemplates.LabelNotFound, labelName), - context); - } - } - } - - public GrammarResult VisitLabels(CILParser.LabelsContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - - GrammarResult ICILVisitor.VisitLabelDecl(CILParser.LabelDeclContext context) => VisitLabelDecl(context); - public GrammarResult VisitLabelDecl(CILParser.LabelDeclContext context) - { - var labelId = context.id(); - string labelName = VisitId(labelId).Value; - _currentMethod!.DeclaredLabels.Add(labelName); - if (!_currentMethod!.Labels.TryGetValue(labelName, out var label)) - { - label = _currentMethod.Definition.MethodBody.DefineLabel(); - _currentMethod.Labels[labelName] = label; - } - _currentMethod.Definition.MethodBody.MarkLabel(label); - return GrammarResult.SentinelValue.Result; - } - - public GrammarResult VisitLanguageDecl(CILParser.LanguageDeclContext context) - { - // .language languageString (',' languageString (',' languageString)?)? - // First GUID: language (e.g., C#, VB, IL) - // Second GUID: vendor (optional) - // Third GUID: document type (optional) - var strings = context.languageString(); - if (strings.Length >= 1 && Guid.TryParse(VisitLanguageString(strings[0]).Value, out var languageGuid)) - { - _currentLanguageGuid = languageGuid; - } - if (strings.Length >= 2 && Guid.TryParse(VisitLanguageString(strings[1]).Value, out var vendorGuid)) - { - _currentLanguageVendorGuid = vendorGuid; - } - if (strings.Length >= 3 && Guid.TryParse(VisitLanguageString(strings[2]).Value, out var docTypeGuid)) - { - _currentDocumentTypeGuid = docTypeGuid; - } - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitLanguageString(CILParser.LanguageStringContext context) => VisitLanguageString(context); - public GrammarResult.String VisitLanguageString(CILParser.LanguageStringContext context) - { - if (context.SQSTRING() is not null) - { - return new(StringHelpers.ParseQuotedString(context.SQSTRING().GetText())); - } - return new(StringHelpers.ParseQuotedString(context.QSTRING().GetText())); - } - - public GrammarResult VisitManifestResDecl(CILParser.ManifestResDeclContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitManifestResDecls(CILParser.ManifestResDeclsContext context) => VisitManifestResDecls(context); - public GrammarResult.Literal<(EntityRegistry.EntityBase? implementation, uint offset, ImmutableArray attributes)> VisitManifestResDecls(CILParser.ManifestResDeclsContext context) - { - EntityRegistry.EntityBase? implementation = null; - uint offset = 0; - var attributes = ImmutableArray.CreateBuilder(); - // COMPAT: Priority order for implementation is the following - // AssemblyRef, File, nil - foreach (var decl in context.manifestResDecl()) - { - if (decl.customAttrDecl() is CILParser.CustomAttrDeclContext customAttrDecl) - { - if (VisitCustomAttrDecl(customAttrDecl).Value is { } attr) - { - attributes.Add(attr); - } - } - string kind = decl.GetChild(0).GetText(); - if (kind == ".file" && implementation is not EntityRegistry.AssemblyReferenceEntity) - { - string fileName = VisitDottedName(decl.dottedName()).Value; - var file = _entityRegistry.FindFile(fileName); - if (file is null) - { - ReportError(DiagnosticIds.FileNotFound, string.Format(DiagnosticMessageTemplates.FileNotFound, fileName), decl); - } - else - { - implementation = file; - offset = (uint)VisitInt32(decl.int32()).Value; - } - } - else if (kind == ".assembly") - { - string assemblyName = VisitDottedName(decl.dottedName()).Value; - implementation = _entityRegistry.GetOrCreateAssemblyReference(assemblyName, _ => { }); - } - } - - return new((implementation, offset, attributes.ToImmutable())); - } - GrammarResult ICILVisitor.VisitManifestResHead(CILParser.ManifestResHeadContext context) => VisitManifestResHead(context); - public GrammarResult.Literal<(string name, string alias, ManifestResourceAttributes attr)> VisitManifestResHead(CILParser.ManifestResHeadContext context) - { - var dottedNames = context.dottedName(); - string name = VisitDottedName(dottedNames[0]).Value; - string alias = dottedNames.Length == 2 ? VisitDottedName(dottedNames[1]).Value : name; - ManifestResourceAttributes attr = 0; - foreach (var attrContext in context.manresAttr()) - { - attr |= VisitManresAttr(attrContext).Value; - } - - return new((name, alias, attr)); - } - - GrammarResult ICILVisitor.VisitManresAttr(CILParser.ManresAttrContext context) => VisitManresAttr(context); - public GrammarResult.Flag VisitManresAttr(CILParser.ManresAttrContext context) - { - return context.GetText() switch - { - "public" => new(ManifestResourceAttributes.Public), - "private" => new(ManifestResourceAttributes.Private), - _ => throw new UnreachableException() - }; - } - - GrammarResult ICILVisitor.VisitMarshalBlob(CILParser.MarshalBlobContext context) => VisitMarshalBlob(context); - public GrammarResult.FormattedBlob VisitMarshalBlob(CILParser.MarshalBlobContext context) - { - var hexBytes = context.hexbyte(); - if (hexBytes.Length > 0) - { - var blob = new BlobBuilder(hexBytes.Length); - foreach (var hb in hexBytes) - { - blob.WriteByte(VisitHexbyte(hb)); - } - return new(blob); - } - - return VisitNativeType(context.nativeType()); - } - - GrammarResult ICILVisitor.VisitMarshalClause(CILParser.MarshalClauseContext context) => VisitMarshalClause(context); - public GrammarResult.FormattedBlob VisitMarshalClause(CILParser.MarshalClauseContext context) - { - if (context.ChildCount == 0) - { - return new(new BlobBuilder(0)); - } - - return VisitMarshalBlob(context.marshalBlob()); - } - - GrammarResult ICILVisitor.VisitMdtoken(ILAssembler.CILParser.MdtokenContext context) => VisitMdtoken(context); - public GrammarResult.Literal VisitMdtoken(CILParser.MdtokenContext context) - { - return new(_entityRegistry.ResolveHandleToEntity(MetadataTokens.EntityHandle(VisitInt32(context.int32()).Value))); - } - - GrammarResult ICILVisitor.VisitMemberRef(CILParser.MemberRefContext context) => VisitMemberRef(context); - public GrammarResult.Literal VisitMemberRef(CILParser.MemberRefContext context) - { - if (context.mdtoken() is CILParser.MdtokenContext mdToken) - { - return VisitMdtoken(mdToken); - } - - if (context.methodRef() is CILParser.MethodRefContext methodRef) - { - return VisitMethodRef(methodRef); - } - if (context.fieldRef() is CILParser.FieldRefContext fieldRef) - { - return VisitFieldRef(fieldRef); - } - - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitMethAttr(CILParser.MethAttrContext context) => VisitMethAttr(context); - public GrammarResult.Flag VisitMethAttr(CILParser.MethAttrContext context) - { - if (context.int32() is CILParser.Int32Context int32) - { - return new((MethodAttributes)VisitInt32(int32).Value, ShouldAppend: false); - } - string attribute = context.GetText(); - return attribute switch - { - "static" => new(MethodAttributes.Static), - "public" => new(MethodAttributes.Public, MethodAttributes.MemberAccessMask), - "private" => new(MethodAttributes.Private, MethodAttributes.MemberAccessMask), - "family" => new(MethodAttributes.Family, MethodAttributes.MemberAccessMask), - "final" => new(MethodAttributes.Final), - "specialname" => new(MethodAttributes.SpecialName), - "virtual" => new(MethodAttributes.Virtual), - "strict" => new(MethodAttributes.CheckAccessOnOverride), - "abstract" => new(MethodAttributes.Abstract), - "assembly" => new(MethodAttributes.Assembly, MethodAttributes.MemberAccessMask), - "famandassem" => new(MethodAttributes.FamANDAssem, MethodAttributes.MemberAccessMask), - "famorassem" => new(MethodAttributes.FamORAssem, MethodAttributes.MemberAccessMask), - "privatescope" => new(MethodAttributes.PrivateScope, MethodAttributes.MemberAccessMask), - "hidebysig" => new(MethodAttributes.HideBySig), - "newslot" => new(MethodAttributes.NewSlot), - "rtspecialname" => new(MethodAttributes.RTSpecialName), - "unmanagedexp" => new(MethodAttributes.UnmanagedExport), - "reqsecobj" => new(MethodAttributes.RequireSecObject), - _ => throw new UnreachableException(), - }; - } - public GrammarResult VisitMethodDecl(CILParser.MethodDeclContext context) - { - Debug.Assert(_currentMethod is not null); - var currentMethod = _currentMethod!; - - if (context.EMITBYTE() is not null) - { - currentMethod.Definition.MethodBody.CodeBuilder.WriteByte((byte)VisitInt32(context.GetChild(0)).Value); - } - else if (context.ENTRYPOINT() is not null) - { - _entityRegistry.EntryPoint = currentMethod.Definition; - } - else if (context.ZEROINIT() is not null) - { - currentMethod.Definition.BodyAttributes = MethodBodyAttributes.InitLocals; - } - else if (context.MAXSTACK() is not null) - { - currentMethod.Definition.MaxStack = VisitInt32(context.GetChild(0)).Value; - } - else if (context.LOCALS() is not null) - { - if (context.ChildCount == 3) - { - // init keyword specified - currentMethod.Definition.BodyAttributes = MethodBodyAttributes.InitLocals; - } - Dictionary localsScope; - if (currentMethod.LocalsScopes.Count != 0) - { - localsScope = currentMethod.LocalsScopes[currentMethod.LocalsScopes.Count - 1]; - } - else - { - localsScope = new(); - currentMethod.LocalsScopes.Add(localsScope); - } - var newLocals = VisitSigArgs(context.sigArgs()).Value; - foreach (var loc in newLocals) - { - // BREAK-COMPAT: We don't allow specifying a local's slot via the [in], [out], or [opt] parameter attributes, or the custom int override. - // This only worked in ilasm due to how ilasm reused fields. - // We're only going to support allowing this tool to determine the slot numbers. - // This blocks two different locals in two different scopes from resuing the same slot - // but that is a very rare scenario (even using more than one .locals block in a method in IL is quite rare) - - // If the local is named, add it to our name-lookup dictionary. - // Otherwise, it will only be accessible via its index. - if (loc.Name is not null) - { - localsScope.TryAdd(loc.Name, currentMethod.AllLocals.Count); - } - currentMethod.AllLocals.Add(loc); - } - } - else if (context.labelDecl() is CILParser.LabelDeclContext labelDecl) - { - var labelId = labelDecl.id(); - string labelName = VisitId(labelId).Value; - currentMethod.DeclaredLabels.Add(labelName); - if (!currentMethod.Labels.TryGetValue(labelName, out var label)) - { - label = currentMethod.Definition.MethodBody.DefineLabel(); - currentMethod.Labels[labelName] = label; - } - currentMethod.Definition.MethodBody.MarkLabel(label); - } - else if (context.EXPORT() is not null) - { - // .export [ordinal] or .export [ordinal] as alias - int ordinal = VisitInt32(context.int32()[0]).Value; - string? alias = context.id() is { } aliasId ? VisitId(aliasId).Value : null; - - currentMethod.Definition.ExportOrdinal = ordinal; - currentMethod.Definition.ExportAlias = alias; - } - else if (context.VTENTRY() is not null) - { - // .vtentry vtableIndex : slotIndex - int vtableEntry = VisitInt32(context.int32()[0]).Value; - int vtableSlot = VisitInt32(context.int32()[1]).Value; - - currentMethod.Definition.VTableEntry = vtableEntry; - currentMethod.Definition.VTableSlot = vtableSlot; - } - else if (context.OVERRIDE() is not null) - { - BlobBuilder signature = currentMethod.Definition.MethodSignature!; - if (context.callConv() is {} callConv) - { - // We have an explicitly specified signature, so we need to parse it. - signature = new(); - var callConvByte = VisitCallConv(callConv).Value; - var arity = VisitGenArity(context.genArity()).Value; - if (arity > 0) - { - callConvByte |= (byte)SignatureAttributes.Generic; - } - signature.WriteByte(callConvByte); - if (arity > 0) - { - signature.WriteCompressedInteger(arity); - } - var args = VisitSigArgs(context.sigArgs()).Value; - signature.WriteCompressedInteger(args.Length); - VisitType(context.type()).Value.WriteContentTo(signature); - foreach (var arg in args) - { - arg.SignatureBlob.WriteContentTo(signature); - } - } - - var ownerType = VisitTypeSpec(context.typeSpec()).Value; - var methodName = VisitMethodName(context.methodName()).Value; - var methodRef = _entityRegistry.CreateLazilyRecordedMemberReference(ownerType, methodName, signature); - _currentTypeDefinition.PeekOrDefault()!.MethodImplementations.Add(EntityRegistry.CreateUnrecordedMethodImplementation(currentMethod.Definition, methodRef)); - } - else if (context.PARAM() is not null) - { - // BREAK-COMPAT: We require attributes on parameters, generic parameters, and constraints - // to be specified directly after the .param directive, not at any point later in the method. - // This matches the IL outputted by ILDASM, ILSpy, and other tools in the ecosystem. - // Attributes not specified directly after the .param directive are applied to the method itself. - var customAttrDeclarations = context.customAttrDecl(); - if (context.TYPE() is not null) - { - // Type parameters - EntityRegistry.GenericParameterEntity? param = null; - if (context.int32() is { Length: > 0 } int32) - { - int index = VisitInt32(int32[0]).Value; - if (index < 0 || index >= currentMethod.Definition.GenericParameters.Count) - { - ReportError(DiagnosticIds.GenericParameterIndexOutOfRange, - string.Format(DiagnosticMessageTemplates.GenericParameterIndexOutOfRange, index), - context); - return GrammarResult.SentinelValue.Result; - } - param = currentMethod.Definition.GenericParameters[index]; - } - else - { - string name = VisitDottedName(context.dottedName()).Value; - foreach (var genericParam in currentMethod.Definition.GenericParameters) - { - if (genericParam.Name == name) - { - param = genericParam; - break; - } - } - if (param is null) - { - ReportError(DiagnosticIds.UnknownGenericParameter, - string.Format(DiagnosticMessageTemplates.UnknownGenericParameter, name), - context); - return GrammarResult.SentinelValue.Result; - } - } - foreach (var attr in customAttrDeclarations ?? Array.Empty()) - { - var customAttrDecl = VisitCustomAttrDecl(attr).Value; - customAttrDecl?.Owner = param; - } - } - else if (context.CONSTRAINT() is not null) - { - // constraints - EntityRegistry.GenericParameterEntity? param = null; - if (context.int32() is { Length: > 0 } int32) - { - int index = VisitInt32(int32[0]).Value; - if (index < 0 || index >= currentMethod.Definition.GenericParameters.Count) - { - ReportError(DiagnosticIds.GenericParameterIndexOutOfRange, - string.Format(DiagnosticMessageTemplates.GenericParameterIndexOutOfRange, index), - context); - return GrammarResult.SentinelValue.Result; - } - param = currentMethod.Definition.GenericParameters[index]; - } - else - { - string name = VisitDottedName(context.dottedName()).Value; - foreach (var genericParam in currentMethod.Definition.GenericParameters) - { - if (genericParam.Name == name) - { - param = genericParam; - break; - } - } - if (param is null) - { - ReportError(DiagnosticIds.UnknownGenericParameter, - string.Format(DiagnosticMessageTemplates.UnknownGenericParameter, name), - context); - return GrammarResult.SentinelValue.Result; - } - } - EntityRegistry.GenericParameterConstraintEntity? constraint = null; - var baseType = VisitTypeSpec(context.typeSpec()).Value; - foreach (var constraintEntity in param.Constraints) - { - if (constraintEntity.BaseType == baseType) - { - constraint = constraintEntity; - break; - } - } - if (constraint is null) - { - constraint = EntityRegistry.CreateGenericConstraint(baseType); - constraint.Owner = param; - param.Constraints.Add(constraint); - currentMethod.Definition.GenericParameterConstraints.Add(constraint); - } - foreach (var attr in customAttrDeclarations ?? Array.Empty()) - { - var customAttrDecl = VisitCustomAttrDecl(attr).Value; - customAttrDecl?.Owner = constraint; - } - } - else - { - // Adding attributes to parameters. - int index = VisitInt32(context.int32()[0]).Value; - if (index < 0 || index >= currentMethod.Definition.Parameters.Count) - { - ReportError(DiagnosticIds.ParameterIndexOutOfRange, - string.Format(DiagnosticMessageTemplates.ParameterIndexOutOfRange, index), - context); - return GrammarResult.SentinelValue.Result; - } - - // Handle initOpt to get the Constant table entry if a constant value is provided. - var constantValue = VisitInitOpt(context.initOpt()).Value; - var param = currentMethod.Definition.Parameters[index]; - if (constantValue is not NoConstantSentinel) - { - param.ConstantValue = constantValue; - param.HasConstant = true; - } - foreach (var attr in customAttrDeclarations ?? Array.Empty()) - { - var customAttrDecl = VisitCustomAttrDecl(attr).Value; - if (customAttrDecl is not null) - { - customAttrDecl.Owner = param; - param.HasCustomAttributes = true; - } - } - } - } - else if (context.secDecl() is {} secDecl) - { - var declarativeSecurity = VisitSecDecl(secDecl).Value; - declarativeSecurity?.Parent = currentMethod.Definition; - } - else if (context.customDescrInMethodBody() is {} customDescrInMethod) - { - var customAttr = VisitCustomDescrInMethodBody(customDescrInMethod).Value; - if (customAttr is not null) - { - customAttr.Owner = currentMethod.Definition; - } - } - else if (context.GetChild(0) is CILParser.InstrContext instr) - { - _ = VisitInstr(instr); - } - else - { - // Handle other methodDecl alternatives - var child = context.children[0]; - _ = child.Accept(this); - } - return GrammarResult.SentinelValue.Result; - } - - - public GrammarResult VisitMethodDecls(CILParser.MethodDeclsContext context) - { - foreach (var decl in context.methodDecl()) - { - VisitMethodDecl(decl); - } - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitMethodHead(CILParser.MethodHeadContext context) => VisitMethodHead(context); - public GrammarResult.Literal VisitMethodHead(CILParser.MethodHeadContext context) - { - string name = VisitMethodName(context.methodName()).Value; - var containingType = _currentTypeDefinition.PeekOrDefault() ?? _entityRegistry.ModuleType; - var methodDefinition = EntityRegistry.CreateUnrecordedMethodDefinition(containingType, name); - - BlobBuilder methodSignature = new(); - byte sigHeader = VisitCallConv(context.callConv()).Value; - - // Two-pass generic parameter processing for method params: - // Pass 1: Register all parameter names (without resolving constraints) - _currentMethod = new(methodDefinition); - var typarContexts = context.typarsClause()?.typars()?.typar() ?? Array.Empty(); - for (int i = 0; i < typarContexts.Length; i++) - { - var attributes = VisitTyparAttribs(typarContexts[i].typarAttribs()).Value; - var param = EntityRegistry.CreateGenericParameter(attributes, VisitDottedName(typarContexts[i].dottedName()).Value); - param.Owner = methodDefinition; - param.Index = i; - methodDefinition.GenericParameters.Add(param); - } - if (typarContexts.Length != 0) - { - sigHeader |= (byte)SignatureAttributes.Generic; - } - methodDefinition.MethodAttributes = context.methAttr().Aggregate((MethodAttributes)0, (acc, attr) => acc | VisitMethAttr(attr)); - - // COMPAT: Native ilasm implicitly adds RTSpecialName + SpecialName for .ctor/.cctor methods - if (name is ".ctor" or ".cctor") - { - methodDefinition.MethodAttributes |= MethodAttributes.RTSpecialName | MethodAttributes.SpecialName; - } - // COMPAT: Native ilasm implicitly adds SpecialName when RTSpecialName is set - else if (methodDefinition.MethodAttributes.HasFlag(MethodAttributes.RTSpecialName)) - { - methodDefinition.MethodAttributes |= MethodAttributes.SpecialName; - } - - if (methodDefinition.MethodAttributes.HasFlag(MethodAttributes.Abstract) && !methodDefinition.ContainingType.Attributes.HasFlag(TypeAttributes.Abstract)) - { - ReportWarning(DiagnosticIds.AbstractMethodNotInAbstractType, - string.Format(DiagnosticMessageTemplates.AbstractMethodNotInAbstractType, methodDefinition.Name), - context); - } - - (EntityRegistry.ModuleReferenceEntity Module, string? EntryPoint, MethodImportAttributes Attributes)? pInvokeInformation = null; - foreach (var pInvokeInfo in context.pinvImpl()) - { - var (moduleName, entryPoint, attributes) = VisitPinvImpl(pInvokeInfo).Value; - if (moduleName is null) - { - ReportError(DiagnosticIds.InvalidPInvokeSignature, - DiagnosticMessageTemplates.InvalidPInvokeSignature, - pInvokeInfo); - continue; - } - pInvokeInformation = (_entityRegistry.GetOrCreateModuleReference(moduleName, _ => { }), entryPoint ?? name, attributes); - } - methodDefinition.MethodImportInformation = pInvokeInformation; - - SignatureHeader parsedHeader = new(sigHeader); - if (methodDefinition.MethodAttributes.HasFlag(MethodAttributes.Static) && (parsedHeader.IsInstance || parsedHeader.HasExplicitThis)) - { - // Error on static + instance. - } - // COMPAT: Native ilasm auto-adds instance calling convention for non-static methods in class context - if (!methodDefinition.MethodAttributes.HasFlag(MethodAttributes.Static) - && !parsedHeader.IsInstance - && _currentTypeDefinition.Count > 0) - { - sigHeader |= (byte)SignatureAttributes.Instance; - parsedHeader = new(sigHeader); - } - if (parsedHeader.HasExplicitThis && !parsedHeader.IsInstance) - { - // Warn on explicit-this + non-instance - parsedHeader = new(sigHeader |= (byte)SignatureAttributes.Instance); - } - methodSignature.WriteByte(sigHeader); - if (typarContexts.Length != 0) - { - methodSignature.WriteCompressedInteger(typarContexts.Length); - } - // Pass 2: Resolve constraints (now all params are registered) - for (int i = 0; i < typarContexts.Length; i++) - { - var param = methodDefinition.GenericParameters[i]; - foreach (var constraint in VisitTyBound(typarContexts[i].tyBound()).Value) - { - constraint.Owner = param; - param.Constraints.Add(constraint); - methodDefinition.GenericParameterConstraints.Add(constraint); - } - } - - var args = VisitSigArgs(context.sigArgs()).Value; - methodSignature.WriteCompressedInteger(args.Length); - - SignatureArg returnValue = new(VisitParamAttr(context.paramAttr()).Value, VisitType(context.type()).Value, VisitMarshalClause(context.marshalClause()).Value, null); - - returnValue.SignatureBlob.WriteContentTo(methodSignature); - methodDefinition.Parameters.Add(EntityRegistry.CreateParameter(returnValue.Attributes, returnValue.Name, returnValue.MarshallingDescriptor, 0)); - for (int i = 0; i < args.Length; i++) - { - SignatureArg? arg = args[i]; - arg.SignatureBlob.WriteContentTo(methodSignature); - // COMPAT: Native ilasm auto-generates A_N names for unnamed parameters - string? paramName = arg.Name ?? $"A_{i}"; - methodDefinition.Parameters.Add(EntityRegistry.CreateParameter(arg.Attributes, paramName, arg.MarshallingDescriptor, i + 1)); - } - // We've parsed all signature information. We can reset the current method now (the caller will handle setting/unsetting it for the method body). - _currentMethod = null; - methodDefinition.SignatureHeader = parsedHeader; - methodDefinition.MethodSignature = methodSignature; - - methodDefinition.ImplementationAttributes = context.implAttr().Aggregate((MethodImplAttributes)0, (acc, attr) => acc | VisitImplAttr(attr)); - if (!EntityRegistry.TryAddMethodDefinitionToContainingType(methodDefinition)) - { - ReportError(DiagnosticIds.DuplicateMethod, - DiagnosticMessageTemplates.DuplicateMethod, - context); - } - - return new(methodDefinition); - } - - GrammarResult ICILVisitor.VisitMethodName(CILParser.MethodNameContext context) => VisitMethodName(context); - public GrammarResult.String VisitMethodName(CILParser.MethodNameContext context) - { - IParseTree child = context.GetChild(0); - if (child is ITerminalNode terminal) - { - return new(terminal.Symbol.Text); - } - Debug.Assert(child is CILParser.DottedNameContext); - return (GrammarResult.String)child.Accept(this); - } - - private bool _expectInstance; - private Subsystem _subsystem = Subsystem.WindowsCui; - private CorFlags _corflags = CorFlags.ILOnly; - private int _alignment = 0x200; - private long _imageBase = 0x00400000; - private long _stackReserve; - - GrammarResult ICILVisitor.VisitMethodRef(CILParser.MethodRefContext context) => VisitMethodRef(context); - public GrammarResult.Literal VisitMethodRef(CILParser.MethodRefContext context) - { - if (context.mdtoken() is CILParser.MdtokenContext token) - { - return new(VisitMdtoken(token).Value); - } - if (context.dottedName() is CILParser.DottedNameContext dottedName) - { - // This is a typedef reference for a method member - string alias = VisitDottedName(dottedName).Value; - var resolved = TryResolveTypedefAsMember(alias); - if (resolved is not null) - { - return new(resolved); - } - ReportError(DiagnosticIds.TypedefNotFound, string.Format(DiagnosticMessageTemplates.TypedefNotFound, alias), context); - return new(_entityRegistry.CreateLazilyRecordedMemberReference(_entityRegistry.ModuleType, alias, new BlobBuilder())); - } - BlobBuilder methodRefSignature = new(); - if (context.callConv() is not CILParser.CallConvContext callConvCtx) - { - // Parse error recovery - callConv is missing - return new(_entityRegistry.CreateLazilyRecordedMemberReference(_entityRegistry.ModuleType, "", methodRefSignature)); - } - byte callConv = VisitCallConv(callConvCtx).Value; - EntityRegistry.TypeEntity owner = _entityRegistry.ModuleType; - if (context.typeSpec() is CILParser.TypeSpecContext typeSpec) - { - owner = VisitTypeSpec(typeSpec).Value; - } - string name = VisitMethodName(context.methodName()).Value; - BlobBuilder? methodSpecSignature = null; - int numGenericParameters = 0; - if (context.typeArgs() is CILParser.TypeArgsContext typeArgs) - { - var types = typeArgs.type(); - numGenericParameters = types.Length; - if (types.Length != 0) - { - methodSpecSignature = new(); - methodSpecSignature.WriteByte((byte)SignatureKind.MethodSpecification); - VisitTypeArgs(typeArgs).Value.WriteContentTo(methodSpecSignature); - } - } - else if (context.genArityNotEmpty() is CILParser.GenArityNotEmptyContext genArityNotEmpty) - { - numGenericParameters = VisitGenArityNotEmpty(genArityNotEmpty).Value; - } - if (numGenericParameters != 0) - { - callConv |= (byte)SignatureAttributes.Generic; - } - if (_expectInstance && (callConv & (byte)SignatureAttributes.Instance) == 0) - { - ReportWarning(DiagnosticIds.MissingInstanceCallConv, - DiagnosticMessageTemplates.MissingInstanceCallConv, - context); - callConv |= (byte)SignatureAttributes.Instance; - } - methodRefSignature.WriteByte(callConv); - if (numGenericParameters != 0) - { - methodRefSignature.WriteCompressedInteger(numGenericParameters); - } - var args = VisitSigArgs(context.sigArgs()).Value; - methodRefSignature.WriteCompressedInteger(args.Count(arg => !arg.IsSentinel)); - // Write return type - VisitType(context.type()).Value.WriteContentTo(methodRefSignature); - // Write arg signatures - foreach (var arg in args) - { - arg.SignatureBlob.WriteContentTo(methodRefSignature); - } - - var memberRef = _entityRegistry.CreateLazilyRecordedMemberReference(owner, name, methodRefSignature); - - if (methodSpecSignature is not null) - { - return new(_entityRegistry.GetOrCreateMethodSpecification(memberRef, methodSpecSignature)); - } - - return new(memberRef); - } - - private EntityRegistry.MemberReferenceEntity CreateExplicitMethodReference( - CILParser.CallConvContext callConv, - CILParser.TypeContext returnType, - CILParser.TypeSpecContext owner, - CILParser.MethodNameContext methodName, - CILParser.GenArityContext? genericArity, - CILParser.SigArgsContext parameterList) - { - EntityRegistry.TypeEntity ownerType = VisitTypeSpec(owner).Value; - string name = VisitMethodName(methodName).Value; - return _entityRegistry.CreateLazilyRecordedMemberReference( - ownerType, - name, - CreateExplicitMethodSignature(callConv, returnType, genericArity, parameterList)); - } - - private BlobBuilder CreateExplicitMethodSignature( - CILParser.CallConvContext callConv, - CILParser.TypeContext returnType, - CILParser.GenArityContext? genericArity, - CILParser.SigArgsContext parameterList) - { - BlobBuilder signature = new(); - byte signatureHeader = VisitCallConv(callConv).Value; - int arity = genericArity is null ? 0 : VisitGenArity(genericArity).Value; - if (arity != 0) - { - signatureHeader |= (byte)SignatureAttributes.Generic; - } - - signature.WriteByte(signatureHeader); - if (arity != 0) - { - signature.WriteCompressedInteger(arity); - } - - ImmutableArray parameters = VisitSigArgs(parameterList).Value; - signature.WriteCompressedInteger(parameters.Count(parameter => !parameter.IsSentinel)); - VisitType(returnType).Value.WriteContentTo(signature); - foreach (SignatureArg parameter in parameters) - { - parameter.SignatureBlob.WriteContentTo(signature); - } - - return signature; - } - - public GrammarResult VisitModuleHead(CILParser.ModuleHeadContext context) - { - if (context.ChildCount > 2) - { - _ = _entityRegistry.GetOrCreateModuleReference(VisitDottedName(context.dottedName()).Value, _ => { }); - return GrammarResult.SentinelValue.Result; - } - - if (context.dottedName() is { } moduleName) - { - _entityRegistry.Module.Name = VisitDottedName(moduleName).Value; - } - return GrammarResult.SentinelValue.Result; - } - - // .mscorlib directive indicates the assembly being compiled is mscorlib itself. - // This is currently a no-op; the flag would be used to affect type resolution - // when support for compiling mscorlib is added. - public GrammarResult VisitMscorlib(CILParser.MscorlibContext context) => GrammarResult.SentinelValue.Result; - - GrammarResult ICILVisitor.VisitNameSpaceHead(CILParser.NameSpaceHeadContext context) => VisitNameSpaceHead(context); - - public static GrammarResult.String VisitNameSpaceHead(CILParser.NameSpaceHeadContext context) => VisitDottedName(context.dottedName()); - - GrammarResult ICILVisitor.VisitNameValPair(CILParser.NameValPairContext context) => VisitNameValPair(context); - public GrammarResult.Literal> VisitNameValPair(CILParser.NameValPairContext context) - { - return new(new(VisitCompQstring(context.compQstring()).Value, VisitCaValue(context.caValue()).Value)); - } - - GrammarResult ICILVisitor.VisitNameValPairs(CILParser.NameValPairsContext context) => VisitNameValPairs(context); - public GrammarResult.Sequence> VisitNameValPairs(CILParser.NameValPairsContext context) => new(context.nameValPair().Select(pair => VisitNameValPair(pair).Value).ToImmutableArray()); - - GrammarResult ICILVisitor.VisitNativeType(CILParser.NativeTypeContext context) => VisitNativeType(context); - public GrammarResult.FormattedBlob VisitNativeType(CILParser.NativeTypeContext context) - { - if (context.nativeTypeElement() is not CILParser.NativeTypeElementContext element) - { - return new(new BlobBuilder()); - } - - CILParser.NativeTypeArrayPointerInfoContext[] arrayPointerInfo = context.nativeTypeArrayPointerInfo(); - if (arrayPointerInfo.Length == 0) - { - return VisitNativeTypeElement(element); - } - var prefix = new BlobBuilder(arrayPointerInfo.Length); - var elementType = VisitNativeTypeElement(element).Value; - var suffix = new BlobBuilder(); - - for (int i = arrayPointerInfo.Length - 1; i >= 0; i--) - { - if (arrayPointerInfo[i] is CILParser.PointerNativeTypeContext) - { - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "pointer in array"), - context); - const int NATIVE_TYPE_PTR = 0x10; - prefix.WriteByte(NATIVE_TYPE_PTR); - } - else - { - prefix.WriteByte((byte)UnmanagedType.LPArray); - if (elementType.Count == 0) - { - // We need to have an element type for arrays, - // so write the invalid NATIVE_TYPE_MAX value so we have something parsable. - const int NATIVE_TYPE_MAX = 0x50; - elementType.WriteByte(NATIVE_TYPE_MAX); - } - } - } - - for (int i = 0; i < arrayPointerInfo.Length; i++) - { - if (arrayPointerInfo[i] is CILParser.PointerArrayTypeSizeContext size) - { - suffix.WriteCompressedInteger(0); - suffix.WriteCompressedInteger(VisitInt32(size.int32()).Value); - suffix.WriteCompressedInteger(0); - } - else if (arrayPointerInfo[i] is CILParser.PointerArrayTypeSizeParamIndexContext sizeParamIndex) - { - var ints = sizeParamIndex.int32(); - suffix.WriteCompressedInteger(VisitInt32(ints[1]).Value); - suffix.WriteCompressedInteger(VisitInt32(ints[0]).Value); - suffix.WriteCompressedInteger(1); // Write that the paramIndex parameter was specified - } - else if (arrayPointerInfo[i] is CILParser.PointerArrayTypeParamIndexContext paramIndex) - { - suffix.WriteCompressedInteger(VisitInt32(paramIndex.int32()).Value); - } - } - - prefix.LinkSuffix(elementType); - prefix.LinkSuffix(suffix); - return new(prefix); - } - - GrammarResult ICILVisitor.VisitNativeTypeElement(CILParser.NativeTypeElementContext context) => VisitNativeTypeElement(context); - public GrammarResult.FormattedBlob VisitNativeTypeElement(CILParser.NativeTypeElementContext context) - { - var blob = new BlobBuilder(); - if (context.dottedName() is CILParser.DottedNameContext typedef) - { - // Native type typedefs are not yet fully supported - // For now, report an error and return empty blob - string alias = VisitDottedName(typedef).Value; - ReportError(DiagnosticIds.TypedefNotFound, string.Format(DiagnosticMessageTemplates.TypedefNotFound, alias), context); - return new(blob); - } - - if (context.marshalType is null) - { - if (context.marshalBool is not null) - { - blob.WriteByte((byte)UnmanagedType.VariantBool); - } - else if (context.unsignedMarshalType is not null) - { - blob.WriteByte(context.unsignedMarshalType.Type switch - { - CILParser.INT8 => (byte)UnmanagedType.U1, - CILParser.INT16 => (byte)UnmanagedType.U2, - CILParser.INT32_ => (byte)UnmanagedType.U4, - CILParser.INT64_ => (byte)UnmanagedType.U8, - _ => throw new UnreachableException(), - }); - } - return new(blob); - } - - switch (context.marshalType.Type) - { - case CILParser.CUSTOM: - { - blob.WriteByte((byte)UnmanagedType.CustomMarshaler); - CILParser.CompQstringContext[] strings = context.compQstring(); - if (strings.Length == 4) - { - ReportWarning(DiagnosticIds.DeprecatedCustomMarshaller, - DiagnosticMessageTemplates.DeprecatedCustomMarshaller, - context); - blob.WriteSerializedString(VisitCompQstring(strings[0]).Value); - blob.WriteSerializedString(VisitCompQstring(strings[1]).Value); - blob.WriteSerializedString(VisitCompQstring(strings[2]).Value); - blob.WriteSerializedString(VisitCompQstring(strings[3]).Value); - } - else - { - Debug.Assert(strings.Length == 2); - blob.WriteCompressedInteger(0); - blob.WriteCompressedInteger(0); - blob.WriteSerializedString(VisitCompQstring(strings[0]).Value); - blob.WriteSerializedString(VisitCompQstring(strings[1]).Value); - } - break; - } - case CILParser.SYSSTRING: - blob.WriteByte((byte)UnmanagedType.ByValTStr); - blob.WriteCompressedInteger(VisitInt32(context.int32()).Value); - break; - case CILParser.ARRAY: - blob.WriteByte((byte)UnmanagedType.ByValArray); - blob.WriteCompressedInteger(VisitInt32(context.int32()).Value); - VisitNativeType(context.nativeType()).Value.WriteContentTo(blob); - break; - case CILParser.VARIANT: - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "VARIANT"), - context); - const int NATIVE_TYPE_VARIANT = 0xe; - blob.WriteByte(NATIVE_TYPE_VARIANT); - break; -#pragma warning disable CS0618 // Type or member is obsolete - case CILParser.CURRENCY: - blob.WriteByte((byte)UnmanagedType.Currency); - break; -#pragma warning restore CS0618 // Type or member is obsolete - case CILParser.SYSCHAR: - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "SYSCHAR"), - context); - const int NATIVE_TYPE_SYSCHAR = 0xd; - blob.WriteByte(NATIVE_TYPE_SYSCHAR); - break; - case CILParser.VOID: - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "VOID"), - context); - const int NATIVE_TYPE_VOID = 0x1; - blob.WriteByte(NATIVE_TYPE_VOID); - break; - case CILParser.BOOL: - blob.WriteByte((byte)UnmanagedType.Bool); - break; - case CILParser.INT8: - blob.WriteByte((byte)UnmanagedType.I1); - break; - case CILParser.INT16: - blob.WriteByte((byte)UnmanagedType.I2); - break; - case CILParser.INT32_: - blob.WriteByte((byte)UnmanagedType.I4); - break; - case CILParser.INT64_: - blob.WriteByte((byte)UnmanagedType.I8); - break; - case CILParser.FLOAT32: - blob.WriteByte((byte)UnmanagedType.R4); - break; - case CILParser.FLOAT64_: - blob.WriteByte((byte)UnmanagedType.R8); - break; - case CILParser.ERROR: - blob.WriteByte((byte)UnmanagedType.Error); - break; - case CILParser.UINT8: - blob.WriteByte((byte)UnmanagedType.U1); - break; - case CILParser.UINT16: - blob.WriteByte((byte)UnmanagedType.U2); - break; - case CILParser.UINT32: - blob.WriteByte((byte)UnmanagedType.U4); - break; - case CILParser.UINT64: - blob.WriteByte((byte)UnmanagedType.U8); - break; - case CILParser.DECIMAL: - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "DECIMAL"), - context); - const int NATIVE_TYPE_DECIMAL = 0x11; - blob.WriteByte(NATIVE_TYPE_DECIMAL); - break; - case CILParser.DATE: - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "DATE"), - context); - const int NATIVE_TYPE_DATE = 0x12; - blob.WriteByte(NATIVE_TYPE_DATE); - break; - case CILParser.BSTR: - // Distinguish 'ansi bstr' (AnsiBStr) from plain 'bstr' (BStr) - if (context.ANSI() is not null) - { -#pragma warning disable CS0618 // Type or member is obsolete - blob.WriteByte((byte)UnmanagedType.AnsiBStr); -#pragma warning restore CS0618 - } - else - { - blob.WriteByte((byte)UnmanagedType.BStr); - } - break; - case CILParser.LPSTR: - blob.WriteByte((byte)UnmanagedType.LPStr); - break; - case CILParser.LPWSTR: - blob.WriteByte((byte)UnmanagedType.LPWStr); - break; - case CILParser.LPTSTR: - blob.WriteByte((byte)UnmanagedType.LPTStr); - break; - case CILParser.OBJECTREF: - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "OBJECTREF"), - context); - const int NATIVE_TYPE_OBJECTREF = 0x18; - blob.WriteByte(NATIVE_TYPE_OBJECTREF); - break; - case CILParser.IUNKNOWN: - { - blob.WriteByte((byte)UnmanagedType.IUnknown); - if (VisitIidParamIndex(context.iidParamIndex()) is { Value: int index }) - { - blob.WriteCompressedInteger(index); - } - break; - } - case CILParser.IDISPATCH: - { - blob.WriteByte((byte)UnmanagedType.IDispatch); - if (VisitIidParamIndex(context.iidParamIndex()) is { Value: int index }) - { - blob.WriteCompressedInteger(index); - } - break; - } - case CILParser.STRUCT: - // Distinguish 'nested struct' from plain 'struct' - if (context.GetChild(0)?.GetText() == "nested") - { - ReportWarning(DiagnosticIds.DeprecatedNativeType, - string.Format(DiagnosticMessageTemplates.DeprecatedNativeType, "NESTEDSTRUCT"), - context); - const int NATIVE_TYPE_NESTEDSTRUCT = 0x21; - blob.WriteByte(NATIVE_TYPE_NESTEDSTRUCT); - } - else - { - blob.WriteByte((byte)UnmanagedType.Struct); - } - break; - case CILParser.INTERFACE: - { - blob.WriteByte((byte)UnmanagedType.Interface); - if (VisitIidParamIndex(context.iidParamIndex()) is { Value: int index }) - { - blob.WriteCompressedInteger(index); - } - break; - } - case CILParser.SAFEARRAY: - blob.WriteByte((byte)UnmanagedType.SafeArray); - blob.WriteCompressedInteger((int)VisitVariantType(context.variantType()).Value); - if (context.compQstring() is { Length: 1 } safeArrayCustomType) - { - string str = VisitCompQstring(safeArrayCustomType[0]).Value; - blob.WriteSerializedString(str); - } - else - { - blob.WriteCompressedInteger(0); - } - break; - case CILParser.INT: - blob.WriteByte((byte)UnmanagedType.SysInt); - break; - case CILParser.UINT: - blob.WriteByte((byte)UnmanagedType.SysUInt); - break; -#pragma warning disable CS0618 // Type or member is obsolete - case CILParser.BYVALSTR: - blob.WriteByte((byte)UnmanagedType.VBByRefStr); - break; - case CILParser.TBSTR: - blob.WriteByte((byte)UnmanagedType.TBStr); - break; -#pragma warning restore CS0618 // Type or member is obsolete - case CILParser.METHOD: - blob.WriteByte((byte)UnmanagedType.FunctionPtr); - break; - case CILParser.LPSTRUCT: - blob.WriteByte((byte)UnmanagedType.LPStruct); - break; -#pragma warning disable CS0618 // Type or member is obsolete - case CILParser.ANY: - blob.WriteByte((byte)UnmanagedType.AsAny); - break; -#pragma warning restore CS0618 // Type or member is obsolete - } - - return new(blob); - } - - GrammarResult ICILVisitor.VisitObjSeq(CILParser.ObjSeqContext context) => VisitObjSeq(context); - public GrammarResult.FormattedBlob VisitObjSeq(CILParser.ObjSeqContext context) - { - BlobBuilder objSeqBlob = new(); - foreach (var item in context.serInit()) - { - // Each element in object[] is encoded as FieldOrPropType + value, - // where FieldOrPropType is the concrete type (bool, int32, string, etc.), - // NOT TaggedObject (0x51). The object(...) wrapper is used to explicitly - // box a value but does not change the element's concrete type in the encoding. - // Unwrap any object(...) wrappers to get the actual typed inner element. - CILParser.SerInitContext actualItem = item; - while (actualItem.serInit() is { } inner) - { - actualItem = inner; - } - WriteCustomAttributeFieldOrPropType(objSeqBlob, actualItem); - objSeqBlob.LinkSuffix(VisitSerInit(actualItem).Value); - } - return new(objSeqBlob); - } - - GrammarResult ICILVisitor.VisitOwnerType(CILParser.OwnerTypeContext context) => VisitOwnerType(context); - public GrammarResult.Literal VisitOwnerType(CILParser.OwnerTypeContext context) - { - if (context.memberRef() is CILParser.MemberRefContext memberRef) - { - return VisitMemberRef(memberRef); - } - if (context.typeSpec() is CILParser.TypeSpecContext typeSpec) - { - return new(VisitTypeSpec(typeSpec).Value); - } - throw new UnreachableException(); - } - GrammarResult ICILVisitor.VisitParamAttr(CILParser.ParamAttrContext context) => VisitParamAttr(context); - public GrammarResult.Literal VisitParamAttr(CILParser.ParamAttrContext context) - { - ParameterAttributes attributes = 0; - foreach (var element in context.paramAttrElement()) - { - attributes |= VisitParamAttrElement(element); - } - return new(attributes); - } - - GrammarResult ICILVisitor.VisitParamAttrElement(CILParser.ParamAttrElementContext context) => VisitParamAttrElement(context); - public GrammarResult.Flag VisitParamAttrElement(CILParser.ParamAttrElementContext context) - { - if (context.int32() is CILParser.Int32Context int32) - { - return new((ParameterAttributes)(VisitInt32(int32).Value + 1), ShouldAppend: false); - } - return context switch - { - { @in: not null } => new(ParameterAttributes.In), - { @out: not null } => new(ParameterAttributes.Out), - { opt: not null } => new(ParameterAttributes.Optional), - _ => throw new UnreachableException() - }; - } - - GrammarResult ICILVisitor.VisitPinvAttr(CILParser.PinvAttrContext context) => VisitPinvAttr(context); - public GrammarResult.Flag VisitPinvAttr(CILParser.PinvAttrContext context) - { - if (context.int32() is CILParser.Int32Context int32) - { - return new((MethodImportAttributes)VisitInt32(int32).Value, ShouldAppend: false); - } - switch (context.GetText()) - { - case "nomangle": - return new(MethodImportAttributes.ExactSpelling); - case "ansi": - return new(MethodImportAttributes.CharSetAnsi); - case "unicode": - return new(MethodImportAttributes.CharSetUnicode); - case "autochar": - return new(MethodImportAttributes.CharSetAuto); - case "lasterr": - return new(MethodImportAttributes.SetLastError); - case "winapi": - return new(MethodImportAttributes.CallingConventionWinApi); - case "cdecl": - return new(MethodImportAttributes.CallingConventionCDecl); - case "stdcall": - return new(MethodImportAttributes.CallingConventionStdCall); - case "thiscall": - return new(MethodImportAttributes.CallingConventionThisCall); - case "fastcall": - return new(MethodImportAttributes.CallingConventionFastCall); - case "bestfit:on": - return new(MethodImportAttributes.BestFitMappingEnable); - case "bestfit:off": - return new(MethodImportAttributes.BestFitMappingDisable); - case "charmaperror:on": - return new(MethodImportAttributes.ThrowOnUnmappableCharEnable); - case "charmaperror:off": - return new(MethodImportAttributes.ThrowOnUnmappableCharDisable); - default: - throw new UnreachableException(); - } - } - - GrammarResult ICILVisitor.VisitPinvImpl(CILParser.PinvImplContext context) => VisitPinvImpl(context); - public GrammarResult.Literal<(string? ModuleName, string? EntryPointName, MethodImportAttributes Attributes)> VisitPinvImpl(CILParser.PinvImplContext context) - { - MethodImportAttributes attrs = MethodImportAttributes.None; - foreach (var attr in context.pinvAttr()) - { - attrs |= VisitPinvAttr(attr); - } - var names = context.compQstring(); - string? moduleName = names.Length > 0 ? VisitCompQstring(names[0]).Value : null; - string? entryPointName = names.Length > 1 ? VisitCompQstring(names[1]).Value : null; - return new((moduleName, entryPointName, attrs)); - } - - GrammarResult ICILVisitor.VisitPropAttr(CILParser.PropAttrContext context) => VisitPropAttr(context); - public static GrammarResult.Flag VisitPropAttr(CILParser.PropAttrContext context) - { - return context.GetText() switch - { - "specialname" => new(PropertyAttributes.SpecialName), - "rtspecialname" => new(0), // COMPAT: Ignore - _ => throw new UnreachableException(), - }; - } - - GrammarResult ICILVisitor.VisitPropDecl(CILParser.PropDeclContext context) => VisitPropDecl(context); - public GrammarResult.Literal<(MethodSemanticsAttributes, EntityRegistry.EntityBase)?> VisitPropDecl(CILParser.PropDeclContext context) - { - if (context.ChildCount != 2) - { - return new(null); - } - string accessor = context.GetChild(0).GetText(); - EntityRegistry.EntityBase memberReference = VisitMethodRef(context.methodRef()).Value; - MethodSemanticsAttributes methodSemanticsAttributes = accessor switch - { - ".set" => MethodSemanticsAttributes.Setter, - ".get" => MethodSemanticsAttributes.Getter, - ".other" => MethodSemanticsAttributes.Other, - _ => throw new UnreachableException(), - }; - return new((methodSemanticsAttributes, memberReference)); - } - - GrammarResult ICILVisitor.VisitPropDecls(CILParser.PropDeclsContext context) => VisitPropDecls(context); - public GrammarResult.Sequence<(MethodSemanticsAttributes, EntityRegistry.EntityBase)> VisitPropDecls(CILParser.PropDeclsContext context) - => new( - context.propDecl() - .Select(decl => VisitPropDecl(decl).Value) - .Where(decl => decl is not null) - .Select(decl => decl!.Value).ToImmutableArray()); - - GrammarResult ICILVisitor.VisitPropHead(ILAssembler.CILParser.PropHeadContext context) => VisitPropHead(context); - public GrammarResult.Literal VisitPropHead(CILParser.PropHeadContext context) - { - var propAttrs = context.propAttr().Select(VisitPropAttr).Aggregate((PropertyAttributes)0, (a, b) => a | b); - var name = VisitDottedName(context.dottedName()).Value; - - var signature = new BlobBuilder(); - byte callConv = (byte)(VisitCallConv(context.callConv()).Value | (byte)SignatureKind.Property); - signature.WriteByte(callConv); - var args = VisitSigArgs(context.sigArgs()).Value; - signature.WriteCompressedInteger(args.Length); - VisitType(context.type()).Value.WriteContentTo(signature); - foreach (var arg in args) - { - arg.SignatureBlob.WriteContentTo(signature); - } - - // Handle initOpt to set the Constant table entry if a constant value is provided. - var constantValue = VisitInitOpt(context.initOpt()).Value; - var property = new EntityRegistry.PropertyEntity(propAttrs, signature, name); - if (constantValue is not NoConstantSentinel) - { - property.ConstantValue = constantValue; - property.HasConstant = true; - property.Attributes |= PropertyAttributes.HasDefault; - } - return new(property); - } - - GrammarResult ICILVisitor.VisitRepeatOpt(CILParser.RepeatOptContext context) => VisitRepeatOpt(context); - public GrammarResult.Literal VisitRepeatOpt(CILParser.RepeatOptContext context) => context.int32() is {} int32 ? new(VisitInt32(int32).Value) : new(null); - - public GrammarResult VisitScopeBlock(CILParser.ScopeBlockContext context) - { - int numLocalsScopes = _currentMethod!.LocalsScopes.Count; - _ = VisitMethodDecls(context.methodDecls()); - _currentMethod.LocalsScopes.RemoveRange(numLocalsScopes, _currentMethod.LocalsScopes.Count - numLocalsScopes); - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitSecAction(CILParser.SecActionContext context) => VisitSecAction(context); - public static GrammarResult.Literal VisitSecAction(CILParser.SecActionContext context) - { - return context.GetText() switch - { - "request" => new(DeclarativeSecurityAction.Request), - "demand" => new(DeclarativeSecurityAction.Demand), - "assert" => new(DeclarativeSecurityAction.Assert), - "deny" => new(DeclarativeSecurityAction.Deny), - "permitonly" => new(DeclarativeSecurityAction.PermitOnly), - "linkcheck" => new(DeclarativeSecurityAction.LinkDemand), - "inheritcheck" => new(DeclarativeSecurityAction.InheritanceDemand), - "reqmin" => new(DeclarativeSecurityAction.RequestMinimum), - "reqopt" => new(DeclarativeSecurityAction.RequestOptional), - "reqrefuse" => new(DeclarativeSecurityAction.RequestRefuse), - "prejitgrant" => new(DeclarativeSecurityAction.PrejitGrant), - "prejitdeny" => new(DeclarativeSecurityAction.PrejitDeny), - "noncasdemand" => new(DeclarativeSecurityAction.NonCasDemand), - "noncaslinkdemand" => new(DeclarativeSecurityAction.NonCasLinkDemand), - "noncasinheritance" => new(DeclarativeSecurityAction.NonCasInheritanceDemand), - _ => throw new UnreachableException() - }; - } - GrammarResult ICILVisitor.VisitSecAttrBlob(CILParser.SecAttrBlobContext context) => VisitSecAttrBlob(context); - public GrammarResult.FormattedBlob VisitSecAttrBlob(CILParser.SecAttrBlobContext context) - { - var blob = new BlobBuilder(); - - string attributeName = string.Empty; - - if (context.typeSpec() is CILParser.TypeSpecContext typeSpec && VisitTypeSpec(typeSpec).Value is EntityRegistry.IHasReflectionNotation reflectionNotation) - { - attributeName = reflectionNotation.ReflectionNotation; - } - else if (context.SQSTRING() is { } sqstring) - { - attributeName = StringHelpers.ParseQuotedString(sqstring.GetText()); - } - - blob.WriteSerializedString(attributeName); - VisitCustomBlobNVPairs(context.customBlobNVPairs()).Value.WriteContentTo(blob); - - return new(blob); - } - - GrammarResult ICILVisitor.VisitSecAttrSetBlob(CILParser.SecAttrSetBlobContext context) => VisitSecAttrSetBlob(context); - public GrammarResult.FormattedBlob VisitSecAttrSetBlob(CILParser.SecAttrSetBlobContext context) - { - BlobBuilder blob = new(); - var secAttributes = context.secAttrBlob(); - blob.WriteByte((byte)'.'); - blob.WriteCompressedInteger(secAttributes.Length); - foreach (var secAttribute in secAttributes) - { - VisitSecAttrBlob(secAttribute).Value.WriteContentTo(blob); - } - return new(blob); - } - - GrammarResult ICILVisitor.VisitSecDecl(CILParser.SecDeclContext context) => VisitSecDecl(context); - public GrammarResult.Literal VisitSecDecl(CILParser.SecDeclContext context) - { - if (context.PERMISSION() is not null) - { - ReportError(DiagnosticIds.UnsupportedSecurityDeclaration, - DiagnosticMessageTemplates.UnsupportedSecurityDeclaration, - context); - return new(null); - } - DeclarativeSecurityAction action = VisitSecAction(context.secAction()).Value; - BlobBuilder value; - if (context.secAttrSetBlob() is CILParser.SecAttrSetBlobContext setBlob) - { - value = VisitSecAttrSetBlob(setBlob).Value; - } - else if (context.bytes() is CILParser.BytesContext bytes) - { - value = new(); - value.WriteBytes(VisitBytes(bytes).Value); - } - else if (context.compQstring() is CILParser.CompQstringContext str) - { - value = new BlobBuilder(); - value.WriteUTF16(VisitCompQstring(str).Value); - value.WriteUTF16("\0"); - } - else - { - throw new UnreachableException(); - } - return new(_entityRegistry.CreateDeclarativeSecurityAttribute(action, value)); - } - - internal abstract record ExceptionClause(LabelHandle Start, LabelHandle End) - { - internal sealed record Catch(EntityRegistry.TypeEntity Type, LabelHandle Start, LabelHandle End) : ExceptionClause(Start, End); - - internal sealed record Filter(LabelHandle FilterStart, LabelHandle Start, LabelHandle End) : ExceptionClause(Start, End); - - internal sealed record Finally(LabelHandle Start, LabelHandle End) : ExceptionClause(Start, End); - - internal sealed record Fault(LabelHandle Start, LabelHandle End) : ExceptionClause(Start, End); - } - - public GrammarResult VisitSehBlock(CILParser.SehBlockContext context) - { - var (tryStart, tryEnd) = VisitTryBlock(context.tryBlock()).Value; - foreach (var clause in VisitSehClauses(context.sehClauses()).Value) - { - switch (clause) - { - case ExceptionClause.Finally finallyClause: - _currentMethod!.Definition.ExceptionRegions.Add(new EntityRegistry.ExceptionRegion.FinallyRegion(tryStart, tryEnd, finallyClause.Start, finallyClause.End)); - break; - case ExceptionClause.Fault faultClause: - _currentMethod!.Definition.ExceptionRegions.Add(new EntityRegistry.ExceptionRegion.FaultRegion(tryStart, tryEnd, faultClause.Start, faultClause.End)); - break; - case ExceptionClause.Catch catchClause: - _currentMethod!.Definition.ExceptionRegions.Add(new EntityRegistry.ExceptionRegion.CatchRegion(tryStart, tryEnd, catchClause.Start, catchClause.End, catchClause.Type)); - break; - case ExceptionClause.Filter filterClause: - _currentMethod!.Definition.ExceptionRegions.Add(new EntityRegistry.ExceptionRegion.FilterRegion(tryStart, tryEnd, filterClause.Start, filterClause.End, filterClause.FilterStart)); - break; - default: - throw new UnreachableException(); - } - } - return GrammarResult.SentinelValue.Result; - } - GrammarResult ICILVisitor.VisitSehClause(CILParser.SehClauseContext context) => VisitSehClause(context); - public GrammarResult.Literal VisitSehClause(CILParser.SehClauseContext context) - { - var (start, end) = VisitHandlerBlock(context.handlerBlock()).Value; - - if (context.finallyClause() is not null) - { - return new(new ExceptionClause.Finally(start, end)); - } - if (context.faultClause() is not null) - { - return new(new ExceptionClause.Fault(start, end)); - } - if (context.catchClause() is CILParser.CatchClauseContext catchClause) - { - return new(new ExceptionClause.Catch(VisitCatchClause(catchClause).Value, start, end)); - } - if (context.filterClause() is CILParser.FilterClauseContext filterClause) - { - return new(new ExceptionClause.Filter(VisitFilterClause(filterClause).Value, start, end)); - } - - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitSehClauses(CILParser.SehClausesContext context) => VisitSehClauses(context); - public GrammarResult.Sequence VisitSehClauses(CILParser.SehClausesContext context) => new(context.sehClause().Select(clause => VisitSehClause(clause).Value).ToImmutableArray()); - - GrammarResult ICILVisitor.VisitSerializType(CILParser.SerializTypeContext context) => VisitSerializType(context); - public GrammarResult.FormattedBlob VisitSerializType(CILParser.SerializTypeContext context) - { - var blob = new BlobBuilder(); - if (context.ARRAY_TYPE_NO_BOUNDS() is not null) - { - blob.WriteByte((byte)SerializationTypeCode.SZArray); - } - VisitSerializTypeElement(context.serializTypeElement()).Value.WriteContentTo(blob); - return new(blob); - } - - GrammarResult ICILVisitor.VisitSerializTypeElement(CILParser.SerializTypeElementContext context) => VisitSerializTypeElement(context); - public GrammarResult.FormattedBlob VisitSerializTypeElement(CILParser.SerializTypeElementContext context) - { - if (context.simpleType() is CILParser.SimpleTypeContext simpleType) - { - BlobBuilder blob = new(1); - blob.WriteByte((byte)VisitSimpleType(simpleType).Value); - return new(blob); - } - if (context.dottedName() is CILParser.DottedNameContext dottedName) - { - // Serialization type typedefs are not yet fully supported - string alias = VisitDottedName(dottedName).Value; - ReportError(DiagnosticIds.TypedefNotFound, string.Format(DiagnosticMessageTemplates.TypedefNotFound, alias), context); - return new(new BlobBuilder(1)); - } - if (context.TYPE() is not null) - { - BlobBuilder blob = new BlobBuilder(1); - blob.WriteByte((byte)SerializationTypeCode.Type); - return new(blob); - } - if (context.OBJECT() is not null) - { - BlobBuilder blob = new BlobBuilder(1); - blob.WriteByte((byte)SerializationTypeCode.TaggedObject); - return new(blob); - } - if (context.ENUM() is not null) - { - BlobBuilder blob = new BlobBuilder(); - blob.WriteByte((byte)SerializationTypeCode.Enum); - if (context.SQSTRING() is ITerminalNode sqString) - { - blob.WriteSerializedString(StringHelpers.ParseQuotedString(sqString.GetText())); - } - else - { - Debug.Assert(context.className() is not null); - blob.WriteSerializedString((VisitClassName(context.className()).Value as EntityRegistry.IHasReflectionNotation)?.ReflectionNotation ?? ""); - } - return new(blob); - } - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitSerInit(CILParser.SerInitContext context) => VisitSerInit(context); - public GrammarResult.FormattedBlob VisitSerInit(CILParser.SerInitContext context) - { - if (context.fieldSerInit() is CILParser.FieldSerInitContext fieldSerInit) - { - if (fieldSerInit.bytes() is not null) - { - ReportError( - DiagnosticIds.InvalidMetadataToken, - "bytearray is not a valid structured custom attribute value", - context); - var invalidValue = new BlobBuilder(); - invalidValue.WriteSerializedString(null); - return new(invalidValue); - } - - ImmutableArray encodedValue = VisitFieldSerInit(fieldSerInit).Value.ToImmutableArray(); - var value = new BlobBuilder(Math.Max(0, encodedValue.Length - 1)); - if (encodedValue.Length > 1) - { - value.WriteBytes(encodedValue.AsSpan().Slice(1).ToArray()); - } - return new(value); - } - - if (context.serInit() is CILParser.SerInitContext serInit) - { - Debug.Assert(context.OBJECT() is not null); - BlobBuilder taggedObjectBlob = new(); - WriteCustomAttributeFieldOrPropType(taggedObjectBlob, serInit); - taggedObjectBlob.LinkSuffix(VisitSerInit(serInit).Value); - return new(taggedObjectBlob); - } - - if (context.int32() is not CILParser.Int32Context arrLength) - { - BlobBuilder blob = new(); - if (context.className() is CILParser.ClassNameContext className) - { - blob.WriteSerializedString(VisitClassName(className).Value is EntityRegistry.IHasReflectionNotation reflection ? reflection.ReflectionNotation : string.Empty); - } - else - { - blob.WriteSerializedString( - context.SQSTRING() is { } stringNode - ? StringHelpers.ParseQuotedString(stringNode.Symbol.Text) - : null); - } - return new(blob); - } - - BlobBuilder arrayHeader = new(sizeof(int)); - arrayHeader.WriteInt32(VisitInt32(arrLength).Value); - var sequenceResult = (GrammarResult.FormattedBlob)Visit(context.GetRuleContext(1)); - arrayHeader.LinkSuffix(sequenceResult.Value); - return new(arrayHeader); - } - - private static void WriteCustomAttributeFieldOrPropType( - BlobBuilder builder, - CILParser.SerInitContext context) - { - int tokenType = context.fieldSerInit() is { } fieldSerInit - ? ((ITerminalNode)fieldSerInit.GetChild(0)).Symbol.Type - : ((ITerminalNode)context.GetChild(0)).Symbol.Type; - if (context.fieldSerInit()?.bytes() is not null) - { - builder.WriteByte((byte)SerializationTypeCode.String); - return; - } - if (context.int32() is not null) - { - builder.WriteByte((byte)SerializationTypeCode.SZArray); - } - - builder.WriteByte((byte)GetTypeCodeForToken(tokenType)); - } - - private static SerializationTypeCode GetTypeCodeForToken(int tokenType) - { - return tokenType switch - { - CILParser.INT8 => SerializationTypeCode.SByte, - CILParser.UINT8 => SerializationTypeCode.Byte, - CILParser.INT16 => SerializationTypeCode.Int16, - CILParser.UINT16 => SerializationTypeCode.UInt16, - CILParser.INT32_ => SerializationTypeCode.Int32, - CILParser.UINT32 => SerializationTypeCode.UInt32, - CILParser.INT64_ => SerializationTypeCode.Int64, - CILParser.UINT64 => SerializationTypeCode.UInt64, - CILParser.FLOAT32 => SerializationTypeCode.Single, - CILParser.FLOAT64_ => SerializationTypeCode.Double, - CILParser.CHAR => SerializationTypeCode.Char, - CILParser.BOOL => SerializationTypeCode.Boolean, - CILParser.STRING => SerializationTypeCode.String, - CILParser.TYPE => SerializationTypeCode.Type, - CILParser.OBJECT => SerializationTypeCode.TaggedObject, - _ => throw new UnreachableException() - }; - } - - /// - /// Checks if a type entity is a well-known corelib type and returns its primitive type code. - /// Native ilasm uses primitive type codes for well-known types like System.String and System.Object - /// in signature blobs instead of class/valuetype TypeRef references. - /// - private static SignatureTypeCode? TryGetPrimitiveTypeCode(EntityRegistry.TypeEntity typeEntity, bool isValueType) - { - if (typeEntity is not EntityRegistry.TypeReferenceEntity typeRef) - { - return null; - } - - string name = typeRef.Name; - string ns = typeRef.Namespace; - - if (ns != "System") - { - return null; - } - - if (isValueType) - { - return name switch - { - "Boolean" => SignatureTypeCode.Boolean, - "Char" => SignatureTypeCode.Char, - "SByte" => SignatureTypeCode.SByte, - "Byte" => SignatureTypeCode.Byte, - "Int16" => SignatureTypeCode.Int16, - "UInt16" => SignatureTypeCode.UInt16, - "Int32" => SignatureTypeCode.Int32, - "UInt32" => SignatureTypeCode.UInt32, - "Int64" => SignatureTypeCode.Int64, - "UInt64" => SignatureTypeCode.UInt64, - "Single" => SignatureTypeCode.Single, - "Double" => SignatureTypeCode.Double, - "IntPtr" => SignatureTypeCode.IntPtr, - "UIntPtr" => SignatureTypeCode.UIntPtr, - "TypedReference" => SignatureTypeCode.TypedReference, - _ => null - }; - } - - return name switch - { - "String" => SignatureTypeCode.String, - "Object" => SignatureTypeCode.Object, - _ => null - }; - } - - GrammarResult ICILVisitor.VisitSigArg(CILParser.SigArgContext context) => VisitSigArg(context); - public GrammarResult.Literal VisitSigArg(CILParser.SigArgContext context) - { - if (context.ELLIPSIS() is not null) - { - return new(SignatureArg.CreateSentinelArgument()); - } - string? name = context.id() is CILParser.IdContext id ? VisitId(id).Value : null; - return new(new SignatureArg( - VisitParamAttr(context.paramAttr()).Value, - VisitType(context.type()).Value, - VisitMarshalClause(context.marshalClause()).Value, - name)); - } - - GrammarResult ICILVisitor.VisitSigArgs(CILParser.SigArgsContext context) => VisitSigArgs(context); - public GrammarResult.Sequence VisitSigArgs(CILParser.SigArgsContext context) => new([.. context.sigArg().Select(arg => VisitSigArg(arg).Value)]); - GrammarResult ICILVisitor.VisitSimpleType(CILParser.SimpleTypeContext context) => VisitSimpleType(context); - public GrammarResult.Literal VisitSimpleType(CILParser.SimpleTypeContext context) - { - // Handle 'unsigned intN' forms (2 children: 'unsigned' + intN keyword) - if (context.ChildCount == 2) - { - return new(context.GetChild(1).Symbol.Type switch - { - CILParser.INT8 => SignatureTypeCode.Byte, - CILParser.INT16 => SignatureTypeCode.UInt16, - CILParser.INT32_ => SignatureTypeCode.UInt32, - CILParser.INT64_ => SignatureTypeCode.UInt64, - _ => throw new UnreachableException() - }); - } - - return new(context.GetChild(0).Symbol.Type switch - { - CILParser.CHAR => SignatureTypeCode.Char, - CILParser.STRING => SignatureTypeCode.String, - CILParser.BOOL => SignatureTypeCode.Boolean, - CILParser.INT8 => SignatureTypeCode.SByte, - CILParser.INT16 => SignatureTypeCode.Int16, - CILParser.INT32_ => SignatureTypeCode.Int32, - CILParser.INT64_ => SignatureTypeCode.Int64, - CILParser.FLOAT32 => SignatureTypeCode.Single, - CILParser.FLOAT64_ => SignatureTypeCode.Double, - CILParser.UINT8 => SignatureTypeCode.Byte, - CILParser.UINT16 => SignatureTypeCode.UInt16, - CILParser.UINT32 => SignatureTypeCode.UInt32, - CILParser.UINT64 => SignatureTypeCode.UInt64, - _ => throw new UnreachableException() - }); - } - - GrammarResult ICILVisitor.VisitSlashedName(CILParser.SlashedNameContext context) - { - return VisitSlashedName(context); - } - - public static GrammarResult.Literal VisitSlashedName(CILParser.SlashedNameContext context) - { - TypeName? currentTypeName = null; - foreach (var item in context.dottedName()) - { - currentTypeName = new TypeName(currentTypeName, VisitDottedName(item).Value); - } - // We'll always have at least one dottedName, so the value here will be non-null - return new(currentTypeName!); - } - - GrammarResult ICILVisitor.VisitSqstringSeq(CILParser.SqstringSeqContext context) => VisitSqstringSeq(context); - - public static GrammarResult.FormattedBlob VisitSqstringSeq(CILParser.SqstringSeqContext context) - { - var strings = ImmutableArray.CreateBuilder(context.ChildCount); - foreach (var child in context.children ?? []) - { - string? str = null; - - if (child is ITerminalNode { Symbol: { Type: CILParser.SQSTRING, Text: string stringValue } }) - { - str = StringHelpers.ParseQuotedString(stringValue); - } - - strings.Add(str); - } - return new(strings.MoveToImmutable().SerializeSequence()); - } - - GrammarResult ICILVisitor.VisitStackreserve(CILParser.StackreserveContext context) => VisitStackreserve(context); - public GrammarResult.Literal VisitStackreserve(CILParser.StackreserveContext context) => VisitInt64(context.int64()); - - GrammarResult ICILVisitor.VisitSubsystem(CILParser.SubsystemContext context) => VisitSubsystem(context); - public GrammarResult.Literal VisitSubsystem(CILParser.SubsystemContext context) => VisitInt32(context.int32()); - - public GrammarResult VisitTerminal(ITerminalNode node) => throw new UnreachableException(); - public GrammarResult VisitTls(CILParser.TlsContext context) - { - // TODO-SRM: System.Reflection.Metadata doesn't provide APIs to point a data declaration at a TLS slot or into the IL stream. - // We have tests for the TLS case (CoreCLR only supports it on Win-x86), but not for the IL case. - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitTruefalse(CILParser.TruefalseContext context) => VisitTruefalse(context); - - public static GrammarResult.Literal VisitTruefalse(CILParser.TruefalseContext context) - { - return new(bool.Parse(context.GetText())); - } - - GrammarResult ICILVisitor.VisitTryBlock(CILParser.TryBlockContext context) => VisitTryBlock(context); - - public GrammarResult.Literal<(LabelHandle Start, LabelHandle End)> VisitTryBlock(CILParser.TryBlockContext context) - { - if (context.scopeBlock() is CILParser.ScopeBlockContext scopeBlock) - { - LabelHandle start = _currentMethod!.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(start); - _ = VisitScopeBlock(scopeBlock); - LabelHandle end = _currentMethod.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(end); - return new((start, end)); - } - var ids = context.id(); - if (ids.Length == 2) - { - var start = _currentMethod!.Labels.TryGetValue(VisitId(ids[0]).Value, out LabelHandle startLabel) ? startLabel : _currentMethod.Labels[VisitId(ids[0]).Value] = _currentMethod.Definition.MethodBody.DefineLabel(); - var end = _currentMethod!.Labels.TryGetValue(VisitId(ids[1]).Value, out LabelHandle endLabel) ? endLabel : _currentMethod.Labels[VisitId(ids[1]).Value] = _currentMethod.Definition.MethodBody.DefineLabel(); - return new((start, end)); - } - var offsets = context.int32(); - if (offsets.Length == 2) - { - var start = _currentMethod!.Definition.MethodBody.DefineLabel(); - var end = _currentMethod.Definition.MethodBody.DefineLabel(); - _currentMethod.Definition.MethodBody.MarkLabel(start, VisitInt32(offsets[0]).Value); - _currentMethod.Definition.MethodBody.MarkLabel(end, VisitInt32(offsets[1]).Value); - return new((start, end)); - } - throw new UnreachableException(); - } - - GrammarResult ICILVisitor.VisitTyBound(CILParser.TyBoundContext context) => VisitTyBound(context); - public GrammarResult.Sequence VisitTyBound(CILParser.TyBoundContext? context) - { - // context or typeList can be null when there are no constraints - if (context?.typeList() is not CILParser.TypeListContext typeList) - { - return new(ImmutableArray.Empty); - } - // Filter out null types (from unresolved type parameters) before creating constraints - return new(VisitTypeList(typeList).Value - .Where(t => t is not null) - .Select(EntityRegistry.CreateGenericConstraint) - .ToImmutableArray()); - } - - GrammarResult ICILVisitor.VisitTypar(CILParser.TyparContext context) => VisitTypar(context); - - public GrammarResult.Literal VisitTypar(CILParser.TyparContext context) - { - GenericParameterAttributes attributes = VisitTyparAttribs(context.typarAttribs()).Value; - EntityRegistry.GenericParameterEntity genericParameter = EntityRegistry.CreateGenericParameter(attributes, VisitDottedName(context.dottedName()).Value); - - foreach (var constraint in VisitTyBound(context.tyBound()).Value) - { - genericParameter.Constraints.Add(constraint); - } - - return new(genericParameter); - } - - GrammarResult ICILVisitor.VisitTyparAttrib(CILParser.TyparAttribContext context) => VisitTyparAttrib(context); - public GrammarResult.Flag VisitTyparAttrib(CILParser.TyparAttribContext context) - { - return context switch - { - { covariant: not null } => new(GenericParameterAttributes.Covariant), - { contravariant: not null } => new(GenericParameterAttributes.Contravariant), - { @class: not null } => new(GenericParameterAttributes.ReferenceTypeConstraint), - { valuetype: not null } => new(GenericParameterAttributes.NotNullableValueTypeConstraint), - { byrefLike: not null } => new(GenericParameterAttributes.AllowByRefLike), - { ctor: not null } => new(GenericParameterAttributes.DefaultConstructorConstraint), - { flags: CILParser.Int32Context int32 } => new((GenericParameterAttributes)VisitInt32(int32).Value), - _ => throw new UnreachableException() - }; - } - GrammarResult ICILVisitor.VisitTyparAttribs(CILParser.TyparAttribsContext context) => VisitTyparAttribs(context); - - public GrammarResult.Literal VisitTyparAttribs(CILParser.TyparAttribsContext context) => - new(context.typarAttrib() - .Select(VisitTyparAttrib) - .Aggregate( - (GenericParameterAttributes)0, (agg, attr) => agg | attr)); - - GrammarResult ICILVisitor.VisitTypars(CILParser.TyparsContext context) => VisitTypars(context); - public GrammarResult.Sequence VisitTypars(CILParser.TyparsContext context) - { - CILParser.TyparContext[] typeParameters = context.typar(); - ImmutableArray.Builder builder = ImmutableArray.CreateBuilder(typeParameters.Length); - - foreach (var typeParameter in typeParameters) - { - builder.Add(VisitTypar(typeParameter).Value); - } - return new(builder.MoveToImmutable()); - } - - GrammarResult ICILVisitor.VisitTyparsClause(CILParser.TyparsClauseContext context) => VisitTyparsClause(context); - public GrammarResult.Sequence VisitTyparsClause(CILParser.TyparsClauseContext context) => context.typars() is null ? new(ImmutableArray.Empty) : VisitTypars(context.typars()); - - GrammarResult ICILVisitor.VisitType(CILParser.TypeContext context) => VisitType(context); - public GrammarResult.FormattedBlob VisitType(CILParser.TypeContext context) - { - // These blobs will likely be very small, so use a smaller default size. - const int DefaultSignatureElementBlobSize = 10; - BlobBuilder prefix = new(DefaultSignatureElementBlobSize); - BlobBuilder suffix = new(DefaultSignatureElementBlobSize); - BlobBuilder elementType = VisitElementType(context.elementType()).Value; - - // Prefix blob writes outer modifiers first. - // Suffix blob writes inner modifiers first. - // Since all blobs are prefix blobs and only some have suffix data, - // We will go in reverse order to write the prefixes - // and then go in forward order to write the suffixes. - CILParser.TypeModifiersContext[] typeModifiers = context.typeModifiers(); - for (int i = typeModifiers.Length - 1; i >= 0; i--) - { - CILParser.TypeModifiersContext? modifier = typeModifiers[i]; - switch (modifier) - { - case CILParser.SZArrayModifierContext: - prefix.WriteByte((byte)SignatureTypeCode.SZArray); - break; - case CILParser.ArrayModifierContext: - prefix.WriteByte((byte)SignatureTypeCode.Array); - break; - case CILParser.ByRefModifierContext: - prefix.WriteByte((byte)SignatureTypeCode.ByReference); - break; - case CILParser.PtrModifierContext: - prefix.WriteByte((byte)SignatureTypeCode.Pointer); - break; - case CILParser.PinnedModifierContext: - prefix.WriteByte((byte)SignatureTypeCode.Pinned); - break; - case CILParser.RequiredModifierContext modreq: - prefix.WriteByte((byte)SignatureTypeCode.RequiredModifier); - prefix.WriteTypeEntity(VisitTypeSpec(modreq.typeSpec()).Value); - break; - case CILParser.OptionalModifierContext modopt: - prefix.WriteByte((byte)SignatureTypeCode.OptionalModifier); - prefix.WriteTypeEntity(VisitTypeSpec(modopt.typeSpec()).Value); - break; - case CILParser.GenericArgumentsModifierContext: - prefix.WriteByte((byte)SignatureTypeCode.GenericTypeInstance); - break; - } - } - - foreach (var modifier in typeModifiers) - { - switch (modifier) - { - case CILParser.ArrayModifierContext arr: - var bounds = VisitBounds(arr.bounds()).Value; - suffix.WriteCompressedInteger(bounds.Length); - // Count contiguous sizes from the start (stop at first null) - int numSizes = 0; - for (int bIdx = 0; bIdx < bounds.Length; bIdx++) - { - if (bounds[bIdx].Upper is null) - break; - numSizes++; - } - // Count contiguous lower bounds from the start (stop at first null) - int numLoBounds = 0; - for (int bIdx = 0; bIdx < bounds.Length; bIdx++) - { - if (bounds[bIdx].Lower is null) - break; - numLoBounds++; - } - suffix.WriteCompressedInteger(numSizes); - for (int bIdx = 0; bIdx < numSizes; bIdx++) - { - suffix.WriteCompressedInteger(bounds[bIdx].Upper.GetValueOrDefault()); - } - suffix.WriteCompressedInteger(numLoBounds); - for (int bIdx = 0; bIdx < numLoBounds; bIdx++) - { - suffix.WriteCompressedSignedInteger(bounds[bIdx].Lower.GetValueOrDefault()); - } - break; - case CILParser.GenericArgumentsModifierContext genericArgs: - VisitTypeArgs(genericArgs.typeArgs()).Value.WriteContentTo(suffix); - break; - } - } - - // Work around https://github.com/dotnet/runtime/issues/127243 - // by writing to a separate blob. - BlobBuilder fullBlob = new(elementType.Count + prefix.Count + suffix.Count); - prefix.WriteContentTo(fullBlob); - elementType.WriteContentTo(fullBlob); - suffix.WriteContentTo(fullBlob); - return new(fullBlob); - } - - GrammarResult ICILVisitor.VisitTypeArgs(CILParser.TypeArgsContext context) => VisitTypeArgs(context); - - public GrammarResult.FormattedBlob VisitTypeArgs(CILParser.TypeArgsContext context) - { - BlobBuilder blob = new(4); - var types = context.type(); - blob.WriteCompressedInteger(types.Length); - foreach (var type in types) - { - blob.LinkSuffix(VisitType(type).Value); - } - return new(blob); - } - - public GrammarResult VisitTypedefDecl(CILParser.TypedefDeclContext context) - { - string alias = VisitDottedName(context.dottedName()).Value; - - if (context.type() is CILParser.TypeContext type) - { - // .typedef type as alias - // This creates an alias for a complete type signature (blob) - var typeBlob = VisitType(type).Value; - // Create a copy of the blob to avoid issues with linked BlobBuilders - var copy = new BlobBuilder(typeBlob.Count); - typeBlob.WriteContentTo(copy); - _typedefs[alias] = new TypedefEntry.TypeBlob(copy); - } - else if (context.className() is CILParser.ClassNameContext className) - { - // .typedef className as alias - var typeEntity = VisitClassName(className).Value; - _typedefs[alias] = new TypedefEntry.Type(typeEntity); - } - else if (context.memberRef() is CILParser.MemberRefContext memberRef) - { - // .typedef memberRef as alias - var member = VisitMemberRef(memberRef).Value; - _typedefs[alias] = new TypedefEntry.Member(member); - } - else if (context.customDescr() is CILParser.CustomDescrContext customDescr) - { - // .typedef customDescr as alias - var attr = VisitCustomDescr(customDescr).Value; - if (attr is not null) - { - _typedefs[alias] = new TypedefEntry.CustomAttribute(attr.Constructor, attr.Value); - } - } - else if (context.customDescrWithOwner() is CILParser.CustomDescrWithOwnerContext customDescrWithOwner) - { - // .typedef customDescrWithOwner as alias - var attr = VisitCustomDescrWithOwner(customDescrWithOwner).Value; - if (attr is not null) - { - _typedefs[alias] = new TypedefEntry.CustomAttribute(attr.Constructor, attr.Value); - } - } - - return GrammarResult.SentinelValue.Result; - } - - /// - /// Tries to resolve a typedef alias to a type entity. - /// - private EntityRegistry.TypeEntity? TryResolveTypedefAsType(string alias) - { - if (_typedefs.TryGetValue(alias, out var entry) && entry is TypedefEntry.Type typeEntry) - { - return typeEntry.Entity; - } - return null; - } - - /// - /// Tries to resolve a typedef alias to a type blob (complete type signature). - /// - private BlobBuilder? TryResolveTypedefAsTypeBlob(string alias) - { - if (_typedefs.TryGetValue(alias, out var entry)) - { - if (entry is TypedefEntry.TypeBlob blobEntry) - { - return blobEntry.Blob; - } - if (entry is TypedefEntry.Type typeEntry) - { - // Encode the type entity as a CLASS reference for the blob - var blob = new BlobBuilder(5); - blob.WriteByte((byte)SignatureTypeKind.Class); - blob.WriteTypeEntity(typeEntry.Entity); - return blob; - } - } - return null; - } - - /// - /// Tries to resolve a typedef alias to a member reference. - /// - private EntityRegistry.EntityBase? TryResolveTypedefAsMember(string alias) - { - if (_typedefs.TryGetValue(alias, out var entry) && entry is TypedefEntry.Member memberEntry) - { - return memberEntry.Entity; - } - return null; - } - - /// - /// Tries to resolve a typedef alias to a custom attribute. - /// - private (EntityRegistry.EntityBase Constructor, BlobBuilder Value)? TryResolveTypedefAsCustomAttribute(string alias) - { - if (_typedefs.TryGetValue(alias, out var entry) && entry is TypedefEntry.CustomAttribute attrEntry) - { - return (attrEntry.Constructor, attrEntry.Value); - } - return null; - } - - public GrammarResult VisitTypelist(CILParser.TypelistContext context) - { - foreach (var name in context.className()) - { - // We don't do anything with the class names here. - // We just go through the name resolution process to ensure that the names are valid - // and to provide TypeReference table rows. - _ = VisitClassName(name); - } - return GrammarResult.SentinelValue.Result; - } - - GrammarResult ICILVisitor.VisitTypeList(CILParser.TypeListContext context) => VisitTypeList(context); - public GrammarResult.Sequence VisitTypeList(CILParser.TypeListContext context) - { - CILParser.TypeSpecContext[] bounds = context.typeSpec(); - ImmutableArray.Builder builder = ImmutableArray.CreateBuilder(bounds.Length); - foreach (var typeSpec in bounds) - { - builder.Add(VisitTypeSpec(typeSpec).Value); - } - return new(builder.MoveToImmutable()); - } - - GrammarResult ICILVisitor.VisitTypeSpec(CILParser.TypeSpecContext context) => VisitTypeSpec(context); - public GrammarResult.Literal VisitTypeSpec(CILParser.TypeSpecContext context) - { - if (context.className() is CILParser.ClassNameContext className) - { - return new(VisitClassName(className).Value); - } - else if (context.dottedName() is CILParser.DottedNameContext dottedName) - { - string nameToResolve = VisitDottedName(dottedName).Value; - if (context.MODULE() is not null) - { - EntityRegistry.ModuleReferenceEntity? module = _entityRegistry.FindModuleReference(nameToResolve); - if (module is null) - { - // report error - return new(new EntityRegistry.FakeTypeEntity(MetadataTokens.ModuleReferenceHandle(0))); - } - return new(new EntityRegistry.FakeTypeEntity(module.Handle)); - } - else - { - return new(new EntityRegistry.FakeTypeEntity( - _entityRegistry.GetOrCreateAssemblyReference(nameToResolve, newRef => - { - // Report warning on implicit assembly reference creation. - }).Handle)); - } - } - else - { - Debug.Assert(context.type() != null); - return new(_entityRegistry.GetOrCreateTypeSpec(VisitType(context.type()).Value)); - } - } - - - GrammarResult ICILVisitor.VisitVariantType(CILParser.VariantTypeContext context) => VisitVariantType(context); - public GrammarResult.Literal VisitVariantType(CILParser.VariantTypeContext context) - { - if (context.variantTypeElement() is not CILParser.VariantTypeElementContext element) - { - return new(VarEnum.VT_EMPTY); - } - - VarEnum variant = VisitVariantTypeElement(element).Value; - // The 0th child is the variant element type. - for (int i = 1; i < context.ChildCount; i++) - { - ITerminalNode childToken = (ITerminalNode)context.children[i]; - if (childToken.Symbol.Type == CILParser.ARRAY_TYPE_NO_BOUNDS) - { - variant |= VarEnum.VT_ARRAY; - } - else if (childToken.Symbol.Type == CILParser.VECTOR) - { - variant |= VarEnum.VT_VECTOR; - } - else - { - Debug.Assert(childToken.Symbol.Type == CILParser.REF); - variant |= VarEnum.VT_BYREF; - } - } - return new(variant); - } - - GrammarResult ICILVisitor.VisitVariantTypeElement(CILParser.VariantTypeElementContext context) => VisitVariantTypeElement(context); - public GrammarResult.Literal VisitVariantTypeElement(CILParser.VariantTypeElementContext context) - { - return new(context.GetChild(0).Symbol.Type switch - { - CILParser.VARIANT => VarEnum.VT_VARIANT, - CILParser.CURRENCY => VarEnum.VT_CY, - CILParser.VOID => VarEnum.VT_VOID, - CILParser.BOOL => VarEnum.VT_BOOL, - CILParser.INT8 => VarEnum.VT_I1, - CILParser.INT16 => VarEnum.VT_I2, - CILParser.INT32_ => VarEnum.VT_I4, - CILParser.INT64_ => VarEnum.VT_I8, - CILParser.FLOAT32 => VarEnum.VT_R4, - CILParser.FLOAT64_ => VarEnum.VT_R8, - CILParser.UINT8 => VarEnum.VT_UI1, - CILParser.UINT16 => VarEnum.VT_UI2, - CILParser.UINT32 => VarEnum.VT_UI4, - CILParser.UINT64 => VarEnum.VT_UI8, - CILParser.PTR => VarEnum.VT_PTR, - CILParser.DECIMAL => VarEnum.VT_DECIMAL, - CILParser.DATE => VarEnum.VT_DATE, - CILParser.BSTR => VarEnum.VT_BSTR, - CILParser.LPSTR => VarEnum.VT_LPSTR, - CILParser.LPWSTR => VarEnum.VT_LPWSTR, - CILParser.IUNKNOWN => VarEnum.VT_UNKNOWN, - CILParser.IDISPATCH => VarEnum.VT_DISPATCH, - CILParser.SAFEARRAY => VarEnum.VT_SAFEARRAY, - CILParser.INT => VarEnum.VT_INT, - CILParser.UINT => VarEnum.VT_UINT, - CILParser.ERROR => VarEnum.VT_ERROR, - CILParser.HRESULT => VarEnum.VT_HRESULT, - CILParser.CARRAY => VarEnum.VT_CARRAY, - CILParser.USERDEFINED => VarEnum.VT_USERDEFINED, - CILParser.RECORD => VarEnum.VT_RECORD, - CILParser.FILETIME => VarEnum.VT_FILETIME, - CILParser.BLOB => VarEnum.VT_BLOB, - CILParser.STREAM => VarEnum.VT_STREAM, - CILParser.STORAGE => VarEnum.VT_STORAGE, - CILParser.STREAMED_OBJECT => VarEnum.VT_STREAMED_OBJECT, - CILParser.STORED_OBJECT => VarEnum.VT_STORED_OBJECT, - CILParser.BLOB_OBJECT => VarEnum.VT_BLOB_OBJECT, - CILParser.CF => VarEnum.VT_CF, - CILParser.CLSID => VarEnum.VT_CLSID, - _ => throw new UnreachableException() - }); - } - - public GrammarResult VisitVtableDecl(CILParser.VtableDeclContext context) - { - // Raw .vtable directive with bytes - not commonly used - // For now, we don't support this legacy syntax - throw new NotImplementedException("raw vtable fixups blob (.vtable) not supported - use .vtfixup instead"); - } - - GrammarResult ICILVisitor.VisitVtfixupAttr(CILParser.VtfixupAttrContext context) => VisitVtfixupAttr(context); - public GrammarResult.Literal VisitVtfixupAttr(CILParser.VtfixupAttrContext context) - { - // vtfixupAttr: | vtfixupAttr INT32_ | vtfixupAttr INT64_ | vtfixupAttr 'fromunmanaged' | vtfixupAttr 'callmostderived' | vtfixupAttr 'retainappdomain' - ushort flags = 0; - foreach (var child in context.children ?? []) - { - string text = child.GetText(); - flags |= text switch - { - "int32" => VTableFixupSupport.COR_VTABLE_32BIT, - "int64" => VTableFixupSupport.COR_VTABLE_64BIT, - "fromunmanaged" => VTableFixupSupport.COR_VTABLE_FROM_UNMANAGED, - "callmostderived" => VTableFixupSupport.COR_VTABLE_CALL_MOST_DERIVED, - "retainappdomain" => VTableFixupSupport.COR_VTABLE_FROM_UNMANAGED_RETAIN_APPDOMAIN, - _ => 0 - }; - } - - // Default to 32-bit if neither 32 nor 64 is specified - if ((flags & (VTableFixupSupport.COR_VTABLE_32BIT | VTableFixupSupport.COR_VTABLE_64BIT)) == 0) - { - flags |= VTableFixupSupport.COR_VTABLE_32BIT; - } - - return new(flags); - } - - GrammarResult ICILVisitor.VisitVtfixupDecl(CILParser.VtfixupDeclContext context) => VisitVtfixupDecl(context); - public GrammarResult VisitVtfixupDecl(CILParser.VtfixupDeclContext context) - { - // vtfixupDecl: '.vtfixup' '[' int32 ']' vtfixupAttr 'at' id; - int slotCount = VisitInt32(context.int32()).Value; - ushort flags = VisitVtfixupAttr(context.vtfixupAttr()).Value; - string dataLabel = VisitId(context.id()).Value; - - _vtableFixups.Add(new VTableFixupSupport.VTableFixupEntry(slotCount, flags, dataLabel)); - - return GrammarResult.SentinelValue.Result; - } - - /// - /// Computes the total metadata size from MetadataSizes. - /// This replicates the internal MetadataSizes.MetadataSize calculation. - /// - private static int ComputeMetadataSize(MetadataSizes sizes) - { - // Metadata header size (fixed structure): - // - signature (4) - // - major/minor version (4) - // - reserved (4) - // - version string length (4) - // - version string padded to 4 bytes ("v4.0.30319" = 12 bytes padded) - // - storage header (4) - // - 5 stream headers (#~, #Strings, #US, #GUID, #Blob) = 76 bytes - // Total header: ~108 bytes - const int metadataHeaderSize = 108; - - // Stream storage: heaps (#Strings, #US, #GUID, #Blob) - we can get aligned sizes - int heapStorageSize = 0; - heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.String); - heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.UserString); - heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.Guid); - heapStorageSize += sizes.GetAlignedHeapSize(HeapIndex.Blob); - - // Table stream (#~): header + table data - // Header: Reserved(4) + Version(2) + HeapSizes(1) + RowIdBitWidth(1) + ValidMask(8) + SortedMask(8) - // + 4 bytes per present table for row counts - int tableStreamSize = 24; // base header - var rowCounts = sizes.RowCounts; - - // Count present tables and add 4 bytes each for row count - for (int i = 0; i < rowCounts.Length; i++) - { - if (rowCounts[i] > 0) - { - tableStreamSize += 4; - } - } - - // Add table data size with estimated row sizes - // Row sizes depend on index sizes (2 or 4 bytes) which we don't have access to - // For small assemblies, all indexes are 2 bytes - tableStreamSize += rowCounts[(int)TableIndex.Module] * 10; // 2+2+2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.TypeRef] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.TypeDef] * 14; // 4+2+2+2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.Field] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.MethodDef] * 14; // 4+2+2+2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.Param] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.InterfaceImpl] * 4; // 2+2 - tableStreamSize += rowCounts[(int)TableIndex.MemberRef] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.Constant] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.CustomAttribute] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.FieldMarshal] * 4; // 2+2 - tableStreamSize += rowCounts[(int)TableIndex.DeclSecurity] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.ClassLayout] * 8; // 2+4+2 - tableStreamSize += rowCounts[(int)TableIndex.FieldLayout] * 6; // 4+2 - tableStreamSize += rowCounts[(int)TableIndex.StandAloneSig] * 2; // 2 - tableStreamSize += rowCounts[(int)TableIndex.EventMap] * 4; // 2+2 - tableStreamSize += rowCounts[(int)TableIndex.Event] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.PropertyMap] * 4; // 2+2 - tableStreamSize += rowCounts[(int)TableIndex.Property] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.MethodSemantics] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.MethodImpl] * 6; // 2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.ModuleRef] * 2; // 2 - tableStreamSize += rowCounts[(int)TableIndex.TypeSpec] * 2; // 2 - tableStreamSize += rowCounts[(int)TableIndex.ImplMap] * 8; // 2+2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.FieldRva] * 6; // 4+2 - tableStreamSize += rowCounts[(int)TableIndex.Assembly] * 22; // 16+2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.AssemblyRef] * 20; // 12+2+2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.File] * 8; // 4+2+2 - tableStreamSize += rowCounts[(int)TableIndex.ExportedType] * 14; // 8+2+2+2 - tableStreamSize += rowCounts[(int)TableIndex.ManifestResource] * 12; // 8+2+2 - tableStreamSize += rowCounts[(int)TableIndex.NestedClass] * 4; // 2+2 - tableStreamSize += rowCounts[(int)TableIndex.GenericParam] * 8; // 4+2+2 - tableStreamSize += rowCounts[(int)TableIndex.MethodSpec] * 4; // 2+2 - tableStreamSize += rowCounts[(int)TableIndex.GenericParamConstraint] * 4; // 2+2 - - // Align table stream to 4 bytes (includes +1 for terminating 0 byte) - tableStreamSize = ((tableStreamSize + 1) + 3) & ~3; - - return metadataHeaderSize + heapStorageSize + tableStreamSize; - } - - GrammarResult ICILVisitor.VisitOptionalModifier(CILParser.OptionalModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitSZArrayModifier(CILParser.SZArrayModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitRequiredModifier(CILParser.RequiredModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitPtrModifier(CILParser.PtrModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitPinnedModifier(CILParser.PinnedModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitGenericArgumentsModifier(CILParser.GenericArgumentsModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitByRefModifier(CILParser.ByRefModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - GrammarResult ICILVisitor.VisitArrayModifier(CILParser.ArrayModifierContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - public GrammarResult VisitNativeTypeArrayPointerInfo(CILParser.NativeTypeArrayPointerInfoContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - public GrammarResult VisitPointerArrayTypeSize(CILParser.PointerArrayTypeSizeContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - public GrammarResult VisitPointerArrayTypeParamIndex(CILParser.PointerArrayTypeParamIndexContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - public GrammarResult VisitPointerNativeType(CILParser.PointerNativeTypeContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - public GrammarResult VisitPointerArrayTypeSizeParamIndex(CILParser.PointerArrayTypeSizeParamIndexContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - public GrammarResult VisitPointerArrayTypeNoSizeData(CILParser.PointerArrayTypeNoSizeDataContext context) => throw new UnreachableException(NodeShouldNeverBeDirectlyVisited); - } -} diff --git a/src/tools/ilasm/src/ILAssembler/ILAssembler.csproj b/src/tools/ilasm/src/ILAssembler/ILAssembler.csproj index 26de5f183c9417..24735966a30333 100644 --- a/src/tools/ilasm/src/ILAssembler/ILAssembler.csproj +++ b/src/tools/ilasm/src/ILAssembler/ILAssembler.csproj @@ -8,10 +8,15 @@ true true false + $(MSBuildThisFileDirectory)ref\ILAssembler.csproj + + + + diff --git a/src/tools/ilasm/src/ILAssembler/PreprocessedTokenSource.cs b/src/tools/ilasm/src/ILAssembler/PreprocessedTokenSource.cs index 9e4ac307fb2d37..096d9a05d9e2db 100644 --- a/src/tools/ilasm/src/ILAssembler/PreprocessedTokenSource.cs +++ b/src/tools/ilasm/src/ILAssembler/PreprocessedTokenSource.cs @@ -99,12 +99,18 @@ private IToken NextTokenWithoutNestedEof(bool errorOnEof = false) { ReportPreprocessorSyntaxError(nextToken); } - _includeSourceStack.Pop(); - if (_includeSourceStack.Count == 0) + + if (_includeSourceStack.Count == 1) { - // If we hit EOF of our entry file, return the EOF token. + // If we hit EOF of our entry file, return the EOF token. The root source is + // deliberately left on the stack so that the accessors below (Line, Column, + // InputStream, SourceName and TokenFactory) keep working after EOF. The parser's + // error recovery queries them while synthesizing missing tokens for a truncated + // document, which would otherwise fault on an empty stack. return nextToken; } + + _includeSourceStack.Pop(); nextToken = CurrentTokenSource.NextToken(); } return nextToken; diff --git a/src/tools/ilasm/src/ILAssembler/StringCharStream.cs b/src/tools/ilasm/src/ILAssembler/StringCharStream.cs new file mode 100644 index 00000000000000..c45c43db4010df --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/StringCharStream.cs @@ -0,0 +1,68 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using Antlr4.Runtime; +using Antlr4.Runtime.Misc; + +namespace ILAssembler; + +internal sealed class StringCharStream : ICharStream +{ + private readonly string _text; + private int _position; + + internal StringCharStream(string text, string? sourceName = null) + { + _text = text; + SourceName = sourceName ?? string.Empty; + } + + public int Index => _position; + + public int Size => _text.Length; + + public string SourceName { get; } + + public void Consume() + { + if (_position >= _text.Length) + { + throw new InvalidOperationException("Cannot consume past the end of the character stream."); + } + + _position++; + } + + public int LA(int i) + { + if (i == 0) + { + return 0; + } + + int offset = i < 0 ? i : i - 1; + int position = _position + offset; + return (uint)position >= (uint)_text.Length ? TokenConstants.EOF : _text[position]; + } + + public int Mark() => -1; + + public void Release(int marker) + { + } + + public void Seek(int index) + { + ArgumentOutOfRangeException.ThrowIfNegative(index); + ArgumentOutOfRangeException.ThrowIfGreaterThan(index, _text.Length); + _position = index; + } + + public string GetText(Interval interval) + { + int start = Math.Max(0, interval.a); + int end = Math.Min(_text.Length - 1, interval.b); + return start > end ? string.Empty : _text.Substring(start, end - start + 1); + } +} diff --git a/src/tools/ilasm/src/ILAssembler/TypeName.cs b/src/tools/ilasm/src/ILAssembler/TypeName.cs deleted file mode 100644 index a4b1a11ddae119..00000000000000 --- a/src/tools/ilasm/src/ILAssembler/TypeName.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Text; - -namespace ILAssembler -{ - internal sealed record TypeName(TypeName? ContainingTypeName, string DottedName); -} diff --git a/src/tools/ilasm/src/ILAssembler/gen/CIL.g4 b/src/tools/ilasm/src/ILAssembler/gen/CIL.g4 index c36609d01cf657..e8ac73ebbdf80c 100644 --- a/src/tools/ilasm/src/ILAssembler/gen/CIL.g4 +++ b/src/tools/ilasm/src/ILAssembler/gen/CIL.g4 @@ -5,6 +5,14 @@ The .NET Foundation licenses this file to you under the MIT license. grammar CIL; +@parser::header { +#nullable enable annotations +} + +@parser::members { + internal GrammarActions Actions { get; set; } = null!; +} + tokens { IncludedFileEof, SyntheticIncludedFileEof } INT32: '-'? ('0x' [0-9A-Fa-f]+ | [0-9]+); @@ -409,80 +417,170 @@ id: | VALUE | INSTANCE | SQSTRING; -dottedName: DOTTEDNAME | ((dottedNamePart '.')* dottedNamePart) | SQSTRING; -dottedNamePart: ID | VALUE | INSTANCE | SQSTRING | DOTTEDNAME | 'volatile'; -compQstring: (QSTRING PLUS)* QSTRING; +dottedName returns [string Value] +locals [CILParser.DottedNameBuilder Builder] +@init {_localctx.Builder = new CILParser.DottedNameBuilder();} +: + direct = DOTTEDNAME {Actions.AddDottedNameToken(_localctx.Builder, $direct);} + | ((part = dottedNamePart {Actions.AddDottedNamePart(_localctx.Builder, $part.Value);} '.')* + tail = dottedNamePart {Actions.AddDottedNamePart(_localctx.Builder, $tail.Value);}) + | quoted = SQSTRING {Actions.AddDottedNameToken(_localctx.Builder, $quoted);} +; +finally {_localctx.Value = Actions.EndDottedName(_localctx.Builder);} + +dottedNamePart returns [string Value] +@init {_localctx.Value = string.Empty;} +@after {_localctx.Value = Actions.ParseDottedNamePart(_localctx.Start);} +: + ID + | VALUE + | INSTANCE + | SQSTRING + | DOTTEDNAME + | 'volatile' +; +compQstring returns [string Value] +locals [System.Text.StringBuilder Builder] +@init {_localctx.Builder = new System.Text.StringBuilder();} +: + (head = QSTRING {Actions.AddComposedStringPart(_localctx.Builder, $head);} PLUS)* + tail = QSTRING {Actions.AddComposedStringPart(_localctx.Builder, $tail);} +; +finally {_localctx.Value = Actions.EndComposedString(_localctx.Builder);} WS: [ \t\r\n] -> skip; SINGLE_LINE_COMMENT: '//' ~[\r\n]* -> skip; COMMENT: '/*' .*? '*/' -> skip; +PERMISSION: '.permission'; +PERMISSIONSET: '.permissionset'; -decls: decl*; +decls +: + decl* +; -decl: +decl +: classHead '{' classDecls '}' | nameSpaceHead '{' decls '}' | methodHead '{' methodDecls '}' | fieldDecl - | dataDecl - | vtableDecl - | vtfixupDecl - | extSourceSpec - | fileDecl - | assemblyBlock - | assemblyRefHead '{' assemblyRefDecls '}' - | exptypeHead '{' exptypeDecls '}' - | manifestResHead '{' manifestResDecls '}' - | moduleHead - | secDecl - | customAttrDecl - | subsystem - | corflags - | alignment - | imagebase - | stackreserve - | languageDecl - | typedefDecl - | compControl + | {Actions.BeginTopLevelDirective();} + data = dataDecl {Actions.ProcessTopLevelDataDeclaration($data.ctx);} + | {Actions.BeginTopLevelDirective();} + vtable = vtableDecl {Actions.ProcessTopLevelVTableDeclaration($vtable.ctx);} + | {Actions.BeginTopLevelDirective();} + vtfixup = vtfixupDecl {Actions.ProcessTopLevelVTableFixupDeclaration($vtfixup.ctx);} + | {Actions.BeginTopLevelDirective();} + source = extSourceSpec {Actions.ProcessTopLevelSourceDirective($source.ctx);} + | {Actions.BeginTopLevelDirective();} + file = fileDecl {Actions.ProcessTopLevelFileDeclaration($file.ctx);} + | {Actions.BeginTopLevelDirective();} + assembly = assemblyBlock {Actions.ProcessTopLevelAssembly($assembly.ctx);} + | {Actions.BeginTopLevelDirective();} + assemblyReference = assemblyRefBlock + {Actions.ProcessTopLevelAssemblyReference($assemblyReference.ctx);} + | {Actions.BeginTopLevelDirective();} + exportedType = exptypeBlock {Actions.ProcessTopLevelExportedType($exportedType.ctx);} + | {Actions.BeginTopLevelDirective();} + resource = manifestResBlock {Actions.ProcessTopLevelManifestResource($resource.ctx);} + | {Actions.BeginTopLevelDirective();} + module = moduleHead + {Actions.ProcessTopLevelModule($module.Value, $module.HasName, $module.IsExternal);} + | {Actions.BeginTopLevelDirective();} + security = secDecl {Actions.ProcessTopLevelSecurityDeclaration($security.ctx);} + | attribute = customAttrDecl {Actions.ProcessTopLevelCustomAttribute($attribute.ctx);} + | {Actions.BeginTopLevelDirective();} subsystem + | {Actions.BeginTopLevelDirective();} corflags + | {Actions.BeginTopLevelDirective();} alignment + | {Actions.BeginTopLevelDirective();} imagebase + | {Actions.BeginTopLevelDirective();} stackreserve + | {Actions.BeginTopLevelDirective();} + language = languageDecl {Actions.ProcessTopLevelLanguageDirective($language.ctx);} + | {Actions.BeginTopLevelDirective();} + typedef = typedefDecl {Actions.ProcessTopLevelTypedef($typedef.ctx);} + | {Actions.BeginTopLevelDirective();} compControl | typelist - | mscorlib; - -subsystem: '.subsystem' int32; - -corflags: '.corflags' int32; - -alignment: '.file' 'alignment' int32; - -imagebase: '.imagebase' int64; - -stackreserve: '.stackreserve' int64; - -assemblyBlock: - '.assembly' asmAttr dottedName '{' assemblyDecls '}'; + | {Actions.BeginTopLevelDirective();} mscorlib; +finally {Actions.EndDeclaration(_localctx);} + +subsystem: + '.subsystem' value = int32 {Actions.ProcessTopLevelSubsystem($value.start);}; + +corflags: + '.corflags' value = int32 {Actions.ProcessTopLevelCorFlags($value.start);}; + +alignment: + '.file' 'alignment' value = int32 {Actions.ProcessTopLevelAlignment($value.start);}; + +imagebase: + '.imagebase' value = int64 {Actions.ProcessTopLevelImageBase($value.start);}; + +stackreserve: + '.stackreserve' value = int64 {Actions.ProcessTopLevelStackReserve($value.start);}; + +assemblyBlock returns [CILParser.AssemblyDefinitionValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + '.assembly' attributes = asmAttr name = dottedName '{' declarations = assemblyDecls '}' + {_localctx.Value = Actions.CreateAssemblyDefinition( + $attributes.Value, + $name.Value, + $declarations.Value);}; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } +} mscorlib: '.mscorlib'; -languageDecl: - '.language' languageString - | '.language' languageString ',' languageString - | '.language' languageString ',' languageString ',' languageString; - -languageString: SQSTRING | QSTRING; - -typelist: '.typelist' '{' (className)* '}'; +languageDecl returns [CILParser.LanguageDirectiveValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + '.language' language = languageString + {_localctx.Value = Actions.CreateLanguageDirective($language.Value);} + | '.language' language = languageString ',' vendor = languageString + {_localctx.Value = Actions.CreateLanguageDirective($language.Value, $vendor.Value);} + | '.language' language = languageString ',' vendor = languageString ',' documentType = languageString + {_localctx.Value = Actions.CreateLanguageDirective($language.Value, $vendor.Value, $documentType.Value);}; +finally {Actions.EndLanguageDirective(_localctx, _localctx.InitialSyntaxErrorCount);} + +languageString returns [string Value] +@init {_localctx.Value = string.Empty;} +@after {_localctx.Value = Actions.ParseLanguageString(_localctx.Start);} +: + SQSTRING + | QSTRING; + +typelist +@init {Actions.BeginTopLevelTypeList();} +: + '.typelist' '{' + (name = className {Actions.ProcessTopLevelTypeListEntry($name.Value);})* + '}' +; int32: INT32; int64: INT64 | INT32; -float64: - FLOAT64 - | int32 '.' /* trailing-dot integer as float (e.g., ldc.r8 1.) */ - | int32 - | FLOAT32 '(' int32 ')' - | FLOAT64_ '(' int64 ')'; +float64 returns [double Value]: + decimal = FLOAT64 {_localctx.Value = Actions.ParseFloatingLiteral($decimal);} + | trailing = int32 '.' {_localctx.Value = Actions.ParseFloatingInteger($trailing.start);} /* trailing-dot integer as float (e.g., ldc.r8 1.) */ + | integer = int32 {_localctx.Value = Actions.ParseFloatingInteger($integer.start);} + | FLOAT32 '(' singleBits = int32 ')' {_localctx.Value = Actions.ParseFloat32Bits($singleBits.start);} + | FLOAT64_ '(' doubleBits = int64 ')' {_localctx.Value = Actions.ParseFloat64Bits($doubleBits.start);}; -intOrWildcard: int32 | PTR; +intOrWildcard returns [int? Value]: + value = int32 {_localctx.Value = Actions.ParseInt32($value.start);} + | PTR {_localctx.Value = null;}; /* This is handled in the PreprocessedTokenSource lexer. We have this in the grammar just for completeness */ compControl: @@ -498,145 +596,383 @@ compControl: /* Aliasing of types, type specs, methods, fields and custom attributes */ -typedefDecl: - '.typedef' type 'as' dottedName - | '.typedef' className 'as' dottedName - | '.typedef' memberRef 'as' dottedName - | '.typedef' customDescr 'as' dottedName - | '.typedef' customDescrWithOwner 'as' dottedName; +typedefDecl returns [CILParser.TypedefDeclarationValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.TypedefDeclarationValue.Error; +} +: + '.typedef' signature = type 'as' alias = dottedName + {_localctx.Value = Actions.CreateTypeSignatureTypedef($signature.Value, $alias.Value);} + | '.typedef' classType = className 'as' alias = dottedName + {_localctx.Value = Actions.CreateClassTypedef($classType.Value, $alias.Value);} + | '.typedef' member = memberRef 'as' alias = dottedName + {_localctx.Value = Actions.CreateMemberTypedef($member.Value, $alias.Value);} + | '.typedef' attribute = customDescr 'as' alias = dottedName + {_localctx.Value = Actions.CreateCustomAttributeTypedefDeclaration( + $attribute.Value, + $attribute.start, + $alias.Value);} + | '.typedef' ownedAttribute = customDescrWithOwner 'as' alias = dottedName + {_localctx.Value = Actions.CreateCustomAttributeTypedefDeclaration( + $ownedAttribute.Value, + $ownedAttribute.start, + $alias.Value);}; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} /* Custom attribute declarations */ -customDescr: - '.custom' customType - | '.custom' customType '=' compQstring - | '.custom' customType '=' '{' customBlobDescr '}' - | '.custom' customType '=' '(' bytes ')'; - -customDescrWithOwner: - '.custom' '(' ownerType ')' customType - | '.custom' '(' ownerType ')' customType '=' compQstring - | '.custom' '(' ownerType ')' customType '=' '{' customBlobDescr '}' - | '.custom' '(' ownerType ')' customType '=' '(' bytes ')'; - -customType: methodRef; - -ownerType: typeSpec | memberRef; +customDescr returns [CILParser.CustomAttributeDescriptorValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDescriptorValue.Error; +} +: + '.custom' constructor = customType + {_localctx.Value = Actions.CreateDefaultCustomAttribute($constructor.Value);} + | '.custom' constructor = customType '=' stringValue = compQstring + {_localctx.Value = Actions.CreateStringCustomAttribute($constructor.Value, $stringValue.Value);} + | '.custom' constructor = customType '=' '{' structuredValue = customBlobDescr '}' + {_localctx.Value = Actions.CreateStructuredCustomAttribute($constructor.Value, $structuredValue.Value);} + | '.custom' constructor = customType '=' '(' rawValue = bytes ')' + {_localctx.Value = Actions.CreateRawCustomAttribute($constructor.Value, $rawValue.Value);}; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} + +customDescrWithOwner returns [CILParser.CustomAttributeDescriptorValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDescriptorValue.Error; +} +: + '.custom' '(' owner = ownerType ')' constructor = customType + {_localctx.Value = Actions.CreateDefaultOwnedCustomAttribute($owner.Value, $constructor.Value);} + | '.custom' '(' owner = ownerType ')' constructor = customType '=' stringValue = compQstring + {_localctx.Value = Actions.CreateStringOwnedCustomAttribute($owner.Value, $constructor.Value, $stringValue.Value);} + | '.custom' '(' owner = ownerType ')' constructor = customType '=' '{' structuredValue = customBlobDescr '}' + {_localctx.Value = Actions.CreateStructuredOwnedCustomAttribute($owner.Value, $constructor.Value, $structuredValue.Value);} + | '.custom' '(' owner = ownerType ')' constructor = customType '=' '(' rawValue = bytes ')' + {_localctx.Value = Actions.CreateRawOwnedCustomAttribute($owner.Value, $constructor.Value, $rawValue.Value);}; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} + +customType returns [CILParser.MethodReferenceValue Value] +@init {_localctx.Value = CILParser.MethodReferenceValue.Error;} +: + constructor = methodRef {_localctx.Value = Actions.CreateCustomAttributeType($constructor.Value);}; + +ownerType +returns [CILParser.OwnerTypeValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.OwnerTypeValue.Error; +} +: + typeValue = typeSpec {_localctx.Value = Actions.CreateTypeOwner($typeValue.Value);} + | member = memberRef {_localctx.Value = Actions.CreateMemberOwner($member.Value);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} /* Verbal description of custom attribute initialization blob */ -customBlobDescr: customBlobArgs customBlobNVPairs; - -customBlobArgs: (serInit | compControl)*; - -customBlobNVPairs: ( - fieldOrProp serializType dottedName '=' serInit +customBlobDescr returns [CILParser.CustomAttributeBlobValue Value] +@init {_localctx.Value = CILParser.CustomAttributeBlobValue.Error;} +: + arguments = customBlobArgs namedArguments = customBlobNVPairs + {_localctx.Value = Actions.CreateCustomAttributeBlob($arguments.Value, $namedArguments.Value);}; + +customBlobArgs returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (argument = serInit {_localctx.Builder.Add($argument.Value);} | compControl)* +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +customBlobNVPairs returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + ( + kind = fieldOrProp argumentType = serializType name = dottedName '=' value = serInit + {_localctx.Builder.Add(Actions.CreateCustomBlobNamedArgument( + $kind.Value, + $argumentType.Value, + $name.Value, + $value.Value));} | compControl - )*; - -fieldOrProp: 'field' | 'property'; - -serializType: serializTypeElement (ARRAY_TYPE_NO_BOUNDS)?; - -serializTypeElement: - simpleType - | dottedName /* typedef */ - | TYPE - | OBJECT - | ENUM 'class' SQSTRING - | ENUM className; + )* +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +fieldOrProp returns [byte Value]: + kind = ('field' | 'property') {_localctx.Value = Actions.GetCustomAttributeNamedArgumentKind($kind);}; + +serializType returns [CILParser.SerializationTypeValue Value] +@init {_localctx.Value = CILParser.SerializationTypeValue.Error;} +: + element = serializTypeElement array = ARRAY_TYPE_NO_BOUNDS? + {_localctx.Value = Actions.CreateSerializationType($element.Value, $array);}; + +serializTypeElement returns [CILParser.SerializationTypeValue Value] +@init {_localctx.Value = CILParser.SerializationTypeValue.Error;} +: + primitive = simpleType {_localctx.Value = Actions.CreatePrimitiveSerializationType($primitive.Value);} + | alias = dottedName {_localctx.Value = Actions.CreateSerializationTypeTypedef(_localctx, $alias.Value);} /* typedef */ + | simpleTypeToken = TYPE {_localctx.Value = Actions.CreateSimpleSerializationType($simpleTypeToken);} + | simpleTypeToken = OBJECT {_localctx.Value = Actions.CreateSimpleSerializationType($simpleTypeToken);} + | ENUM 'class' quotedName = SQSTRING {_localctx.Value = Actions.CreateEnumSerializationType($quotedName);} + | ENUM classNameValue = className {_localctx.Value = Actions.CreateEnumSerializationType($classNameValue.Value);}; /* Module declaration */ -moduleHead: - MODULE 'extern' dottedName - | MODULE dottedName - | MODULE; +moduleHead returns [string? Value, bool HasName, bool IsExternal] +@init {_localctx.Value = null;} +: + MODULE 'extern' name = dottedName + {Actions.SetModuleHeader(_localctx, $name.Value, true);} + | MODULE name = dottedName + {Actions.SetModuleHeader(_localctx, $name.Value, false);} + | MODULE + {Actions.SetEmptyModuleHeader(_localctx);}; /* VTable Fixup table declaration */ -vtfixupDecl: '.vtfixup' '[' int32 ']' vtfixupAttr 'at' id; - -vtfixupAttr: - /* EMPTY */ - | vtfixupAttr INT32_ - | vtfixupAttr INT64_ - | vtfixupAttr 'fromunmanaged' - | vtfixupAttr 'callmostderived' - | vtfixupAttr 'retainappdomain'; - -vtableDecl: '.vtable' '=' '(' bytes ')' /* deprecated */; +vtfixupDecl returns [CILParser.VTableFixupValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + '.vtfixup' '[' count = int32 ']' attributes = vtfixupAttr 'at' label = id + {_localctx.Value = Actions.CreateVTableFixup( + $count.start, + $attributes.Value, + $label.start);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } +} + +vtfixupAttr returns [ushort Value] +@init {_localctx.Value = 0;} +: + (attribute = vtfixupAttrElement + {_localctx.Value = Actions.AddVTableFixupAttribute(_localctx.Value, $attribute.Value);})* + {_localctx.Value = Actions.CompleteVTableFixupAttributes(_localctx.Value);} +; + +vtfixupAttrElement returns [ushort Value] +@after {_localctx.Value = Actions.ParseVTableFixupAttribute(_localctx.Start);} +: + INT32_ + | INT64_ + | 'fromunmanaged' + | 'callmostderived' + | 'retainappdomain'; + +vtableDecl returns [CILParser.RawVTableValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + '.vtable' '=' '(' value = bytes ')' + {_localctx.Value = Actions.CreateRawVTable($value.Value);} /* deprecated */ +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } +} /* Namespace and class declaration */ -nameSpaceHead: '.namespace' dottedName; - -classHead: - '.class' classAttr* dottedName typarsClause extendsClause implClause; - - -classAttr: - 'public' - | 'private' - | VALUE - | ENUM - | INTERFACE - | 'sealed' - | 'abstract' - | 'auto' - | 'sequential' - | EXPLICIT - | 'extended' - | ANSI - | 'unicode' - | 'autochar' - | 'import' - | 'serializable' - | 'windowsruntime' - | 'nested' 'public' - | 'nested' 'private' - | 'nested' 'family' - | 'nested' 'assembly' - | 'nested' 'famandassem' - | 'nested' 'famorassem' - | 'beforefieldinit' - | 'specialname' - | 'rtspecialname' - | 'flags' '(' int32 ')'; - -extendsClause: /* EMPTY */ | 'extends' typeSpec; - -implClause: /* EMPTY */ | 'implements' implList; - -classDecls: classDecl*; +nameSpaceHead returns [string Value] +locals [int InitialSyntaxErrorCount] +@init { + Actions.PrepareNamespaceHeader(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = string.Empty; +} +@after {Actions.BeginNamespace(_localctx, _localctx.Value, _localctx.InitialSyntaxErrorCount);} +: + '.namespace' name = dottedName {_localctx.Value = $name.Value;} +; + +classHead returns [CILParser.ClassHeaderValue Value] +locals [int InitialSyntaxErrorCount, CILParser.ClassHeaderBuilder Builder] +@init { + _localctx.Builder = Actions.PrepareClassHeader(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.ClassHeaderValue.Error; +} +@after {Actions.BeginType(_localctx, _localctx.Value);} +: + '.class' + (attribute = classAttr {Actions.AddClassHeaderAttribute(_localctx.Builder, $attribute.Value);})* + name = dottedName genericParameters = typarsClause baseType = extendsClause interfaces = implClause + {_localctx.Value = Actions.CreateClassHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + $name.stop, + $name.Value, + $genericParameters.Value, + $baseType.Value, + $interfaces.Value);} +; + + +classAttr returns [CILParser.ClassAttributeValue Value] +@init {_localctx.Value = CILParser.ClassAttributeValue.Empty;} +: + attribute = 'public' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'private' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = VALUE {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = ENUM {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = INTERFACE {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'sealed' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'abstract' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'auto' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'sequential' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = EXPLICIT {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'extended' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = ANSI {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'unicode' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'autochar' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'import' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'serializable' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'windowsruntime' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | 'nested' visibility = 'public' {_localctx.Value = Actions.CreateNestedClassAttribute($visibility);} + | 'nested' visibility = 'private' {_localctx.Value = Actions.CreateNestedClassAttribute($visibility);} + | 'nested' visibility = 'family' {_localctx.Value = Actions.CreateNestedClassAttribute($visibility);} + | 'nested' visibility = 'assembly' {_localctx.Value = Actions.CreateNestedClassAttribute($visibility);} + | 'nested' visibility = 'famandassem' {_localctx.Value = Actions.CreateNestedClassAttribute($visibility);} + | 'nested' visibility = 'famorassem' {_localctx.Value = Actions.CreateNestedClassAttribute($visibility);} + | attribute = 'beforefieldinit' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'specialname' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | attribute = 'rtspecialname' {_localctx.Value = Actions.CreateClassAttribute($attribute);} + | 'flags' '(' flags = int32 ')' {_localctx.Value = Actions.CreateRawClassAttribute($flags.start);}; + +extendsClause returns [CILParser.TypeSpecificationValue? Value] +@init {_localctx.Value = Actions.CreateEmptyClassBase();} +: + /* EMPTY */ + | 'extends' baseType = typeSpec {_localctx.Value = Actions.CreateClassBase($baseType.Value);} +; -implList: (typeSpec ',')* typeSpec; +implClause returns [System.Collections.Immutable.ImmutableArray Value] +@init {_localctx.Value = Actions.CreateEmptyInterfaceList();} +: + /* EMPTY */ + | 'implements' interfaces = implList {_localctx.Value = $interfaces.Value;} +; + +classDecls +: + classDecl* +; + +implList returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (interfaceType = typeSpec {_localctx.Builder.Add($interfaceType.Value);} ',')* + lastInterfaceType = typeSpec {_localctx.Builder.Add($lastInterfaceType.Value);} +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} /* External source declarations */ -esHead: '.line' | '#line'; - -extSourceSpec: - esHead int32 SQSTRING - | esHead int32 - | esHead int32 ':' int32 SQSTRING - | esHead int32 ':' int32 - | esHead int32 ':' int32 ',' int32 SQSTRING - | esHead int32 ':' int32 ',' int32 - | esHead int32 ',' int32 ':' int32 SQSTRING - | esHead int32 ',' int32 ':' int32 - | esHead int32 ',' int32 ':' int32 ',' int32 SQSTRING - | esHead int32 ',' int32 ':' int32 ',' int32 - | esHead int32 QSTRING - | esHead int32 ':' int32 QSTRING - | esHead int32 ':' int32 ',' int32 QSTRING - | esHead int32 ',' int32 ':' int32 QSTRING - | esHead int32 ',' int32 ':' int32 ',' int32 QSTRING; +esHead returns [bool AutoIncrement] +@after {_localctx.AutoIncrement = Actions.IsAutoIncrementSourceDirective(_localctx.Start);} +: + '.line' + | '#line'; + +extSourceSpec returns [CILParser.SourceDirectiveValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + head = esHead line = int32 path = (SQSTRING | QSTRING)? + {_localctx.Value = Actions.CreateSourceLine($head.AutoIncrement, $line.start, $path);} + | head = esHead line = int32 ':' column = int32 path = (SQSTRING | QSTRING)? + {_localctx.Value = Actions.CreateSourceColumn($head.AutoIncrement, $line.start, $column.start, $path);} + | head = esHead line = int32 ':' startColumn = int32 ',' endColumn = int32 path = (SQSTRING | QSTRING)? + {_localctx.Value = Actions.CreateSourceColumnRange( + $head.AutoIncrement, + $line.start, + $startColumn.start, + $endColumn.start, + $path);} + | head = esHead startLine = int32 ',' endLine = int32 ':' column = int32 path = (SQSTRING | QSTRING)? + {_localctx.Value = Actions.CreateSourceLineRange( + $head.AutoIncrement, + $startLine.start, + $endLine.start, + $column.start, + $path);} + | head = esHead startLine = int32 ',' endLine = int32 ':' startColumn = int32 ',' endColumn = int32 + path = (SQSTRING | QSTRING)? + {_localctx.Value = Actions.CreateSourceRange( + $head.AutoIncrement, + $startLine.start, + $endLine.start, + $startColumn.start, + $endColumn.start, + $path);}; +finally {Actions.EndSourceDirective(_localctx, _localctx.InitialSyntaxErrorCount);} /* Manifest declarations */ -fileDecl: - '.file' fileAttr* dottedName fileEntry HASH '=' '(' bytes ')' fileEntry - | '.file' fileAttr* dottedName fileEntry; - -fileAttr: 'nometadata'; - -fileEntry: /* EMPTY */ | '.entrypoint'; +fileDecl returns [CILParser.FileDeclarationValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount, CILParser.FileDeclarationBuilder Builder] +@init { + _localctx.Builder = new CILParser.FileDeclarationBuilder(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; +} +: + '.file' + (attribute = fileAttr {Actions.AddFileAttribute(_localctx.Builder, $attribute.Value);})* + name = dottedName {Actions.SetFileName(_localctx.Builder, $name.Value);} + entry = fileEntry {Actions.AddFileEntry(_localctx.Builder, $entry.Value);} + (HASH '=' '(' hash = bytes ')' {Actions.SetFileHash(_localctx.Builder, $hash.Value);} + trailingEntry = fileEntry {Actions.AddFileEntry(_localctx.Builder, $trailingEntry.Value);})? +; +finally {Actions.EndFileDeclaration(_localctx, _localctx.Builder, _localctx.InitialSyntaxErrorCount);} + +fileAttr returns [bool Value] +@after {_localctx.Value = Actions.ParseFileAttribute(_localctx.Start);} +: + 'nometadata'; + +fileEntry returns [bool Value] +@init {_localctx.Value = false;} +: + /* EMPTY */ + | entry = '.entrypoint' {_localctx.Value = Actions.ParseFileEntry($entry);}; -asmAttrAny: +asmAttrAny returns [System.Reflection.AssemblyFlags Value, System.Reflection.AssemblyFlags Mask] +@after {Actions.SetAssemblyAttribute(_localctx);} +: 'retargetable' | 'windowsruntime' | 'noplatform' @@ -647,308 +983,485 @@ asmAttrAny: | 'arm' | 'arm64'; -asmAttr: asmAttrAny*; +asmAttr returns [System.Reflection.AssemblyFlags Value] +@init {_localctx.Value = 0;} +: + (attribute = asmAttrAny + {_localctx.Value = Actions.AddAssemblyAttribute( + _localctx.Value, + $attribute.Value, + $attribute.Mask);})*; /* IL instructions and associated definitions */ -instr_none: INSTR_NONE; - -instr_var: INSTR_VAR; - -instr_i: INSTR_I; - -instr_i8: INSTR_I8; - -instr_r: INSTR_R; - -instr_brtarget: INSTR_BRTARGET; - -instr_method: INSTR_METHOD; - -instr_field: INSTR_FIELD; - -instr_type: INSTR_TYPE; - -instr_string: INSTR_STRING; - -instr_sig: INSTR_SIG; - -instr_tok: INSTR_TOK; - -instr_switch: INSTR_SWITCH; - instr: - instr_none - | instr_var int32 - | instr_var id - | instr_i int32 - | instr_i8 int64 - | instr_r float64 - | instr_r int64 - | instr_r '(' bytes ')' - | instr_r 'bytearray' '(' bytes ')' // Support bytearray syntax for floating point instructions - | instr_brtarget int32 - | instr_brtarget id - | instr_method methodRef - | instr_field fieldRef - | instr_field mdtoken - | instr_type typeSpec - | instr_string compQstring - | instr_string ANSI '(' compQstring ')' - | instr_string 'bytearray' '(' bytes ')' - | instr_sig callConv type sigArgs - | instr_tok ownerType /* ownerType ::= memberRef | typeSpec */ - | instr_tok int32 - | instr_switch '(' labels ')' - | instr_switch '()'; - -labels: + simpleInstr + | op = INSTR_METHOD methodOperand = methodRef {Actions.EmitMethodReferenceInstruction($op, $methodOperand.ctx);} + | op = INSTR_FIELD fieldOperand = fieldRef {Actions.EmitFieldReferenceInstruction($op, $fieldOperand.ctx);} + | op = INSTR_FIELD metadataOperand = mdtoken {Actions.EmitMetadataTokenInstruction($op, $metadataOperand.ctx);} + | op = INSTR_TYPE typeOperand = typeSpec {Actions.EmitTypeReferenceInstruction($op, $typeOperand.ctx);} + | op = INSTR_SIG signatureOperand = calliSignature {Actions.EmitCalliInstruction($op, $signatureOperand.ctx);} + | op = INSTR_TOK ownerOperand = ownerType {Actions.EmitOwnerTokenInstruction($op, $ownerOperand.ctx);} +; + +simpleInstr +locals [CILParser.SwitchInstructionBuilder SwitchBuilder] +@after {Actions.CompleteSwitchInstruction(_localctx.SwitchBuilder);} +: + op = INSTR_NONE {Actions.EmitNoOperandInstruction($op);} + | op = INSTR_VAR index = int32 {Actions.EmitVariableIndexInstruction($op, $index.start);} + | op = INSTR_VAR name = id {Actions.EmitVariableNameInstruction($op, $name.start);} + | op = INSTR_I value32 = int32 {Actions.EmitInt32Instruction($op, $value32.start);} + | op = INSTR_I8 value64 = int64 {Actions.EmitInt64Instruction($op, $value64.start);} + | op = INSTR_R value = float64 {Actions.EmitFloatingInstruction($op, $value.Value);} + | op = INSTR_R integerValue = int64 {Actions.EmitFloatingInstruction($op, $integerValue.start);} + | op = INSTR_R '(' rawFloat = bytes ')' {Actions.EmitRawFloatingInstruction($op, $rawFloat.Value, $rawFloat.start);} + | op = INSTR_R 'bytearray' '(' rawFloat = bytes ')' {Actions.EmitRawFloatingInstruction($op, $rawFloat.Value, $rawFloat.start);} + | op = INSTR_BRTARGET offset = int32 {Actions.EmitBranchOffsetInstruction($op, $offset.start);} + | op = INSTR_BRTARGET label = id {Actions.EmitBranchLabelInstruction($op, $label.start);} + | op = INSTR_STRING userString = compQstring {Actions.EmitStringInstruction($op, $userString.Value);} + | op = INSTR_STRING ANSI '(' ansiString = compQstring ')' {Actions.EmitAnsiStringInstruction($op, $ansiString.Value);} + | op = INSTR_STRING 'bytearray' '(' rawString = bytes ')' {Actions.EmitRawStringInstruction($op, $rawString.Value);} + | op = INSTR_TOK rawToken = int32 {Actions.EmitRawTokenInstruction($op, $rawToken.start);} + | op = INSTR_SWITCH {_localctx.SwitchBuilder = Actions.CreateSwitchInstruction($op);} + ('(' labels[_localctx.SwitchBuilder] ')' | '()') +; + +calliSignature +returns [CILParser.CalliSignatureValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CalliSignatureValue.Error; +} +: + convention = callConv returnType = type arguments = sigArgs + {_localctx.Value = Actions.CreateCalliSignature($convention.Value, $returnType.Value, $arguments.Value);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} + +labels [CILParser.SwitchInstructionBuilder Builder]: /* empty */ - | ((id | int32) ',')* (id | int32); - -typeArgs: '<' (type ',')* type '>'; - -bounds: '[' (bound ',')* bound ']'; - -sigArgs: '(' (sigArg ',')* sigArg ')' | '()'; - -sigArg: - ELLIPSIS - | paramAttr type marshalClause id?; + | ((headLabel = id {Actions.AddSwitchLabel($Builder, $headLabel.start);} | headOffset = int32 {Actions.AddSwitchOffset($Builder, $headOffset.start);}) ',')* + (tailLabel = id {Actions.AddSwitchLabel($Builder, $tailLabel.start);} | tailOffset = int32 {Actions.AddSwitchOffset($Builder, $tailOffset.start);}); + +typeArgs returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + '<' (argument = type {_localctx.Builder.Add($argument.Value);} ',')* + lastArgument = type {_localctx.Builder.Add($lastArgument.Value);} '>' +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +bounds returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + '[' (item = bound {_localctx.Builder.Add(Actions.CreateArrayBound($item.ctx));} ',')* + lastItem = bound {_localctx.Builder.Add(Actions.CreateArrayBound($lastItem.ctx));} ']' +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +sigArgs returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + '(' (argument = sigArg {_localctx.Builder.Add($argument.Value);} ',')* + lastArgument = sigArg {_localctx.Builder.Add($lastArgument.Value);} ')' + | '()' +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +sigArg returns [CILParser.SignatureArgumentValue Value] +@init {_localctx.Value = CILParser.SignatureArgumentValue.Error;} +: + ELLIPSIS {_localctx.Value = Actions.CreateSentinelSignatureArgument();} + | attributes = paramAttr argumentType = type marshalling = marshalClause name = id? + {_localctx.Value = Actions.CreateSignatureArgument($attributes.Value, $argumentType.Value, $marshalling.Value, $name.ctx);}; /* Class referencing */ -className: - '[' dottedName ']' slashedName - | '[' mdtoken ']' slashedName - | '[' PTR ']' slashedName - | '[' MODULE dottedName ']' slashedName - | slashedName - | mdtoken - | THIS - | BASE - | NESTER; - -slashedName: (dottedName '/')* dottedName; - -assemblyDecls: assemblyDecl*; - -assemblyDecl: (HASH 'algorithm' int32) | secDecl | asmOrRefDecl; - -typeSpec: - className - | '[' dottedName ']' - | '[' MODULE dottedName ']' - | type; +className returns [CILParser.ClassNameValue Value] +@init {_localctx.Value = CILParser.ClassNameValue.Error;} +: + '[' assemblyName = dottedName ']' typeName = slashedName + {_localctx.Value = Actions.CreateAssemblyQualifiedClassName($assemblyName.Value, $typeName.Value);} + | '[' scopeToken = mdtoken ']' typeName = slashedName + {_localctx.Value = Actions.CreateTokenQualifiedClassName($scopeToken.Value, $typeName.Value);} + | '[' PTR ']' typeName = slashedName + {_localctx.Value = Actions.CreatePointerQualifiedClassName($typeName.Value);} + | '[' MODULE moduleName = dottedName ']' typeName = slashedName + {_localctx.Value = Actions.CreateModuleQualifiedClassName(_localctx.Start, $moduleName.Value, $typeName.Value);} + | typeName = slashedName {_localctx.Value = Actions.CreateUnqualifiedClassName($typeName.Value);} + | typeToken = mdtoken {_localctx.Value = Actions.CreateTokenClassName($typeToken.Value);} + | THIS {_localctx.Value = Actions.CreateThisClassName(_localctx.Start);} + | BASE {_localctx.Value = Actions.CreateBaseClassName(_localctx.Start);} + | NESTER {_localctx.Value = Actions.CreateNesterClassName(_localctx.Start);}; + +slashedName returns [CILParser.TypeName Value] +locals [CILParser.TypeName CurrentName] +: + (part = dottedName {_localctx.CurrentName = Actions.AddSlashedNamePart(_localctx.CurrentName, $part.Value);} '/')* + lastPart = dottedName {_localctx.CurrentName = Actions.AddSlashedNamePart(_localctx.CurrentName, $lastPart.Value);} +; +finally {_localctx.Value = _localctx.CurrentName ?? new CILParser.TypeName(null, string.Empty);} + +assemblyDecls returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (declaration = assemblyDecl + {if ($declaration.Value is not null) _localctx.Builder.Add($declaration.Value);})* +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +assemblyDecl returns [CILParser.AssemblyDeclarationValue? Value]: + HASH 'algorithm' algorithm = int32 + {_localctx.Value = Actions.CreateAssemblyHashAlgorithmDeclaration($algorithm.start);} + | security = secDecl + {_localctx.Value = Actions.CreateAssemblySecurityDeclaration( + $security.Value, + $security.start);} + | shared = asmOrRefDecl {_localctx.Value = $shared.Value;}; + +typeSpec +returns [CILParser.TypeSpecificationValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.TypeSpecificationValue.Error; +} +: + classType = className {_localctx.Value = Actions.CreateClassTypeSpecification($classType.Value);} + | '[' assemblyName = dottedName ']' {_localctx.Value = Actions.CreateAssemblyTypeSpecification($assemblyName.Value);} + | '[' MODULE moduleName = dottedName ']' {_localctx.Value = Actions.CreateModuleTypeSpecification($moduleName.Value);} + | signatureType = type {_localctx.Value = Actions.CreateSignatureTypeSpecification($signatureType.Value);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} /* Native types for marshaling signatures */ -nativeType: +nativeType returns [CILParser.NativeTypeValue Value] +locals [CILParser.NativeTypeBuilder Builder] +@init {_localctx.Builder = new CILParser.NativeTypeBuilder();} +: /* EMPTY */ - | nativeTypeElement nativeTypeArrayPointerInfo*; - -nativeTypeArrayPointerInfo: - PTR # PointerNativeType - | ARRAY_TYPE_NO_BOUNDS # PointerArrayTypeNoSizeData - | '[' int32 ']' # PointerArrayTypeSize - | '[' int32 PLUS int32 ']' # PointerArrayTypeSizeParamIndex - | '[' PLUS int32 ']' # PointerArrayTypeParamIndex + | element = nativeTypeElement {Actions.SetNativeTypeElement(_localctx.Builder, $element.Value);} + (info = nativeTypeArrayPointerInfo {Actions.AddNativeTypeArrayPointerInfo(_localctx.Builder, $info.Value);})* +; +finally {_localctx.Value = Actions.CreateNativeType(_localctx.Start, _localctx.Builder);} + +nativeTypeArrayPointerInfo returns [CILParser.NativeTypeArrayPointerInfoValue Value] +@init {_localctx.Value = Actions.CreatePointerNativeType();} +: + PTR {_localctx.Value = Actions.CreatePointerNativeType();} # PointerNativeType + | ARRAY_TYPE_NO_BOUNDS {_localctx.Value = Actions.CreatePointerArrayTypeNoSizeData();} # PointerArrayTypeNoSizeData + | '[' size = int32 ']' {_localctx.Value = Actions.CreatePointerArrayTypeSize($size.start);} # PointerArrayTypeSize + | '[' size = int32 PLUS parameterIndex = int32 ']' + {_localctx.Value = Actions.CreatePointerArrayTypeSizeParamIndex($size.start, $parameterIndex.start);} # PointerArrayTypeSizeParamIndex + | '[' PLUS parameterIndex = int32 ']' + {_localctx.Value = Actions.CreatePointerArrayTypeParamIndex($parameterIndex.start);} # PointerArrayTypeParamIndex ; -nativeTypeElement: +nativeTypeElement returns [CILParser.NativeTypeElementValue Value] +@init {_localctx.Value = CILParser.EmptyNativeTypeElementValue.Instance;} +: + /* EMPTY */ {_localctx.Value = Actions.CreateEmptyNativeType();} + | marshalType = CUSTOM '(' guid = compQstring ',' nativeTypeName = compQstring ',' + marshallerType = compQstring ',' cookie = compQstring ')' + {_localctx.Value = Actions.CreateDeprecatedCustomMarshallerNativeType( + _localctx, $guid.Value, $nativeTypeName.Value, $marshallerType.Value, $cookie.Value);} + | marshalType = CUSTOM '(' marshallerType = compQstring ',' cookie = compQstring ')' + {_localctx.Value = Actions.CreateCustomMarshallerNativeType($marshallerType.Value, $cookie.Value);} + | FIXED marshalType = SYSSTRING '[' size = int32 ']' + {_localctx.Value = Actions.CreateFixedSysStringNativeType($size.start);} + | FIXED marshalType = ARRAY '[' size = int32 ']' element = nativeType + {_localctx.Value = Actions.CreateFixedArrayNativeType($size.start, $element.Value);} + | marshalType = VARIANT {_localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, $marshalType);} + | marshalType = CURRENCY {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = SYSCHAR {_localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, $marshalType);} + | marshalType = VOID {_localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, $marshalType);} + | marshalType = BOOL {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = INT8 {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = INT16 {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = INT32_ {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = INT64_ {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = FLOAT32 {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = FLOAT64_ {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = ERROR {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = UINT8 {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = UINT16 {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = UINT32 {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = UINT64 {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = DECIMAL {_localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, $marshalType);} + | marshalType = DATE {_localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, $marshalType);} + | marshalType = BSTR {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = LPSTR {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = LPWSTR {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = LPTSTR {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = OBJECTREF {_localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, $marshalType);} + | marshalType = IUNKNOWN index = iidParamIndex {_localctx.Value = Actions.CreateIidNativeType($marshalType, $index.Value);} + | marshalType = IDISPATCH index = iidParamIndex {_localctx.Value = Actions.CreateIidNativeType($marshalType, $index.Value);} + | marshalType = STRUCT {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = INTERFACE index = iidParamIndex {_localctx.Value = Actions.CreateIidNativeType($marshalType, $index.Value);} + | marshalType = SAFEARRAY variant = variantType + {_localctx.Value = Actions.CreateSafeArrayNativeType($variant.Value, null);} + | marshalType = SAFEARRAY variant = variantType ',' userDefinedType = compQstring + {_localctx.Value = Actions.CreateSafeArrayNativeType($variant.Value, $userDefinedType.Value);} + | marshalType = INT {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = UINT {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | 'unsigned' unsignedMarshalType = INT8 {_localctx.Value = Actions.CreateUnsignedNativeType($unsignedMarshalType);} + | 'unsigned' unsignedMarshalType = INT16 {_localctx.Value = Actions.CreateUnsignedNativeType($unsignedMarshalType);} + | 'unsigned' unsignedMarshalType = INT32_ {_localctx.Value = Actions.CreateUnsignedNativeType($unsignedMarshalType);} + | 'unsigned' unsignedMarshalType = INT64_ {_localctx.Value = Actions.CreateUnsignedNativeType($unsignedMarshalType);} + | 'nested' marshalType = STRUCT {_localctx.Value = Actions.CreateNestedStructNativeType(_localctx);} + | marshalType = BYVALSTR {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | ANSI marshalType = BSTR {_localctx.Value = Actions.CreateAnsiBstrNativeType();} + | marshalType = TBSTR {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | VARIANT marshalBool = BOOL {_localctx.Value = Actions.CreateVariantBoolNativeType();} + | marshalType = METHOD {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | marshalType = LPSTRUCT {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | 'as' marshalType = ANY {_localctx.Value = Actions.CreateSimpleNativeType($marshalType);} + | alias = dottedName {_localctx.Value = Actions.CreateNativeTypeTypedef(_localctx, $alias.Value);} /* typedef */; + +iidParamIndex returns [CILParser.IidParamIndexValue Value] +@init {_localctx.Value = CILParser.IidParamIndexValue.Empty;} +: /* EMPTY */ - | marshalType=CUSTOM '(' compQstring ',' compQstring ',' compQstring ',' compQstring ')' - | marshalType=CUSTOM '(' compQstring ',' compQstring ')' - | FIXED marshalType=SYSSTRING '[' int32 ']' - | FIXED marshalType=ARRAY '[' int32 ']' nativeType - | marshalType=VARIANT - | marshalType=CURRENCY - | marshalType=SYSCHAR - | marshalType=VOID - | marshalType=BOOL - | marshalType=INT8 - | marshalType=INT16 - | marshalType=INT32_ - | marshalType=INT64_ - | marshalType=FLOAT32 - | marshalType=FLOAT64_ - | marshalType=ERROR - | marshalType=UINT8 - | marshalType=UINT16 - | marshalType=UINT32 - | marshalType=UINT64 - | marshalType=DECIMAL - | marshalType=DATE - | marshalType=BSTR - | marshalType=LPSTR - | marshalType=LPWSTR - | marshalType=LPTSTR - | marshalType=OBJECTREF - | marshalType=IUNKNOWN iidParamIndex - | marshalType=IDISPATCH iidParamIndex - | marshalType=STRUCT - | marshalType=INTERFACE iidParamIndex - | marshalType=SAFEARRAY variantType - | marshalType=SAFEARRAY variantType ',' compQstring - | marshalType=INT - | marshalType=UINT - | 'unsigned' unsignedMarshalType=INT8 - | 'unsigned' unsignedMarshalType=INT16 - | 'unsigned' unsignedMarshalType=INT32_ - | 'unsigned' unsignedMarshalType=INT64_ - | 'nested' marshalType=STRUCT - | marshalType=BYVALSTR - | ANSI marshalType=BSTR - | marshalType=TBSTR - | VARIANT marshalBool=BOOL - | marshalType=METHOD - | marshalType=LPSTRUCT - | 'as' marshalType=ANY - | dottedName /* typedef */; - -iidParamIndex: /* EMPTY */ | '(' 'iidparam' '=' int32 ')'; - -variantType: + | '(' 'iidparam' '=' index = int32 ')' {_localctx.Value = Actions.GetIidParamIndex($index.start);}; + +variantType returns [CILParser.VariantTypeValue Value] +locals [CILParser.VariantTypeBuilder Builder] +@init {_localctx.Builder = new CILParser.VariantTypeBuilder();} +: /*EMPTY */ - | variantTypeElement (ARRAY_TYPE_NO_BOUNDS | VECTOR | REF)*; - -variantTypeElement: - NULL - | VARIANT - | CURRENCY - | VOID - | BOOL - | INT8 - | INT16 - | INT32_ - | INT64_ - | FLOAT32 - | FLOAT64_ - | UINT8 - | UINT16 - | UINT32 - | UINT64 - | PTR - | DECIMAL - | DATE - | BSTR - | LPSTR - | LPWSTR - | IUNKNOWN - | IDISPATCH - | SAFEARRAY - | INT - | UINT - | ERROR - | HRESULT - | CARRAY - | USERDEFINED - | RECORD - | FILETIME - | BLOB - | STREAM - | STORAGE - | STREAMED_OBJECT - | STORED_OBJECT - | BLOB_OBJECT - | CF - | CLSID; + | element = variantTypeElement {Actions.SetVariantTypeElement(_localctx.Builder, $element.Value);} + (modifier = (ARRAY_TYPE_NO_BOUNDS | VECTOR | REF) {Actions.AddVariantTypeModifier(_localctx.Builder, $modifier);})* +; +finally {_localctx.Value = Actions.CreateVariantType(_localctx.Builder);} + +variantTypeElement returns [CILParser.VariantTypeElementValue Value] +@init {_localctx.Value = CILParser.VariantTypeElementValue.Error;} +: + value = NULL {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = VARIANT {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = CURRENCY {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = VOID {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = BOOL {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = INT8 {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = INT16 {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = INT32_ {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = INT64_ {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = FLOAT32 {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = FLOAT64_ {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = UINT8 {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = UINT16 {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = UINT32 {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = UINT64 {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = PTR {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = DECIMAL {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = DATE {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = BSTR {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = LPSTR {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = LPWSTR {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = IUNKNOWN {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = IDISPATCH {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = SAFEARRAY {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = INT {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = UINT {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = ERROR {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = HRESULT {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = CARRAY {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = USERDEFINED {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = RECORD {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = FILETIME {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = BLOB {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = STREAM {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = STORAGE {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = STREAMED_OBJECT {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = STORED_OBJECT {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = BLOB_OBJECT {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = CF {_localctx.Value = Actions.GetVariantTypeElement($value);} + | value = CLSID {_localctx.Value = Actions.GetVariantTypeElement($value);}; /* Managed types for signatures */ -type: elementType typeModifiers*; - -typeModifiers: - ARRAY_TYPE_NO_BOUNDS # SZArrayModifier - | '[' ']' # SZArrayModifier - | bounds # ArrayModifier - | REF # ByRefModifier - | PTR # PtrModifier - | 'pinned' # PinnedModifier - | 'modreq' '(' typeSpec ')' # RequiredModifier - | 'modopt' '(' typeSpec ')' # OptionalModifier - | typeArgs # GenericArgumentsModifier; - -elementType: - 'class' className - | OBJECT - | VALUE 'class' className - | VALUETYPE className - | 'method' callConv type PTR sigArgs - | METHOD_TYPE_PARAMETER int32 - | TYPE_PARAMETER int32 - | METHOD_TYPE_PARAMETER dottedName - | TYPE_PARAMETER dottedName - | TYPEDREF - | VOID - | nativeInt - | nativeUint - | simpleType - | dottedName /* typedef */ - | ELLIPSIS type; - -simpleType: - CHAR - | STRING - | BOOL - | INT8 - | INT16 - | INT32_ - | INT64_ - | FLOAT32 - | FLOAT64_ - | UINT8 - | UINT16 - | UINT32 - | UINT64 - | 'unsigned' INT8 - | 'unsigned' INT16 - | 'unsigned' INT32_ - | 'unsigned' INT64_; - -bound: +type returns [CILParser.TypeValue Value] +locals [ + CILParser.ElementTypeValue ElementType, + System.Collections.Immutable.ImmutableArray.Builder Modifiers +] +@init { + _localctx.ElementType = CILParser.ElementTypeValue.Error; + _localctx.Modifiers = System.Collections.Immutable.ImmutableArray.CreateBuilder(); +} +: + element = elementType {_localctx.ElementType = $element.Value;} + (modifier = typeModifiers {_localctx.Modifiers.Add($modifier.Value);})* +; +finally {_localctx.Value = new CILParser.TypeValue(_localctx.ElementType, _localctx.Modifiers.ToImmutable());} + +typeModifiers returns [CILParser.TypeModifierValue Value] +@init {_localctx.Value = CILParser.TypeModifierValue.Error;} +: + ARRAY_TYPE_NO_BOUNDS {_localctx.Value = Actions.CreateSzArrayTypeModifier();} # SZArrayModifier + | '[' ']' {_localctx.Value = Actions.CreateSzArrayTypeModifier();} # SZArrayModifier + | arrayBounds = bounds {_localctx.Value = Actions.CreateArrayTypeModifier($arrayBounds.Value);} # ArrayModifier + | REF {_localctx.Value = Actions.CreateByReferenceTypeModifier();} # ByRefModifier + | PTR {_localctx.Value = Actions.CreatePointerTypeModifier();} # PtrModifier + | 'pinned' {_localctx.Value = Actions.CreatePinnedTypeModifier();} # PinnedModifier + | 'modreq' '(' modifierType = typeSpec ')' {_localctx.Value = Actions.CreateCustomTypeModifier($modifierType.Value, true);} # RequiredModifier + | 'modopt' '(' modifierType = typeSpec ')' {_localctx.Value = Actions.CreateCustomTypeModifier($modifierType.Value, false);} # OptionalModifier + | arguments = typeArgs {_localctx.Value = Actions.CreateGenericArgumentsModifier($arguments.Value);} # GenericArgumentsModifier; + +elementType returns [CILParser.ElementTypeValue Value] +@init {_localctx.Value = CILParser.ElementTypeValue.Error;} +: + 'class' classType = className {_localctx.Value = Actions.CreateClassElementType($classType.Value, false);} + | OBJECT {_localctx.Value = Actions.CreateObjectElementType();} + | VALUE 'class' valueClassType = className {_localctx.Value = Actions.CreateClassElementType($valueClassType.Value, true);} + | VALUETYPE valueType = className {_localctx.Value = Actions.CreateClassElementType($valueType.Value, true);} + | 'method' convention = callConv returnType = type PTR arguments = sigArgs + {_localctx.Value = Actions.CreateFunctionPointerElementType($convention.Value, $returnType.Value, $arguments.Value);} + | METHOD_TYPE_PARAMETER parameterIndex = int32 {_localctx.Value = Actions.CreateIndexedGenericParameterElementType(true, $parameterIndex.start);} + | TYPE_PARAMETER parameterIndex = int32 {_localctx.Value = Actions.CreateIndexedGenericParameterElementType(false, $parameterIndex.start);} + | METHOD_TYPE_PARAMETER parameterName = dottedName {_localctx.Value = Actions.CreateNamedGenericParameterElementType(_localctx.Start, true, $parameterName.Value);} + | TYPE_PARAMETER parameterName = dottedName {_localctx.Value = Actions.CreateNamedGenericParameterElementType(_localctx.Start, false, $parameterName.Value);} + | TYPEDREF {_localctx.Value = Actions.CreateTypedReferenceElementType();} + | VOID {_localctx.Value = Actions.CreateVoidElementType();} + | signedNative = nativeInt {_localctx.Value = Actions.CreatePrimitiveElementType($signedNative.Value);} + | unsignedNative = nativeUint {_localctx.Value = Actions.CreatePrimitiveElementType($unsignedNative.Value);} + | primitive = simpleType {_localctx.Value = Actions.CreatePrimitiveElementType($primitive.Value);} + | alias = dottedName {_localctx.Value = Actions.CreateTypedefElementType(_localctx.Start, $alias.Value);} /* typedef */ + | ELLIPSIS sentinelType = type {_localctx.Value = Actions.CreateSentinelElementType($sentinelType.Value);}; + +simpleType returns [byte Value]: + value = CHAR {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = STRING {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = BOOL {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = INT8 {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = INT16 {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = INT32_ {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = INT64_ {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = FLOAT32 {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = FLOAT64_ {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = UINT8 {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = UINT16 {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = UINT32 {_localctx.Value = Actions.GetSimpleType($value, false);} + | value = UINT64 {_localctx.Value = Actions.GetSimpleType($value, false);} + | 'unsigned' value = INT8 {_localctx.Value = Actions.GetSimpleType($value, true);} + | 'unsigned' value = INT16 {_localctx.Value = Actions.GetSimpleType($value, true);} + | 'unsigned' value = INT32_ {_localctx.Value = Actions.GetSimpleType($value, true);} + | 'unsigned' value = INT64_ {_localctx.Value = Actions.GetSimpleType($value, true);}; + +bound returns [int Lower, int Upper, bool HasLower, bool HasUpper] +@init {Actions.InitializeBound(_localctx);} +: + /* EMPTY */ | ELLIPSIS - | int32 - | int32 ELLIPSIS int32 - | int32 ELLIPSIS; + | size = int32 {Actions.SetBoundSize(_localctx, $size.start);} + | lower = int32 ELLIPSIS upper = int32 {Actions.SetBoundRange(_localctx, $lower.start, $upper.start);} + | lower = int32 ELLIPSIS {Actions.SetBoundLower(_localctx, $lower.start);} +; /* Parser rules for multi-word type tokens that need whitespace handling */ -nativeInt: 'native' INT; -nativeUint: 'native' ('unsigned' INT | UINT); - -/* Security declarations */ -PERMISSION: '.permission'; -PERMISSIONSET: '.permissionset'; - -secDecl: - PERMISSION secAction typeSpec '(' nameValPairs ')' - | PERMISSION secAction typeSpec '=' '{' customBlobDescr '}' - | PERMISSION secAction typeSpec - | PERMISSIONSET secAction '=' 'bytearray'? '(' bytes ')' - | PERMISSIONSET secAction 'bytearray' '(' bytes ')' - | PERMISSIONSET secAction compQstring - | PERMISSIONSET secAction '=' '{' secAttrSetBlob '}'; - -secAttrSetBlob: | (secAttrBlob ',')* secAttrBlob; - -secAttrBlob: - 'class' SQSTRING '=' '{' customBlobNVPairs '}' - | typeSpec '=' '{' customBlobNVPairs '}'; - -nameValPairs: (nameValPair ',')* nameValPair; +nativeInt returns [byte Value]: + 'native' INT {_localctx.Value = Actions.GetNativeIntType();}; -nameValPair: compQstring '=' caValue; +nativeUint returns [byte Value]: + 'native' ('unsigned' INT | UINT) {_localctx.Value = Actions.GetNativeUIntType();}; -truefalse: 'true' | 'false'; - -caValue: - truefalse - | int32 - | INT32_ '(' int32 ')' - | compQstring - | className '(' INT8 ':' int32 ')' - | className '(' INT16 ':' int32 ')' - | className '(' INT32_ ':' int32 ')' - | className '(' int32 ')'; - -secAction: +/* Security declarations */ +secDecl returns [CILParser.SecurityDeclarationValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + PERMISSION action = secAction permissionType = typeSpec '(' pairs = nameValPairs ')' + {_localctx.Value = Actions.CreateNamedPermissionDeclaration( + $action.Value, + $permissionType.Value, + $pairs.Value);} + | PERMISSION action = secAction permissionType = typeSpec '=' '{' structuredValue = customBlobDescr '}' + {_localctx.Value = Actions.CreateStructuredPermissionDeclaration( + $action.Value, + $permissionType.Value, + $structuredValue.Value);} + | PERMISSION action = secAction permissionType = typeSpec + {_localctx.Value = Actions.CreateEmptyPermissionDeclaration($action.Value, $permissionType.Value);} + | PERMISSIONSET action = secAction '=' 'bytearray'? '(' rawValue = bytes ')' + {_localctx.Value = Actions.CreateRawPermissionSetDeclaration($action.Value, $rawValue.Value);} + | PERMISSIONSET action = secAction 'bytearray' '(' rawValue = bytes ')' + {_localctx.Value = Actions.CreateRawPermissionSetDeclaration($action.Value, $rawValue.Value);} + | PERMISSIONSET action = secAction textValue = compQstring + {_localctx.Value = Actions.CreateStringPermissionSetDeclaration($action.Value, $textValue.Value);} + | PERMISSIONSET action = secAction '=' '{' attributes = secAttrSetBlob '}' + {_localctx.Value = Actions.CreateAttributePermissionSetDeclaration($action.Value, $attributes.Value);}; +finally {Actions.EndSecurityDeclaration(_localctx, _localctx.InitialSyntaxErrorCount);} + +secAttrSetBlob returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + /* EMPTY */ + | (attribute = secAttrBlob {_localctx.Builder.Add($attribute.Value);} ',')* + tail = secAttrBlob {_localctx.Builder.Add($tail.Value);} +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +secAttrBlob returns [CILParser.SecurityAttributeValue Value] +@init {_localctx.Value = CILParser.SecurityAttributeValue.Error;} +: + 'class' name = SQSTRING '=' '{' arguments = customBlobNVPairs '}' + {_localctx.Value = Actions.CreateNamedSecurityAttribute($name, $arguments.Value);} + | securityType = typeSpec '=' '{' arguments = customBlobNVPairs '}' + {_localctx.Value = Actions.CreateTypedSecurityAttribute($securityType.Value, $arguments.Value);}; + +nameValPairs returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (pair = nameValPair {_localctx.Builder.Add($pair.Value);} ',')* + tail = nameValPair {_localctx.Builder.Add($tail.Value);} +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +nameValPair returns [CILParser.SecurityNameValuePairValue Value] +@init {_localctx.Value = CILParser.SecurityNameValuePairValue.Error;} +: + name = compQstring '=' value = caValue + {_localctx.Value = Actions.CreateSecurityNameValuePair($name.Value, $value.Value);}; + +truefalse returns [bool Value] +@after {_localctx.Value = Actions.ParseBoolean(_localctx.Start);} +: + 'true' + | 'false'; + +caValue returns [CILParser.SecurityCaValue Value] +@init {_localctx.Value = CILParser.SecurityCaValue.Error;} +: + booleanValue = truefalse {_localctx.Value = Actions.CreateSecurityBooleanValue($booleanValue.Value);} + | integerValue = int32 {_localctx.Value = Actions.CreateSecurityInt32Value($integerValue.start);} + | INT32_ '(' integerValue = int32 ')' {_localctx.Value = Actions.CreateSecurityInt32Value($integerValue.start);} + | textValue = compQstring {_localctx.Value = Actions.CreateSecurityStringValue($textValue.Value);} + | enumType = className '(' kind = INT8 ':' enumValue = int32 ')' + {_localctx.Value = Actions.CreateSecurityEnumValue($enumType.Value, $kind, $enumValue.start);} + | enumType = className '(' kind = INT16 ':' enumValue = int32 ')' + {_localctx.Value = Actions.CreateSecurityEnumValue($enumType.Value, $kind, $enumValue.start);} + | enumType = className '(' kind = INT32_ ':' enumValue = int32 ')' + {_localctx.Value = Actions.CreateSecurityEnumValue($enumType.Value, $kind, $enumValue.start);} + | enumType = className '(' enumValue = int32 ')' + {_localctx.Value = Actions.CreateSecurityEnumValue($enumType.Value, $enumValue.start);}; + +secAction returns [System.Reflection.DeclarativeSecurityAction Value] +@after {_localctx.Value = Actions.ParseSecurityAction(_localctx.Start);} +: 'request' | 'demand' | 'assert' @@ -966,238 +1479,532 @@ secAction: | 'noncasinheritance'; /* Method referencing */ -methodRef: - callConv type typeSpec '::' methodName typeArgs? sigArgs - | callConv type typeSpec '::' methodName genArityNotEmpty sigArgs - | callConv type methodName typeArgs? sigArgs - | callConv type methodName genArityNotEmpty sigArgs - | mdtoken - | dottedName /* typeDef */; - -callConv: - INSTANCE callConv - | EXPLICIT callConv - | callKind - | 'callconv' '(' int32 ')'; - -callKind: +methodRef +returns [CILParser.MethodReferenceValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.MethodReferenceValue.Error; +} +: + convention = callConv returnType = type owner = typeSpec '::' name = methodName genericArguments = typeArgs? arguments = sigArgs + {_localctx.Value = Actions.CreateMethodReference(_localctx.Start, $convention.Value, $returnType.Value, $owner.Value, $name.Value, $genericArguments.ctx is null ? null : $genericArguments.Value, null, $arguments.Value);} + | convention = callConv returnType = type owner = typeSpec '::' name = methodName genericArity = genArityNotEmpty arguments = sigArgs + {_localctx.Value = Actions.CreateMethodReference(_localctx.Start, $convention.Value, $returnType.Value, $owner.Value, $name.Value, null, $genericArity.Value, $arguments.Value);} + | convention = callConv returnType = type name = methodName genericArguments = typeArgs? arguments = sigArgs + {_localctx.Value = Actions.CreateMethodReference(_localctx.Start, $convention.Value, $returnType.Value, null, $name.Value, $genericArguments.ctx is null ? null : $genericArguments.Value, null, $arguments.Value);} + | convention = callConv returnType = type name = methodName genericArity = genArityNotEmpty arguments = sigArgs + {_localctx.Value = Actions.CreateMethodReference(_localctx.Start, $convention.Value, $returnType.Value, null, $name.Value, null, $genericArity.Value, $arguments.Value);} + | token = mdtoken {_localctx.Value = Actions.CreateTokenMethodReference($token.Value);} + | alias = dottedName {_localctx.Value = Actions.CreateTypedefMethodReference(_localctx.Start, $alias.Value);} /* typeDef */ +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} + +callConv returns [byte Value]: + INSTANCE inner = callConv {_localctx.Value = Actions.AddInstanceCallingConvention($inner.Value);} + | EXPLICIT inner = callConv {_localctx.Value = Actions.AddExplicitCallingConvention($inner.Value);} + | kind = callKind {_localctx.Value = $kind.Value;} + | 'callconv' '(' raw = int32 ')' {_localctx.Value = Actions.GetRawCallingConvention($raw.start);}; + +callKind returns [byte Value] +@init {_localctx.Value = Actions.GetDefaultCallingConvention();} +: /* EMPTY */ - | DEFAULT - | VARARG - | UNMANAGED CDECL - | UNMANAGED STDCALL - | UNMANAGED THISCALL - | UNMANAGED FASTCALL - | UNMANAGED; - -mdtoken: 'mdtoken' '(' int32 ')'; - -memberRef: - 'method' methodRef - | 'field' fieldRef - | mdtoken; - -fieldRef: - type typeSpec '::' dottedName - | type dottedName - | dottedName // typedef - ; + | kind = DEFAULT {_localctx.Value = Actions.GetCallingConvention($kind);} + | kind = VARARG {_localctx.Value = Actions.GetCallingConvention($kind);} + | UNMANAGED kind = CDECL {_localctx.Value = Actions.GetCallingConvention($kind);} + | UNMANAGED kind = STDCALL {_localctx.Value = Actions.GetCallingConvention($kind);} + | UNMANAGED kind = THISCALL {_localctx.Value = Actions.GetCallingConvention($kind);} + | UNMANAGED kind = FASTCALL {_localctx.Value = Actions.GetCallingConvention($kind);} + | kind = UNMANAGED {_localctx.Value = Actions.GetCallingConvention($kind);} +; + +mdtoken +returns [int Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + 'mdtoken' '(' token = int32 ')' {_localctx.Value = Actions.ParseInt32($token.start);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} + +memberRef returns [CILParser.MemberReferenceValue Value] +@init {_localctx.Value = CILParser.MemberReferenceValue.Error;} +: + 'method' method = methodRef {_localctx.Value = Actions.CreateMethodMemberReference($method.Value);} + | 'field' field = fieldRef {_localctx.Value = Actions.CreateFieldMemberReference($field.Value);} + | token = mdtoken {_localctx.Value = Actions.CreateTokenMemberReference($token.Value);}; + +fieldRef +returns [CILParser.FieldReferenceValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.FieldReferenceValue.Error; +} +: + fieldType = type owner = typeSpec '::' name = dottedName + {_localctx.Value = Actions.CreateFieldReference($fieldType.Value, $owner.Value, $name.Value);} + | fieldType = type name = dottedName + {_localctx.Value = Actions.CreateFieldReference($fieldType.Value, null, $name.Value);} + | alias = dottedName {_localctx.Value = Actions.CreateTypedefFieldReference(_localctx.Start, $alias.Value);} // typedef +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} /* Generic type parameters declaration */ -typeList: (typeSpec ',')* typeSpec; - -typarsClause: /* EMPTY */ | '<' typars '>'; - -typarAttrib: - covariant = PLUS - | contravariant = '-' - | class = 'class' - | valuetype = VALUETYPE - | byrefLike = 'byreflike' - | ctor = '.ctor' - | 'flags' '(' flags = int32 ')'; - -typarAttribs: typarAttrib*; - -typar: typarAttribs tyBound? dottedName; - -typars: (typar ',')* typar; - -tyBound: '(' typeList ')'; - -genArity: /* EMPTY */ | genArityNotEmpty; - -genArityNotEmpty: '<' '[' int32 ']' '>'; +typeList returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (item = typeSpec {_localctx.Builder.Add($item.Value);} ',')* + tail = typeSpec {_localctx.Builder.Add($tail.Value);} +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +typarsClause returns [System.Collections.Immutable.ImmutableArray Value] +@init {_localctx.Value = System.Collections.Immutable.ImmutableArray.Empty;} +: + /* EMPTY */ + | '<' parameters = typars '>' {_localctx.Value = $parameters.Value;} +; + +typarAttrib returns [CILParser.AttributeValue Value] +@init {_localctx.Value = CILParser.AttributeValue.Empty;} +: + covariant = PLUS {_localctx.Value = Actions.CreateGenericParameterAttribute($covariant);} + | contravariant = '-' {_localctx.Value = Actions.CreateGenericParameterAttribute($contravariant);} + | class = 'class' {_localctx.Value = Actions.CreateGenericParameterAttribute($class);} + | valuetype = VALUETYPE {_localctx.Value = Actions.CreateGenericParameterAttribute($valuetype);} + | byrefLike = 'byreflike' {_localctx.Value = Actions.CreateGenericParameterAttribute($byrefLike);} + | ctor = '.ctor' {_localctx.Value = Actions.CreateGenericParameterAttribute($ctor);} + | 'flags' '(' flags = int32 ')' {_localctx.Value = Actions.CreateRawGenericParameterAttribute($flags.start);}; + +typarAttribs returns [System.Reflection.GenericParameterAttributes Value] +@init {_localctx.Value = 0;} +: + (attribute = typarAttrib + {_localctx.Value = Actions.AddGenericParameterAttribute(_localctx.Value, $attribute.Value);})* +; + +typar returns [CILParser.GenericParameterDeclarationValue Value] +@init {_localctx.Value = CILParser.GenericParameterDeclarationValue.Error;} +: + attributes = typarAttribs constraints = tyBound? name = dottedName + {_localctx.Value = Actions.CreateGenericParameterDeclaration($attributes.Value, $constraints.ctx, $name.Value);}; + +typars returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (parameter = typar {_localctx.Builder.Add($parameter.Value);} ',')* + tail = typar {_localctx.Builder.Add($tail.Value);} +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +tyBound returns [System.Collections.Immutable.ImmutableArray Value] +@init {_localctx.Value = System.Collections.Immutable.ImmutableArray.Empty;} +: + '(' constraints = typeList ')' {_localctx.Value = $constraints.Value;}; + +genArity returns [int Value]: + value = genArityNotEmpty? {_localctx.Value = Actions.GetGenericArity($value.ctx);}; + +genArityNotEmpty returns [int Value]: + '<' '[' value = int32 ']' '>' {_localctx.Value = Actions.ParseInt32($value.start);}; /* Class body declarations */ -classDecl: +classDecl +locals [ + CILParser.PropertyBodyValue PropertyBody, + CILParser.EventBodyValue EventBody, + CILParser.CustomAttributeOwnerValue AttributeOwner +] +: methodHead '{' methodDecls '}' | classHead '{' classDecls '}' - | eventHead '{' eventDecls '}' - | propHead '{' propDecls '}' + | eventHeader = eventHead {_localctx.EventBody = Actions.BeginEvent($eventHeader.Value);} + '{' eventDecls[_localctx.EventBody] '}' + | property = propHead {_localctx.PropertyBody = Actions.BeginProperty($property.Value);} + '{' propDecls[_localctx.PropertyBody] '}' | fieldDecl - | dataDecl - | secDecl - | extSourceSpec - | customAttrDecl - | '.size' int32 - | '.pack' int32 - | exportHead '{' exptypeDecls '}' - | OVERRIDE typeSpec '::' methodName 'with' callConv type typeSpec '::' methodName sigArgs - | OVERRIDE 'method' callConv type typeSpec '::' methodName genArity sigArgs 'with' 'method' - callConv type typeSpec '::' methodName genArity sigArgs - | languageDecl - | compControl - | PARAM TYPE '[' int32 ']' customAttrDecl* - | PARAM TYPE dottedName customAttrDecl* - | PARAM CONSTRAINT '[' int32 ']' ',' typeSpec customAttrDecl* - | PARAM CONSTRAINT dottedName ',' typeSpec customAttrDecl* - | '.interfaceimpl' TYPE typeSpec customDescr; + | data = dataDecl {Actions.ProcessClassDataDeclaration($data.ctx);} + | security = secDecl {Actions.ProcessClassSecurityDeclaration($security.ctx);} + | source = extSourceSpec {Actions.ProcessClassSourceDirective($source.ctx);} + | attribute = customAttrDecl {Actions.ProcessClassCustomAttribute($attribute.ctx);} + | '.size' size = int32 {Actions.SetClassSize($size.start);} + | '.pack' packing = int32 {Actions.SetClassPackingSize($packing.start);} + | export = exportHead '{' exportDeclarations = exptypeDecls '}' + {Actions.ProcessClassExport($export.ctx, $exportDeclarations.ctx);} + | OVERRIDE declarationOwner = typeSpec '::' declarationName = methodName 'with' + bodyConvention = callConv bodyReturnType = type bodyOwner = typeSpec '::' + bodyName = methodName bodyArguments = sigArgs + {Actions.AddClassMethodOverride( + _localctx, + $declarationOwner.Value, + $declarationName.Value, + $bodyConvention.Value, + $bodyReturnType.Value, + $bodyOwner.Value, + $bodyName.Value, + $bodyArguments.Value);} + | OVERRIDE 'method' + declarationConvention = callConv declarationReturnType = type declarationOwner = typeSpec '::' + declarationName = methodName declarationArity = genArity declarationArguments = sigArgs + 'with' 'method' + bodyConvention = callConv bodyReturnType = type bodyOwner = typeSpec '::' + bodyName = methodName bodyArity = genArity bodyArguments = sigArgs + {Actions.AddClassMethodOverride( + _localctx, + $declarationConvention.Value, + $declarationReturnType.Value, + $declarationOwner.Value, + $declarationName.Value, + $declarationArity.Value, + $declarationArguments.Value, + $bodyConvention.Value, + $bodyReturnType.Value, + $bodyOwner.Value, + $bodyName.Value, + $bodyArity.Value, + $bodyArguments.Value);} + | language = languageDecl {Actions.ProcessClassLanguageDirective($language.ctx);} + | compControl {Actions.ProcessClassCompilerControl();} + | PARAM TYPE '[' parameterIndex = int32 ']' + {_localctx.AttributeOwner = Actions.BeginClassGenericParameterDirective(_localctx, $parameterIndex.start);} + (attribute = customAttrDecl {Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, $attribute.ctx);})* + | PARAM TYPE parameterName = dottedName + {_localctx.AttributeOwner = Actions.BeginClassGenericParameterDirective($parameterName.Value);} + (attribute = customAttrDecl {Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, $attribute.ctx);})* + | PARAM CONSTRAINT '[' parameterIndex = int32 ']' ',' constraintType = typeSpec + {_localctx.AttributeOwner = Actions.BeginClassGenericConstraintDirective(_localctx, $parameterIndex.start, $constraintType.Value);} + (attribute = customAttrDecl {Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, $attribute.ctx);})* + | PARAM CONSTRAINT parameterName = dottedName ',' constraintType = typeSpec + {_localctx.AttributeOwner = Actions.BeginClassGenericConstraintDirective($parameterName.Value, $constraintType.Value);} + (attribute = customAttrDecl {Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, $attribute.ctx);})* + | '.interfaceimpl' TYPE interfaceType = typeSpec interfaceAttribute = customDescr + {Actions.AddInterfaceImplementationAttribute(_localctx, $interfaceType.Value, $interfaceAttribute.ctx);} +; +finally {Actions.EndClassDeclaration(_localctx);} /* Field declaration */ -fieldDecl: - '.field' repeatOpt (fieldAttr | 'marshal' '(' marshalBlob ')')* type dottedName atOpt initOpt; - -fieldAttr: - 'static' - | 'public' - | 'private' - | 'family' - | 'initonly' - | 'rtspecialname' - | 'specialname' - | 'assembly' - | 'famandassem' - | 'famorassem' - | 'privatescope' - | 'literal' - | 'notserialized' - | 'volatile' - | 'flags' '(' int32 ')'; - -atOpt: /* EMPTY */ | 'at' id | 'at' int32; - -initOpt: /* EMPTY */ | '=' fieldInit; - -repeatOpt: /* EMPTY */ | '[' int32 ']'; +fieldDecl returns [CILParser.FieldDeclarationValue Value] +locals [int InitialSyntaxErrorCount, CILParser.FieldDeclarationBuilder Builder] +@init { + _localctx.Builder = Actions.PrepareFieldDeclaration(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.FieldDeclarationValue.Error; +} +@after {Actions.DefineField(_localctx, _localctx.Value);} +: + '.field' offset = repeatOpt + ( + attribute = fieldAttr {Actions.AddFieldAttribute(_localctx.Builder, $attribute.Value);} + | 'marshal' '(' marshalling = marshalBlob ')' {Actions.SetFieldMarshalling(_localctx.Builder, $marshalling.Value);} + )* + fieldType = type name = dottedName data = atOpt initializer = initOpt + {_localctx.Value = Actions.CreateFieldDeclaration( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + $offset.ctx, + $fieldType.Value, + $name.Value, + $data.Value, + $initializer.Value);} +; + +fieldAttr returns [CILParser.AttributeValue Value] +@init {_localctx.Value = CILParser.AttributeValue.Empty;} +: + attribute = 'static' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'public' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'private' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'family' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'initonly' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'rtspecialname' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'specialname' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'assembly' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'famandassem' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'famorassem' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'privatescope' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'literal' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'notserialized' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | attribute = 'volatile' {_localctx.Value = Actions.CreateFieldAttribute($attribute);} + | 'flags' '(' flags = int32 ')' {_localctx.Value = Actions.CreateRawFieldAttribute($flags.start);}; + +atOpt returns [string? Value] +@init {_localctx.Value = null;} +: + /* EMPTY */ + | 'at' name = id {_localctx.Value = Actions.GetFieldDataName($name.start);} + | 'at' offset = int32 {_localctx.Value = Actions.GetFieldDataOffset($offset.start);}; + +initOpt returns [CILParser.FieldInitializerValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.FieldInitializerValue.Empty; +} +: + /* EMPTY */ + | '=' initializer = fieldInit {_localctx.Value = $initializer.Value;} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} + +repeatOpt returns [int Value, bool HasValue]: + /* EMPTY */ + | '[' offset = int32 ']' {Actions.SetFieldOffset(_localctx, $offset.start);}; /* Event declaration */ -eventHead: - '.event' eventAttr* typeSpec dottedName - | '.event' eventAttr* dottedName; - -eventAttr: - 'rtspecialname' - | 'specialname'; - -eventDecls: eventDecl*; - -eventDecl: - '.addon' methodRef - | '.removeon' methodRef - | '.fire' methodRef - | '.other' methodRef - | extSourceSpec - | customAttrDecl - | languageDecl +eventHead returns [CILParser.EventHeaderValue Value] +locals [int InitialSyntaxErrorCount, CILParser.EventHeaderBuilder Builder] +@init { + _localctx.Builder = new CILParser.EventHeaderBuilder(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.EventHeaderValue.Error; +} +: + '.event' + (attribute = eventAttr {Actions.AddEventAttribute(_localctx.Builder, $attribute.Value);})* + eventType = typeSpec name = dottedName + {_localctx.Value = Actions.CreateEventHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + $eventType.Value, + $name.Value);} + | '.event' + (attribute = eventAttr {Actions.AddEventAttribute(_localctx.Builder, $attribute.Value);})* + name = dottedName + {_localctx.Value = Actions.CreateEventHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + null, + $name.Value);} +; + +eventAttr returns [CILParser.AttributeValue Value] +@init {_localctx.Value = CILParser.AttributeValue.Empty;} +: + attribute = 'rtspecialname' {_localctx.Value = Actions.CreateEventAttribute($attribute);} + | attribute = 'specialname' {_localctx.Value = Actions.CreateEventAttribute($attribute);}; + +eventDecls [CILParser.EventBodyValue Body]: eventDecl[$Body]*; + +eventDecl [CILParser.EventBodyValue Body]: + '.addon' accessor = methodRef {Actions.AddEventAdder($Body, $accessor.Value);} + | '.removeon' accessor = methodRef {Actions.AddEventRemover($Body, $accessor.Value);} + | '.fire' accessor = methodRef {Actions.AddEventRaiser($Body, $accessor.Value);} + | '.other' accessor = methodRef {Actions.AddEventOther($Body, $accessor.Value);} + | source = extSourceSpec {Actions.ProcessEventSourceDirective($Body, $source.ctx);} + | attribute = customAttrDecl {Actions.AddEventCustomAttribute($Body, $attribute.ctx);} + | language = languageDecl {Actions.ProcessEventLanguageDirective($Body, $language.ctx);} | compControl; /* Property declaration */ -propHead: - '.property' propAttr* callConv type dottedName sigArgs initOpt; - -propAttr: - 'rtspecialname' - | 'specialname'; - -propDecls: propDecl*; - -propDecl: - '.set' methodRef - | '.get' methodRef - | '.other' methodRef - | customAttrDecl - | extSourceSpec - | languageDecl +propHead returns [CILParser.PropertyHeaderValue Value] +locals [int InitialSyntaxErrorCount, CILParser.PropertyHeaderBuilder Builder] +@init { + _localctx.Builder = new CILParser.PropertyHeaderBuilder(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.PropertyHeaderValue.Error; +} +: + '.property' + (attribute = propAttr {Actions.AddPropertyAttribute(_localctx.Builder, $attribute.Value);})* + convention = callConv propertyType = type name = dottedName arguments = sigArgs initializer = initOpt + {_localctx.Value = Actions.CreatePropertyHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + $convention.Value, + $propertyType.Value, + $name.Value, + $arguments.Value, + $initializer.Value);} +; + +propAttr returns [CILParser.AttributeValue Value] +@init {_localctx.Value = CILParser.AttributeValue.Empty;} +: + attribute = 'rtspecialname' {_localctx.Value = Actions.CreatePropertyAttribute($attribute);} + | attribute = 'specialname' {_localctx.Value = Actions.CreatePropertyAttribute($attribute);}; + +propDecls [CILParser.PropertyBodyValue Body]: propDecl[$Body]*; + +propDecl [CILParser.PropertyBodyValue Body]: + '.set' accessor = methodRef {Actions.AddPropertySetter($Body, $accessor.Value);} + | '.get' accessor = methodRef {Actions.AddPropertyGetter($Body, $accessor.Value);} + | '.other' accessor = methodRef {Actions.AddPropertyOther($Body, $accessor.Value);} + | attribute = customAttrDecl {Actions.AddPropertyCustomAttribute($Body, $attribute.ctx);} + | source = extSourceSpec {Actions.ProcessPropertySourceDirective($Body, $source.ctx);} + | language = languageDecl {Actions.ProcessPropertyLanguageDirective($Body, $language.ctx);} | compControl; /* Method declaration */ -marshalClause: /* EMPTY */ | 'marshal' '(' marshalBlob ')'; - -marshalBlob: nativeType | '{' hexbyte+ '}'; - -paramAttr: paramAttrElement*; - -paramAttrElement: - '[' in = 'in' ']' - | '[' out = 'out' ']' - | '[' opt = 'opt' ']' - | '[' int32 ']'; - -methodHead: - '.method' (methAttr | pinvImpl)* callConv paramAttr type marshalClause methodName typarsClause sigArgs - implAttr*; - -methAttr: 'static' - | 'public' - | 'private' - | 'family' - | 'final' - | 'specialname' - | 'virtual' - | 'strict' - | 'abstract' - | 'assembly' - | 'famandassem' - | 'famorassem' - | 'privatescope' - | 'hidebysig' - | 'newslot' - | 'rtspecialname' - | 'unmanagedexp' - | 'reqsecobj' - | 'flags' '(' int32 ')'; - -pinvImpl: 'pinvokeimpl' '(' (compQstring ('as' compQstring)?)? pinvAttr* ')' | 'pinvokeimpl' '()'; - -pinvAttr: - 'nomangle' - | 'ansi' - | 'unicode' - | 'autochar' - | 'lasterr' - | 'winapi' - | 'cdecl' - | 'stdcall' - | 'thiscall' - | 'fastcall' - | 'bestfit' ':' 'on' - | 'bestfit' ':' 'off' - | 'charmaperror' ':' 'on' - | 'charmaperror' ':' 'off' - | 'flags' '(' int32 ')'; - -methodName: '.ctor' | '.cctor' | dottedName; - -implAttr: - 'native' - | 'cil' - | 'il' - | 'optil' - | 'managed' - | 'unmanaged' - | 'forwardref' - | 'preservesig' - | 'runtime' - | 'internalcall' - | 'synchronized' - | 'noinlining' - | 'aggressiveinlining' - | 'nooptimization' - | 'aggressiveoptimization' - | 'async' - | 'flags' '(' int32 ')'; +marshalClause returns [CILParser.MarshallingDescriptorValue Value] +@init {_localctx.Value = CILParser.MarshallingDescriptorValue.Empty;} +: + /* EMPTY */ {_localctx.Value = Actions.CreateEmptyMarshallingDescriptor();} + | 'marshal' '(' value = marshalBlob ')' {_localctx.Value = Actions.CompleteMarshalClause($value.Value);} +; + +marshalBlob returns [CILParser.MarshallingDescriptorValue Value] +locals [CILParser.MarshalBlobBuilder Builder] +@init {_localctx.Builder = new CILParser.MarshalBlobBuilder();} +: + nativeValue = nativeType {Actions.SetMarshalBlobNativeType(_localctx.Builder, $nativeValue.Value);} + | '{' (rawByte = hexbyte {Actions.AddMarshalBlobByte(_localctx.Builder, $rawByte.Value);})+ '}' +; +finally {_localctx.Value = Actions.CreateMarshallingDescriptor(_localctx.Builder);} + +paramAttr returns [int Value] +@init {_localctx.Value = 0;} +: + (element = paramAttrElement + {_localctx.Value = Actions.AddParameterAttribute( + _localctx.Value, + $element.Value, + $element.ShouldAppend);})* +; + +paramAttrElement returns [int Value, bool ShouldAppend]: + '[' attribute = 'in' ']' {Actions.SetParameterAttributeElement(_localctx, $attribute);} + | '[' attribute = 'out' ']' {Actions.SetParameterAttributeElement(_localctx, $attribute);} + | '[' attribute = 'opt' ']' {Actions.SetParameterAttributeElement(_localctx, $attribute);} + | '[' raw = int32 ']' {Actions.SetRawParameterAttributeElement(_localctx, $raw.start);}; + +methodHead +returns [CILParser.MethodHeaderValue Value] +locals [int InitialSyntaxErrorCount, CILParser.MethodHeaderBuilder Builder] +@init { + _localctx.Builder = Actions.PrepareMethodHeader(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.MethodHeaderValue.Error; +} +@after {Actions.BeginMethod(_localctx, _localctx.Value);} +: + '.method' + ( + attribute = methAttr {Actions.AddMethodAttribute(_localctx.Builder, $attribute.Value);} + | pInvoke = pinvImpl {Actions.AddPInvoke(_localctx.Builder, $pInvoke.Value);} + )* + convention = callConv returnAttributes = paramAttr returnType = type returnMarshalling = marshalClause + name = methodName genericParameters = typarsClause arguments = sigArgs + (implementation = implAttr {Actions.AddMethodImplementationAttribute(_localctx.Builder, $implementation.Value);})* + {_localctx.Value = Actions.CreateMethodHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + $convention.Value, + $returnAttributes.Value, + $returnType.Value, + $returnMarshalling.Value, + $name.Value, + $genericParameters.Value, + $arguments.Value);} +; + +methAttr returns [CILParser.AttributeValue Value] +@init {_localctx.Value = CILParser.AttributeValue.Empty;} +: + attribute = 'static' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'public' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'private' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'family' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'final' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'specialname' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'virtual' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'strict' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'abstract' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'assembly' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'famandassem' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'famorassem' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'privatescope' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'hidebysig' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'newslot' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'rtspecialname' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'unmanagedexp' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | attribute = 'reqsecobj' {_localctx.Value = Actions.CreateMethodAttribute($attribute);} + | 'flags' '(' flags = int32 ')' {_localctx.Value = Actions.CreateRawMethodAttribute($flags.start);}; + +pinvImpl returns [CILParser.PInvokeValue Value] +locals [CILParser.PInvokeBuilder Builder] +@init {_localctx.Builder = new CILParser.PInvokeBuilder();} +: + 'pinvokeimpl' '(' + (module = compQstring {Actions.SetPInvokeModule(_localctx.Builder, $module.Value);} + ('as' entryPoint = compQstring {Actions.SetPInvokeEntryPoint(_localctx.Builder, $entryPoint.Value);})?)? + (attribute = pinvAttr {Actions.AddPInvokeAttribute(_localctx.Builder, $attribute.Value);})* + ')' + | 'pinvokeimpl' '()' +; +finally {_localctx.Value = Actions.CreatePInvoke(_localctx.Builder);} + +pinvAttr returns [CILParser.AttributeValue Value] +@init {_localctx.Value = CILParser.AttributeValue.Empty;} +: + attribute = 'nomangle' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'ansi' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'unicode' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'autochar' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'lasterr' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'winapi' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'cdecl' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'stdcall' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'thiscall' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | attribute = 'fastcall' {_localctx.Value = Actions.CreatePInvokeAttribute($attribute);} + | 'bestfit' ':' setting = 'on' {_localctx.Value = Actions.CreateBestFitPInvokeAttribute($setting);} + | 'bestfit' ':' setting = 'off' {_localctx.Value = Actions.CreateBestFitPInvokeAttribute($setting);} + | 'charmaperror' ':' setting = 'on' {_localctx.Value = Actions.CreateCharMapErrorPInvokeAttribute($setting);} + | 'charmaperror' ':' setting = 'off' {_localctx.Value = Actions.CreateCharMapErrorPInvokeAttribute($setting);} + | 'flags' '(' flags = int32 ')' {_localctx.Value = Actions.CreateRawPInvokeAttribute($flags.start);}; + +methodName returns [string Value] +@init {_localctx.Value = string.Empty;} +: + ctorName = '.ctor' {_localctx.Value = Actions.GetMethodName($ctorName);} + | cctorName = '.cctor' {_localctx.Value = Actions.GetMethodName($cctorName);} + | dotted = dottedName {_localctx.Value = $dotted.Value;}; + +implAttr returns [CILParser.AttributeValue Value] +@init {_localctx.Value = CILParser.AttributeValue.Empty;} +: + attribute = 'native' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'cil' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'il' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'optil' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'managed' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'unmanaged' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'forwardref' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'preservesig' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'runtime' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'internalcall' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'synchronized' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'noinlining' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'aggressiveinlining' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'nooptimization' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'aggressiveoptimization' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | attribute = 'async' {_localctx.Value = Actions.CreateMethodImplementationAttribute($attribute);} + | 'flags' '(' flags = int32 ')' {_localctx.Value = Actions.CreateRawMethodImplementationAttribute($flags.start);}; EMITBYTE: '.emitbyte'; MAXSTACK: '.maxstack'; @@ -1208,209 +2015,565 @@ EXPORT: '.export'; OVERRIDE: '.override'; VTENTRY: '.vtentry'; -methodDecls: methodDecl*; +methodDecls +: + methodDecl* +; methodDecl: - instr // MOVED TO TOP - instructions must be matched first! - | EMITBYTE int32 + instr + | EMITBYTE value = int32 {Actions.EmitByte($value.start);} | sehBlock - | MAXSTACK int32 - | LOCALS sigArgs - | LOCALS 'init' sigArgs - | ENTRYPOINT - | ZEROINIT - | dataDecl + | MAXSTACK value = int32 {Actions.SetMaxStack($value.start);} + | ENTRYPOINT {Actions.SetEntryPoint();} + | ZEROINIT {Actions.SetZeroInit();} | labelDecl - | secDecl - | extSourceSpec - | languageDecl - | customDescrInMethodBody // Only customDescr and customDescrWithOwner, NOT bare typedefs - | compControl - | EXPORT '[' int32 ']' - | EXPORT '[' int32 ']' 'as' id - | VTENTRY int32 ':' int32 - | OVERRIDE typeSpec '::' methodName - | OVERRIDE 'method' callConv type typeSpec '::' methodName genArity sigArgs | scopeBlock - | PARAM TYPE '[' int32 ']' customAttrDecl* - | PARAM TYPE dottedName customAttrDecl* - | PARAM CONSTRAINT '[' int32 ']' ',' typeSpec customAttrDecl* - | PARAM CONSTRAINT dottedName ',' typeSpec customAttrDecl* - | PARAM '[' int32 ']' initOpt customAttrDecl*; - -labelDecl: id ':'; - -customDescrInMethodBody: - customDescr - | customDescrWithOwner; - -scopeBlock: '{' methodDecls '}'; + | localsDecl + | declaration = dataDecl {Actions.ProcessMethodDataDeclaration($declaration.ctx);} + | security = secDecl {Actions.ProcessMethodSecurityDeclaration($security.ctx);} + | source = extSourceSpec {Actions.ProcessMethodSourceDirective($source.ctx);} + | language = languageDecl {Actions.ProcessMethodLanguageDirective($language.ctx);} + | attribute = customDescrInMethodBody {Actions.ProcessMethodCustomAttribute($attribute.ctx);} + | compControl + | exportDecl + | vtentryDecl + | overrideDecl + | parameterDecl +; + +localsDecl +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + LOCALS initialize = 'init'? arguments = sigArgs +; +finally {Actions.EndLocalsDirective(_localctx, _localctx.InitialSyntaxErrorCount);} + +exportDecl +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + EXPORT '[' ordinal = int32 ']' ('as' alias = id)? +; +finally {Actions.EndExportDirective(_localctx, _localctx.InitialSyntaxErrorCount);} + +vtentryDecl +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + VTENTRY table = int32 ':' slot = int32 +; +finally {Actions.EndVTableEntryDirective(_localctx, _localctx.InitialSyntaxErrorCount);} + +overrideDecl +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + OVERRIDE owner = typeSpec '::' name = methodName + | OVERRIDE 'method' convention = callConv returnType = type owner = typeSpec '::' name = methodName + arity = genArity arguments = sigArgs +; +finally {Actions.EndOverrideDirective(_localctx, _localctx.InitialSyntaxErrorCount);} + +parameterDecl +locals [ + int InitialSyntaxErrorCount, + System.Collections.Immutable.ImmutableArray.Builder Attributes +] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Attributes = System.Collections.Immutable.ImmutableArray.CreateBuilder(); +} +: + PARAM TYPE '[' genericIndex = int32 ']' (attribute = customAttrDecl {Actions.AddCustomAttributeApplication(_localctx.Attributes, $attribute.ctx);})* + | PARAM TYPE genericName = dottedName (attribute = customAttrDecl {Actions.AddCustomAttributeApplication(_localctx.Attributes, $attribute.ctx);})* + | PARAM CONSTRAINT '[' constraintIndex = int32 ']' ',' constraintType = typeSpec + (attribute = customAttrDecl {Actions.AddCustomAttributeApplication(_localctx.Attributes, $attribute.ctx);})* + | PARAM CONSTRAINT constraintName = dottedName ',' constraintType = typeSpec + (attribute = customAttrDecl {Actions.AddCustomAttributeApplication(_localctx.Attributes, $attribute.ctx);})* + | PARAM '[' parameterIndex = int32 ']' initializer = initOpt + (attribute = customAttrDecl {Actions.AddCustomAttributeApplication(_localctx.Attributes, $attribute.ctx);})* +; +finally {Actions.EndParameterDirective( + _localctx, + _localctx.Attributes.ToImmutable(), + _localctx.InitialSyntaxErrorCount);} + +labelDecl: + name = id ':' {Actions.DefineLabel($name.start);}; + +customDescrInMethodBody returns [CILParser.CustomAttributeDeclarationValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDeclarationValue.Error; +} +: + directAttribute = customDescr {_localctx.Value = Actions.CreateCustomAttributeDeclaration($directAttribute.Value);} + | ownedAttribute = customDescrWithOwner {_localctx.Value = Actions.CreateCustomAttributeDeclaration($ownedAttribute.Value);}; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} + +scopeBlock +@init {Actions.BeginScope(_localctx);} +: + '{' methodDecls '}' +; +finally {Actions.EndScope(_localctx);} /* Structured exception handling directives */ -sehBlock: tryBlock sehClauses; - -sehClauses: sehClause+; - -tryBlock: - '.try' scopeBlock - | '.try' id 'to' id - | '.try' int32 'to' int32; - -sehClause: - catchClause handlerBlock - | filterClause handlerBlock - | finallyClause handlerBlock - | faultClause handlerBlock; - -filterClause: - 'filter' scopeBlock - | 'filter' id - | 'filter' int32; - -catchClause: 'catch' typeSpec; +sehBlock +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + tryRange = tryBlock clauses = sehClauses +; +finally {Actions.EndExceptionBlock(_localctx, _localctx.InitialSyntaxErrorCount);} + +sehClauses returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (clause = sehClause {_localctx.Builder.Add($clause.Value);})+ +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +tryBlock returns [CILParser.ExceptionRangeValue Value] +@init {_localctx.Value = CILParser.ExceptionRangeValue.Invalid;} +: + '.try' body = scopeBlock {_localctx.Value = Actions.CreateScopeExceptionRange($body.ctx);} + | '.try' startLabel = id 'to' endLabel = id + {_localctx.Value = Actions.CreateLabelExceptionRange($startLabel.start, $endLabel.start);} + | '.try' startOffset = int32 'to' endOffset = int32 + {_localctx.Value = Actions.CreateOffsetExceptionRange($startOffset.start, $endOffset.start);}; + +sehClause returns [CILParser.ExceptionClauseValue Value] +@init {_localctx.Value = CILParser.ExceptionClauseValue.Invalid;} +: + caught = catchClause handler = handlerBlock + {_localctx.Value = Actions.CreateCatchExceptionClause($caught.Value, $handler.Value);} + | filtered = filterClause handler = handlerBlock + {_localctx.Value = Actions.CreateFilterExceptionClause($filtered.Value, $handler.Value);} + | finallyClause handler = handlerBlock + {_localctx.Value = Actions.CreateFinallyExceptionClause($handler.Value);} + | faultClause handler = handlerBlock + {_localctx.Value = Actions.CreateFaultExceptionClause($handler.Value);}; + +filterClause returns [CILParser.ExceptionFilterValue Value] +@init {_localctx.Value = CILParser.ExceptionFilterValue.Invalid;} +: + 'filter' body = scopeBlock {_localctx.Value = Actions.CreateScopeFilter($body.ctx);} + | 'filter' label = id {_localctx.Value = Actions.CreateLabelFilter($label.start);} + | 'filter' offset = int32 {_localctx.Value = Actions.CreateOffsetFilter($offset.start);}; + +catchClause +returns [CILParser.CatchTypeValue Value] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CatchTypeValue.Invalid; +} +: + 'catch' catchType = typeSpec +; +finally {_localctx.Value = Actions.EndCatchClause(_localctx, _localctx.InitialSyntaxErrorCount);} finallyClause: 'finally'; faultClause: 'fault'; -handlerBlock: - scopeBlock - | 'handler' id 'to' id - | 'handler' int32 'to' int32; +handlerBlock returns [CILParser.ExceptionRangeValue Value] +@init {_localctx.Value = CILParser.ExceptionRangeValue.Invalid;} +: + body = scopeBlock {_localctx.Value = Actions.CreateScopeExceptionRange($body.ctx);} + | 'handler' startLabel = id 'to' endLabel = id + {_localctx.Value = Actions.CreateLabelExceptionRange($startLabel.start, $endLabel.start);} + | 'handler' startOffset = int32 'to' endOffset = int32 + {_localctx.Value = Actions.CreateOffsetExceptionRange($startOffset.start, $endOffset.start);}; /* Data declaration */ -dataDecl: ddHead ddBody; - -ddHead: '.data' tls id '=' | '.data' tls; - -tls: /* EMPTY */ | 'tls' | 'cil'; - -ddBody: '{' ddItemList '}' | ddItem+; +dataDecl returns [bool HasSyntaxError] +locals [int InitialSyntaxErrorCount, CILParser.DataDeclarationBuilder Builder] +@init { + _localctx.Builder = Actions.CreateDataDeclaration(_localctx); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; +} +: + ddHead[_localctx.Builder] ddBody[_localctx.Builder] +; +finally {Actions.EndDataDeclaration(_localctx, _localctx.Builder, _localctx.InitialSyntaxErrorCount);} + +ddHead [CILParser.DataDeclarationBuilder Builder]: + '.data' section = tls name = id '=' + {Actions.SetDataDeclarationHeader($Builder, $section.Value, $name.start);} + | '.data' section = tls + {Actions.SetAnonymousDataDeclarationHeader($Builder, $section.Value);}; + +tls returns [byte Value] +@init {_localctx.Value = Actions.GetMappedDataSection();} +: + /* EMPTY */ + | 'tls' {_localctx.Value = Actions.GetTlsDataSection();} + | 'cil' {_localctx.Value = Actions.GetCilDataSection();}; -ddItemList: (ddItem ',')* ddItem; +ddBody [CILParser.DataDeclarationBuilder Builder]: + '{' ddItemList[$Builder] '}' | ddItem[$Builder]+; -ddItemCount: /* EMPTY */ | '[' int32 ']'; +ddItemList [CILParser.DataDeclarationBuilder Builder]: + (ddItem[$Builder] ',')* ddItem[$Builder]; -ddItem: - CHAR PTR '(' compQstring ')' - | REF '(' id ')' - | REF id - | 'bytearray' '(' bytes ')' - | FLOAT32 '(' float64 ')' ddItemCount - | FLOAT64_ '(' float64 ')' ddItemCount - | INT64_ '(' int64 ')' ddItemCount - | INT32_ '(' int32 ')' ddItemCount - | INT16 '(' int32 ')' ddItemCount - | INT8 '(' int32 ')' ddItemCount - | FLOAT32 ddItemCount - | FLOAT64_ ddItemCount - | INT64_ ddItemCount - | INT32_ ddItemCount - | INT16 ddItemCount - | INT8 ddItemCount; +ddItemCount returns [int Value] +@init {_localctx.Value = 1;} +: + /* EMPTY */ + | '[' count = int32 ']' {_localctx.Value = Actions.ParseDataItemCount($count.start);}; + +ddItem [CILParser.DataDeclarationBuilder Builder]: + CHAR PTR '(' stringValue = compQstring ')' {Actions.AddDataString($Builder, $stringValue.Value);} + | REF '(' target = id ')' {Actions.AddDataReference($Builder, $target.start);} + | REF target = id {Actions.AddDataReference($Builder, $target.start);} + | 'bytearray' '(' byteValue = bytes ')' {Actions.AddDataBytes($Builder, $byteValue.Value);} + | kind = (FLOAT32 | FLOAT64_) '(' floatingValue = float64 ')' count = ddItemCount + {Actions.AddFloatingPointData($Builder, $kind, $floatingValue.Value, $count.Value);} + | kind = INT64_ '(' int64Value = int64 ')' count = ddItemCount + {Actions.AddInt64Data($Builder, $kind, $int64Value.start, $count.Value);} + | kind = (INT32_ | INT16 | INT8) '(' integerValue = int32 ')' count = ddItemCount + {Actions.AddIntegerData($Builder, $kind, $integerValue.start, $count.Value);} + | kind = (FLOAT32 | FLOAT64_ | INT64_ | INT32_ | INT16 | INT8) count = ddItemCount + {Actions.AddZeroData($Builder, $kind, $count.Value);}; /* Default values declaration for fields, parameters and verbal form of CA blob description */ -fieldSerInit: - FLOAT32 '(' float64 ')' - | FLOAT64_ '(' float64 ')' - | FLOAT32 '(' int32 ')' - | FLOAT64_ '(' int64 ')' - | INT64_ '(' int64 ')' - | INT32_ '(' int32 ')' - | INT16 '(' int32 ')' - | INT8 '(' int32 ')' - | UINT64 '(' int64 ')' - | UINT32 '(' int32 ')' - | UINT16 '(' int32 ')' - | UINT8 '(' int32 ')' - | CHAR '(' int32 ')' - | BOOL '(' truefalse ')' - | 'bytearray' '(' bytes ')'; - -bytes: hexbyte*; - -hexbyte: INT32 | ID | HEXBYTE; +fieldSerInit returns [System.Reflection.Metadata.BlobBuilder Value]: + FLOAT32 '(' float32Value = float64 ')' + {_localctx.Value = Actions.CreateFloat32SerializedInitializer($float32Value.ctx, $float32Value.Value);} + | FLOAT64_ '(' float64Value = float64 ')' + {_localctx.Value = Actions.CreateFloat64SerializedInitializer($float64Value.ctx, $float64Value.Value);} + | FLOAT32 '(' float32Bits = int32 ')' + {_localctx.Value = Actions.CreateFloat32BitsSerializedInitializer($float32Bits.start);} + | FLOAT64_ '(' float64Bits = int64 ')' + {_localctx.Value = Actions.CreateFloat64BitsSerializedInitializer($float64Bits.start);} + | int64Type = INT64_ '(' int64Value = int64 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($int64Type, $int64Value.start);} + | int32Type = INT32_ '(' int32Value = int32 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($int32Type, $int32Value.start);} + | int16Type = INT16 '(' int16Value = int32 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($int16Type, $int16Value.start);} + | int8Type = INT8 '(' int8Value = int32 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($int8Type, $int8Value.start);} + | uint64Type = UINT64 '(' uint64Value = int64 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($uint64Type, $uint64Value.start);} + | uint32Type = UINT32 '(' uint32Value = int32 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($uint32Type, $uint32Value.start);} + | uint16Type = UINT16 '(' uint16Value = int32 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($uint16Type, $uint16Value.start);} + | uint8Type = UINT8 '(' uint8Value = int32 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($uint8Type, $uint8Value.start);} + | charType = CHAR '(' charValue = int32 ')' + {_localctx.Value = Actions.CreateIntegerSerializedInitializer($charType, $charValue.start);} + | boolType = BOOL '(' boolValue = truefalse ')' + {_localctx.Value = Actions.CreateBooleanSerializedInitializer($boolType, $boolValue.Value);} + | 'bytearray' '(' byteArrayValue = bytes ')' + {_localctx.Value = Actions.CreateByteArraySerializedInitializer($byteArrayValue.Value);}; +finally {_localctx.Value ??= new System.Reflection.Metadata.BlobBuilder();} + +bytes +returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = Actions.CreateByteAccumulator();} +: + (b = hexbyte {Actions.AddByte(_localctx.Builder, $b.Value);})* +; +finally {_localctx.Value = Actions.EndBytes(_localctx.Builder);} + +hexbyte +returns [byte Value] +@after {_localctx.Value = GrammarActions.ParseHexbyte(_localctx.Start);} +: + INT32 + | ID + | HEXBYTE +; /* Field/parameter initialization */ -fieldInit: fieldSerInit | compQstring | NULLREF; +fieldInit returns [CILParser.FieldInitializerValue Value] +@init {_localctx.Value = CILParser.FieldInitializerValue.Empty;} +: + serializedValue = fieldSerInit {_localctx.Value = Actions.CreateFieldInitializer($serializedValue.Value);} + | stringValue = compQstring {_localctx.Value = Actions.CreateFieldInitializer($stringValue.Value);} + | NULLREF {_localctx.Value = Actions.CreateNullFieldInitializer();}; /* Values for verbal form of CA blob description */ -serInit: - fieldSerInit - | STRING '(' NULLREF ')' - | STRING '(' SQSTRING ')' - | TYPE '(' 'class' SQSTRING ')' - | TYPE '(' className ')' - | TYPE '(' NULLREF ')' - | OBJECT '(' serInit ')' - | FLOAT32 '[' int32 ']' '(' f32seq ')' - | FLOAT64_ '[' int32 ']' '(' f64seq ')' - | INT64_ '[' int32 ']' '(' i64seq ')' - | INT32_ '[' int32 ']' '(' i32seq ')' - | INT16 '[' int32 ']' '(' i16seq ')' - | INT8 '[' int32 ']' '(' i8seq ')' - | UINT64 '[' int32 ']' '(' i64seq ')' - | UINT32 '[' int32 ']' '(' i32seq ')' - | UINT16 '[' int32 ']' '(' i16seq ')' - | UINT8 '[' int32 ']' '(' i8seq ')' - | CHAR '[' int32 ']' '(' i16seq ')' - | BOOL '[' int32 ']' '(' boolSeq ')' - | STRING '[' int32 ']' '(' sqstringSeq ')' - | TYPE '[' int32 ']' '(' classSeq ')' - | OBJECT '[' int32 ']' '(' objSeq ')'; - -f32seq: (float64 | int32)*; - -f64seq: (float64 | int64)*; - -i64seq: int64*; - -i32seq: int32*; - -i16seq: int32*; - -i8seq: int32*; - -boolSeq: truefalse*; - -sqstringSeq: (NULLREF | SQSTRING)*; - -classSeq: classSeqElement*; - -classSeqElement: NULLREF | 'class' SQSTRING | className; - -objSeq: serInit*; - -customAttrDecl: - customDescr - | customDescrWithOwner - | dottedName /* typedef */; +serInit returns [CILParser.SerializedInitializerValue Value] +@init {_localctx.Value = CILParser.SerializedInitializerValue.Error;} +: + scalarValue = fieldSerInit + {_localctx.Value = Actions.CreateScalarSerializedValue(_localctx, $scalarValue.ctx, $scalarValue.Value);} + | STRING '(' NULLREF ')' {_localctx.Value = Actions.CreateStringSerializedValue();} + | STRING '(' stringToken = SQSTRING ')' {_localctx.Value = Actions.CreateStringSerializedValue($stringToken);} + | TYPE '(' 'class' typeToken = SQSTRING ')' {_localctx.Value = Actions.CreateTypeSerializedValue($typeToken);} + | TYPE '(' typeName = className ')' {_localctx.Value = Actions.CreateTypeSerializedValue($typeName.Value);} + | TYPE '(' NULLREF ')' {_localctx.Value = Actions.CreateNullTypeSerializedValue();} + | OBJECT '(' objectValue = serInit ')' {_localctx.Value = Actions.CreateObjectSerializedValue($objectValue.Value);} + | f32ElementToken = FLOAT32 '[' f32Length = int32 ']' '(' f32Values = f32seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($f32ElementToken, $f32Length.start, $f32Values.Value);} + | f64ElementToken = FLOAT64_ '[' f64Length = int32 ']' '(' f64Values = f64seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($f64ElementToken, $f64Length.start, $f64Values.Value);} + | i64ElementToken = INT64_ '[' i64Length = int32 ']' '(' i64Values = i64seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($i64ElementToken, $i64Length.start, $i64Values.Value);} + | i32ElementToken = INT32_ '[' i32Length = int32 ']' '(' i32Values = i32seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($i32ElementToken, $i32Length.start, $i32Values.Value);} + | i16ElementToken = INT16 '[' i16Length = int32 ']' '(' i16Values = i16seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($i16ElementToken, $i16Length.start, $i16Values.Value);} + | i8ElementToken = INT8 '[' i8Length = int32 ']' '(' i8Values = i8seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($i8ElementToken, $i8Length.start, $i8Values.Value);} + | u64ElementToken = UINT64 '[' u64Length = int32 ']' '(' u64Values = i64seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($u64ElementToken, $u64Length.start, $u64Values.Value);} + | u32ElementToken = UINT32 '[' u32Length = int32 ']' '(' u32Values = i32seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($u32ElementToken, $u32Length.start, $u32Values.Value);} + | u16ElementToken = UINT16 '[' u16Length = int32 ']' '(' u16Values = i16seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($u16ElementToken, $u16Length.start, $u16Values.Value);} + | u8ElementToken = UINT8 '[' u8Length = int32 ']' '(' u8Values = i8seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($u8ElementToken, $u8Length.start, $u8Values.Value);} + | charElementToken = CHAR '[' charLength = int32 ']' '(' charValues = i16seq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($charElementToken, $charLength.start, $charValues.Value);} + | boolElementToken = BOOL '[' boolLength = int32 ']' '(' boolValues = boolSeq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($boolElementToken, $boolLength.start, $boolValues.Value);} + | stringElementToken = STRING '[' stringLength = int32 ']' '(' stringValues = sqstringSeq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($stringElementToken, $stringLength.start, $stringValues.Value);} + | typeElementToken = TYPE '[' typeLength = int32 ']' '(' typeValues = classSeq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($typeElementToken, $typeLength.start, $typeValues.Value);} + | objectElementToken = OBJECT '[' objectLength = int32 ']' '(' objectValues = objSeq ')' + {_localctx.Value = Actions.CreateArraySerializedValue($objectElementToken, $objectLength.start, $objectValues.Value);}; + +f32seq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (floatingValue = float64 {Actions.AddFloat32SequenceValue(_localctx.Builder, $floatingValue.Value);} + | integerValue = int32 {Actions.AddFloat32SequenceValue(_localctx.Builder, $integerValue.start);})* +; +finally {_localctx.Value = _localctx.Builder;} + +f64seq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (floatingValue = float64 {Actions.AddFloat64SequenceValue(_localctx.Builder, $floatingValue.Value);} + | integerValue = int64 {Actions.AddFloat64SequenceValue(_localctx.Builder, $integerValue.start);})* +; +finally {_localctx.Value = _localctx.Builder;} + +i64seq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (value = int64 {Actions.AddInt64SequenceValue(_localctx.Builder, $value.start);})* +; +finally {_localctx.Value = _localctx.Builder;} + +i32seq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (value = int32 {Actions.AddInt32SequenceValue(_localctx.Builder, $value.start);})* +; +finally {_localctx.Value = _localctx.Builder;} + +i16seq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (value = int32 {Actions.AddInt16SequenceValue(_localctx.Builder, $value.start);})* +; +finally {_localctx.Value = _localctx.Builder;} + +i8seq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (value = int32 {Actions.AddInt8SequenceValue(_localctx.Builder, $value.start);})* +; +finally {_localctx.Value = _localctx.Builder;} + +boolSeq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (value = truefalse {Actions.AddBooleanSequenceValue(_localctx.Builder, $value.Value);})* +; +finally {_localctx.Value = _localctx.Builder;} + +sqstringSeq returns [System.Reflection.Metadata.BlobBuilder Value] +locals [System.Reflection.Metadata.BlobBuilder Builder] +@init {_localctx.Builder = new System.Reflection.Metadata.BlobBuilder();} +: + (nullValue = NULLREF {Actions.AddStringSequenceValue(_localctx.Builder, $nullValue);} + | stringValue = SQSTRING {Actions.AddStringSequenceValue(_localctx.Builder, $stringValue);})* +; +finally {_localctx.Value = _localctx.Builder;} + +classSeq returns [CILParser.SerializedSequenceValue Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (value = classSeqElement {_localctx.Builder.Add($value.Value);})* +; +finally {_localctx.Value = new CILParser.ClassSerializedSequenceValue(_localctx.Builder.ToImmutable());} + +classSeqElement returns [CILParser.ClassSequenceElementValue Value] +@init {_localctx.Value = CILParser.ClassSequenceElementValue.Error;} +: + NULLREF {_localctx.Value = Actions.CreateNullClassSequenceValue();} + | 'class' quotedValue = SQSTRING {_localctx.Value = Actions.CreateQuotedClassSequenceValue($quotedValue);} + | typeValue = className {_localctx.Value = Actions.CreateClassSequenceValue($typeValue.Value);}; + +objSeq returns [CILParser.SerializedSequenceValue Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (value = serInit {_localctx.Builder.Add($value.Value);})* +; +finally {_localctx.Value = new CILParser.ObjectSerializedSequenceValue(_localctx.Builder.ToImmutable());} + +customAttrDecl returns [CILParser.CustomAttributeDeclarationValue Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init { + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDeclarationValue.Error; +} +: + directAttribute = customDescr {_localctx.Value = Actions.CreateCustomAttributeDeclaration($directAttribute.Value);} + | ownedAttribute = customDescrWithOwner {_localctx.Value = Actions.CreateCustomAttributeDeclaration($ownedAttribute.Value);} + | alias = dottedName {_localctx.Value = Actions.CreateCustomAttributeTypedef($alias.Value);}; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; +} /* Assembly References */ -asmOrRefDecl: - ('.publickey' | '.publicKey') '=' '(' bytes ')' - | '.ver' intOrWildcard ':' intOrWildcard ':' intOrWildcard ':' intOrWildcard - | '.locale' compQstring - | '.locale' '=' '(' bytes ')' - | customAttrDecl +asmOrRefDecl returns [CILParser.AssemblyDeclarationValue? Value]: + ('.publickey' | '.publicKey') '=' '(' key = bytes ')' + {_localctx.Value = Actions.CreateAssemblyPublicKeyDeclaration($key.Value);} + | '.ver' major = intOrWildcard ':' minor = intOrWildcard ':' build = intOrWildcard ':' revision = intOrWildcard + {_localctx.Value = Actions.CreateAssemblyVersionDeclaration( + $major.Value, + $minor.Value, + $build.Value, + $revision.Value);} + | '.locale' locale = compQstring + {_localctx.Value = Actions.CreateAssemblyLocaleDeclaration($locale.Value);} + | '.locale' '=' '(' localeBytes = bytes ')' + {_localctx.Value = Actions.CreateAssemblyLocaleDeclaration($localeBytes.Value);} + | attribute = customAttrDecl + {_localctx.Value = Actions.CreateAssemblyCustomAttributeDeclaration( + $attribute.Value, + $attribute.start);} | compControl; -assemblyRefHead: - '.assembly' 'extern' asmAttr dottedName - | '.assembly' 'extern' asmAttr dottedName 'as' dottedName; - -assemblyRefDecls: assemblyRefDecl*; - -assemblyRefDecl: - '.hash' '=' '(' bytes ')' - | asmOrRefDecl - | '.publickeytoken' '=' '(' bytes ')' - | 'auto'; - -exptypeHead: '.class' 'extern' exptAttr* dottedName; - -exportHead: '.export' exptAttr* dottedName; - -exptAttr: +assemblyRefBlock returns [CILParser.AssemblyReferenceValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + header = assemblyRefHead '{' declarations = assemblyRefDecls '}' + {_localctx.Value = Actions.CreateAssemblyReference( + $header.Value, + $declarations.Value);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } +} + +assemblyRefHead returns [CILParser.AssemblyReferenceHeaderValue Value] +@init {_localctx.Value = CILParser.AssemblyReferenceHeaderValue.Error;} +: + '.assembly' 'extern' attributes = asmAttr name = dottedName + {_localctx.Value = Actions.CreateAssemblyReferenceHeader( + $attributes.Value, + $name.Value, + $name.Value);} + | '.assembly' 'extern' attributes = asmAttr name = dottedName 'as' alias = dottedName + {_localctx.Value = Actions.CreateAssemblyReferenceHeader( + $attributes.Value, + $name.Value, + $alias.Value);}; + +assemblyRefDecls returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (declaration = assemblyRefDecl + {if ($declaration.Value is not null) _localctx.Builder.Add($declaration.Value);})* +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +assemblyRefDecl returns [CILParser.AssemblyDeclarationValue? Value]: + '.hash' '=' '(' hash = bytes ')' + {_localctx.Value = Actions.CreateAssemblyReferenceHashDeclaration($hash.Value);} + | shared = asmOrRefDecl {_localctx.Value = $shared.Value;} + | '.publickeytoken' '=' '(' token = bytes ')' + {_localctx.Value = Actions.CreateAssemblyReferencePublicKeyTokenDeclaration($token.Value);} + | 'auto' {_localctx.Value = Actions.CreateAssemblyReferenceAutoDeclaration();}; + +exptypeBlock returns [CILParser.ExportedTypeValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + header = exptypeHead '{' declarations = exptypeDecls '}' + {_localctx.Value = Actions.CreateExportedType( + $header.Value, + $declarations.Value);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } +} + +exptypeHead returns [CILParser.ExportedTypeHeaderValue Value] +@init {_localctx.Value = CILParser.ExportedTypeHeaderValue.Error;} +: + head = '.class' 'extern' attributes = exptAttrs name = dottedName + {_localctx.Value = Actions.CreateExportedTypeHeader( + $attributes.Value, + $name.Value, + $head);}; + +exportHead returns [CILParser.ExportedTypeHeaderValue Value] +@init {_localctx.Value = CILParser.ExportedTypeHeaderValue.Error;} +: + head = '.export' attributes = exptAttrs name = dottedName + {_localctx.Value = Actions.CreateExportedTypeHeader( + $attributes.Value, + $name.Value, + $head);}; + +exptAttrs returns [System.Reflection.TypeAttributes Value] +@init {_localctx.Value = 0;} +: + (attribute = exptAttr + {_localctx.Value = Actions.AddExportedTypeAttribute( + _localctx.Value, + $attribute.Value, + $attribute.Mask);})* +; + +exptAttr returns [System.Reflection.TypeAttributes Value, System.Reflection.TypeAttributes Mask] +@after {Actions.SetExportedTypeAttribute(_localctx);} +: 'private' | 'public' | 'forwarder' @@ -1421,27 +2584,110 @@ exptAttr: | 'nested' 'famandassem' | 'nested' 'famorassem'; -exptypeDecls: exptypeDecl*; - -exptypeDecl: - '.file' dottedName - | '.class' 'extern' slashedName - | '.assembly' 'extern' dottedName - | mdtoken - | '.class' int32 - | customAttrDecl +exptypeDecls returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (declaration = exptypeDecl + {if ($declaration.Value is not null) _localctx.Builder.Add($declaration.Value);})* +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +exptypeDecl returns [CILParser.ExportedTypeDeclarationValue? Value]: + location = '.file' name = dottedName + {_localctx.Value = Actions.CreateExportedTypeFileDeclaration( + $name.Value, + $location);} + | location = '.class' 'extern' nestedName = slashedName + {_localctx.Value = Actions.CreateNestedExportedTypeDeclaration( + $nestedName.Value, + $location);} + | location = '.assembly' 'extern' assemblyName = dottedName + {_localctx.Value = Actions.CreateExportedTypeAssemblyDeclaration( + $assemblyName.Value, + $location);} + | token = mdtoken + {_localctx.Value = Actions.CreateExportedTypeMetadataTokenDeclaration( + $token.Value, + $token.start);} + | '.class' typeDefinitionId = int32 + {_localctx.Value = Actions.CreateExportedTypeDefinitionIdDeclaration( + $typeDefinitionId.start);} + | attribute = customAttrDecl + {_localctx.Value = Actions.CreateExportedTypeCustomAttributeDeclaration( + $attribute.Value, + $attribute.start);} | compControl; -manifestResHead: - MRESOURCE manresAttr* dottedName - | MRESOURCE manresAttr* dottedName 'as' dottedName; - -manresAttr: 'public' | 'private'; - -manifestResDecls: manifestResDecl*; - -manifestResDecl: - '.file' dottedName 'at' int32 - | '.assembly' 'extern' dottedName - | customAttrDecl +manifestResBlock returns [CILParser.ManifestResourceValue? Value, bool HasSyntaxError] +locals [int InitialSyntaxErrorCount] +@init {_localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount;} +: + header = manifestResHead '{' declarations = manifestResDecls '}' + {_localctx.Value = Actions.CreateManifestResource( + $header.Value, + $declarations.Value);} +; +finally { + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } +} + +manifestResHead returns [CILParser.ManifestResourceHeaderValue Value] +@init {_localctx.Value = CILParser.ManifestResourceHeaderValue.Error;} +: + head = MRESOURCE attributes = manresAttrs name = dottedName + {_localctx.Value = Actions.CreateManifestResourceHeader( + $attributes.Value, + $name.Value, + $name.Value, + $head);} + | head = MRESOURCE attributes = manresAttrs name = dottedName 'as' alias = dottedName + {_localctx.Value = Actions.CreateManifestResourceHeader( + $attributes.Value, + $name.Value, + $alias.Value, + $head);}; + +manresAttrs returns [System.Reflection.ManifestResourceAttributes Value] +@init {_localctx.Value = 0;} +: + (attribute = manresAttr + {_localctx.Value = Actions.AddManifestResourceAttribute( + _localctx.Value, + $attribute.Value);})* +; + +manresAttr returns [System.Reflection.ManifestResourceAttributes Value] +@after {_localctx.Value = Actions.ParseManifestResourceAttribute(_localctx.Start);} +: + 'public' + | 'private'; + +manifestResDecls returns [System.Collections.Immutable.ImmutableArray Value] +locals [System.Collections.Immutable.ImmutableArray.Builder Builder] +@init {_localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder();} +: + (declaration = manifestResDecl + {if ($declaration.Value is not null) _localctx.Builder.Add($declaration.Value);})* +; +finally {_localctx.Value = _localctx.Builder.ToImmutable();} + +manifestResDecl returns [CILParser.ManifestResourceDeclarationValue? Value]: + location = '.file' name = dottedName 'at' offset = int32 + {_localctx.Value = Actions.CreateManifestResourceFileDeclaration( + $name.Value, + $offset.start, + $location);} + | '.assembly' 'extern' name = dottedName + {_localctx.Value = Actions.CreateManifestResourceAssemblyDeclaration($name.Value);} + | attribute = customAttrDecl + {_localctx.Value = Actions.CreateManifestResourceCustomAttributeDeclaration( + $attribute.Value, + $attribute.start);} | compControl; diff --git a/src/tools/ilasm/src/ILAssembler/gen/CIL.interp b/src/tools/ilasm/src/ILAssembler/gen/CIL.interp index efb796a93425a6..d188d340c27b70 100644 --- a/src/tools/ilasm/src/ILAssembler/gen/CIL.interp +++ b/src/tools/ilasm/src/ILAssembler/gen/CIL.interp @@ -650,6 +650,7 @@ serializTypeElement moduleHead vtfixupDecl vtfixupAttr +vtfixupAttrElement vtableDecl nameSpaceHead classHead @@ -665,20 +666,9 @@ fileAttr fileEntry asmAttrAny asmAttr -instr_none -instr_var -instr_i -instr_i8 -instr_r -instr_brtarget -instr_method -instr_field -instr_type -instr_string -instr_sig -instr_tok -instr_switch instr +simpleInstr +calliSignature labels typeArgs bounds @@ -751,6 +741,11 @@ methodName implAttr methodDecls methodDecl +localsDecl +exportDecl +vtentryDecl +overrideDecl +parameterDecl labelDecl customDescrInMethodBody scopeBlock @@ -788,19 +783,24 @@ classSeqElement objSeq customAttrDecl asmOrRefDecl +assemblyRefBlock assemblyRefHead assemblyRefDecls assemblyRefDecl +exptypeBlock exptypeHead exportHead +exptAttrs exptAttr exptypeDecls exptypeDecl +manifestResBlock manifestResHead +manresAttrs manresAttr manifestResDecls manifestResDecl atn: -[4, 1, 305, 2908, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 2, 82, 7, 82, 2, 83, 7, 83, 2, 84, 7, 84, 2, 85, 7, 85, 2, 86, 7, 86, 2, 87, 7, 87, 2, 88, 7, 88, 2, 89, 7, 89, 2, 90, 7, 90, 2, 91, 7, 91, 2, 92, 7, 92, 2, 93, 7, 93, 2, 94, 7, 94, 2, 95, 7, 95, 2, 96, 7, 96, 2, 97, 7, 97, 2, 98, 7, 98, 2, 99, 7, 99, 2, 100, 7, 100, 2, 101, 7, 101, 2, 102, 7, 102, 2, 103, 7, 103, 2, 104, 7, 104, 2, 105, 7, 105, 2, 106, 7, 106, 2, 107, 7, 107, 2, 108, 7, 108, 2, 109, 7, 109, 2, 110, 7, 110, 2, 111, 7, 111, 2, 112, 7, 112, 2, 113, 7, 113, 2, 114, 7, 114, 2, 115, 7, 115, 2, 116, 7, 116, 2, 117, 7, 117, 2, 118, 7, 118, 2, 119, 7, 119, 2, 120, 7, 120, 2, 121, 7, 121, 2, 122, 7, 122, 2, 123, 7, 123, 2, 124, 7, 124, 2, 125, 7, 125, 2, 126, 7, 126, 2, 127, 7, 127, 2, 128, 7, 128, 2, 129, 7, 129, 2, 130, 7, 130, 2, 131, 7, 131, 2, 132, 7, 132, 2, 133, 7, 133, 2, 134, 7, 134, 2, 135, 7, 135, 2, 136, 7, 136, 2, 137, 7, 137, 2, 138, 7, 138, 2, 139, 7, 139, 2, 140, 7, 140, 2, 141, 7, 141, 2, 142, 7, 142, 2, 143, 7, 143, 2, 144, 7, 144, 2, 145, 7, 145, 2, 146, 7, 146, 2, 147, 7, 147, 2, 148, 7, 148, 2, 149, 7, 149, 2, 150, 7, 150, 2, 151, 7, 151, 2, 152, 7, 152, 2, 153, 7, 153, 2, 154, 7, 154, 2, 155, 7, 155, 2, 156, 7, 156, 2, 157, 7, 157, 2, 158, 7, 158, 2, 159, 7, 159, 2, 160, 7, 160, 2, 161, 7, 161, 2, 162, 7, 162, 2, 163, 7, 163, 2, 164, 7, 164, 2, 165, 7, 165, 2, 166, 7, 166, 2, 167, 7, 167, 2, 168, 7, 168, 2, 169, 7, 169, 2, 170, 7, 170, 2, 171, 7, 171, 2, 172, 7, 172, 2, 173, 7, 173, 2, 174, 7, 174, 2, 175, 7, 175, 2, 176, 7, 176, 2, 177, 7, 177, 2, 178, 7, 178, 2, 179, 7, 179, 2, 180, 7, 180, 2, 181, 7, 181, 2, 182, 7, 182, 2, 183, 7, 183, 2, 184, 7, 184, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 377, 8, 1, 10, 1, 12, 1, 380, 9, 1, 1, 1, 1, 1, 3, 1, 384, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 5, 3, 390, 8, 3, 10, 3, 12, 3, 393, 9, 3, 1, 3, 1, 3, 1, 4, 5, 4, 398, 8, 4, 10, 4, 12, 4, 401, 9, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 453, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 494, 8, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 5, 15, 501, 8, 15, 10, 15, 12, 15, 504, 9, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 527, 8, 18, 1, 19, 1, 19, 3, 19, 531, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 549, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 576, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 599, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 635, 8, 23, 1, 24, 1, 24, 1, 25, 1, 25, 3, 25, 641, 8, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 5, 27, 648, 8, 27, 10, 27, 12, 27, 651, 9, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 5, 28, 660, 8, 28, 10, 28, 12, 28, 663, 9, 28, 1, 29, 1, 29, 1, 30, 1, 30, 3, 30, 669, 8, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 3, 31, 680, 8, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 3, 32, 688, 8, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 5, 34, 709, 8, 34, 10, 34, 12, 34, 712, 9, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 5, 37, 725, 8, 37, 10, 37, 12, 37, 728, 9, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 772, 8, 38, 1, 39, 1, 39, 1, 39, 3, 39, 777, 8, 39, 1, 40, 1, 40, 1, 40, 3, 40, 782, 8, 40, 1, 41, 5, 41, 785, 8, 41, 10, 41, 12, 41, 788, 9, 41, 1, 42, 1, 42, 1, 42, 5, 42, 793, 8, 42, 10, 42, 12, 42, 796, 9, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 3, 44, 905, 8, 44, 1, 45, 1, 45, 5, 45, 909, 8, 45, 10, 45, 12, 45, 912, 9, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 5, 45, 925, 8, 45, 10, 45, 12, 45, 928, 9, 45, 1, 45, 1, 45, 1, 45, 3, 45, 933, 8, 45, 1, 46, 1, 46, 1, 47, 1, 47, 3, 47, 939, 8, 47, 1, 48, 1, 48, 1, 49, 5, 49, 944, 8, 49, 10, 49, 12, 49, 947, 9, 49, 1, 50, 1, 50, 1, 51, 1, 51, 1, 52, 1, 52, 1, 53, 1, 53, 1, 54, 1, 54, 1, 55, 1, 55, 1, 56, 1, 56, 1, 57, 1, 57, 1, 58, 1, 58, 1, 59, 1, 59, 1, 60, 1, 60, 1, 61, 1, 61, 1, 62, 1, 62, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 3, 63, 1057, 8, 63, 1, 64, 1, 64, 1, 64, 3, 64, 1062, 8, 64, 1, 64, 1, 64, 5, 64, 1066, 8, 64, 10, 64, 12, 64, 1069, 9, 64, 1, 64, 1, 64, 3, 64, 1073, 8, 64, 3, 64, 1075, 8, 64, 1, 65, 1, 65, 1, 65, 1, 65, 5, 65, 1081, 8, 65, 10, 65, 12, 65, 1084, 9, 65, 1, 65, 1, 65, 1, 65, 1, 66, 1, 66, 1, 66, 1, 66, 5, 66, 1093, 8, 66, 10, 66, 12, 66, 1096, 9, 66, 1, 66, 1, 66, 1, 66, 1, 67, 1, 67, 1, 67, 1, 67, 5, 67, 1105, 8, 67, 10, 67, 12, 67, 1108, 9, 67, 1, 67, 1, 67, 1, 67, 1, 67, 3, 67, 1114, 8, 67, 1, 68, 1, 68, 1, 68, 1, 68, 1, 68, 3, 68, 1121, 8, 68, 3, 68, 1123, 8, 68, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 3, 69, 1150, 8, 69, 1, 70, 1, 70, 1, 70, 5, 70, 1155, 8, 70, 10, 70, 12, 70, 1158, 9, 70, 1, 70, 1, 70, 1, 71, 5, 71, 1163, 8, 71, 10, 71, 12, 71, 1166, 9, 71, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 3, 72, 1173, 8, 72, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 3, 73, 1186, 8, 73, 1, 74, 1, 74, 1, 74, 5, 74, 1191, 8, 74, 10, 74, 12, 74, 1194, 9, 74, 3, 74, 1196, 8, 74, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 1, 75, 3, 75, 1215, 8, 75, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 1, 76, 3, 76, 1309, 8, 76, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 3, 77, 1318, 8, 77, 1, 78, 1, 78, 1, 78, 5, 78, 1323, 8, 78, 10, 78, 12, 78, 1326, 9, 78, 3, 78, 1328, 8, 78, 1, 79, 1, 79, 1, 80, 1, 80, 5, 80, 1334, 8, 80, 10, 80, 12, 80, 1337, 9, 80, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 3, 81, 1357, 8, 81, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 1, 82, 3, 82, 1389, 8, 82, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 3, 83, 1412, 8, 83, 1, 84, 1, 84, 1, 84, 1, 84, 1, 84, 1, 84, 1, 84, 1, 84, 1, 84, 1, 84, 3, 84, 1424, 8, 84, 1, 85, 1, 85, 1, 85, 1, 86, 1, 86, 1, 86, 1, 86, 3, 86, 1433, 8, 86, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 3, 87, 1458, 8, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 3, 87, 1482, 8, 87, 1, 88, 1, 88, 1, 88, 1, 88, 5, 88, 1488, 8, 88, 10, 88, 12, 88, 1491, 9, 88, 1, 88, 3, 88, 1494, 8, 88, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 3, 89, 1509, 8, 89, 1, 90, 1, 90, 1, 90, 5, 90, 1514, 8, 90, 10, 90, 12, 90, 1517, 9, 90, 1, 90, 1, 90, 1, 91, 1, 91, 1, 91, 1, 91, 1, 92, 1, 92, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 3, 93, 1561, 8, 93, 1, 94, 1, 94, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 3, 95, 1571, 8, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 3, 95, 1587, 8, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 1, 95, 3, 95, 1599, 8, 95, 1, 96, 1, 96, 1, 96, 1, 96, 1, 96, 1, 96, 1, 96, 1, 96, 1, 96, 1, 96, 3, 96, 1611, 8, 96, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 3, 97, 1625, 8, 97, 1, 98, 1, 98, 1, 98, 1, 98, 1, 98, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 3, 99, 1637, 8, 99, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 3, 100, 1648, 8, 100, 1, 101, 1, 101, 1, 101, 5, 101, 1653, 8, 101, 10, 101, 12, 101, 1656, 9, 101, 1, 101, 1, 101, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 3, 102, 1665, 8, 102, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 3, 103, 1678, 8, 103, 1, 104, 5, 104, 1681, 8, 104, 10, 104, 12, 104, 1684, 9, 104, 1, 105, 1, 105, 3, 105, 1688, 8, 105, 1, 105, 1, 105, 1, 106, 1, 106, 1, 106, 5, 106, 1695, 8, 106, 10, 106, 12, 106, 1698, 9, 106, 1, 106, 1, 106, 1, 107, 1, 107, 1, 107, 1, 107, 1, 108, 1, 108, 3, 108, 1708, 8, 108, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 5, 110, 1789, 8, 110, 10, 110, 12, 110, 1792, 9, 110, 1, 110, 1, 110, 1, 110, 1, 110, 5, 110, 1798, 8, 110, 10, 110, 12, 110, 1801, 9, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 5, 110, 1811, 8, 110, 10, 110, 12, 110, 1814, 9, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 5, 110, 1822, 8, 110, 10, 110, 12, 110, 1825, 9, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 3, 110, 1832, 8, 110, 1, 111, 1, 111, 1, 111, 1, 111, 1, 111, 1, 111, 1, 111, 1, 111, 5, 111, 1842, 8, 111, 10, 111, 12, 111, 1845, 9, 111, 1, 111, 1, 111, 1, 111, 1, 111, 1, 111, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 1, 112, 3, 112, 1871, 8, 112, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 3, 113, 1878, 8, 113, 1, 114, 1, 114, 1, 114, 3, 114, 1883, 8, 114, 1, 115, 1, 115, 1, 115, 1, 115, 1, 115, 3, 115, 1890, 8, 115, 1, 116, 1, 116, 5, 116, 1894, 8, 116, 10, 116, 12, 116, 1897, 9, 116, 1, 116, 1, 116, 1, 116, 1, 116, 1, 116, 5, 116, 1904, 8, 116, 10, 116, 12, 116, 1907, 9, 116, 1, 116, 3, 116, 1910, 8, 116, 1, 117, 1, 117, 1, 118, 5, 118, 1915, 8, 118, 10, 118, 12, 118, 1918, 9, 118, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 3, 119, 1932, 8, 119, 1, 120, 1, 120, 5, 120, 1936, 8, 120, 10, 120, 12, 120, 1939, 9, 120, 1, 120, 1, 120, 1, 120, 1, 120, 1, 120, 1, 120, 1, 121, 1, 121, 1, 122, 5, 122, 1950, 8, 122, 10, 122, 12, 122, 1953, 9, 122, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 3, 123, 1965, 8, 123, 1, 124, 1, 124, 1, 124, 1, 124, 1, 124, 1, 124, 3, 124, 1973, 8, 124, 1, 125, 1, 125, 1, 125, 4, 125, 1978, 8, 125, 11, 125, 12, 125, 1979, 1, 125, 1, 125, 3, 125, 1984, 8, 125, 1, 126, 5, 126, 1987, 8, 126, 10, 126, 12, 126, 1990, 9, 126, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 3, 127, 2005, 8, 127, 1, 128, 1, 128, 1, 128, 5, 128, 2010, 8, 128, 10, 128, 12, 128, 2013, 9, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 5, 128, 2023, 8, 128, 10, 128, 12, 128, 2026, 9, 128, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 3, 129, 2051, 8, 129, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 3, 130, 2058, 8, 130, 3, 130, 2060, 8, 130, 1, 130, 5, 130, 2063, 8, 130, 10, 130, 12, 130, 2066, 9, 130, 1, 130, 1, 130, 1, 130, 3, 130, 2071, 8, 130, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 1, 131, 3, 131, 2100, 8, 131, 1, 132, 1, 132, 1, 132, 3, 132, 2105, 8, 132, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 1, 133, 3, 133, 2128, 8, 133, 1, 134, 5, 134, 2131, 8, 134, 10, 134, 12, 134, 2134, 9, 134, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 5, 135, 2195, 8, 135, 10, 135, 12, 135, 2198, 9, 135, 1, 135, 1, 135, 1, 135, 1, 135, 5, 135, 2204, 8, 135, 10, 135, 12, 135, 2207, 9, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 5, 135, 2217, 8, 135, 10, 135, 12, 135, 2220, 9, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 5, 135, 2228, 8, 135, 10, 135, 12, 135, 2231, 9, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 1, 135, 5, 135, 2239, 8, 135, 10, 135, 12, 135, 2242, 9, 135, 3, 135, 2244, 8, 135, 1, 136, 1, 136, 1, 136, 1, 137, 1, 137, 3, 137, 2251, 8, 137, 1, 138, 1, 138, 1, 138, 1, 138, 1, 139, 1, 139, 1, 139, 1, 140, 4, 140, 2261, 8, 140, 11, 140, 12, 140, 2262, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 1, 141, 3, 141, 2277, 8, 141, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 3, 142, 2291, 8, 142, 1, 143, 1, 143, 1, 143, 1, 143, 1, 143, 1, 143, 3, 143, 2299, 8, 143, 1, 144, 1, 144, 1, 144, 1, 145, 1, 145, 1, 146, 1, 146, 1, 147, 1, 147, 1, 147, 1, 147, 1, 147, 1, 147, 1, 147, 1, 147, 1, 147, 1, 147, 1, 147, 3, 147, 2319, 8, 147, 1, 148, 1, 148, 1, 148, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 3, 149, 2331, 8, 149, 1, 150, 1, 150, 1, 150, 3, 150, 2336, 8, 150, 1, 151, 1, 151, 1, 151, 1, 151, 1, 151, 4, 151, 2343, 8, 151, 11, 151, 12, 151, 2344, 3, 151, 2347, 8, 151, 1, 152, 1, 152, 1, 152, 5, 152, 2352, 8, 152, 10, 152, 12, 152, 2355, 9, 152, 1, 152, 1, 152, 1, 153, 1, 153, 1, 153, 1, 153, 1, 153, 3, 153, 2364, 8, 153, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 3, 154, 2432, 8, 154, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 3, 155, 2509, 8, 155, 1, 156, 5, 156, 2512, 8, 156, 10, 156, 12, 156, 2515, 9, 156, 1, 157, 1, 157, 1, 158, 1, 158, 1, 158, 3, 158, 2522, 8, 158, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 1, 159, 3, 159, 2672, 8, 159, 1, 160, 1, 160, 5, 160, 2676, 8, 160, 10, 160, 12, 160, 2679, 9, 160, 1, 161, 1, 161, 5, 161, 2683, 8, 161, 10, 161, 12, 161, 2686, 9, 161, 1, 162, 5, 162, 2689, 8, 162, 10, 162, 12, 162, 2692, 9, 162, 1, 163, 5, 163, 2695, 8, 163, 10, 163, 12, 163, 2698, 9, 163, 1, 164, 5, 164, 2701, 8, 164, 10, 164, 12, 164, 2704, 9, 164, 1, 165, 5, 165, 2707, 8, 165, 10, 165, 12, 165, 2710, 9, 165, 1, 166, 5, 166, 2713, 8, 166, 10, 166, 12, 166, 2716, 9, 166, 1, 167, 5, 167, 2719, 8, 167, 10, 167, 12, 167, 2722, 9, 167, 1, 168, 5, 168, 2725, 8, 168, 10, 168, 12, 168, 2728, 9, 168, 1, 169, 1, 169, 1, 169, 1, 169, 3, 169, 2734, 8, 169, 1, 170, 5, 170, 2737, 8, 170, 10, 170, 12, 170, 2740, 9, 170, 1, 171, 1, 171, 1, 171, 3, 171, 2745, 8, 171, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 3, 172, 2772, 8, 172, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 3, 173, 2786, 8, 173, 1, 174, 5, 174, 2789, 8, 174, 10, 174, 12, 174, 2792, 9, 174, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 1, 175, 3, 175, 2808, 8, 175, 1, 176, 1, 176, 1, 176, 5, 176, 2813, 8, 176, 10, 176, 12, 176, 2816, 9, 176, 1, 176, 1, 176, 1, 177, 1, 177, 5, 177, 2822, 8, 177, 10, 177, 12, 177, 2825, 9, 177, 1, 177, 1, 177, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 3, 178, 2844, 8, 178, 1, 179, 5, 179, 2847, 8, 179, 10, 179, 12, 179, 2850, 9, 179, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 3, 180, 2865, 8, 180, 1, 181, 1, 181, 5, 181, 2869, 8, 181, 10, 181, 12, 181, 2872, 9, 181, 1, 181, 1, 181, 1, 181, 5, 181, 2877, 8, 181, 10, 181, 12, 181, 2880, 9, 181, 1, 181, 1, 181, 1, 181, 1, 181, 3, 181, 2886, 8, 181, 1, 182, 1, 182, 1, 183, 5, 183, 2891, 8, 183, 10, 183, 12, 183, 2894, 9, 183, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 3, 184, 2906, 8, 184, 1, 184, 0, 1, 68, 185, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 0, 16, 6, 0, 1, 15, 199, 199, 243, 243, 247, 247, 264, 264, 289, 289, 5, 0, 16, 16, 199, 199, 243, 243, 264, 264, 288, 289, 1, 0, 263, 264, 1, 0, 173, 174, 1, 0, 37, 38, 1, 0, 73, 74, 3, 0, 2, 2, 61, 61, 77, 83, 2, 0, 229, 229, 260, 261, 9, 0, 178, 178, 183, 195, 201, 201, 207, 208, 210, 215, 218, 219, 222, 222, 230, 242, 262, 262, 1, 0, 95, 96, 1, 0, 97, 111, 1, 0, 68, 69, 2, 0, 173, 173, 289, 290, 2, 0, 179, 179, 264, 264, 1, 0, 167, 168, 1, 0, 51, 52, 3325, 0, 370, 1, 0, 0, 0, 2, 383, 1, 0, 0, 0, 4, 385, 1, 0, 0, 0, 6, 391, 1, 0, 0, 0, 8, 399, 1, 0, 0, 0, 10, 452, 1, 0, 0, 0, 12, 454, 1, 0, 0, 0, 14, 457, 1, 0, 0, 0, 16, 460, 1, 0, 0, 0, 18, 464, 1, 0, 0, 0, 20, 467, 1, 0, 0, 0, 22, 470, 1, 0, 0, 0, 24, 477, 1, 0, 0, 0, 26, 493, 1, 0, 0, 0, 28, 495, 1, 0, 0, 0, 30, 497, 1, 0, 0, 0, 32, 507, 1, 0, 0, 0, 34, 509, 1, 0, 0, 0, 36, 526, 1, 0, 0, 0, 38, 530, 1, 0, 0, 0, 40, 548, 1, 0, 0, 0, 42, 575, 1, 0, 0, 0, 44, 598, 1, 0, 0, 0, 46, 634, 1, 0, 0, 0, 48, 636, 1, 0, 0, 0, 50, 640, 1, 0, 0, 0, 52, 642, 1, 0, 0, 0, 54, 649, 1, 0, 0, 0, 56, 661, 1, 0, 0, 0, 58, 664, 1, 0, 0, 0, 60, 666, 1, 0, 0, 0, 62, 679, 1, 0, 0, 0, 64, 687, 1, 0, 0, 0, 66, 689, 1, 0, 0, 0, 68, 697, 1, 0, 0, 0, 70, 713, 1, 0, 0, 0, 72, 719, 1, 0, 0, 0, 74, 722, 1, 0, 0, 0, 76, 771, 1, 0, 0, 0, 78, 776, 1, 0, 0, 0, 80, 781, 1, 0, 0, 0, 82, 786, 1, 0, 0, 0, 84, 794, 1, 0, 0, 0, 86, 799, 1, 0, 0, 0, 88, 904, 1, 0, 0, 0, 90, 932, 1, 0, 0, 0, 92, 934, 1, 0, 0, 0, 94, 938, 1, 0, 0, 0, 96, 940, 1, 0, 0, 0, 98, 945, 1, 0, 0, 0, 100, 948, 1, 0, 0, 0, 102, 950, 1, 0, 0, 0, 104, 952, 1, 0, 0, 0, 106, 954, 1, 0, 0, 0, 108, 956, 1, 0, 0, 0, 110, 958, 1, 0, 0, 0, 112, 960, 1, 0, 0, 0, 114, 962, 1, 0, 0, 0, 116, 964, 1, 0, 0, 0, 118, 966, 1, 0, 0, 0, 120, 968, 1, 0, 0, 0, 122, 970, 1, 0, 0, 0, 124, 972, 1, 0, 0, 0, 126, 1056, 1, 0, 0, 0, 128, 1074, 1, 0, 0, 0, 130, 1076, 1, 0, 0, 0, 132, 1088, 1, 0, 0, 0, 134, 1113, 1, 0, 0, 0, 136, 1122, 1, 0, 0, 0, 138, 1149, 1, 0, 0, 0, 140, 1156, 1, 0, 0, 0, 142, 1164, 1, 0, 0, 0, 144, 1172, 1, 0, 0, 0, 146, 1185, 1, 0, 0, 0, 148, 1195, 1, 0, 0, 0, 150, 1214, 1, 0, 0, 0, 152, 1308, 1, 0, 0, 0, 154, 1317, 1, 0, 0, 0, 156, 1327, 1, 0, 0, 0, 158, 1329, 1, 0, 0, 0, 160, 1331, 1, 0, 0, 0, 162, 1356, 1, 0, 0, 0, 164, 1388, 1, 0, 0, 0, 166, 1411, 1, 0, 0, 0, 168, 1423, 1, 0, 0, 0, 170, 1425, 1, 0, 0, 0, 172, 1428, 1, 0, 0, 0, 174, 1481, 1, 0, 0, 0, 176, 1493, 1, 0, 0, 0, 178, 1508, 1, 0, 0, 0, 180, 1515, 1, 0, 0, 0, 182, 1520, 1, 0, 0, 0, 184, 1524, 1, 0, 0, 0, 186, 1560, 1, 0, 0, 0, 188, 1562, 1, 0, 0, 0, 190, 1598, 1, 0, 0, 0, 192, 1610, 1, 0, 0, 0, 194, 1624, 1, 0, 0, 0, 196, 1626, 1, 0, 0, 0, 198, 1636, 1, 0, 0, 0, 200, 1647, 1, 0, 0, 0, 202, 1654, 1, 0, 0, 0, 204, 1664, 1, 0, 0, 0, 206, 1677, 1, 0, 0, 0, 208, 1682, 1, 0, 0, 0, 210, 1685, 1, 0, 0, 0, 212, 1696, 1, 0, 0, 0, 214, 1701, 1, 0, 0, 0, 216, 1707, 1, 0, 0, 0, 218, 1709, 1, 0, 0, 0, 220, 1831, 1, 0, 0, 0, 222, 1833, 1, 0, 0, 0, 224, 1870, 1, 0, 0, 0, 226, 1877, 1, 0, 0, 0, 228, 1882, 1, 0, 0, 0, 230, 1889, 1, 0, 0, 0, 232, 1909, 1, 0, 0, 0, 234, 1911, 1, 0, 0, 0, 236, 1916, 1, 0, 0, 0, 238, 1931, 1, 0, 0, 0, 240, 1933, 1, 0, 0, 0, 242, 1946, 1, 0, 0, 0, 244, 1951, 1, 0, 0, 0, 246, 1964, 1, 0, 0, 0, 248, 1972, 1, 0, 0, 0, 250, 1983, 1, 0, 0, 0, 252, 1988, 1, 0, 0, 0, 254, 2004, 1, 0, 0, 0, 256, 2006, 1, 0, 0, 0, 258, 2050, 1, 0, 0, 0, 260, 2070, 1, 0, 0, 0, 262, 2099, 1, 0, 0, 0, 264, 2104, 1, 0, 0, 0, 266, 2127, 1, 0, 0, 0, 268, 2132, 1, 0, 0, 0, 270, 2243, 1, 0, 0, 0, 272, 2245, 1, 0, 0, 0, 274, 2250, 1, 0, 0, 0, 276, 2252, 1, 0, 0, 0, 278, 2256, 1, 0, 0, 0, 280, 2260, 1, 0, 0, 0, 282, 2276, 1, 0, 0, 0, 284, 2290, 1, 0, 0, 0, 286, 2298, 1, 0, 0, 0, 288, 2300, 1, 0, 0, 0, 290, 2303, 1, 0, 0, 0, 292, 2305, 1, 0, 0, 0, 294, 2318, 1, 0, 0, 0, 296, 2320, 1, 0, 0, 0, 298, 2330, 1, 0, 0, 0, 300, 2335, 1, 0, 0, 0, 302, 2346, 1, 0, 0, 0, 304, 2353, 1, 0, 0, 0, 306, 2363, 1, 0, 0, 0, 308, 2431, 1, 0, 0, 0, 310, 2508, 1, 0, 0, 0, 312, 2513, 1, 0, 0, 0, 314, 2516, 1, 0, 0, 0, 316, 2521, 1, 0, 0, 0, 318, 2671, 1, 0, 0, 0, 320, 2677, 1, 0, 0, 0, 322, 2684, 1, 0, 0, 0, 324, 2690, 1, 0, 0, 0, 326, 2696, 1, 0, 0, 0, 328, 2702, 1, 0, 0, 0, 330, 2708, 1, 0, 0, 0, 332, 2714, 1, 0, 0, 0, 334, 2720, 1, 0, 0, 0, 336, 2726, 1, 0, 0, 0, 338, 2733, 1, 0, 0, 0, 340, 2738, 1, 0, 0, 0, 342, 2744, 1, 0, 0, 0, 344, 2771, 1, 0, 0, 0, 346, 2785, 1, 0, 0, 0, 348, 2790, 1, 0, 0, 0, 350, 2807, 1, 0, 0, 0, 352, 2809, 1, 0, 0, 0, 354, 2819, 1, 0, 0, 0, 356, 2843, 1, 0, 0, 0, 358, 2848, 1, 0, 0, 0, 360, 2864, 1, 0, 0, 0, 362, 2885, 1, 0, 0, 0, 364, 2887, 1, 0, 0, 0, 366, 2892, 1, 0, 0, 0, 368, 2905, 1, 0, 0, 0, 370, 371, 7, 0, 0, 0, 371, 1, 1, 0, 0, 0, 372, 384, 5, 288, 0, 0, 373, 374, 3, 4, 2, 0, 374, 375, 5, 265, 0, 0, 375, 377, 1, 0, 0, 0, 376, 373, 1, 0, 0, 0, 377, 380, 1, 0, 0, 0, 378, 376, 1, 0, 0, 0, 378, 379, 1, 0, 0, 0, 379, 381, 1, 0, 0, 0, 380, 378, 1, 0, 0, 0, 381, 384, 3, 4, 2, 0, 382, 384, 5, 264, 0, 0, 383, 372, 1, 0, 0, 0, 383, 378, 1, 0, 0, 0, 383, 382, 1, 0, 0, 0, 384, 3, 1, 0, 0, 0, 385, 386, 7, 1, 0, 0, 386, 5, 1, 0, 0, 0, 387, 388, 5, 263, 0, 0, 388, 390, 5, 266, 0, 0, 389, 387, 1, 0, 0, 0, 390, 393, 1, 0, 0, 0, 391, 389, 1, 0, 0, 0, 391, 392, 1, 0, 0, 0, 392, 394, 1, 0, 0, 0, 393, 391, 1, 0, 0, 0, 394, 395, 5, 263, 0, 0, 395, 7, 1, 0, 0, 0, 396, 398, 3, 10, 5, 0, 397, 396, 1, 0, 0, 0, 398, 401, 1, 0, 0, 0, 399, 397, 1, 0, 0, 0, 399, 400, 1, 0, 0, 0, 400, 9, 1, 0, 0, 0, 401, 399, 1, 0, 0, 0, 402, 403, 3, 74, 37, 0, 403, 404, 5, 17, 0, 0, 404, 405, 3, 82, 41, 0, 405, 406, 5, 18, 0, 0, 406, 453, 1, 0, 0, 0, 407, 408, 3, 72, 36, 0, 408, 409, 5, 17, 0, 0, 409, 410, 3, 8, 4, 0, 410, 411, 5, 18, 0, 0, 411, 453, 1, 0, 0, 0, 412, 413, 3, 256, 128, 0, 413, 414, 5, 17, 0, 0, 414, 415, 3, 268, 134, 0, 415, 416, 5, 18, 0, 0, 416, 453, 1, 0, 0, 0, 417, 453, 3, 222, 111, 0, 418, 453, 3, 296, 148, 0, 419, 453, 3, 70, 35, 0, 420, 453, 3, 66, 33, 0, 421, 453, 3, 88, 44, 0, 422, 453, 3, 90, 45, 0, 423, 453, 3, 22, 11, 0, 424, 425, 3, 346, 173, 0, 425, 426, 5, 17, 0, 0, 426, 427, 3, 348, 174, 0, 427, 428, 5, 18, 0, 0, 428, 453, 1, 0, 0, 0, 429, 430, 3, 352, 176, 0, 430, 431, 5, 17, 0, 0, 431, 432, 3, 358, 179, 0, 432, 433, 5, 18, 0, 0, 433, 453, 1, 0, 0, 0, 434, 435, 3, 362, 181, 0, 435, 436, 5, 17, 0, 0, 436, 437, 3, 366, 183, 0, 437, 438, 5, 18, 0, 0, 438, 453, 1, 0, 0, 0, 439, 453, 3, 64, 32, 0, 440, 453, 3, 174, 87, 0, 441, 453, 3, 342, 171, 0, 442, 453, 3, 12, 6, 0, 443, 453, 3, 14, 7, 0, 444, 453, 3, 16, 8, 0, 445, 453, 3, 18, 9, 0, 446, 453, 3, 20, 10, 0, 447, 453, 3, 26, 13, 0, 448, 453, 3, 42, 21, 0, 449, 453, 3, 40, 20, 0, 450, 453, 3, 30, 15, 0, 451, 453, 3, 24, 12, 0, 452, 402, 1, 0, 0, 0, 452, 407, 1, 0, 0, 0, 452, 412, 1, 0, 0, 0, 452, 417, 1, 0, 0, 0, 452, 418, 1, 0, 0, 0, 452, 419, 1, 0, 0, 0, 452, 420, 1, 0, 0, 0, 452, 421, 1, 0, 0, 0, 452, 422, 1, 0, 0, 0, 452, 423, 1, 0, 0, 0, 452, 424, 1, 0, 0, 0, 452, 429, 1, 0, 0, 0, 452, 434, 1, 0, 0, 0, 452, 439, 1, 0, 0, 0, 452, 440, 1, 0, 0, 0, 452, 441, 1, 0, 0, 0, 452, 442, 1, 0, 0, 0, 452, 443, 1, 0, 0, 0, 452, 444, 1, 0, 0, 0, 452, 445, 1, 0, 0, 0, 452, 446, 1, 0, 0, 0, 452, 447, 1, 0, 0, 0, 452, 448, 1, 0, 0, 0, 452, 449, 1, 0, 0, 0, 452, 450, 1, 0, 0, 0, 452, 451, 1, 0, 0, 0, 453, 11, 1, 0, 0, 0, 454, 455, 5, 19, 0, 0, 455, 456, 3, 32, 16, 0, 456, 13, 1, 0, 0, 0, 457, 458, 5, 20, 0, 0, 458, 459, 3, 32, 16, 0, 459, 15, 1, 0, 0, 0, 460, 461, 5, 21, 0, 0, 461, 462, 5, 22, 0, 0, 462, 463, 3, 32, 16, 0, 463, 17, 1, 0, 0, 0, 464, 465, 5, 23, 0, 0, 465, 466, 3, 34, 17, 0, 466, 19, 1, 0, 0, 0, 467, 468, 5, 24, 0, 0, 468, 469, 3, 34, 17, 0, 469, 21, 1, 0, 0, 0, 470, 471, 5, 25, 0, 0, 471, 472, 3, 98, 49, 0, 472, 473, 3, 2, 1, 0, 473, 474, 5, 17, 0, 0, 474, 475, 3, 142, 71, 0, 475, 476, 5, 18, 0, 0, 476, 23, 1, 0, 0, 0, 477, 478, 5, 26, 0, 0, 478, 25, 1, 0, 0, 0, 479, 480, 5, 27, 0, 0, 480, 494, 3, 28, 14, 0, 481, 482, 5, 27, 0, 0, 482, 483, 3, 28, 14, 0, 483, 484, 5, 28, 0, 0, 484, 485, 3, 28, 14, 0, 485, 494, 1, 0, 0, 0, 486, 487, 5, 27, 0, 0, 487, 488, 3, 28, 14, 0, 488, 489, 5, 28, 0, 0, 489, 490, 3, 28, 14, 0, 490, 491, 5, 28, 0, 0, 491, 492, 3, 28, 14, 0, 492, 494, 1, 0, 0, 0, 493, 479, 1, 0, 0, 0, 493, 481, 1, 0, 0, 0, 493, 486, 1, 0, 0, 0, 494, 27, 1, 0, 0, 0, 495, 496, 7, 2, 0, 0, 496, 29, 1, 0, 0, 0, 497, 498, 5, 29, 0, 0, 498, 502, 5, 17, 0, 0, 499, 501, 3, 138, 69, 0, 500, 499, 1, 0, 0, 0, 501, 504, 1, 0, 0, 0, 502, 500, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 505, 1, 0, 0, 0, 504, 502, 1, 0, 0, 0, 505, 506, 5, 18, 0, 0, 506, 31, 1, 0, 0, 0, 507, 508, 5, 173, 0, 0, 508, 33, 1, 0, 0, 0, 509, 510, 7, 3, 0, 0, 510, 35, 1, 0, 0, 0, 511, 527, 5, 175, 0, 0, 512, 513, 3, 32, 16, 0, 513, 514, 5, 265, 0, 0, 514, 527, 1, 0, 0, 0, 515, 527, 3, 32, 16, 0, 516, 517, 5, 188, 0, 0, 517, 518, 5, 30, 0, 0, 518, 519, 3, 32, 16, 0, 519, 520, 5, 31, 0, 0, 520, 527, 1, 0, 0, 0, 521, 522, 5, 189, 0, 0, 522, 523, 5, 30, 0, 0, 523, 524, 3, 34, 17, 0, 524, 525, 5, 31, 0, 0, 525, 527, 1, 0, 0, 0, 526, 511, 1, 0, 0, 0, 526, 512, 1, 0, 0, 0, 526, 515, 1, 0, 0, 0, 526, 516, 1, 0, 0, 0, 526, 521, 1, 0, 0, 0, 527, 37, 1, 0, 0, 0, 528, 531, 3, 32, 16, 0, 529, 531, 5, 262, 0, 0, 530, 528, 1, 0, 0, 0, 530, 529, 1, 0, 0, 0, 531, 39, 1, 0, 0, 0, 532, 533, 5, 267, 0, 0, 533, 549, 5, 289, 0, 0, 534, 535, 5, 267, 0, 0, 535, 536, 5, 289, 0, 0, 536, 549, 5, 263, 0, 0, 537, 538, 5, 268, 0, 0, 538, 549, 5, 289, 0, 0, 539, 540, 5, 269, 0, 0, 540, 549, 5, 289, 0, 0, 541, 542, 5, 270, 0, 0, 542, 549, 5, 289, 0, 0, 543, 549, 5, 271, 0, 0, 544, 549, 5, 272, 0, 0, 545, 546, 5, 273, 0, 0, 546, 549, 5, 263, 0, 0, 547, 549, 5, 32, 0, 0, 548, 532, 1, 0, 0, 0, 548, 534, 1, 0, 0, 0, 548, 537, 1, 0, 0, 0, 548, 539, 1, 0, 0, 0, 548, 541, 1, 0, 0, 0, 548, 543, 1, 0, 0, 0, 548, 544, 1, 0, 0, 0, 548, 545, 1, 0, 0, 0, 548, 547, 1, 0, 0, 0, 549, 41, 1, 0, 0, 0, 550, 551, 5, 33, 0, 0, 551, 552, 3, 160, 80, 0, 552, 553, 5, 34, 0, 0, 553, 554, 3, 2, 1, 0, 554, 576, 1, 0, 0, 0, 555, 556, 5, 33, 0, 0, 556, 557, 3, 138, 69, 0, 557, 558, 5, 34, 0, 0, 558, 559, 3, 2, 1, 0, 559, 576, 1, 0, 0, 0, 560, 561, 5, 33, 0, 0, 561, 562, 3, 198, 99, 0, 562, 563, 5, 34, 0, 0, 563, 564, 3, 2, 1, 0, 564, 576, 1, 0, 0, 0, 565, 566, 5, 33, 0, 0, 566, 567, 3, 44, 22, 0, 567, 568, 5, 34, 0, 0, 568, 569, 3, 2, 1, 0, 569, 576, 1, 0, 0, 0, 570, 571, 5, 33, 0, 0, 571, 572, 3, 46, 23, 0, 572, 573, 5, 34, 0, 0, 573, 574, 3, 2, 1, 0, 574, 576, 1, 0, 0, 0, 575, 550, 1, 0, 0, 0, 575, 555, 1, 0, 0, 0, 575, 560, 1, 0, 0, 0, 575, 565, 1, 0, 0, 0, 575, 570, 1, 0, 0, 0, 576, 43, 1, 0, 0, 0, 577, 578, 5, 35, 0, 0, 578, 599, 3, 48, 24, 0, 579, 580, 5, 35, 0, 0, 580, 581, 3, 48, 24, 0, 581, 582, 5, 36, 0, 0, 582, 583, 3, 6, 3, 0, 583, 599, 1, 0, 0, 0, 584, 585, 5, 35, 0, 0, 585, 586, 3, 48, 24, 0, 586, 587, 5, 36, 0, 0, 587, 588, 5, 17, 0, 0, 588, 589, 3, 52, 26, 0, 589, 590, 5, 18, 0, 0, 590, 599, 1, 0, 0, 0, 591, 592, 5, 35, 0, 0, 592, 593, 3, 48, 24, 0, 593, 594, 5, 36, 0, 0, 594, 595, 5, 30, 0, 0, 595, 596, 3, 312, 156, 0, 596, 597, 5, 31, 0, 0, 597, 599, 1, 0, 0, 0, 598, 577, 1, 0, 0, 0, 598, 579, 1, 0, 0, 0, 598, 584, 1, 0, 0, 0, 598, 591, 1, 0, 0, 0, 599, 45, 1, 0, 0, 0, 600, 601, 5, 35, 0, 0, 601, 602, 5, 30, 0, 0, 602, 603, 3, 50, 25, 0, 603, 604, 5, 31, 0, 0, 604, 605, 3, 48, 24, 0, 605, 635, 1, 0, 0, 0, 606, 607, 5, 35, 0, 0, 607, 608, 5, 30, 0, 0, 608, 609, 3, 50, 25, 0, 609, 610, 5, 31, 0, 0, 610, 611, 3, 48, 24, 0, 611, 612, 5, 36, 0, 0, 612, 613, 3, 6, 3, 0, 613, 635, 1, 0, 0, 0, 614, 615, 5, 35, 0, 0, 615, 616, 5, 30, 0, 0, 616, 617, 3, 50, 25, 0, 617, 618, 5, 31, 0, 0, 618, 619, 3, 48, 24, 0, 619, 620, 5, 36, 0, 0, 620, 621, 5, 17, 0, 0, 621, 622, 3, 52, 26, 0, 622, 623, 5, 18, 0, 0, 623, 635, 1, 0, 0, 0, 624, 625, 5, 35, 0, 0, 625, 626, 5, 30, 0, 0, 626, 627, 3, 50, 25, 0, 627, 628, 5, 31, 0, 0, 628, 629, 3, 48, 24, 0, 629, 630, 5, 36, 0, 0, 630, 631, 5, 30, 0, 0, 631, 632, 3, 312, 156, 0, 632, 633, 5, 31, 0, 0, 633, 635, 1, 0, 0, 0, 634, 600, 1, 0, 0, 0, 634, 606, 1, 0, 0, 0, 634, 614, 1, 0, 0, 0, 634, 624, 1, 0, 0, 0, 635, 47, 1, 0, 0, 0, 636, 637, 3, 190, 95, 0, 637, 49, 1, 0, 0, 0, 638, 641, 3, 146, 73, 0, 639, 641, 3, 198, 99, 0, 640, 638, 1, 0, 0, 0, 640, 639, 1, 0, 0, 0, 641, 51, 1, 0, 0, 0, 642, 643, 3, 54, 27, 0, 643, 644, 3, 56, 28, 0, 644, 53, 1, 0, 0, 0, 645, 648, 3, 318, 159, 0, 646, 648, 3, 40, 20, 0, 647, 645, 1, 0, 0, 0, 647, 646, 1, 0, 0, 0, 648, 651, 1, 0, 0, 0, 649, 647, 1, 0, 0, 0, 649, 650, 1, 0, 0, 0, 650, 55, 1, 0, 0, 0, 651, 649, 1, 0, 0, 0, 652, 653, 3, 58, 29, 0, 653, 654, 3, 60, 30, 0, 654, 655, 3, 2, 1, 0, 655, 656, 5, 36, 0, 0, 656, 657, 3, 318, 159, 0, 657, 660, 1, 0, 0, 0, 658, 660, 3, 40, 20, 0, 659, 652, 1, 0, 0, 0, 659, 658, 1, 0, 0, 0, 660, 663, 1, 0, 0, 0, 661, 659, 1, 0, 0, 0, 661, 662, 1, 0, 0, 0, 662, 57, 1, 0, 0, 0, 663, 661, 1, 0, 0, 0, 664, 665, 7, 4, 0, 0, 665, 59, 1, 0, 0, 0, 666, 668, 3, 62, 31, 0, 667, 669, 5, 261, 0, 0, 668, 667, 1, 0, 0, 0, 668, 669, 1, 0, 0, 0, 669, 61, 1, 0, 0, 0, 670, 680, 3, 166, 83, 0, 671, 680, 3, 2, 1, 0, 672, 680, 5, 196, 0, 0, 673, 680, 5, 197, 0, 0, 674, 675, 5, 202, 0, 0, 675, 676, 5, 39, 0, 0, 676, 680, 5, 264, 0, 0, 677, 678, 5, 202, 0, 0, 678, 680, 3, 138, 69, 0, 679, 670, 1, 0, 0, 0, 679, 671, 1, 0, 0, 0, 679, 672, 1, 0, 0, 0, 679, 673, 1, 0, 0, 0, 679, 674, 1, 0, 0, 0, 679, 677, 1, 0, 0, 0, 680, 63, 1, 0, 0, 0, 681, 682, 5, 198, 0, 0, 682, 683, 5, 40, 0, 0, 683, 688, 3, 2, 1, 0, 684, 685, 5, 198, 0, 0, 685, 688, 3, 2, 1, 0, 686, 688, 5, 198, 0, 0, 687, 681, 1, 0, 0, 0, 687, 684, 1, 0, 0, 0, 687, 686, 1, 0, 0, 0, 688, 65, 1, 0, 0, 0, 689, 690, 5, 41, 0, 0, 690, 691, 5, 42, 0, 0, 691, 692, 3, 32, 16, 0, 692, 693, 5, 43, 0, 0, 693, 694, 3, 68, 34, 0, 694, 695, 5, 44, 0, 0, 695, 696, 3, 0, 0, 0, 696, 67, 1, 0, 0, 0, 697, 710, 6, 34, -1, 0, 698, 699, 10, 5, 0, 0, 699, 709, 5, 186, 0, 0, 700, 701, 10, 4, 0, 0, 701, 709, 5, 187, 0, 0, 702, 703, 10, 3, 0, 0, 703, 709, 5, 45, 0, 0, 704, 705, 10, 2, 0, 0, 705, 709, 5, 46, 0, 0, 706, 707, 10, 1, 0, 0, 707, 709, 5, 47, 0, 0, 708, 698, 1, 0, 0, 0, 708, 700, 1, 0, 0, 0, 708, 702, 1, 0, 0, 0, 708, 704, 1, 0, 0, 0, 708, 706, 1, 0, 0, 0, 709, 712, 1, 0, 0, 0, 710, 708, 1, 0, 0, 0, 710, 711, 1, 0, 0, 0, 711, 69, 1, 0, 0, 0, 712, 710, 1, 0, 0, 0, 713, 714, 5, 48, 0, 0, 714, 715, 5, 36, 0, 0, 715, 716, 5, 30, 0, 0, 716, 717, 3, 312, 156, 0, 717, 718, 5, 31, 0, 0, 718, 71, 1, 0, 0, 0, 719, 720, 5, 49, 0, 0, 720, 721, 3, 2, 1, 0, 721, 73, 1, 0, 0, 0, 722, 726, 5, 50, 0, 0, 723, 725, 3, 76, 38, 0, 724, 723, 1, 0, 0, 0, 725, 728, 1, 0, 0, 0, 726, 724, 1, 0, 0, 0, 726, 727, 1, 0, 0, 0, 727, 729, 1, 0, 0, 0, 728, 726, 1, 0, 0, 0, 729, 730, 3, 2, 1, 0, 730, 731, 3, 204, 102, 0, 731, 732, 3, 78, 39, 0, 732, 733, 3, 80, 40, 0, 733, 75, 1, 0, 0, 0, 734, 772, 5, 51, 0, 0, 735, 772, 5, 52, 0, 0, 736, 772, 5, 199, 0, 0, 737, 772, 5, 202, 0, 0, 738, 772, 5, 221, 0, 0, 739, 772, 5, 53, 0, 0, 740, 772, 5, 54, 0, 0, 741, 772, 5, 55, 0, 0, 742, 772, 5, 56, 0, 0, 743, 772, 5, 244, 0, 0, 744, 772, 5, 15, 0, 0, 745, 772, 5, 224, 0, 0, 746, 772, 5, 57, 0, 0, 747, 772, 5, 58, 0, 0, 748, 772, 5, 59, 0, 0, 749, 772, 5, 60, 0, 0, 750, 772, 5, 61, 0, 0, 751, 752, 5, 62, 0, 0, 752, 772, 5, 51, 0, 0, 753, 754, 5, 62, 0, 0, 754, 772, 5, 52, 0, 0, 755, 756, 5, 62, 0, 0, 756, 772, 5, 63, 0, 0, 757, 758, 5, 62, 0, 0, 758, 772, 5, 64, 0, 0, 759, 760, 5, 62, 0, 0, 760, 772, 5, 65, 0, 0, 761, 762, 5, 62, 0, 0, 762, 772, 5, 66, 0, 0, 763, 772, 5, 67, 0, 0, 764, 772, 5, 68, 0, 0, 765, 772, 5, 69, 0, 0, 766, 767, 5, 70, 0, 0, 767, 768, 5, 30, 0, 0, 768, 769, 3, 32, 16, 0, 769, 770, 5, 31, 0, 0, 770, 772, 1, 0, 0, 0, 771, 734, 1, 0, 0, 0, 771, 735, 1, 0, 0, 0, 771, 736, 1, 0, 0, 0, 771, 737, 1, 0, 0, 0, 771, 738, 1, 0, 0, 0, 771, 739, 1, 0, 0, 0, 771, 740, 1, 0, 0, 0, 771, 741, 1, 0, 0, 0, 771, 742, 1, 0, 0, 0, 771, 743, 1, 0, 0, 0, 771, 744, 1, 0, 0, 0, 771, 745, 1, 0, 0, 0, 771, 746, 1, 0, 0, 0, 771, 747, 1, 0, 0, 0, 771, 748, 1, 0, 0, 0, 771, 749, 1, 0, 0, 0, 771, 750, 1, 0, 0, 0, 771, 751, 1, 0, 0, 0, 771, 753, 1, 0, 0, 0, 771, 755, 1, 0, 0, 0, 771, 757, 1, 0, 0, 0, 771, 759, 1, 0, 0, 0, 771, 761, 1, 0, 0, 0, 771, 763, 1, 0, 0, 0, 771, 764, 1, 0, 0, 0, 771, 765, 1, 0, 0, 0, 771, 766, 1, 0, 0, 0, 772, 77, 1, 0, 0, 0, 773, 777, 1, 0, 0, 0, 774, 775, 5, 71, 0, 0, 775, 777, 3, 146, 73, 0, 776, 773, 1, 0, 0, 0, 776, 774, 1, 0, 0, 0, 777, 79, 1, 0, 0, 0, 778, 782, 1, 0, 0, 0, 779, 780, 5, 72, 0, 0, 780, 782, 3, 84, 42, 0, 781, 778, 1, 0, 0, 0, 781, 779, 1, 0, 0, 0, 782, 81, 1, 0, 0, 0, 783, 785, 3, 220, 110, 0, 784, 783, 1, 0, 0, 0, 785, 788, 1, 0, 0, 0, 786, 784, 1, 0, 0, 0, 786, 787, 1, 0, 0, 0, 787, 83, 1, 0, 0, 0, 788, 786, 1, 0, 0, 0, 789, 790, 3, 146, 73, 0, 790, 791, 5, 28, 0, 0, 791, 793, 1, 0, 0, 0, 792, 789, 1, 0, 0, 0, 793, 796, 1, 0, 0, 0, 794, 792, 1, 0, 0, 0, 794, 795, 1, 0, 0, 0, 795, 797, 1, 0, 0, 0, 796, 794, 1, 0, 0, 0, 797, 798, 3, 146, 73, 0, 798, 85, 1, 0, 0, 0, 799, 800, 7, 5, 0, 0, 800, 87, 1, 0, 0, 0, 801, 802, 3, 86, 43, 0, 802, 803, 3, 32, 16, 0, 803, 804, 5, 264, 0, 0, 804, 905, 1, 0, 0, 0, 805, 806, 3, 86, 43, 0, 806, 807, 3, 32, 16, 0, 807, 905, 1, 0, 0, 0, 808, 809, 3, 86, 43, 0, 809, 810, 3, 32, 16, 0, 810, 811, 5, 75, 0, 0, 811, 812, 3, 32, 16, 0, 812, 813, 5, 264, 0, 0, 813, 905, 1, 0, 0, 0, 814, 815, 3, 86, 43, 0, 815, 816, 3, 32, 16, 0, 816, 817, 5, 75, 0, 0, 817, 818, 3, 32, 16, 0, 818, 905, 1, 0, 0, 0, 819, 820, 3, 86, 43, 0, 820, 821, 3, 32, 16, 0, 821, 822, 5, 75, 0, 0, 822, 823, 3, 32, 16, 0, 823, 824, 5, 28, 0, 0, 824, 825, 3, 32, 16, 0, 825, 826, 5, 264, 0, 0, 826, 905, 1, 0, 0, 0, 827, 828, 3, 86, 43, 0, 828, 829, 3, 32, 16, 0, 829, 830, 5, 75, 0, 0, 830, 831, 3, 32, 16, 0, 831, 832, 5, 28, 0, 0, 832, 833, 3, 32, 16, 0, 833, 905, 1, 0, 0, 0, 834, 835, 3, 86, 43, 0, 835, 836, 3, 32, 16, 0, 836, 837, 5, 28, 0, 0, 837, 838, 3, 32, 16, 0, 838, 839, 5, 75, 0, 0, 839, 840, 3, 32, 16, 0, 840, 841, 5, 264, 0, 0, 841, 905, 1, 0, 0, 0, 842, 843, 3, 86, 43, 0, 843, 844, 3, 32, 16, 0, 844, 845, 5, 28, 0, 0, 845, 846, 3, 32, 16, 0, 846, 847, 5, 75, 0, 0, 847, 848, 3, 32, 16, 0, 848, 905, 1, 0, 0, 0, 849, 850, 3, 86, 43, 0, 850, 851, 3, 32, 16, 0, 851, 852, 5, 28, 0, 0, 852, 853, 3, 32, 16, 0, 853, 854, 5, 75, 0, 0, 854, 855, 3, 32, 16, 0, 855, 856, 5, 28, 0, 0, 856, 857, 3, 32, 16, 0, 857, 858, 5, 264, 0, 0, 858, 905, 1, 0, 0, 0, 859, 860, 3, 86, 43, 0, 860, 861, 3, 32, 16, 0, 861, 862, 5, 28, 0, 0, 862, 863, 3, 32, 16, 0, 863, 864, 5, 75, 0, 0, 864, 865, 3, 32, 16, 0, 865, 866, 5, 28, 0, 0, 866, 867, 3, 32, 16, 0, 867, 905, 1, 0, 0, 0, 868, 869, 3, 86, 43, 0, 869, 870, 3, 32, 16, 0, 870, 871, 5, 263, 0, 0, 871, 905, 1, 0, 0, 0, 872, 873, 3, 86, 43, 0, 873, 874, 3, 32, 16, 0, 874, 875, 5, 75, 0, 0, 875, 876, 3, 32, 16, 0, 876, 877, 5, 263, 0, 0, 877, 905, 1, 0, 0, 0, 878, 879, 3, 86, 43, 0, 879, 880, 3, 32, 16, 0, 880, 881, 5, 75, 0, 0, 881, 882, 3, 32, 16, 0, 882, 883, 5, 28, 0, 0, 883, 884, 3, 32, 16, 0, 884, 885, 5, 263, 0, 0, 885, 905, 1, 0, 0, 0, 886, 887, 3, 86, 43, 0, 887, 888, 3, 32, 16, 0, 888, 889, 5, 28, 0, 0, 889, 890, 3, 32, 16, 0, 890, 891, 5, 75, 0, 0, 891, 892, 3, 32, 16, 0, 892, 893, 5, 263, 0, 0, 893, 905, 1, 0, 0, 0, 894, 895, 3, 86, 43, 0, 895, 896, 3, 32, 16, 0, 896, 897, 5, 28, 0, 0, 897, 898, 3, 32, 16, 0, 898, 899, 5, 75, 0, 0, 899, 900, 3, 32, 16, 0, 900, 901, 5, 28, 0, 0, 901, 902, 3, 32, 16, 0, 902, 903, 5, 263, 0, 0, 903, 905, 1, 0, 0, 0, 904, 801, 1, 0, 0, 0, 904, 805, 1, 0, 0, 0, 904, 808, 1, 0, 0, 0, 904, 814, 1, 0, 0, 0, 904, 819, 1, 0, 0, 0, 904, 827, 1, 0, 0, 0, 904, 834, 1, 0, 0, 0, 904, 842, 1, 0, 0, 0, 904, 849, 1, 0, 0, 0, 904, 859, 1, 0, 0, 0, 904, 868, 1, 0, 0, 0, 904, 872, 1, 0, 0, 0, 904, 878, 1, 0, 0, 0, 904, 886, 1, 0, 0, 0, 904, 894, 1, 0, 0, 0, 905, 89, 1, 0, 0, 0, 906, 910, 5, 21, 0, 0, 907, 909, 3, 92, 46, 0, 908, 907, 1, 0, 0, 0, 909, 912, 1, 0, 0, 0, 910, 908, 1, 0, 0, 0, 910, 911, 1, 0, 0, 0, 911, 913, 1, 0, 0, 0, 912, 910, 1, 0, 0, 0, 913, 914, 3, 2, 1, 0, 914, 915, 3, 94, 47, 0, 915, 916, 5, 180, 0, 0, 916, 917, 5, 36, 0, 0, 917, 918, 5, 30, 0, 0, 918, 919, 3, 312, 156, 0, 919, 920, 5, 31, 0, 0, 920, 921, 3, 94, 47, 0, 921, 933, 1, 0, 0, 0, 922, 926, 5, 21, 0, 0, 923, 925, 3, 92, 46, 0, 924, 923, 1, 0, 0, 0, 925, 928, 1, 0, 0, 0, 926, 924, 1, 0, 0, 0, 926, 927, 1, 0, 0, 0, 927, 929, 1, 0, 0, 0, 928, 926, 1, 0, 0, 0, 929, 930, 3, 2, 1, 0, 930, 931, 3, 94, 47, 0, 931, 933, 1, 0, 0, 0, 932, 906, 1, 0, 0, 0, 932, 922, 1, 0, 0, 0, 933, 91, 1, 0, 0, 0, 934, 935, 5, 76, 0, 0, 935, 93, 1, 0, 0, 0, 936, 939, 1, 0, 0, 0, 937, 939, 5, 298, 0, 0, 938, 936, 1, 0, 0, 0, 938, 937, 1, 0, 0, 0, 939, 95, 1, 0, 0, 0, 940, 941, 7, 6, 0, 0, 941, 97, 1, 0, 0, 0, 942, 944, 3, 96, 48, 0, 943, 942, 1, 0, 0, 0, 944, 947, 1, 0, 0, 0, 945, 943, 1, 0, 0, 0, 945, 946, 1, 0, 0, 0, 946, 99, 1, 0, 0, 0, 947, 945, 1, 0, 0, 0, 948, 949, 5, 275, 0, 0, 949, 101, 1, 0, 0, 0, 950, 951, 5, 276, 0, 0, 951, 103, 1, 0, 0, 0, 952, 953, 5, 277, 0, 0, 953, 105, 1, 0, 0, 0, 954, 955, 5, 278, 0, 0, 955, 107, 1, 0, 0, 0, 956, 957, 5, 279, 0, 0, 957, 109, 1, 0, 0, 0, 958, 959, 5, 282, 0, 0, 959, 111, 1, 0, 0, 0, 960, 961, 5, 280, 0, 0, 961, 113, 1, 0, 0, 0, 962, 963, 5, 286, 0, 0, 963, 115, 1, 0, 0, 0, 964, 965, 5, 284, 0, 0, 965, 117, 1, 0, 0, 0, 966, 967, 5, 285, 0, 0, 967, 119, 1, 0, 0, 0, 968, 969, 5, 281, 0, 0, 969, 121, 1, 0, 0, 0, 970, 971, 5, 287, 0, 0, 971, 123, 1, 0, 0, 0, 972, 973, 5, 283, 0, 0, 973, 125, 1, 0, 0, 0, 974, 1057, 3, 100, 50, 0, 975, 976, 3, 102, 51, 0, 976, 977, 3, 32, 16, 0, 977, 1057, 1, 0, 0, 0, 978, 979, 3, 102, 51, 0, 979, 980, 3, 0, 0, 0, 980, 1057, 1, 0, 0, 0, 981, 982, 3, 104, 52, 0, 982, 983, 3, 32, 16, 0, 983, 1057, 1, 0, 0, 0, 984, 985, 3, 106, 53, 0, 985, 986, 3, 34, 17, 0, 986, 1057, 1, 0, 0, 0, 987, 988, 3, 108, 54, 0, 988, 989, 3, 36, 18, 0, 989, 1057, 1, 0, 0, 0, 990, 991, 3, 108, 54, 0, 991, 992, 3, 34, 17, 0, 992, 1057, 1, 0, 0, 0, 993, 994, 3, 108, 54, 0, 994, 995, 5, 30, 0, 0, 995, 996, 3, 312, 156, 0, 996, 997, 5, 31, 0, 0, 997, 1057, 1, 0, 0, 0, 998, 999, 3, 108, 54, 0, 999, 1000, 5, 84, 0, 0, 1000, 1001, 5, 30, 0, 0, 1001, 1002, 3, 312, 156, 0, 1002, 1003, 5, 31, 0, 0, 1003, 1057, 1, 0, 0, 0, 1004, 1005, 3, 110, 55, 0, 1005, 1006, 3, 32, 16, 0, 1006, 1057, 1, 0, 0, 0, 1007, 1008, 3, 110, 55, 0, 1008, 1009, 3, 0, 0, 0, 1009, 1057, 1, 0, 0, 0, 1010, 1011, 3, 112, 56, 0, 1011, 1012, 3, 190, 95, 0, 1012, 1057, 1, 0, 0, 0, 1013, 1014, 3, 114, 57, 0, 1014, 1015, 3, 200, 100, 0, 1015, 1057, 1, 0, 0, 0, 1016, 1017, 3, 114, 57, 0, 1017, 1018, 3, 196, 98, 0, 1018, 1057, 1, 0, 0, 0, 1019, 1020, 3, 116, 58, 0, 1020, 1021, 3, 146, 73, 0, 1021, 1057, 1, 0, 0, 0, 1022, 1023, 3, 118, 59, 0, 1023, 1024, 3, 6, 3, 0, 1024, 1057, 1, 0, 0, 0, 1025, 1026, 3, 118, 59, 0, 1026, 1027, 5, 224, 0, 0, 1027, 1028, 5, 30, 0, 0, 1028, 1029, 3, 6, 3, 0, 1029, 1030, 5, 31, 0, 0, 1030, 1057, 1, 0, 0, 0, 1031, 1032, 3, 118, 59, 0, 1032, 1033, 5, 84, 0, 0, 1033, 1034, 5, 30, 0, 0, 1034, 1035, 3, 312, 156, 0, 1035, 1036, 5, 31, 0, 0, 1036, 1057, 1, 0, 0, 0, 1037, 1038, 3, 120, 60, 0, 1038, 1039, 3, 192, 96, 0, 1039, 1040, 3, 160, 80, 0, 1040, 1041, 3, 134, 67, 0, 1041, 1057, 1, 0, 0, 0, 1042, 1043, 3, 122, 61, 0, 1043, 1044, 3, 50, 25, 0, 1044, 1057, 1, 0, 0, 0, 1045, 1046, 3, 122, 61, 0, 1046, 1047, 3, 32, 16, 0, 1047, 1057, 1, 0, 0, 0, 1048, 1049, 3, 124, 62, 0, 1049, 1050, 5, 30, 0, 0, 1050, 1051, 3, 128, 64, 0, 1051, 1052, 5, 31, 0, 0, 1052, 1057, 1, 0, 0, 0, 1053, 1054, 3, 124, 62, 0, 1054, 1055, 5, 85, 0, 0, 1055, 1057, 1, 0, 0, 0, 1056, 974, 1, 0, 0, 0, 1056, 975, 1, 0, 0, 0, 1056, 978, 1, 0, 0, 0, 1056, 981, 1, 0, 0, 0, 1056, 984, 1, 0, 0, 0, 1056, 987, 1, 0, 0, 0, 1056, 990, 1, 0, 0, 0, 1056, 993, 1, 0, 0, 0, 1056, 998, 1, 0, 0, 0, 1056, 1004, 1, 0, 0, 0, 1056, 1007, 1, 0, 0, 0, 1056, 1010, 1, 0, 0, 0, 1056, 1013, 1, 0, 0, 0, 1056, 1016, 1, 0, 0, 0, 1056, 1019, 1, 0, 0, 0, 1056, 1022, 1, 0, 0, 0, 1056, 1025, 1, 0, 0, 0, 1056, 1031, 1, 0, 0, 0, 1056, 1037, 1, 0, 0, 0, 1056, 1042, 1, 0, 0, 0, 1056, 1045, 1, 0, 0, 0, 1056, 1048, 1, 0, 0, 0, 1056, 1053, 1, 0, 0, 0, 1057, 127, 1, 0, 0, 0, 1058, 1075, 1, 0, 0, 0, 1059, 1062, 3, 0, 0, 0, 1060, 1062, 3, 32, 16, 0, 1061, 1059, 1, 0, 0, 0, 1061, 1060, 1, 0, 0, 0, 1062, 1063, 1, 0, 0, 0, 1063, 1064, 5, 28, 0, 0, 1064, 1066, 1, 0, 0, 0, 1065, 1061, 1, 0, 0, 0, 1066, 1069, 1, 0, 0, 0, 1067, 1065, 1, 0, 0, 0, 1067, 1068, 1, 0, 0, 0, 1068, 1072, 1, 0, 0, 0, 1069, 1067, 1, 0, 0, 0, 1070, 1073, 3, 0, 0, 0, 1071, 1073, 3, 32, 16, 0, 1072, 1070, 1, 0, 0, 0, 1072, 1071, 1, 0, 0, 0, 1073, 1075, 1, 0, 0, 0, 1074, 1058, 1, 0, 0, 0, 1074, 1067, 1, 0, 0, 0, 1075, 129, 1, 0, 0, 0, 1076, 1082, 5, 86, 0, 0, 1077, 1078, 3, 160, 80, 0, 1078, 1079, 5, 28, 0, 0, 1079, 1081, 1, 0, 0, 0, 1080, 1077, 1, 0, 0, 0, 1081, 1084, 1, 0, 0, 0, 1082, 1080, 1, 0, 0, 0, 1082, 1083, 1, 0, 0, 0, 1083, 1085, 1, 0, 0, 0, 1084, 1082, 1, 0, 0, 0, 1085, 1086, 3, 160, 80, 0, 1086, 1087, 5, 87, 0, 0, 1087, 131, 1, 0, 0, 0, 1088, 1094, 5, 42, 0, 0, 1089, 1090, 3, 168, 84, 0, 1090, 1091, 5, 28, 0, 0, 1091, 1093, 1, 0, 0, 0, 1092, 1089, 1, 0, 0, 0, 1093, 1096, 1, 0, 0, 0, 1094, 1092, 1, 0, 0, 0, 1094, 1095, 1, 0, 0, 0, 1095, 1097, 1, 0, 0, 0, 1096, 1094, 1, 0, 0, 0, 1097, 1098, 3, 168, 84, 0, 1098, 1099, 5, 43, 0, 0, 1099, 133, 1, 0, 0, 0, 1100, 1106, 5, 30, 0, 0, 1101, 1102, 3, 136, 68, 0, 1102, 1103, 5, 28, 0, 0, 1103, 1105, 1, 0, 0, 0, 1104, 1101, 1, 0, 0, 0, 1105, 1108, 1, 0, 0, 0, 1106, 1104, 1, 0, 0, 0, 1106, 1107, 1, 0, 0, 0, 1107, 1109, 1, 0, 0, 0, 1108, 1106, 1, 0, 0, 0, 1109, 1110, 3, 136, 68, 0, 1110, 1111, 5, 31, 0, 0, 1111, 1114, 1, 0, 0, 0, 1112, 1114, 5, 85, 0, 0, 1113, 1100, 1, 0, 0, 0, 1113, 1112, 1, 0, 0, 0, 1114, 135, 1, 0, 0, 0, 1115, 1123, 5, 177, 0, 0, 1116, 1117, 3, 252, 126, 0, 1117, 1118, 3, 160, 80, 0, 1118, 1120, 3, 248, 124, 0, 1119, 1121, 3, 0, 0, 0, 1120, 1119, 1, 0, 0, 0, 1120, 1121, 1, 0, 0, 0, 1121, 1123, 1, 0, 0, 0, 1122, 1115, 1, 0, 0, 0, 1122, 1116, 1, 0, 0, 0, 1123, 137, 1, 0, 0, 0, 1124, 1125, 5, 42, 0, 0, 1125, 1126, 3, 2, 1, 0, 1126, 1127, 5, 43, 0, 0, 1127, 1128, 3, 140, 70, 0, 1128, 1150, 1, 0, 0, 0, 1129, 1130, 5, 42, 0, 0, 1130, 1131, 3, 196, 98, 0, 1131, 1132, 5, 43, 0, 0, 1132, 1133, 3, 140, 70, 0, 1133, 1150, 1, 0, 0, 0, 1134, 1135, 5, 42, 0, 0, 1135, 1136, 5, 262, 0, 0, 1136, 1137, 5, 43, 0, 0, 1137, 1150, 3, 140, 70, 0, 1138, 1139, 5, 42, 0, 0, 1139, 1140, 5, 198, 0, 0, 1140, 1141, 3, 2, 1, 0, 1141, 1142, 5, 43, 0, 0, 1142, 1143, 3, 140, 70, 0, 1143, 1150, 1, 0, 0, 0, 1144, 1150, 3, 140, 70, 0, 1145, 1150, 3, 196, 98, 0, 1146, 1150, 5, 257, 0, 0, 1147, 1150, 5, 258, 0, 0, 1148, 1150, 5, 259, 0, 0, 1149, 1124, 1, 0, 0, 0, 1149, 1129, 1, 0, 0, 0, 1149, 1134, 1, 0, 0, 0, 1149, 1138, 1, 0, 0, 0, 1149, 1144, 1, 0, 0, 0, 1149, 1145, 1, 0, 0, 0, 1149, 1146, 1, 0, 0, 0, 1149, 1147, 1, 0, 0, 0, 1149, 1148, 1, 0, 0, 0, 1150, 139, 1, 0, 0, 0, 1151, 1152, 3, 2, 1, 0, 1152, 1153, 5, 88, 0, 0, 1153, 1155, 1, 0, 0, 0, 1154, 1151, 1, 0, 0, 0, 1155, 1158, 1, 0, 0, 0, 1156, 1154, 1, 0, 0, 0, 1156, 1157, 1, 0, 0, 0, 1157, 1159, 1, 0, 0, 0, 1158, 1156, 1, 0, 0, 0, 1159, 1160, 3, 2, 1, 0, 1160, 141, 1, 0, 0, 0, 1161, 1163, 3, 144, 72, 0, 1162, 1161, 1, 0, 0, 0, 1163, 1166, 1, 0, 0, 0, 1164, 1162, 1, 0, 0, 0, 1164, 1165, 1, 0, 0, 0, 1165, 143, 1, 0, 0, 0, 1166, 1164, 1, 0, 0, 0, 1167, 1168, 5, 180, 0, 0, 1168, 1169, 5, 89, 0, 0, 1169, 1173, 3, 32, 16, 0, 1170, 1173, 3, 174, 87, 0, 1171, 1173, 3, 344, 172, 0, 1172, 1167, 1, 0, 0, 0, 1172, 1170, 1, 0, 0, 0, 1172, 1171, 1, 0, 0, 0, 1173, 145, 1, 0, 0, 0, 1174, 1186, 3, 138, 69, 0, 1175, 1176, 5, 42, 0, 0, 1176, 1177, 3, 2, 1, 0, 1177, 1178, 5, 43, 0, 0, 1178, 1186, 1, 0, 0, 0, 1179, 1180, 5, 42, 0, 0, 1180, 1181, 5, 198, 0, 0, 1181, 1182, 3, 2, 1, 0, 1182, 1183, 5, 43, 0, 0, 1183, 1186, 1, 0, 0, 0, 1184, 1186, 3, 160, 80, 0, 1185, 1174, 1, 0, 0, 0, 1185, 1175, 1, 0, 0, 0, 1185, 1179, 1, 0, 0, 0, 1185, 1184, 1, 0, 0, 0, 1186, 147, 1, 0, 0, 0, 1187, 1196, 1, 0, 0, 0, 1188, 1192, 3, 152, 76, 0, 1189, 1191, 3, 150, 75, 0, 1190, 1189, 1, 0, 0, 0, 1191, 1194, 1, 0, 0, 0, 1192, 1190, 1, 0, 0, 0, 1192, 1193, 1, 0, 0, 0, 1193, 1196, 1, 0, 0, 0, 1194, 1192, 1, 0, 0, 0, 1195, 1187, 1, 0, 0, 0, 1195, 1188, 1, 0, 0, 0, 1196, 149, 1, 0, 0, 0, 1197, 1215, 5, 262, 0, 0, 1198, 1215, 5, 261, 0, 0, 1199, 1200, 5, 42, 0, 0, 1200, 1201, 3, 32, 16, 0, 1201, 1202, 5, 43, 0, 0, 1202, 1215, 1, 0, 0, 0, 1203, 1204, 5, 42, 0, 0, 1204, 1205, 3, 32, 16, 0, 1205, 1206, 5, 266, 0, 0, 1206, 1207, 3, 32, 16, 0, 1207, 1208, 5, 43, 0, 0, 1208, 1215, 1, 0, 0, 0, 1209, 1210, 5, 42, 0, 0, 1210, 1211, 5, 266, 0, 0, 1211, 1212, 3, 32, 16, 0, 1212, 1213, 5, 43, 0, 0, 1213, 1215, 1, 0, 0, 0, 1214, 1197, 1, 0, 0, 0, 1214, 1198, 1, 0, 0, 0, 1214, 1199, 1, 0, 0, 0, 1214, 1203, 1, 0, 0, 0, 1214, 1209, 1, 0, 0, 0, 1215, 151, 1, 0, 0, 0, 1216, 1309, 1, 0, 0, 0, 1217, 1218, 5, 203, 0, 0, 1218, 1219, 5, 30, 0, 0, 1219, 1220, 3, 6, 3, 0, 1220, 1221, 5, 28, 0, 0, 1221, 1222, 3, 6, 3, 0, 1222, 1223, 5, 28, 0, 0, 1223, 1224, 3, 6, 3, 0, 1224, 1225, 5, 28, 0, 0, 1225, 1226, 3, 6, 3, 0, 1226, 1227, 5, 31, 0, 0, 1227, 1309, 1, 0, 0, 0, 1228, 1229, 5, 203, 0, 0, 1229, 1230, 5, 30, 0, 0, 1230, 1231, 3, 6, 3, 0, 1231, 1232, 5, 28, 0, 0, 1232, 1233, 3, 6, 3, 0, 1233, 1234, 5, 31, 0, 0, 1234, 1309, 1, 0, 0, 0, 1235, 1236, 5, 204, 0, 0, 1236, 1237, 5, 205, 0, 0, 1237, 1238, 5, 42, 0, 0, 1238, 1239, 3, 32, 16, 0, 1239, 1240, 5, 43, 0, 0, 1240, 1309, 1, 0, 0, 0, 1241, 1242, 5, 204, 0, 0, 1242, 1243, 5, 206, 0, 0, 1243, 1244, 5, 42, 0, 0, 1244, 1245, 3, 32, 16, 0, 1245, 1246, 5, 43, 0, 0, 1246, 1247, 3, 148, 74, 0, 1247, 1309, 1, 0, 0, 0, 1248, 1309, 5, 207, 0, 0, 1249, 1309, 5, 208, 0, 0, 1250, 1309, 5, 209, 0, 0, 1251, 1309, 5, 201, 0, 0, 1252, 1309, 5, 183, 0, 0, 1253, 1309, 5, 184, 0, 0, 1254, 1309, 5, 185, 0, 0, 1255, 1309, 5, 186, 0, 0, 1256, 1309, 5, 187, 0, 0, 1257, 1309, 5, 188, 0, 0, 1258, 1309, 5, 189, 0, 0, 1259, 1309, 5, 210, 0, 0, 1260, 1309, 5, 190, 0, 0, 1261, 1309, 5, 191, 0, 0, 1262, 1309, 5, 192, 0, 0, 1263, 1309, 5, 193, 0, 0, 1264, 1309, 5, 211, 0, 0, 1265, 1309, 5, 212, 0, 0, 1266, 1309, 5, 213, 0, 0, 1267, 1309, 5, 214, 0, 0, 1268, 1309, 5, 215, 0, 0, 1269, 1309, 5, 216, 0, 0, 1270, 1309, 5, 217, 0, 0, 1271, 1272, 5, 218, 0, 0, 1272, 1309, 3, 154, 77, 0, 1273, 1274, 5, 219, 0, 0, 1274, 1309, 3, 154, 77, 0, 1275, 1309, 5, 220, 0, 0, 1276, 1277, 5, 221, 0, 0, 1277, 1309, 3, 154, 77, 0, 1278, 1279, 5, 222, 0, 0, 1279, 1309, 3, 156, 78, 0, 1280, 1281, 5, 222, 0, 0, 1281, 1282, 3, 156, 78, 0, 1282, 1283, 5, 28, 0, 0, 1283, 1284, 3, 6, 3, 0, 1284, 1309, 1, 0, 0, 0, 1285, 1309, 5, 194, 0, 0, 1286, 1309, 5, 195, 0, 0, 1287, 1288, 5, 90, 0, 0, 1288, 1309, 5, 184, 0, 0, 1289, 1290, 5, 90, 0, 0, 1290, 1309, 5, 185, 0, 0, 1291, 1292, 5, 90, 0, 0, 1292, 1309, 5, 186, 0, 0, 1293, 1294, 5, 90, 0, 0, 1294, 1309, 5, 187, 0, 0, 1295, 1296, 5, 62, 0, 0, 1296, 1309, 5, 220, 0, 0, 1297, 1309, 5, 223, 0, 0, 1298, 1299, 5, 224, 0, 0, 1299, 1309, 5, 213, 0, 0, 1300, 1309, 5, 225, 0, 0, 1301, 1302, 5, 207, 0, 0, 1302, 1309, 5, 183, 0, 0, 1303, 1309, 5, 226, 0, 0, 1304, 1309, 5, 228, 0, 0, 1305, 1306, 5, 34, 0, 0, 1306, 1309, 5, 227, 0, 0, 1307, 1309, 3, 2, 1, 0, 1308, 1216, 1, 0, 0, 0, 1308, 1217, 1, 0, 0, 0, 1308, 1228, 1, 0, 0, 0, 1308, 1235, 1, 0, 0, 0, 1308, 1241, 1, 0, 0, 0, 1308, 1248, 1, 0, 0, 0, 1308, 1249, 1, 0, 0, 0, 1308, 1250, 1, 0, 0, 0, 1308, 1251, 1, 0, 0, 0, 1308, 1252, 1, 0, 0, 0, 1308, 1253, 1, 0, 0, 0, 1308, 1254, 1, 0, 0, 0, 1308, 1255, 1, 0, 0, 0, 1308, 1256, 1, 0, 0, 0, 1308, 1257, 1, 0, 0, 0, 1308, 1258, 1, 0, 0, 0, 1308, 1259, 1, 0, 0, 0, 1308, 1260, 1, 0, 0, 0, 1308, 1261, 1, 0, 0, 0, 1308, 1262, 1, 0, 0, 0, 1308, 1263, 1, 0, 0, 0, 1308, 1264, 1, 0, 0, 0, 1308, 1265, 1, 0, 0, 0, 1308, 1266, 1, 0, 0, 0, 1308, 1267, 1, 0, 0, 0, 1308, 1268, 1, 0, 0, 0, 1308, 1269, 1, 0, 0, 0, 1308, 1270, 1, 0, 0, 0, 1308, 1271, 1, 0, 0, 0, 1308, 1273, 1, 0, 0, 0, 1308, 1275, 1, 0, 0, 0, 1308, 1276, 1, 0, 0, 0, 1308, 1278, 1, 0, 0, 0, 1308, 1280, 1, 0, 0, 0, 1308, 1285, 1, 0, 0, 0, 1308, 1286, 1, 0, 0, 0, 1308, 1287, 1, 0, 0, 0, 1308, 1289, 1, 0, 0, 0, 1308, 1291, 1, 0, 0, 0, 1308, 1293, 1, 0, 0, 0, 1308, 1295, 1, 0, 0, 0, 1308, 1297, 1, 0, 0, 0, 1308, 1298, 1, 0, 0, 0, 1308, 1300, 1, 0, 0, 0, 1308, 1301, 1, 0, 0, 0, 1308, 1303, 1, 0, 0, 0, 1308, 1304, 1, 0, 0, 0, 1308, 1305, 1, 0, 0, 0, 1308, 1307, 1, 0, 0, 0, 1309, 153, 1, 0, 0, 0, 1310, 1318, 1, 0, 0, 0, 1311, 1312, 5, 30, 0, 0, 1312, 1313, 5, 91, 0, 0, 1313, 1314, 5, 36, 0, 0, 1314, 1315, 3, 32, 16, 0, 1315, 1316, 5, 31, 0, 0, 1316, 1318, 1, 0, 0, 0, 1317, 1310, 1, 0, 0, 0, 1317, 1311, 1, 0, 0, 0, 1318, 155, 1, 0, 0, 0, 1319, 1328, 1, 0, 0, 0, 1320, 1324, 3, 158, 79, 0, 1321, 1323, 7, 7, 0, 0, 1322, 1321, 1, 0, 0, 0, 1323, 1326, 1, 0, 0, 0, 1324, 1322, 1, 0, 0, 0, 1324, 1325, 1, 0, 0, 0, 1325, 1328, 1, 0, 0, 0, 1326, 1324, 1, 0, 0, 0, 1327, 1319, 1, 0, 0, 0, 1327, 1320, 1, 0, 0, 0, 1328, 157, 1, 0, 0, 0, 1329, 1330, 7, 8, 0, 0, 1330, 159, 1, 0, 0, 0, 1331, 1335, 3, 164, 82, 0, 1332, 1334, 3, 162, 81, 0, 1333, 1332, 1, 0, 0, 0, 1334, 1337, 1, 0, 0, 0, 1335, 1333, 1, 0, 0, 0, 1335, 1336, 1, 0, 0, 0, 1336, 161, 1, 0, 0, 0, 1337, 1335, 1, 0, 0, 0, 1338, 1357, 5, 261, 0, 0, 1339, 1340, 5, 42, 0, 0, 1340, 1357, 5, 43, 0, 0, 1341, 1357, 3, 132, 66, 0, 1342, 1357, 5, 260, 0, 0, 1343, 1357, 5, 262, 0, 0, 1344, 1357, 5, 92, 0, 0, 1345, 1346, 5, 93, 0, 0, 1346, 1347, 5, 30, 0, 0, 1347, 1348, 3, 146, 73, 0, 1348, 1349, 5, 31, 0, 0, 1349, 1357, 1, 0, 0, 0, 1350, 1351, 5, 94, 0, 0, 1351, 1352, 5, 30, 0, 0, 1352, 1353, 3, 146, 73, 0, 1353, 1354, 5, 31, 0, 0, 1354, 1357, 1, 0, 0, 0, 1355, 1357, 3, 130, 65, 0, 1356, 1338, 1, 0, 0, 0, 1356, 1339, 1, 0, 0, 0, 1356, 1341, 1, 0, 0, 0, 1356, 1342, 1, 0, 0, 0, 1356, 1343, 1, 0, 0, 0, 1356, 1344, 1, 0, 0, 0, 1356, 1345, 1, 0, 0, 0, 1356, 1350, 1, 0, 0, 0, 1356, 1355, 1, 0, 0, 0, 1357, 163, 1, 0, 0, 0, 1358, 1359, 5, 39, 0, 0, 1359, 1389, 3, 138, 69, 0, 1360, 1389, 5, 197, 0, 0, 1361, 1362, 5, 199, 0, 0, 1362, 1363, 5, 39, 0, 0, 1363, 1389, 3, 138, 69, 0, 1364, 1365, 5, 200, 0, 0, 1365, 1389, 3, 138, 69, 0, 1366, 1367, 5, 226, 0, 0, 1367, 1368, 3, 192, 96, 0, 1368, 1369, 3, 160, 80, 0, 1369, 1370, 5, 262, 0, 0, 1370, 1371, 3, 134, 67, 0, 1371, 1389, 1, 0, 0, 0, 1372, 1373, 5, 253, 0, 0, 1373, 1389, 3, 32, 16, 0, 1374, 1375, 5, 252, 0, 0, 1375, 1389, 3, 32, 16, 0, 1376, 1377, 5, 253, 0, 0, 1377, 1389, 3, 2, 1, 0, 1378, 1379, 5, 252, 0, 0, 1379, 1389, 3, 2, 1, 0, 1380, 1389, 5, 254, 0, 0, 1381, 1389, 5, 201, 0, 0, 1382, 1389, 3, 170, 85, 0, 1383, 1389, 3, 172, 86, 0, 1384, 1389, 3, 166, 83, 0, 1385, 1389, 3, 2, 1, 0, 1386, 1387, 5, 177, 0, 0, 1387, 1389, 3, 160, 80, 0, 1388, 1358, 1, 0, 0, 0, 1388, 1360, 1, 0, 0, 0, 1388, 1361, 1, 0, 0, 0, 1388, 1364, 1, 0, 0, 0, 1388, 1366, 1, 0, 0, 0, 1388, 1372, 1, 0, 0, 0, 1388, 1374, 1, 0, 0, 0, 1388, 1376, 1, 0, 0, 0, 1388, 1378, 1, 0, 0, 0, 1388, 1380, 1, 0, 0, 0, 1388, 1381, 1, 0, 0, 0, 1388, 1382, 1, 0, 0, 0, 1388, 1383, 1, 0, 0, 0, 1388, 1384, 1, 0, 0, 0, 1388, 1385, 1, 0, 0, 0, 1388, 1386, 1, 0, 0, 0, 1389, 165, 1, 0, 0, 0, 1390, 1412, 5, 181, 0, 0, 1391, 1412, 5, 182, 0, 0, 1392, 1412, 5, 183, 0, 0, 1393, 1412, 5, 184, 0, 0, 1394, 1412, 5, 185, 0, 0, 1395, 1412, 5, 186, 0, 0, 1396, 1412, 5, 187, 0, 0, 1397, 1412, 5, 188, 0, 0, 1398, 1412, 5, 189, 0, 0, 1399, 1412, 5, 190, 0, 0, 1400, 1412, 5, 191, 0, 0, 1401, 1412, 5, 192, 0, 0, 1402, 1412, 5, 193, 0, 0, 1403, 1404, 5, 90, 0, 0, 1404, 1412, 5, 184, 0, 0, 1405, 1406, 5, 90, 0, 0, 1406, 1412, 5, 185, 0, 0, 1407, 1408, 5, 90, 0, 0, 1408, 1412, 5, 186, 0, 0, 1409, 1410, 5, 90, 0, 0, 1410, 1412, 5, 187, 0, 0, 1411, 1390, 1, 0, 0, 0, 1411, 1391, 1, 0, 0, 0, 1411, 1392, 1, 0, 0, 0, 1411, 1393, 1, 0, 0, 0, 1411, 1394, 1, 0, 0, 0, 1411, 1395, 1, 0, 0, 0, 1411, 1396, 1, 0, 0, 0, 1411, 1397, 1, 0, 0, 0, 1411, 1398, 1, 0, 0, 0, 1411, 1399, 1, 0, 0, 0, 1411, 1400, 1, 0, 0, 0, 1411, 1401, 1, 0, 0, 0, 1411, 1402, 1, 0, 0, 0, 1411, 1403, 1, 0, 0, 0, 1411, 1405, 1, 0, 0, 0, 1411, 1407, 1, 0, 0, 0, 1411, 1409, 1, 0, 0, 0, 1412, 167, 1, 0, 0, 0, 1413, 1424, 1, 0, 0, 0, 1414, 1424, 5, 177, 0, 0, 1415, 1424, 3, 32, 16, 0, 1416, 1417, 3, 32, 16, 0, 1417, 1418, 5, 177, 0, 0, 1418, 1419, 3, 32, 16, 0, 1419, 1424, 1, 0, 0, 0, 1420, 1421, 3, 32, 16, 0, 1421, 1422, 5, 177, 0, 0, 1422, 1424, 1, 0, 0, 0, 1423, 1413, 1, 0, 0, 0, 1423, 1414, 1, 0, 0, 0, 1423, 1415, 1, 0, 0, 0, 1423, 1416, 1, 0, 0, 0, 1423, 1420, 1, 0, 0, 0, 1424, 169, 1, 0, 0, 0, 1425, 1426, 5, 1, 0, 0, 1426, 1427, 5, 194, 0, 0, 1427, 171, 1, 0, 0, 0, 1428, 1432, 5, 1, 0, 0, 1429, 1430, 5, 90, 0, 0, 1430, 1433, 5, 194, 0, 0, 1431, 1433, 5, 195, 0, 0, 1432, 1429, 1, 0, 0, 0, 1432, 1431, 1, 0, 0, 0, 1433, 173, 1, 0, 0, 0, 1434, 1435, 5, 294, 0, 0, 1435, 1436, 3, 188, 94, 0, 1436, 1437, 3, 146, 73, 0, 1437, 1438, 5, 30, 0, 0, 1438, 1439, 3, 180, 90, 0, 1439, 1440, 5, 31, 0, 0, 1440, 1482, 1, 0, 0, 0, 1441, 1442, 5, 294, 0, 0, 1442, 1443, 3, 188, 94, 0, 1443, 1444, 3, 146, 73, 0, 1444, 1445, 5, 36, 0, 0, 1445, 1446, 5, 17, 0, 0, 1446, 1447, 3, 52, 26, 0, 1447, 1448, 5, 18, 0, 0, 1448, 1482, 1, 0, 0, 0, 1449, 1450, 5, 294, 0, 0, 1450, 1451, 3, 188, 94, 0, 1451, 1452, 3, 146, 73, 0, 1452, 1482, 1, 0, 0, 0, 1453, 1454, 5, 295, 0, 0, 1454, 1455, 3, 188, 94, 0, 1455, 1457, 5, 36, 0, 0, 1456, 1458, 5, 84, 0, 0, 1457, 1456, 1, 0, 0, 0, 1457, 1458, 1, 0, 0, 0, 1458, 1459, 1, 0, 0, 0, 1459, 1460, 5, 30, 0, 0, 1460, 1461, 3, 312, 156, 0, 1461, 1462, 5, 31, 0, 0, 1462, 1482, 1, 0, 0, 0, 1463, 1464, 5, 295, 0, 0, 1464, 1465, 3, 188, 94, 0, 1465, 1466, 5, 84, 0, 0, 1466, 1467, 5, 30, 0, 0, 1467, 1468, 3, 312, 156, 0, 1468, 1469, 5, 31, 0, 0, 1469, 1482, 1, 0, 0, 0, 1470, 1471, 5, 295, 0, 0, 1471, 1472, 3, 188, 94, 0, 1472, 1473, 3, 6, 3, 0, 1473, 1482, 1, 0, 0, 0, 1474, 1475, 5, 295, 0, 0, 1475, 1476, 3, 188, 94, 0, 1476, 1477, 5, 36, 0, 0, 1477, 1478, 5, 17, 0, 0, 1478, 1479, 3, 176, 88, 0, 1479, 1480, 5, 18, 0, 0, 1480, 1482, 1, 0, 0, 0, 1481, 1434, 1, 0, 0, 0, 1481, 1441, 1, 0, 0, 0, 1481, 1449, 1, 0, 0, 0, 1481, 1453, 1, 0, 0, 0, 1481, 1463, 1, 0, 0, 0, 1481, 1470, 1, 0, 0, 0, 1481, 1474, 1, 0, 0, 0, 1482, 175, 1, 0, 0, 0, 1483, 1494, 1, 0, 0, 0, 1484, 1485, 3, 178, 89, 0, 1485, 1486, 5, 28, 0, 0, 1486, 1488, 1, 0, 0, 0, 1487, 1484, 1, 0, 0, 0, 1488, 1491, 1, 0, 0, 0, 1489, 1487, 1, 0, 0, 0, 1489, 1490, 1, 0, 0, 0, 1490, 1492, 1, 0, 0, 0, 1491, 1489, 1, 0, 0, 0, 1492, 1494, 3, 178, 89, 0, 1493, 1483, 1, 0, 0, 0, 1493, 1489, 1, 0, 0, 0, 1494, 177, 1, 0, 0, 0, 1495, 1496, 5, 39, 0, 0, 1496, 1497, 5, 264, 0, 0, 1497, 1498, 5, 36, 0, 0, 1498, 1499, 5, 17, 0, 0, 1499, 1500, 3, 56, 28, 0, 1500, 1501, 5, 18, 0, 0, 1501, 1509, 1, 0, 0, 0, 1502, 1503, 3, 146, 73, 0, 1503, 1504, 5, 36, 0, 0, 1504, 1505, 5, 17, 0, 0, 1505, 1506, 3, 56, 28, 0, 1506, 1507, 5, 18, 0, 0, 1507, 1509, 1, 0, 0, 0, 1508, 1495, 1, 0, 0, 0, 1508, 1502, 1, 0, 0, 0, 1509, 179, 1, 0, 0, 0, 1510, 1511, 3, 182, 91, 0, 1511, 1512, 5, 28, 0, 0, 1512, 1514, 1, 0, 0, 0, 1513, 1510, 1, 0, 0, 0, 1514, 1517, 1, 0, 0, 0, 1515, 1513, 1, 0, 0, 0, 1515, 1516, 1, 0, 0, 0, 1516, 1518, 1, 0, 0, 0, 1517, 1515, 1, 0, 0, 0, 1518, 1519, 3, 182, 91, 0, 1519, 181, 1, 0, 0, 0, 1520, 1521, 3, 6, 3, 0, 1521, 1522, 5, 36, 0, 0, 1522, 1523, 3, 186, 93, 0, 1523, 183, 1, 0, 0, 0, 1524, 1525, 7, 9, 0, 0, 1525, 185, 1, 0, 0, 0, 1526, 1561, 3, 184, 92, 0, 1527, 1561, 3, 32, 16, 0, 1528, 1529, 5, 186, 0, 0, 1529, 1530, 5, 30, 0, 0, 1530, 1531, 3, 32, 16, 0, 1531, 1532, 5, 31, 0, 0, 1532, 1561, 1, 0, 0, 0, 1533, 1561, 3, 6, 3, 0, 1534, 1535, 3, 138, 69, 0, 1535, 1536, 5, 30, 0, 0, 1536, 1537, 5, 184, 0, 0, 1537, 1538, 5, 75, 0, 0, 1538, 1539, 3, 32, 16, 0, 1539, 1540, 5, 31, 0, 0, 1540, 1561, 1, 0, 0, 0, 1541, 1542, 3, 138, 69, 0, 1542, 1543, 5, 30, 0, 0, 1543, 1544, 5, 185, 0, 0, 1544, 1545, 5, 75, 0, 0, 1545, 1546, 3, 32, 16, 0, 1546, 1547, 5, 31, 0, 0, 1547, 1561, 1, 0, 0, 0, 1548, 1549, 3, 138, 69, 0, 1549, 1550, 5, 30, 0, 0, 1550, 1551, 5, 186, 0, 0, 1551, 1552, 5, 75, 0, 0, 1552, 1553, 3, 32, 16, 0, 1553, 1554, 5, 31, 0, 0, 1554, 1561, 1, 0, 0, 0, 1555, 1556, 3, 138, 69, 0, 1556, 1557, 5, 30, 0, 0, 1557, 1558, 3, 32, 16, 0, 1558, 1559, 5, 31, 0, 0, 1559, 1561, 1, 0, 0, 0, 1560, 1526, 1, 0, 0, 0, 1560, 1527, 1, 0, 0, 0, 1560, 1528, 1, 0, 0, 0, 1560, 1533, 1, 0, 0, 0, 1560, 1534, 1, 0, 0, 0, 1560, 1541, 1, 0, 0, 0, 1560, 1548, 1, 0, 0, 0, 1560, 1555, 1, 0, 0, 0, 1561, 187, 1, 0, 0, 0, 1562, 1563, 7, 10, 0, 0, 1563, 189, 1, 0, 0, 0, 1564, 1565, 3, 192, 96, 0, 1565, 1566, 3, 160, 80, 0, 1566, 1567, 3, 146, 73, 0, 1567, 1568, 5, 176, 0, 0, 1568, 1570, 3, 264, 132, 0, 1569, 1571, 3, 130, 65, 0, 1570, 1569, 1, 0, 0, 0, 1570, 1571, 1, 0, 0, 0, 1571, 1572, 1, 0, 0, 0, 1572, 1573, 3, 134, 67, 0, 1573, 1599, 1, 0, 0, 0, 1574, 1575, 3, 192, 96, 0, 1575, 1576, 3, 160, 80, 0, 1576, 1577, 3, 146, 73, 0, 1577, 1578, 5, 176, 0, 0, 1578, 1579, 3, 264, 132, 0, 1579, 1580, 3, 218, 109, 0, 1580, 1581, 3, 134, 67, 0, 1581, 1599, 1, 0, 0, 0, 1582, 1583, 3, 192, 96, 0, 1583, 1584, 3, 160, 80, 0, 1584, 1586, 3, 264, 132, 0, 1585, 1587, 3, 130, 65, 0, 1586, 1585, 1, 0, 0, 0, 1586, 1587, 1, 0, 0, 0, 1587, 1588, 1, 0, 0, 0, 1588, 1589, 3, 134, 67, 0, 1589, 1599, 1, 0, 0, 0, 1590, 1591, 3, 192, 96, 0, 1591, 1592, 3, 160, 80, 0, 1592, 1593, 3, 264, 132, 0, 1593, 1594, 3, 218, 109, 0, 1594, 1595, 3, 134, 67, 0, 1595, 1599, 1, 0, 0, 0, 1596, 1599, 3, 196, 98, 0, 1597, 1599, 3, 2, 1, 0, 1598, 1564, 1, 0, 0, 0, 1598, 1574, 1, 0, 0, 0, 1598, 1582, 1, 0, 0, 0, 1598, 1590, 1, 0, 0, 0, 1598, 1596, 1, 0, 0, 0, 1598, 1597, 1, 0, 0, 0, 1599, 191, 1, 0, 0, 0, 1600, 1601, 5, 243, 0, 0, 1601, 1611, 3, 192, 96, 0, 1602, 1603, 5, 244, 0, 0, 1603, 1611, 3, 192, 96, 0, 1604, 1611, 3, 194, 97, 0, 1605, 1606, 5, 112, 0, 0, 1606, 1607, 5, 30, 0, 0, 1607, 1608, 3, 32, 16, 0, 1608, 1609, 5, 31, 0, 0, 1609, 1611, 1, 0, 0, 0, 1610, 1600, 1, 0, 0, 0, 1610, 1602, 1, 0, 0, 0, 1610, 1604, 1, 0, 0, 0, 1610, 1605, 1, 0, 0, 0, 1611, 193, 1, 0, 0, 0, 1612, 1625, 1, 0, 0, 0, 1613, 1625, 5, 245, 0, 0, 1614, 1625, 5, 246, 0, 0, 1615, 1616, 5, 247, 0, 0, 1616, 1625, 5, 248, 0, 0, 1617, 1618, 5, 247, 0, 0, 1618, 1625, 5, 249, 0, 0, 1619, 1620, 5, 247, 0, 0, 1620, 1625, 5, 250, 0, 0, 1621, 1622, 5, 247, 0, 0, 1622, 1625, 5, 251, 0, 0, 1623, 1625, 5, 247, 0, 0, 1624, 1612, 1, 0, 0, 0, 1624, 1613, 1, 0, 0, 0, 1624, 1614, 1, 0, 0, 0, 1624, 1615, 1, 0, 0, 0, 1624, 1617, 1, 0, 0, 0, 1624, 1619, 1, 0, 0, 0, 1624, 1621, 1, 0, 0, 0, 1624, 1623, 1, 0, 0, 0, 1625, 195, 1, 0, 0, 0, 1626, 1627, 5, 113, 0, 0, 1627, 1628, 5, 30, 0, 0, 1628, 1629, 3, 32, 16, 0, 1629, 1630, 5, 31, 0, 0, 1630, 197, 1, 0, 0, 0, 1631, 1632, 5, 226, 0, 0, 1632, 1637, 3, 190, 95, 0, 1633, 1634, 5, 37, 0, 0, 1634, 1637, 3, 200, 100, 0, 1635, 1637, 3, 196, 98, 0, 1636, 1631, 1, 0, 0, 0, 1636, 1633, 1, 0, 0, 0, 1636, 1635, 1, 0, 0, 0, 1637, 199, 1, 0, 0, 0, 1638, 1639, 3, 160, 80, 0, 1639, 1640, 3, 146, 73, 0, 1640, 1641, 5, 176, 0, 0, 1641, 1642, 3, 2, 1, 0, 1642, 1648, 1, 0, 0, 0, 1643, 1644, 3, 160, 80, 0, 1644, 1645, 3, 2, 1, 0, 1645, 1648, 1, 0, 0, 0, 1646, 1648, 3, 2, 1, 0, 1647, 1638, 1, 0, 0, 0, 1647, 1643, 1, 0, 0, 0, 1647, 1646, 1, 0, 0, 0, 1648, 201, 1, 0, 0, 0, 1649, 1650, 3, 146, 73, 0, 1650, 1651, 5, 28, 0, 0, 1651, 1653, 1, 0, 0, 0, 1652, 1649, 1, 0, 0, 0, 1653, 1656, 1, 0, 0, 0, 1654, 1652, 1, 0, 0, 0, 1654, 1655, 1, 0, 0, 0, 1655, 1657, 1, 0, 0, 0, 1656, 1654, 1, 0, 0, 0, 1657, 1658, 3, 146, 73, 0, 1658, 203, 1, 0, 0, 0, 1659, 1665, 1, 0, 0, 0, 1660, 1661, 5, 86, 0, 0, 1661, 1662, 3, 212, 106, 0, 1662, 1663, 5, 87, 0, 0, 1663, 1665, 1, 0, 0, 0, 1664, 1659, 1, 0, 0, 0, 1664, 1660, 1, 0, 0, 0, 1665, 205, 1, 0, 0, 0, 1666, 1678, 5, 266, 0, 0, 1667, 1678, 5, 114, 0, 0, 1668, 1678, 5, 39, 0, 0, 1669, 1678, 5, 200, 0, 0, 1670, 1678, 5, 115, 0, 0, 1671, 1678, 5, 116, 0, 0, 1672, 1673, 5, 70, 0, 0, 1673, 1674, 5, 30, 0, 0, 1674, 1675, 3, 32, 16, 0, 1675, 1676, 5, 31, 0, 0, 1676, 1678, 1, 0, 0, 0, 1677, 1666, 1, 0, 0, 0, 1677, 1667, 1, 0, 0, 0, 1677, 1668, 1, 0, 0, 0, 1677, 1669, 1, 0, 0, 0, 1677, 1670, 1, 0, 0, 0, 1677, 1671, 1, 0, 0, 0, 1677, 1672, 1, 0, 0, 0, 1678, 207, 1, 0, 0, 0, 1679, 1681, 3, 206, 103, 0, 1680, 1679, 1, 0, 0, 0, 1681, 1684, 1, 0, 0, 0, 1682, 1680, 1, 0, 0, 0, 1682, 1683, 1, 0, 0, 0, 1683, 209, 1, 0, 0, 0, 1684, 1682, 1, 0, 0, 0, 1685, 1687, 3, 208, 104, 0, 1686, 1688, 3, 214, 107, 0, 1687, 1686, 1, 0, 0, 0, 1687, 1688, 1, 0, 0, 0, 1688, 1689, 1, 0, 0, 0, 1689, 1690, 3, 2, 1, 0, 1690, 211, 1, 0, 0, 0, 1691, 1692, 3, 210, 105, 0, 1692, 1693, 5, 28, 0, 0, 1693, 1695, 1, 0, 0, 0, 1694, 1691, 1, 0, 0, 0, 1695, 1698, 1, 0, 0, 0, 1696, 1694, 1, 0, 0, 0, 1696, 1697, 1, 0, 0, 0, 1697, 1699, 1, 0, 0, 0, 1698, 1696, 1, 0, 0, 0, 1699, 1700, 3, 210, 105, 0, 1700, 213, 1, 0, 0, 0, 1701, 1702, 5, 30, 0, 0, 1702, 1703, 3, 202, 101, 0, 1703, 1704, 5, 31, 0, 0, 1704, 215, 1, 0, 0, 0, 1705, 1708, 1, 0, 0, 0, 1706, 1708, 3, 218, 109, 0, 1707, 1705, 1, 0, 0, 0, 1707, 1706, 1, 0, 0, 0, 1708, 217, 1, 0, 0, 0, 1709, 1710, 5, 86, 0, 0, 1710, 1711, 5, 42, 0, 0, 1711, 1712, 3, 32, 16, 0, 1712, 1713, 5, 43, 0, 0, 1713, 1714, 5, 87, 0, 0, 1714, 219, 1, 0, 0, 0, 1715, 1716, 3, 256, 128, 0, 1716, 1717, 5, 17, 0, 0, 1717, 1718, 3, 268, 134, 0, 1718, 1719, 5, 18, 0, 0, 1719, 1832, 1, 0, 0, 0, 1720, 1721, 3, 74, 37, 0, 1721, 1722, 5, 17, 0, 0, 1722, 1723, 3, 82, 41, 0, 1723, 1724, 5, 18, 0, 0, 1724, 1832, 1, 0, 0, 0, 1725, 1726, 3, 232, 116, 0, 1726, 1727, 5, 17, 0, 0, 1727, 1728, 3, 236, 118, 0, 1728, 1729, 5, 18, 0, 0, 1729, 1832, 1, 0, 0, 0, 1730, 1731, 3, 240, 120, 0, 1731, 1732, 5, 17, 0, 0, 1732, 1733, 3, 244, 122, 0, 1733, 1734, 5, 18, 0, 0, 1734, 1832, 1, 0, 0, 0, 1735, 1832, 3, 222, 111, 0, 1736, 1832, 3, 296, 148, 0, 1737, 1832, 3, 174, 87, 0, 1738, 1832, 3, 88, 44, 0, 1739, 1832, 3, 342, 171, 0, 1740, 1741, 5, 117, 0, 0, 1741, 1832, 3, 32, 16, 0, 1742, 1743, 5, 118, 0, 0, 1743, 1832, 3, 32, 16, 0, 1744, 1745, 3, 354, 177, 0, 1745, 1746, 5, 17, 0, 0, 1746, 1747, 3, 358, 179, 0, 1747, 1748, 5, 18, 0, 0, 1748, 1832, 1, 0, 0, 0, 1749, 1750, 5, 302, 0, 0, 1750, 1751, 3, 146, 73, 0, 1751, 1752, 5, 176, 0, 0, 1752, 1753, 3, 264, 132, 0, 1753, 1754, 5, 119, 0, 0, 1754, 1755, 3, 192, 96, 0, 1755, 1756, 3, 160, 80, 0, 1756, 1757, 3, 146, 73, 0, 1757, 1758, 5, 176, 0, 0, 1758, 1759, 3, 264, 132, 0, 1759, 1760, 3, 134, 67, 0, 1760, 1832, 1, 0, 0, 0, 1761, 1762, 5, 302, 0, 0, 1762, 1763, 5, 226, 0, 0, 1763, 1764, 3, 192, 96, 0, 1764, 1765, 3, 160, 80, 0, 1765, 1766, 3, 146, 73, 0, 1766, 1767, 5, 176, 0, 0, 1767, 1768, 3, 264, 132, 0, 1768, 1769, 3, 216, 108, 0, 1769, 1770, 3, 134, 67, 0, 1770, 1771, 5, 119, 0, 0, 1771, 1772, 5, 226, 0, 0, 1772, 1773, 3, 192, 96, 0, 1773, 1774, 3, 160, 80, 0, 1774, 1775, 3, 146, 73, 0, 1775, 1776, 5, 176, 0, 0, 1776, 1777, 3, 264, 132, 0, 1777, 1778, 3, 216, 108, 0, 1778, 1779, 3, 134, 67, 0, 1779, 1832, 1, 0, 0, 0, 1780, 1832, 3, 26, 13, 0, 1781, 1832, 3, 40, 20, 0, 1782, 1783, 5, 255, 0, 0, 1783, 1784, 5, 196, 0, 0, 1784, 1785, 5, 42, 0, 0, 1785, 1786, 3, 32, 16, 0, 1786, 1790, 5, 43, 0, 0, 1787, 1789, 3, 342, 171, 0, 1788, 1787, 1, 0, 0, 0, 1789, 1792, 1, 0, 0, 0, 1790, 1788, 1, 0, 0, 0, 1790, 1791, 1, 0, 0, 0, 1791, 1832, 1, 0, 0, 0, 1792, 1790, 1, 0, 0, 0, 1793, 1794, 5, 255, 0, 0, 1794, 1795, 5, 196, 0, 0, 1795, 1799, 3, 2, 1, 0, 1796, 1798, 3, 342, 171, 0, 1797, 1796, 1, 0, 0, 0, 1798, 1801, 1, 0, 0, 0, 1799, 1797, 1, 0, 0, 0, 1799, 1800, 1, 0, 0, 0, 1800, 1832, 1, 0, 0, 0, 1801, 1799, 1, 0, 0, 0, 1802, 1803, 5, 255, 0, 0, 1803, 1804, 5, 256, 0, 0, 1804, 1805, 5, 42, 0, 0, 1805, 1806, 3, 32, 16, 0, 1806, 1807, 5, 43, 0, 0, 1807, 1808, 5, 28, 0, 0, 1808, 1812, 3, 146, 73, 0, 1809, 1811, 3, 342, 171, 0, 1810, 1809, 1, 0, 0, 0, 1811, 1814, 1, 0, 0, 0, 1812, 1810, 1, 0, 0, 0, 1812, 1813, 1, 0, 0, 0, 1813, 1832, 1, 0, 0, 0, 1814, 1812, 1, 0, 0, 0, 1815, 1816, 5, 255, 0, 0, 1816, 1817, 5, 256, 0, 0, 1817, 1818, 3, 2, 1, 0, 1818, 1819, 5, 28, 0, 0, 1819, 1823, 3, 146, 73, 0, 1820, 1822, 3, 342, 171, 0, 1821, 1820, 1, 0, 0, 0, 1822, 1825, 1, 0, 0, 0, 1823, 1821, 1, 0, 0, 0, 1823, 1824, 1, 0, 0, 0, 1824, 1832, 1, 0, 0, 0, 1825, 1823, 1, 0, 0, 0, 1826, 1827, 5, 120, 0, 0, 1827, 1828, 5, 196, 0, 0, 1828, 1829, 3, 146, 73, 0, 1829, 1830, 3, 44, 22, 0, 1830, 1832, 1, 0, 0, 0, 1831, 1715, 1, 0, 0, 0, 1831, 1720, 1, 0, 0, 0, 1831, 1725, 1, 0, 0, 0, 1831, 1730, 1, 0, 0, 0, 1831, 1735, 1, 0, 0, 0, 1831, 1736, 1, 0, 0, 0, 1831, 1737, 1, 0, 0, 0, 1831, 1738, 1, 0, 0, 0, 1831, 1739, 1, 0, 0, 0, 1831, 1740, 1, 0, 0, 0, 1831, 1742, 1, 0, 0, 0, 1831, 1744, 1, 0, 0, 0, 1831, 1749, 1, 0, 0, 0, 1831, 1761, 1, 0, 0, 0, 1831, 1780, 1, 0, 0, 0, 1831, 1781, 1, 0, 0, 0, 1831, 1782, 1, 0, 0, 0, 1831, 1793, 1, 0, 0, 0, 1831, 1802, 1, 0, 0, 0, 1831, 1815, 1, 0, 0, 0, 1831, 1826, 1, 0, 0, 0, 1832, 221, 1, 0, 0, 0, 1833, 1834, 5, 121, 0, 0, 1834, 1843, 3, 230, 115, 0, 1835, 1842, 3, 224, 112, 0, 1836, 1837, 5, 122, 0, 0, 1837, 1838, 5, 30, 0, 0, 1838, 1839, 3, 250, 125, 0, 1839, 1840, 5, 31, 0, 0, 1840, 1842, 1, 0, 0, 0, 1841, 1835, 1, 0, 0, 0, 1841, 1836, 1, 0, 0, 0, 1842, 1845, 1, 0, 0, 0, 1843, 1841, 1, 0, 0, 0, 1843, 1844, 1, 0, 0, 0, 1844, 1846, 1, 0, 0, 0, 1845, 1843, 1, 0, 0, 0, 1846, 1847, 3, 160, 80, 0, 1847, 1848, 3, 2, 1, 0, 1848, 1849, 3, 226, 113, 0, 1849, 1850, 3, 228, 114, 0, 1850, 223, 1, 0, 0, 0, 1851, 1871, 5, 123, 0, 0, 1852, 1871, 5, 51, 0, 0, 1853, 1871, 5, 52, 0, 0, 1854, 1871, 5, 63, 0, 0, 1855, 1871, 5, 124, 0, 0, 1856, 1871, 5, 69, 0, 0, 1857, 1871, 5, 68, 0, 0, 1858, 1871, 5, 64, 0, 0, 1859, 1871, 5, 65, 0, 0, 1860, 1871, 5, 66, 0, 0, 1861, 1871, 5, 125, 0, 0, 1862, 1871, 5, 126, 0, 0, 1863, 1871, 5, 127, 0, 0, 1864, 1871, 5, 16, 0, 0, 1865, 1866, 5, 70, 0, 0, 1866, 1867, 5, 30, 0, 0, 1867, 1868, 3, 32, 16, 0, 1868, 1869, 5, 31, 0, 0, 1869, 1871, 1, 0, 0, 0, 1870, 1851, 1, 0, 0, 0, 1870, 1852, 1, 0, 0, 0, 1870, 1853, 1, 0, 0, 0, 1870, 1854, 1, 0, 0, 0, 1870, 1855, 1, 0, 0, 0, 1870, 1856, 1, 0, 0, 0, 1870, 1857, 1, 0, 0, 0, 1870, 1858, 1, 0, 0, 0, 1870, 1859, 1, 0, 0, 0, 1870, 1860, 1, 0, 0, 0, 1870, 1861, 1, 0, 0, 0, 1870, 1862, 1, 0, 0, 0, 1870, 1863, 1, 0, 0, 0, 1870, 1864, 1, 0, 0, 0, 1870, 1865, 1, 0, 0, 0, 1871, 225, 1, 0, 0, 0, 1872, 1878, 1, 0, 0, 0, 1873, 1874, 5, 44, 0, 0, 1874, 1878, 3, 0, 0, 0, 1875, 1876, 5, 44, 0, 0, 1876, 1878, 3, 32, 16, 0, 1877, 1872, 1, 0, 0, 0, 1877, 1873, 1, 0, 0, 0, 1877, 1875, 1, 0, 0, 0, 1878, 227, 1, 0, 0, 0, 1879, 1883, 1, 0, 0, 0, 1880, 1881, 5, 36, 0, 0, 1881, 1883, 3, 316, 158, 0, 1882, 1879, 1, 0, 0, 0, 1882, 1880, 1, 0, 0, 0, 1883, 229, 1, 0, 0, 0, 1884, 1890, 1, 0, 0, 0, 1885, 1886, 5, 42, 0, 0, 1886, 1887, 3, 32, 16, 0, 1887, 1888, 5, 43, 0, 0, 1888, 1890, 1, 0, 0, 0, 1889, 1884, 1, 0, 0, 0, 1889, 1885, 1, 0, 0, 0, 1890, 231, 1, 0, 0, 0, 1891, 1895, 5, 128, 0, 0, 1892, 1894, 3, 234, 117, 0, 1893, 1892, 1, 0, 0, 0, 1894, 1897, 1, 0, 0, 0, 1895, 1893, 1, 0, 0, 0, 1895, 1896, 1, 0, 0, 0, 1896, 1898, 1, 0, 0, 0, 1897, 1895, 1, 0, 0, 0, 1898, 1899, 3, 146, 73, 0, 1899, 1900, 3, 2, 1, 0, 1900, 1910, 1, 0, 0, 0, 1901, 1905, 5, 128, 0, 0, 1902, 1904, 3, 234, 117, 0, 1903, 1902, 1, 0, 0, 0, 1904, 1907, 1, 0, 0, 0, 1905, 1903, 1, 0, 0, 0, 1905, 1906, 1, 0, 0, 0, 1906, 1908, 1, 0, 0, 0, 1907, 1905, 1, 0, 0, 0, 1908, 1910, 3, 2, 1, 0, 1909, 1891, 1, 0, 0, 0, 1909, 1901, 1, 0, 0, 0, 1910, 233, 1, 0, 0, 0, 1911, 1912, 7, 11, 0, 0, 1912, 235, 1, 0, 0, 0, 1913, 1915, 3, 238, 119, 0, 1914, 1913, 1, 0, 0, 0, 1915, 1918, 1, 0, 0, 0, 1916, 1914, 1, 0, 0, 0, 1916, 1917, 1, 0, 0, 0, 1917, 237, 1, 0, 0, 0, 1918, 1916, 1, 0, 0, 0, 1919, 1920, 5, 129, 0, 0, 1920, 1932, 3, 190, 95, 0, 1921, 1922, 5, 130, 0, 0, 1922, 1932, 3, 190, 95, 0, 1923, 1924, 5, 131, 0, 0, 1924, 1932, 3, 190, 95, 0, 1925, 1926, 5, 132, 0, 0, 1926, 1932, 3, 190, 95, 0, 1927, 1932, 3, 88, 44, 0, 1928, 1932, 3, 342, 171, 0, 1929, 1932, 3, 26, 13, 0, 1930, 1932, 3, 40, 20, 0, 1931, 1919, 1, 0, 0, 0, 1931, 1921, 1, 0, 0, 0, 1931, 1923, 1, 0, 0, 0, 1931, 1925, 1, 0, 0, 0, 1931, 1927, 1, 0, 0, 0, 1931, 1928, 1, 0, 0, 0, 1931, 1929, 1, 0, 0, 0, 1931, 1930, 1, 0, 0, 0, 1932, 239, 1, 0, 0, 0, 1933, 1937, 5, 133, 0, 0, 1934, 1936, 3, 242, 121, 0, 1935, 1934, 1, 0, 0, 0, 1936, 1939, 1, 0, 0, 0, 1937, 1935, 1, 0, 0, 0, 1937, 1938, 1, 0, 0, 0, 1938, 1940, 1, 0, 0, 0, 1939, 1937, 1, 0, 0, 0, 1940, 1941, 3, 192, 96, 0, 1941, 1942, 3, 160, 80, 0, 1942, 1943, 3, 2, 1, 0, 1943, 1944, 3, 134, 67, 0, 1944, 1945, 3, 228, 114, 0, 1945, 241, 1, 0, 0, 0, 1946, 1947, 7, 11, 0, 0, 1947, 243, 1, 0, 0, 0, 1948, 1950, 3, 246, 123, 0, 1949, 1948, 1, 0, 0, 0, 1950, 1953, 1, 0, 0, 0, 1951, 1949, 1, 0, 0, 0, 1951, 1952, 1, 0, 0, 0, 1952, 245, 1, 0, 0, 0, 1953, 1951, 1, 0, 0, 0, 1954, 1955, 5, 134, 0, 0, 1955, 1965, 3, 190, 95, 0, 1956, 1957, 5, 135, 0, 0, 1957, 1965, 3, 190, 95, 0, 1958, 1959, 5, 132, 0, 0, 1959, 1965, 3, 190, 95, 0, 1960, 1965, 3, 342, 171, 0, 1961, 1965, 3, 88, 44, 0, 1962, 1965, 3, 26, 13, 0, 1963, 1965, 3, 40, 20, 0, 1964, 1954, 1, 0, 0, 0, 1964, 1956, 1, 0, 0, 0, 1964, 1958, 1, 0, 0, 0, 1964, 1960, 1, 0, 0, 0, 1964, 1961, 1, 0, 0, 0, 1964, 1962, 1, 0, 0, 0, 1964, 1963, 1, 0, 0, 0, 1965, 247, 1, 0, 0, 0, 1966, 1973, 1, 0, 0, 0, 1967, 1968, 5, 122, 0, 0, 1968, 1969, 5, 30, 0, 0, 1969, 1970, 3, 250, 125, 0, 1970, 1971, 5, 31, 0, 0, 1971, 1973, 1, 0, 0, 0, 1972, 1966, 1, 0, 0, 0, 1972, 1967, 1, 0, 0, 0, 1973, 249, 1, 0, 0, 0, 1974, 1984, 3, 148, 74, 0, 1975, 1977, 5, 17, 0, 0, 1976, 1978, 3, 314, 157, 0, 1977, 1976, 1, 0, 0, 0, 1978, 1979, 1, 0, 0, 0, 1979, 1977, 1, 0, 0, 0, 1979, 1980, 1, 0, 0, 0, 1980, 1981, 1, 0, 0, 0, 1981, 1982, 5, 18, 0, 0, 1982, 1984, 1, 0, 0, 0, 1983, 1974, 1, 0, 0, 0, 1983, 1975, 1, 0, 0, 0, 1984, 251, 1, 0, 0, 0, 1985, 1987, 3, 254, 127, 0, 1986, 1985, 1, 0, 0, 0, 1987, 1990, 1, 0, 0, 0, 1988, 1986, 1, 0, 0, 0, 1988, 1989, 1, 0, 0, 0, 1989, 253, 1, 0, 0, 0, 1990, 1988, 1, 0, 0, 0, 1991, 1992, 5, 42, 0, 0, 1992, 1993, 5, 136, 0, 0, 1993, 2005, 5, 43, 0, 0, 1994, 1995, 5, 42, 0, 0, 1995, 1996, 5, 137, 0, 0, 1996, 2005, 5, 43, 0, 0, 1997, 1998, 5, 42, 0, 0, 1998, 1999, 5, 138, 0, 0, 1999, 2005, 5, 43, 0, 0, 2000, 2001, 5, 42, 0, 0, 2001, 2002, 3, 32, 16, 0, 2002, 2003, 5, 43, 0, 0, 2003, 2005, 1, 0, 0, 0, 2004, 1991, 1, 0, 0, 0, 2004, 1994, 1, 0, 0, 0, 2004, 1997, 1, 0, 0, 0, 2004, 2000, 1, 0, 0, 0, 2005, 255, 1, 0, 0, 0, 2006, 2011, 5, 139, 0, 0, 2007, 2010, 3, 258, 129, 0, 2008, 2010, 3, 260, 130, 0, 2009, 2007, 1, 0, 0, 0, 2009, 2008, 1, 0, 0, 0, 2010, 2013, 1, 0, 0, 0, 2011, 2009, 1, 0, 0, 0, 2011, 2012, 1, 0, 0, 0, 2012, 2014, 1, 0, 0, 0, 2013, 2011, 1, 0, 0, 0, 2014, 2015, 3, 192, 96, 0, 2015, 2016, 3, 252, 126, 0, 2016, 2017, 3, 160, 80, 0, 2017, 2018, 3, 248, 124, 0, 2018, 2019, 3, 264, 132, 0, 2019, 2020, 3, 204, 102, 0, 2020, 2024, 3, 134, 67, 0, 2021, 2023, 3, 266, 133, 0, 2022, 2021, 1, 0, 0, 0, 2023, 2026, 1, 0, 0, 0, 2024, 2022, 1, 0, 0, 0, 2024, 2025, 1, 0, 0, 0, 2025, 257, 1, 0, 0, 0, 2026, 2024, 1, 0, 0, 0, 2027, 2051, 5, 123, 0, 0, 2028, 2051, 5, 51, 0, 0, 2029, 2051, 5, 52, 0, 0, 2030, 2051, 5, 63, 0, 0, 2031, 2051, 5, 140, 0, 0, 2032, 2051, 5, 68, 0, 0, 2033, 2051, 5, 141, 0, 0, 2034, 2051, 5, 142, 0, 0, 2035, 2051, 5, 54, 0, 0, 2036, 2051, 5, 64, 0, 0, 2037, 2051, 5, 65, 0, 0, 2038, 2051, 5, 66, 0, 0, 2039, 2051, 5, 125, 0, 0, 2040, 2051, 5, 143, 0, 0, 2041, 2051, 5, 144, 0, 0, 2042, 2051, 5, 69, 0, 0, 2043, 2051, 5, 145, 0, 0, 2044, 2051, 5, 146, 0, 0, 2045, 2046, 5, 70, 0, 0, 2046, 2047, 5, 30, 0, 0, 2047, 2048, 3, 32, 16, 0, 2048, 2049, 5, 31, 0, 0, 2049, 2051, 1, 0, 0, 0, 2050, 2027, 1, 0, 0, 0, 2050, 2028, 1, 0, 0, 0, 2050, 2029, 1, 0, 0, 0, 2050, 2030, 1, 0, 0, 0, 2050, 2031, 1, 0, 0, 0, 2050, 2032, 1, 0, 0, 0, 2050, 2033, 1, 0, 0, 0, 2050, 2034, 1, 0, 0, 0, 2050, 2035, 1, 0, 0, 0, 2050, 2036, 1, 0, 0, 0, 2050, 2037, 1, 0, 0, 0, 2050, 2038, 1, 0, 0, 0, 2050, 2039, 1, 0, 0, 0, 2050, 2040, 1, 0, 0, 0, 2050, 2041, 1, 0, 0, 0, 2050, 2042, 1, 0, 0, 0, 2050, 2043, 1, 0, 0, 0, 2050, 2044, 1, 0, 0, 0, 2050, 2045, 1, 0, 0, 0, 2051, 259, 1, 0, 0, 0, 2052, 2053, 5, 147, 0, 0, 2053, 2059, 5, 30, 0, 0, 2054, 2057, 3, 6, 3, 0, 2055, 2056, 5, 34, 0, 0, 2056, 2058, 3, 6, 3, 0, 2057, 2055, 1, 0, 0, 0, 2057, 2058, 1, 0, 0, 0, 2058, 2060, 1, 0, 0, 0, 2059, 2054, 1, 0, 0, 0, 2059, 2060, 1, 0, 0, 0, 2060, 2064, 1, 0, 0, 0, 2061, 2063, 3, 262, 131, 0, 2062, 2061, 1, 0, 0, 0, 2063, 2066, 1, 0, 0, 0, 2064, 2062, 1, 0, 0, 0, 2064, 2065, 1, 0, 0, 0, 2065, 2067, 1, 0, 0, 0, 2066, 2064, 1, 0, 0, 0, 2067, 2071, 5, 31, 0, 0, 2068, 2069, 5, 147, 0, 0, 2069, 2071, 5, 85, 0, 0, 2070, 2052, 1, 0, 0, 0, 2070, 2068, 1, 0, 0, 0, 2071, 261, 1, 0, 0, 0, 2072, 2100, 5, 148, 0, 0, 2073, 2100, 5, 224, 0, 0, 2074, 2100, 5, 57, 0, 0, 2075, 2100, 5, 58, 0, 0, 2076, 2100, 5, 149, 0, 0, 2077, 2100, 5, 150, 0, 0, 2078, 2100, 5, 248, 0, 0, 2079, 2100, 5, 249, 0, 0, 2080, 2100, 5, 250, 0, 0, 2081, 2100, 5, 251, 0, 0, 2082, 2083, 5, 151, 0, 0, 2083, 2084, 5, 75, 0, 0, 2084, 2100, 5, 152, 0, 0, 2085, 2086, 5, 151, 0, 0, 2086, 2087, 5, 75, 0, 0, 2087, 2100, 5, 153, 0, 0, 2088, 2089, 5, 154, 0, 0, 2089, 2090, 5, 75, 0, 0, 2090, 2100, 5, 152, 0, 0, 2091, 2092, 5, 154, 0, 0, 2092, 2093, 5, 75, 0, 0, 2093, 2100, 5, 153, 0, 0, 2094, 2095, 5, 70, 0, 0, 2095, 2096, 5, 30, 0, 0, 2096, 2097, 3, 32, 16, 0, 2097, 2098, 5, 31, 0, 0, 2098, 2100, 1, 0, 0, 0, 2099, 2072, 1, 0, 0, 0, 2099, 2073, 1, 0, 0, 0, 2099, 2074, 1, 0, 0, 0, 2099, 2075, 1, 0, 0, 0, 2099, 2076, 1, 0, 0, 0, 2099, 2077, 1, 0, 0, 0, 2099, 2078, 1, 0, 0, 0, 2099, 2079, 1, 0, 0, 0, 2099, 2080, 1, 0, 0, 0, 2099, 2081, 1, 0, 0, 0, 2099, 2082, 1, 0, 0, 0, 2099, 2085, 1, 0, 0, 0, 2099, 2088, 1, 0, 0, 0, 2099, 2091, 1, 0, 0, 0, 2099, 2094, 1, 0, 0, 0, 2100, 263, 1, 0, 0, 0, 2101, 2105, 5, 116, 0, 0, 2102, 2105, 5, 155, 0, 0, 2103, 2105, 3, 2, 1, 0, 2104, 2101, 1, 0, 0, 0, 2104, 2102, 1, 0, 0, 0, 2104, 2103, 1, 0, 0, 0, 2105, 265, 1, 0, 0, 0, 2106, 2128, 5, 1, 0, 0, 2107, 2128, 5, 2, 0, 0, 2108, 2128, 5, 156, 0, 0, 2109, 2128, 5, 3, 0, 0, 2110, 2128, 5, 4, 0, 0, 2111, 2128, 5, 247, 0, 0, 2112, 2128, 5, 5, 0, 0, 2113, 2128, 5, 6, 0, 0, 2114, 2128, 5, 7, 0, 0, 2115, 2128, 5, 8, 0, 0, 2116, 2128, 5, 9, 0, 0, 2117, 2128, 5, 10, 0, 0, 2118, 2128, 5, 11, 0, 0, 2119, 2128, 5, 12, 0, 0, 2120, 2128, 5, 13, 0, 0, 2121, 2128, 5, 14, 0, 0, 2122, 2123, 5, 70, 0, 0, 2123, 2124, 5, 30, 0, 0, 2124, 2125, 3, 32, 16, 0, 2125, 2126, 5, 31, 0, 0, 2126, 2128, 1, 0, 0, 0, 2127, 2106, 1, 0, 0, 0, 2127, 2107, 1, 0, 0, 0, 2127, 2108, 1, 0, 0, 0, 2127, 2109, 1, 0, 0, 0, 2127, 2110, 1, 0, 0, 0, 2127, 2111, 1, 0, 0, 0, 2127, 2112, 1, 0, 0, 0, 2127, 2113, 1, 0, 0, 0, 2127, 2114, 1, 0, 0, 0, 2127, 2115, 1, 0, 0, 0, 2127, 2116, 1, 0, 0, 0, 2127, 2117, 1, 0, 0, 0, 2127, 2118, 1, 0, 0, 0, 2127, 2119, 1, 0, 0, 0, 2127, 2120, 1, 0, 0, 0, 2127, 2121, 1, 0, 0, 0, 2127, 2122, 1, 0, 0, 0, 2128, 267, 1, 0, 0, 0, 2129, 2131, 3, 270, 135, 0, 2130, 2129, 1, 0, 0, 0, 2131, 2134, 1, 0, 0, 0, 2132, 2130, 1, 0, 0, 0, 2132, 2133, 1, 0, 0, 0, 2133, 269, 1, 0, 0, 0, 2134, 2132, 1, 0, 0, 0, 2135, 2244, 3, 126, 63, 0, 2136, 2137, 5, 296, 0, 0, 2137, 2244, 3, 32, 16, 0, 2138, 2244, 3, 278, 139, 0, 2139, 2140, 5, 297, 0, 0, 2140, 2244, 3, 32, 16, 0, 2141, 2142, 5, 300, 0, 0, 2142, 2244, 3, 134, 67, 0, 2143, 2144, 5, 300, 0, 0, 2144, 2145, 5, 157, 0, 0, 2145, 2244, 3, 134, 67, 0, 2146, 2244, 5, 298, 0, 0, 2147, 2244, 5, 299, 0, 0, 2148, 2244, 3, 296, 148, 0, 2149, 2244, 3, 272, 136, 0, 2150, 2244, 3, 174, 87, 0, 2151, 2244, 3, 88, 44, 0, 2152, 2244, 3, 26, 13, 0, 2153, 2244, 3, 274, 137, 0, 2154, 2244, 3, 40, 20, 0, 2155, 2156, 5, 301, 0, 0, 2156, 2157, 5, 42, 0, 0, 2157, 2158, 3, 32, 16, 0, 2158, 2159, 5, 43, 0, 0, 2159, 2244, 1, 0, 0, 0, 2160, 2161, 5, 301, 0, 0, 2161, 2162, 5, 42, 0, 0, 2162, 2163, 3, 32, 16, 0, 2163, 2164, 5, 43, 0, 0, 2164, 2165, 5, 34, 0, 0, 2165, 2166, 3, 0, 0, 0, 2166, 2244, 1, 0, 0, 0, 2167, 2168, 5, 303, 0, 0, 2168, 2169, 3, 32, 16, 0, 2169, 2170, 5, 75, 0, 0, 2170, 2171, 3, 32, 16, 0, 2171, 2244, 1, 0, 0, 0, 2172, 2173, 5, 302, 0, 0, 2173, 2174, 3, 146, 73, 0, 2174, 2175, 5, 176, 0, 0, 2175, 2176, 3, 264, 132, 0, 2176, 2244, 1, 0, 0, 0, 2177, 2178, 5, 302, 0, 0, 2178, 2179, 5, 226, 0, 0, 2179, 2180, 3, 192, 96, 0, 2180, 2181, 3, 160, 80, 0, 2181, 2182, 3, 146, 73, 0, 2182, 2183, 5, 176, 0, 0, 2183, 2184, 3, 264, 132, 0, 2184, 2185, 3, 216, 108, 0, 2185, 2186, 3, 134, 67, 0, 2186, 2244, 1, 0, 0, 0, 2187, 2244, 3, 276, 138, 0, 2188, 2189, 5, 255, 0, 0, 2189, 2190, 5, 196, 0, 0, 2190, 2191, 5, 42, 0, 0, 2191, 2192, 3, 32, 16, 0, 2192, 2196, 5, 43, 0, 0, 2193, 2195, 3, 342, 171, 0, 2194, 2193, 1, 0, 0, 0, 2195, 2198, 1, 0, 0, 0, 2196, 2194, 1, 0, 0, 0, 2196, 2197, 1, 0, 0, 0, 2197, 2244, 1, 0, 0, 0, 2198, 2196, 1, 0, 0, 0, 2199, 2200, 5, 255, 0, 0, 2200, 2201, 5, 196, 0, 0, 2201, 2205, 3, 2, 1, 0, 2202, 2204, 3, 342, 171, 0, 2203, 2202, 1, 0, 0, 0, 2204, 2207, 1, 0, 0, 0, 2205, 2203, 1, 0, 0, 0, 2205, 2206, 1, 0, 0, 0, 2206, 2244, 1, 0, 0, 0, 2207, 2205, 1, 0, 0, 0, 2208, 2209, 5, 255, 0, 0, 2209, 2210, 5, 256, 0, 0, 2210, 2211, 5, 42, 0, 0, 2211, 2212, 3, 32, 16, 0, 2212, 2213, 5, 43, 0, 0, 2213, 2214, 5, 28, 0, 0, 2214, 2218, 3, 146, 73, 0, 2215, 2217, 3, 342, 171, 0, 2216, 2215, 1, 0, 0, 0, 2217, 2220, 1, 0, 0, 0, 2218, 2216, 1, 0, 0, 0, 2218, 2219, 1, 0, 0, 0, 2219, 2244, 1, 0, 0, 0, 2220, 2218, 1, 0, 0, 0, 2221, 2222, 5, 255, 0, 0, 2222, 2223, 5, 256, 0, 0, 2223, 2224, 3, 2, 1, 0, 2224, 2225, 5, 28, 0, 0, 2225, 2229, 3, 146, 73, 0, 2226, 2228, 3, 342, 171, 0, 2227, 2226, 1, 0, 0, 0, 2228, 2231, 1, 0, 0, 0, 2229, 2227, 1, 0, 0, 0, 2229, 2230, 1, 0, 0, 0, 2230, 2244, 1, 0, 0, 0, 2231, 2229, 1, 0, 0, 0, 2232, 2233, 5, 255, 0, 0, 2233, 2234, 5, 42, 0, 0, 2234, 2235, 3, 32, 16, 0, 2235, 2236, 5, 43, 0, 0, 2236, 2240, 3, 228, 114, 0, 2237, 2239, 3, 342, 171, 0, 2238, 2237, 1, 0, 0, 0, 2239, 2242, 1, 0, 0, 0, 2240, 2238, 1, 0, 0, 0, 2240, 2241, 1, 0, 0, 0, 2241, 2244, 1, 0, 0, 0, 2242, 2240, 1, 0, 0, 0, 2243, 2135, 1, 0, 0, 0, 2243, 2136, 1, 0, 0, 0, 2243, 2138, 1, 0, 0, 0, 2243, 2139, 1, 0, 0, 0, 2243, 2141, 1, 0, 0, 0, 2243, 2143, 1, 0, 0, 0, 2243, 2146, 1, 0, 0, 0, 2243, 2147, 1, 0, 0, 0, 2243, 2148, 1, 0, 0, 0, 2243, 2149, 1, 0, 0, 0, 2243, 2150, 1, 0, 0, 0, 2243, 2151, 1, 0, 0, 0, 2243, 2152, 1, 0, 0, 0, 2243, 2153, 1, 0, 0, 0, 2243, 2154, 1, 0, 0, 0, 2243, 2155, 1, 0, 0, 0, 2243, 2160, 1, 0, 0, 0, 2243, 2167, 1, 0, 0, 0, 2243, 2172, 1, 0, 0, 0, 2243, 2177, 1, 0, 0, 0, 2243, 2187, 1, 0, 0, 0, 2243, 2188, 1, 0, 0, 0, 2243, 2199, 1, 0, 0, 0, 2243, 2208, 1, 0, 0, 0, 2243, 2221, 1, 0, 0, 0, 2243, 2232, 1, 0, 0, 0, 2244, 271, 1, 0, 0, 0, 2245, 2246, 3, 0, 0, 0, 2246, 2247, 5, 75, 0, 0, 2247, 273, 1, 0, 0, 0, 2248, 2251, 3, 44, 22, 0, 2249, 2251, 3, 46, 23, 0, 2250, 2248, 1, 0, 0, 0, 2250, 2249, 1, 0, 0, 0, 2251, 275, 1, 0, 0, 0, 2252, 2253, 5, 17, 0, 0, 2253, 2254, 3, 268, 134, 0, 2254, 2255, 5, 18, 0, 0, 2255, 277, 1, 0, 0, 0, 2256, 2257, 3, 282, 141, 0, 2257, 2258, 3, 280, 140, 0, 2258, 279, 1, 0, 0, 0, 2259, 2261, 3, 284, 142, 0, 2260, 2259, 1, 0, 0, 0, 2261, 2262, 1, 0, 0, 0, 2262, 2260, 1, 0, 0, 0, 2262, 2263, 1, 0, 0, 0, 2263, 281, 1, 0, 0, 0, 2264, 2265, 5, 158, 0, 0, 2265, 2277, 3, 276, 138, 0, 2266, 2267, 5, 158, 0, 0, 2267, 2268, 3, 0, 0, 0, 2268, 2269, 5, 159, 0, 0, 2269, 2270, 3, 0, 0, 0, 2270, 2277, 1, 0, 0, 0, 2271, 2272, 5, 158, 0, 0, 2272, 2273, 3, 32, 16, 0, 2273, 2274, 5, 159, 0, 0, 2274, 2275, 3, 32, 16, 0, 2275, 2277, 1, 0, 0, 0, 2276, 2264, 1, 0, 0, 0, 2276, 2266, 1, 0, 0, 0, 2276, 2271, 1, 0, 0, 0, 2277, 283, 1, 0, 0, 0, 2278, 2279, 3, 288, 144, 0, 2279, 2280, 3, 294, 147, 0, 2280, 2291, 1, 0, 0, 0, 2281, 2282, 3, 286, 143, 0, 2282, 2283, 3, 294, 147, 0, 2283, 2291, 1, 0, 0, 0, 2284, 2285, 3, 290, 145, 0, 2285, 2286, 3, 294, 147, 0, 2286, 2291, 1, 0, 0, 0, 2287, 2288, 3, 292, 146, 0, 2288, 2289, 3, 294, 147, 0, 2289, 2291, 1, 0, 0, 0, 2290, 2278, 1, 0, 0, 0, 2290, 2281, 1, 0, 0, 0, 2290, 2284, 1, 0, 0, 0, 2290, 2287, 1, 0, 0, 0, 2291, 285, 1, 0, 0, 0, 2292, 2293, 5, 160, 0, 0, 2293, 2299, 3, 276, 138, 0, 2294, 2295, 5, 160, 0, 0, 2295, 2299, 3, 0, 0, 0, 2296, 2297, 5, 160, 0, 0, 2297, 2299, 3, 32, 16, 0, 2298, 2292, 1, 0, 0, 0, 2298, 2294, 1, 0, 0, 0, 2298, 2296, 1, 0, 0, 0, 2299, 287, 1, 0, 0, 0, 2300, 2301, 5, 161, 0, 0, 2301, 2302, 3, 146, 73, 0, 2302, 289, 1, 0, 0, 0, 2303, 2304, 5, 162, 0, 0, 2304, 291, 1, 0, 0, 0, 2305, 2306, 5, 163, 0, 0, 2306, 293, 1, 0, 0, 0, 2307, 2319, 3, 276, 138, 0, 2308, 2309, 5, 164, 0, 0, 2309, 2310, 3, 0, 0, 0, 2310, 2311, 5, 159, 0, 0, 2311, 2312, 3, 0, 0, 0, 2312, 2319, 1, 0, 0, 0, 2313, 2314, 5, 164, 0, 0, 2314, 2315, 3, 32, 16, 0, 2315, 2316, 5, 159, 0, 0, 2316, 2317, 3, 32, 16, 0, 2317, 2319, 1, 0, 0, 0, 2318, 2307, 1, 0, 0, 0, 2318, 2308, 1, 0, 0, 0, 2318, 2313, 1, 0, 0, 0, 2319, 295, 1, 0, 0, 0, 2320, 2321, 3, 298, 149, 0, 2321, 2322, 3, 302, 151, 0, 2322, 297, 1, 0, 0, 0, 2323, 2324, 5, 165, 0, 0, 2324, 2325, 3, 300, 150, 0, 2325, 2326, 3, 0, 0, 0, 2326, 2327, 5, 36, 0, 0, 2327, 2331, 1, 0, 0, 0, 2328, 2329, 5, 165, 0, 0, 2329, 2331, 3, 300, 150, 0, 2330, 2323, 1, 0, 0, 0, 2330, 2328, 1, 0, 0, 0, 2331, 299, 1, 0, 0, 0, 2332, 2336, 1, 0, 0, 0, 2333, 2336, 5, 166, 0, 0, 2334, 2336, 5, 2, 0, 0, 2335, 2332, 1, 0, 0, 0, 2335, 2333, 1, 0, 0, 0, 2335, 2334, 1, 0, 0, 0, 2336, 301, 1, 0, 0, 0, 2337, 2338, 5, 17, 0, 0, 2338, 2339, 3, 304, 152, 0, 2339, 2340, 5, 18, 0, 0, 2340, 2347, 1, 0, 0, 0, 2341, 2343, 3, 308, 154, 0, 2342, 2341, 1, 0, 0, 0, 2343, 2344, 1, 0, 0, 0, 2344, 2342, 1, 0, 0, 0, 2344, 2345, 1, 0, 0, 0, 2345, 2347, 1, 0, 0, 0, 2346, 2337, 1, 0, 0, 0, 2346, 2342, 1, 0, 0, 0, 2347, 303, 1, 0, 0, 0, 2348, 2349, 3, 308, 154, 0, 2349, 2350, 5, 28, 0, 0, 2350, 2352, 1, 0, 0, 0, 2351, 2348, 1, 0, 0, 0, 2352, 2355, 1, 0, 0, 0, 2353, 2351, 1, 0, 0, 0, 2353, 2354, 1, 0, 0, 0, 2354, 2356, 1, 0, 0, 0, 2355, 2353, 1, 0, 0, 0, 2356, 2357, 3, 308, 154, 0, 2357, 305, 1, 0, 0, 0, 2358, 2364, 1, 0, 0, 0, 2359, 2360, 5, 42, 0, 0, 2360, 2361, 3, 32, 16, 0, 2361, 2362, 5, 43, 0, 0, 2362, 2364, 1, 0, 0, 0, 2363, 2358, 1, 0, 0, 0, 2363, 2359, 1, 0, 0, 0, 2364, 307, 1, 0, 0, 0, 2365, 2366, 5, 181, 0, 0, 2366, 2367, 5, 262, 0, 0, 2367, 2368, 5, 30, 0, 0, 2368, 2369, 3, 6, 3, 0, 2369, 2370, 5, 31, 0, 0, 2370, 2432, 1, 0, 0, 0, 2371, 2372, 5, 260, 0, 0, 2372, 2373, 5, 30, 0, 0, 2373, 2374, 3, 0, 0, 0, 2374, 2375, 5, 31, 0, 0, 2375, 2432, 1, 0, 0, 0, 2376, 2377, 5, 260, 0, 0, 2377, 2432, 3, 0, 0, 0, 2378, 2379, 5, 84, 0, 0, 2379, 2380, 5, 30, 0, 0, 2380, 2381, 3, 312, 156, 0, 2381, 2382, 5, 31, 0, 0, 2382, 2432, 1, 0, 0, 0, 2383, 2384, 5, 188, 0, 0, 2384, 2385, 5, 30, 0, 0, 2385, 2386, 3, 36, 18, 0, 2386, 2387, 5, 31, 0, 0, 2387, 2388, 3, 306, 153, 0, 2388, 2432, 1, 0, 0, 0, 2389, 2390, 5, 189, 0, 0, 2390, 2391, 5, 30, 0, 0, 2391, 2392, 3, 36, 18, 0, 2392, 2393, 5, 31, 0, 0, 2393, 2394, 3, 306, 153, 0, 2394, 2432, 1, 0, 0, 0, 2395, 2396, 5, 187, 0, 0, 2396, 2397, 5, 30, 0, 0, 2397, 2398, 3, 34, 17, 0, 2398, 2399, 5, 31, 0, 0, 2399, 2400, 3, 306, 153, 0, 2400, 2432, 1, 0, 0, 0, 2401, 2402, 5, 186, 0, 0, 2402, 2403, 5, 30, 0, 0, 2403, 2404, 3, 32, 16, 0, 2404, 2405, 5, 31, 0, 0, 2405, 2406, 3, 306, 153, 0, 2406, 2432, 1, 0, 0, 0, 2407, 2408, 5, 185, 0, 0, 2408, 2409, 5, 30, 0, 0, 2409, 2410, 3, 32, 16, 0, 2410, 2411, 5, 31, 0, 0, 2411, 2412, 3, 306, 153, 0, 2412, 2432, 1, 0, 0, 0, 2413, 2414, 5, 184, 0, 0, 2414, 2415, 5, 30, 0, 0, 2415, 2416, 3, 32, 16, 0, 2416, 2417, 5, 31, 0, 0, 2417, 2418, 3, 306, 153, 0, 2418, 2432, 1, 0, 0, 0, 2419, 2420, 5, 188, 0, 0, 2420, 2432, 3, 306, 153, 0, 2421, 2422, 5, 189, 0, 0, 2422, 2432, 3, 306, 153, 0, 2423, 2424, 5, 187, 0, 0, 2424, 2432, 3, 306, 153, 0, 2425, 2426, 5, 186, 0, 0, 2426, 2432, 3, 306, 153, 0, 2427, 2428, 5, 185, 0, 0, 2428, 2432, 3, 306, 153, 0, 2429, 2430, 5, 184, 0, 0, 2430, 2432, 3, 306, 153, 0, 2431, 2365, 1, 0, 0, 0, 2431, 2371, 1, 0, 0, 0, 2431, 2376, 1, 0, 0, 0, 2431, 2378, 1, 0, 0, 0, 2431, 2383, 1, 0, 0, 0, 2431, 2389, 1, 0, 0, 0, 2431, 2395, 1, 0, 0, 0, 2431, 2401, 1, 0, 0, 0, 2431, 2407, 1, 0, 0, 0, 2431, 2413, 1, 0, 0, 0, 2431, 2419, 1, 0, 0, 0, 2431, 2421, 1, 0, 0, 0, 2431, 2423, 1, 0, 0, 0, 2431, 2425, 1, 0, 0, 0, 2431, 2427, 1, 0, 0, 0, 2431, 2429, 1, 0, 0, 0, 2432, 309, 1, 0, 0, 0, 2433, 2434, 5, 188, 0, 0, 2434, 2435, 5, 30, 0, 0, 2435, 2436, 3, 36, 18, 0, 2436, 2437, 5, 31, 0, 0, 2437, 2509, 1, 0, 0, 0, 2438, 2439, 5, 189, 0, 0, 2439, 2440, 5, 30, 0, 0, 2440, 2441, 3, 36, 18, 0, 2441, 2442, 5, 31, 0, 0, 2442, 2509, 1, 0, 0, 0, 2443, 2444, 5, 188, 0, 0, 2444, 2445, 5, 30, 0, 0, 2445, 2446, 3, 32, 16, 0, 2446, 2447, 5, 31, 0, 0, 2447, 2509, 1, 0, 0, 0, 2448, 2449, 5, 189, 0, 0, 2449, 2450, 5, 30, 0, 0, 2450, 2451, 3, 34, 17, 0, 2451, 2452, 5, 31, 0, 0, 2452, 2509, 1, 0, 0, 0, 2453, 2454, 5, 187, 0, 0, 2454, 2455, 5, 30, 0, 0, 2455, 2456, 3, 34, 17, 0, 2456, 2457, 5, 31, 0, 0, 2457, 2509, 1, 0, 0, 0, 2458, 2459, 5, 186, 0, 0, 2459, 2460, 5, 30, 0, 0, 2460, 2461, 3, 32, 16, 0, 2461, 2462, 5, 31, 0, 0, 2462, 2509, 1, 0, 0, 0, 2463, 2464, 5, 185, 0, 0, 2464, 2465, 5, 30, 0, 0, 2465, 2466, 3, 32, 16, 0, 2466, 2467, 5, 31, 0, 0, 2467, 2509, 1, 0, 0, 0, 2468, 2469, 5, 184, 0, 0, 2469, 2470, 5, 30, 0, 0, 2470, 2471, 3, 32, 16, 0, 2471, 2472, 5, 31, 0, 0, 2472, 2509, 1, 0, 0, 0, 2473, 2474, 5, 193, 0, 0, 2474, 2475, 5, 30, 0, 0, 2475, 2476, 3, 34, 17, 0, 2476, 2477, 5, 31, 0, 0, 2477, 2509, 1, 0, 0, 0, 2478, 2479, 5, 192, 0, 0, 2479, 2480, 5, 30, 0, 0, 2480, 2481, 3, 32, 16, 0, 2481, 2482, 5, 31, 0, 0, 2482, 2509, 1, 0, 0, 0, 2483, 2484, 5, 191, 0, 0, 2484, 2485, 5, 30, 0, 0, 2485, 2486, 3, 32, 16, 0, 2486, 2487, 5, 31, 0, 0, 2487, 2509, 1, 0, 0, 0, 2488, 2489, 5, 190, 0, 0, 2489, 2490, 5, 30, 0, 0, 2490, 2491, 3, 32, 16, 0, 2491, 2492, 5, 31, 0, 0, 2492, 2509, 1, 0, 0, 0, 2493, 2494, 5, 181, 0, 0, 2494, 2495, 5, 30, 0, 0, 2495, 2496, 3, 32, 16, 0, 2496, 2497, 5, 31, 0, 0, 2497, 2509, 1, 0, 0, 0, 2498, 2499, 5, 183, 0, 0, 2499, 2500, 5, 30, 0, 0, 2500, 2501, 3, 184, 92, 0, 2501, 2502, 5, 31, 0, 0, 2502, 2509, 1, 0, 0, 0, 2503, 2504, 5, 84, 0, 0, 2504, 2505, 5, 30, 0, 0, 2505, 2506, 3, 312, 156, 0, 2506, 2507, 5, 31, 0, 0, 2507, 2509, 1, 0, 0, 0, 2508, 2433, 1, 0, 0, 0, 2508, 2438, 1, 0, 0, 0, 2508, 2443, 1, 0, 0, 0, 2508, 2448, 1, 0, 0, 0, 2508, 2453, 1, 0, 0, 0, 2508, 2458, 1, 0, 0, 0, 2508, 2463, 1, 0, 0, 0, 2508, 2468, 1, 0, 0, 0, 2508, 2473, 1, 0, 0, 0, 2508, 2478, 1, 0, 0, 0, 2508, 2483, 1, 0, 0, 0, 2508, 2488, 1, 0, 0, 0, 2508, 2493, 1, 0, 0, 0, 2508, 2498, 1, 0, 0, 0, 2508, 2503, 1, 0, 0, 0, 2509, 311, 1, 0, 0, 0, 2510, 2512, 3, 314, 157, 0, 2511, 2510, 1, 0, 0, 0, 2512, 2515, 1, 0, 0, 0, 2513, 2511, 1, 0, 0, 0, 2513, 2514, 1, 0, 0, 0, 2514, 313, 1, 0, 0, 0, 2515, 2513, 1, 0, 0, 0, 2516, 2517, 7, 12, 0, 0, 2517, 315, 1, 0, 0, 0, 2518, 2522, 3, 310, 155, 0, 2519, 2522, 3, 6, 3, 0, 2520, 2522, 5, 179, 0, 0, 2521, 2518, 1, 0, 0, 0, 2521, 2519, 1, 0, 0, 0, 2521, 2520, 1, 0, 0, 0, 2522, 317, 1, 0, 0, 0, 2523, 2672, 3, 310, 155, 0, 2524, 2525, 5, 182, 0, 0, 2525, 2526, 5, 30, 0, 0, 2526, 2527, 5, 179, 0, 0, 2527, 2672, 5, 31, 0, 0, 2528, 2529, 5, 182, 0, 0, 2529, 2530, 5, 30, 0, 0, 2530, 2531, 5, 264, 0, 0, 2531, 2672, 5, 31, 0, 0, 2532, 2533, 5, 196, 0, 0, 2533, 2534, 5, 30, 0, 0, 2534, 2535, 5, 39, 0, 0, 2535, 2536, 5, 264, 0, 0, 2536, 2672, 5, 31, 0, 0, 2537, 2538, 5, 196, 0, 0, 2538, 2539, 5, 30, 0, 0, 2539, 2540, 3, 138, 69, 0, 2540, 2541, 5, 31, 0, 0, 2541, 2672, 1, 0, 0, 0, 2542, 2543, 5, 196, 0, 0, 2543, 2544, 5, 30, 0, 0, 2544, 2545, 5, 179, 0, 0, 2545, 2672, 5, 31, 0, 0, 2546, 2547, 5, 197, 0, 0, 2547, 2548, 5, 30, 0, 0, 2548, 2549, 3, 318, 159, 0, 2549, 2550, 5, 31, 0, 0, 2550, 2672, 1, 0, 0, 0, 2551, 2552, 5, 188, 0, 0, 2552, 2553, 5, 42, 0, 0, 2553, 2554, 3, 32, 16, 0, 2554, 2555, 5, 43, 0, 0, 2555, 2556, 5, 30, 0, 0, 2556, 2557, 3, 320, 160, 0, 2557, 2558, 5, 31, 0, 0, 2558, 2672, 1, 0, 0, 0, 2559, 2560, 5, 189, 0, 0, 2560, 2561, 5, 42, 0, 0, 2561, 2562, 3, 32, 16, 0, 2562, 2563, 5, 43, 0, 0, 2563, 2564, 5, 30, 0, 0, 2564, 2565, 3, 322, 161, 0, 2565, 2566, 5, 31, 0, 0, 2566, 2672, 1, 0, 0, 0, 2567, 2568, 5, 187, 0, 0, 2568, 2569, 5, 42, 0, 0, 2569, 2570, 3, 32, 16, 0, 2570, 2571, 5, 43, 0, 0, 2571, 2572, 5, 30, 0, 0, 2572, 2573, 3, 324, 162, 0, 2573, 2574, 5, 31, 0, 0, 2574, 2672, 1, 0, 0, 0, 2575, 2576, 5, 186, 0, 0, 2576, 2577, 5, 42, 0, 0, 2577, 2578, 3, 32, 16, 0, 2578, 2579, 5, 43, 0, 0, 2579, 2580, 5, 30, 0, 0, 2580, 2581, 3, 326, 163, 0, 2581, 2582, 5, 31, 0, 0, 2582, 2672, 1, 0, 0, 0, 2583, 2584, 5, 185, 0, 0, 2584, 2585, 5, 42, 0, 0, 2585, 2586, 3, 32, 16, 0, 2586, 2587, 5, 43, 0, 0, 2587, 2588, 5, 30, 0, 0, 2588, 2589, 3, 328, 164, 0, 2589, 2590, 5, 31, 0, 0, 2590, 2672, 1, 0, 0, 0, 2591, 2592, 5, 184, 0, 0, 2592, 2593, 5, 42, 0, 0, 2593, 2594, 3, 32, 16, 0, 2594, 2595, 5, 43, 0, 0, 2595, 2596, 5, 30, 0, 0, 2596, 2597, 3, 330, 165, 0, 2597, 2598, 5, 31, 0, 0, 2598, 2672, 1, 0, 0, 0, 2599, 2600, 5, 193, 0, 0, 2600, 2601, 5, 42, 0, 0, 2601, 2602, 3, 32, 16, 0, 2602, 2603, 5, 43, 0, 0, 2603, 2604, 5, 30, 0, 0, 2604, 2605, 3, 324, 162, 0, 2605, 2606, 5, 31, 0, 0, 2606, 2672, 1, 0, 0, 0, 2607, 2608, 5, 192, 0, 0, 2608, 2609, 5, 42, 0, 0, 2609, 2610, 3, 32, 16, 0, 2610, 2611, 5, 43, 0, 0, 2611, 2612, 5, 30, 0, 0, 2612, 2613, 3, 326, 163, 0, 2613, 2614, 5, 31, 0, 0, 2614, 2672, 1, 0, 0, 0, 2615, 2616, 5, 191, 0, 0, 2616, 2617, 5, 42, 0, 0, 2617, 2618, 3, 32, 16, 0, 2618, 2619, 5, 43, 0, 0, 2619, 2620, 5, 30, 0, 0, 2620, 2621, 3, 328, 164, 0, 2621, 2622, 5, 31, 0, 0, 2622, 2672, 1, 0, 0, 0, 2623, 2624, 5, 190, 0, 0, 2624, 2625, 5, 42, 0, 0, 2625, 2626, 3, 32, 16, 0, 2626, 2627, 5, 43, 0, 0, 2627, 2628, 5, 30, 0, 0, 2628, 2629, 3, 330, 165, 0, 2629, 2630, 5, 31, 0, 0, 2630, 2672, 1, 0, 0, 0, 2631, 2632, 5, 181, 0, 0, 2632, 2633, 5, 42, 0, 0, 2633, 2634, 3, 32, 16, 0, 2634, 2635, 5, 43, 0, 0, 2635, 2636, 5, 30, 0, 0, 2636, 2637, 3, 328, 164, 0, 2637, 2638, 5, 31, 0, 0, 2638, 2672, 1, 0, 0, 0, 2639, 2640, 5, 183, 0, 0, 2640, 2641, 5, 42, 0, 0, 2641, 2642, 3, 32, 16, 0, 2642, 2643, 5, 43, 0, 0, 2643, 2644, 5, 30, 0, 0, 2644, 2645, 3, 332, 166, 0, 2645, 2646, 5, 31, 0, 0, 2646, 2672, 1, 0, 0, 0, 2647, 2648, 5, 182, 0, 0, 2648, 2649, 5, 42, 0, 0, 2649, 2650, 3, 32, 16, 0, 2650, 2651, 5, 43, 0, 0, 2651, 2652, 5, 30, 0, 0, 2652, 2653, 3, 334, 167, 0, 2653, 2654, 5, 31, 0, 0, 2654, 2672, 1, 0, 0, 0, 2655, 2656, 5, 196, 0, 0, 2656, 2657, 5, 42, 0, 0, 2657, 2658, 3, 32, 16, 0, 2658, 2659, 5, 43, 0, 0, 2659, 2660, 5, 30, 0, 0, 2660, 2661, 3, 336, 168, 0, 2661, 2662, 5, 31, 0, 0, 2662, 2672, 1, 0, 0, 0, 2663, 2664, 5, 197, 0, 0, 2664, 2665, 5, 42, 0, 0, 2665, 2666, 3, 32, 16, 0, 2666, 2667, 5, 43, 0, 0, 2667, 2668, 5, 30, 0, 0, 2668, 2669, 3, 340, 170, 0, 2669, 2670, 5, 31, 0, 0, 2670, 2672, 1, 0, 0, 0, 2671, 2523, 1, 0, 0, 0, 2671, 2524, 1, 0, 0, 0, 2671, 2528, 1, 0, 0, 0, 2671, 2532, 1, 0, 0, 0, 2671, 2537, 1, 0, 0, 0, 2671, 2542, 1, 0, 0, 0, 2671, 2546, 1, 0, 0, 0, 2671, 2551, 1, 0, 0, 0, 2671, 2559, 1, 0, 0, 0, 2671, 2567, 1, 0, 0, 0, 2671, 2575, 1, 0, 0, 0, 2671, 2583, 1, 0, 0, 0, 2671, 2591, 1, 0, 0, 0, 2671, 2599, 1, 0, 0, 0, 2671, 2607, 1, 0, 0, 0, 2671, 2615, 1, 0, 0, 0, 2671, 2623, 1, 0, 0, 0, 2671, 2631, 1, 0, 0, 0, 2671, 2639, 1, 0, 0, 0, 2671, 2647, 1, 0, 0, 0, 2671, 2655, 1, 0, 0, 0, 2671, 2663, 1, 0, 0, 0, 2672, 319, 1, 0, 0, 0, 2673, 2676, 3, 36, 18, 0, 2674, 2676, 3, 32, 16, 0, 2675, 2673, 1, 0, 0, 0, 2675, 2674, 1, 0, 0, 0, 2676, 2679, 1, 0, 0, 0, 2677, 2675, 1, 0, 0, 0, 2677, 2678, 1, 0, 0, 0, 2678, 321, 1, 0, 0, 0, 2679, 2677, 1, 0, 0, 0, 2680, 2683, 3, 36, 18, 0, 2681, 2683, 3, 34, 17, 0, 2682, 2680, 1, 0, 0, 0, 2682, 2681, 1, 0, 0, 0, 2683, 2686, 1, 0, 0, 0, 2684, 2682, 1, 0, 0, 0, 2684, 2685, 1, 0, 0, 0, 2685, 323, 1, 0, 0, 0, 2686, 2684, 1, 0, 0, 0, 2687, 2689, 3, 34, 17, 0, 2688, 2687, 1, 0, 0, 0, 2689, 2692, 1, 0, 0, 0, 2690, 2688, 1, 0, 0, 0, 2690, 2691, 1, 0, 0, 0, 2691, 325, 1, 0, 0, 0, 2692, 2690, 1, 0, 0, 0, 2693, 2695, 3, 32, 16, 0, 2694, 2693, 1, 0, 0, 0, 2695, 2698, 1, 0, 0, 0, 2696, 2694, 1, 0, 0, 0, 2696, 2697, 1, 0, 0, 0, 2697, 327, 1, 0, 0, 0, 2698, 2696, 1, 0, 0, 0, 2699, 2701, 3, 32, 16, 0, 2700, 2699, 1, 0, 0, 0, 2701, 2704, 1, 0, 0, 0, 2702, 2700, 1, 0, 0, 0, 2702, 2703, 1, 0, 0, 0, 2703, 329, 1, 0, 0, 0, 2704, 2702, 1, 0, 0, 0, 2705, 2707, 3, 32, 16, 0, 2706, 2705, 1, 0, 0, 0, 2707, 2710, 1, 0, 0, 0, 2708, 2706, 1, 0, 0, 0, 2708, 2709, 1, 0, 0, 0, 2709, 331, 1, 0, 0, 0, 2710, 2708, 1, 0, 0, 0, 2711, 2713, 3, 184, 92, 0, 2712, 2711, 1, 0, 0, 0, 2713, 2716, 1, 0, 0, 0, 2714, 2712, 1, 0, 0, 0, 2714, 2715, 1, 0, 0, 0, 2715, 333, 1, 0, 0, 0, 2716, 2714, 1, 0, 0, 0, 2717, 2719, 7, 13, 0, 0, 2718, 2717, 1, 0, 0, 0, 2719, 2722, 1, 0, 0, 0, 2720, 2718, 1, 0, 0, 0, 2720, 2721, 1, 0, 0, 0, 2721, 335, 1, 0, 0, 0, 2722, 2720, 1, 0, 0, 0, 2723, 2725, 3, 338, 169, 0, 2724, 2723, 1, 0, 0, 0, 2725, 2728, 1, 0, 0, 0, 2726, 2724, 1, 0, 0, 0, 2726, 2727, 1, 0, 0, 0, 2727, 337, 1, 0, 0, 0, 2728, 2726, 1, 0, 0, 0, 2729, 2734, 5, 179, 0, 0, 2730, 2731, 5, 39, 0, 0, 2731, 2734, 5, 264, 0, 0, 2732, 2734, 3, 138, 69, 0, 2733, 2729, 1, 0, 0, 0, 2733, 2730, 1, 0, 0, 0, 2733, 2732, 1, 0, 0, 0, 2734, 339, 1, 0, 0, 0, 2735, 2737, 3, 318, 159, 0, 2736, 2735, 1, 0, 0, 0, 2737, 2740, 1, 0, 0, 0, 2738, 2736, 1, 0, 0, 0, 2738, 2739, 1, 0, 0, 0, 2739, 341, 1, 0, 0, 0, 2740, 2738, 1, 0, 0, 0, 2741, 2745, 3, 44, 22, 0, 2742, 2745, 3, 46, 23, 0, 2743, 2745, 3, 2, 1, 0, 2744, 2741, 1, 0, 0, 0, 2744, 2742, 1, 0, 0, 0, 2744, 2743, 1, 0, 0, 0, 2745, 343, 1, 0, 0, 0, 2746, 2747, 7, 14, 0, 0, 2747, 2748, 5, 36, 0, 0, 2748, 2749, 5, 30, 0, 0, 2749, 2750, 3, 312, 156, 0, 2750, 2751, 5, 31, 0, 0, 2751, 2772, 1, 0, 0, 0, 2752, 2753, 5, 169, 0, 0, 2753, 2754, 3, 38, 19, 0, 2754, 2755, 5, 75, 0, 0, 2755, 2756, 3, 38, 19, 0, 2756, 2757, 5, 75, 0, 0, 2757, 2758, 3, 38, 19, 0, 2758, 2759, 5, 75, 0, 0, 2759, 2760, 3, 38, 19, 0, 2760, 2772, 1, 0, 0, 0, 2761, 2762, 5, 170, 0, 0, 2762, 2772, 3, 6, 3, 0, 2763, 2764, 5, 170, 0, 0, 2764, 2765, 5, 36, 0, 0, 2765, 2766, 5, 30, 0, 0, 2766, 2767, 3, 312, 156, 0, 2767, 2768, 5, 31, 0, 0, 2768, 2772, 1, 0, 0, 0, 2769, 2772, 3, 342, 171, 0, 2770, 2772, 3, 40, 20, 0, 2771, 2746, 1, 0, 0, 0, 2771, 2752, 1, 0, 0, 0, 2771, 2761, 1, 0, 0, 0, 2771, 2763, 1, 0, 0, 0, 2771, 2769, 1, 0, 0, 0, 2771, 2770, 1, 0, 0, 0, 2772, 345, 1, 0, 0, 0, 2773, 2774, 5, 25, 0, 0, 2774, 2775, 5, 40, 0, 0, 2775, 2776, 3, 98, 49, 0, 2776, 2777, 3, 2, 1, 0, 2777, 2786, 1, 0, 0, 0, 2778, 2779, 5, 25, 0, 0, 2779, 2780, 5, 40, 0, 0, 2780, 2781, 3, 98, 49, 0, 2781, 2782, 3, 2, 1, 0, 2782, 2783, 5, 34, 0, 0, 2783, 2784, 3, 2, 1, 0, 2784, 2786, 1, 0, 0, 0, 2785, 2773, 1, 0, 0, 0, 2785, 2778, 1, 0, 0, 0, 2786, 347, 1, 0, 0, 0, 2787, 2789, 3, 350, 175, 0, 2788, 2787, 1, 0, 0, 0, 2789, 2792, 1, 0, 0, 0, 2790, 2788, 1, 0, 0, 0, 2790, 2791, 1, 0, 0, 0, 2791, 349, 1, 0, 0, 0, 2792, 2790, 1, 0, 0, 0, 2793, 2794, 5, 180, 0, 0, 2794, 2795, 5, 36, 0, 0, 2795, 2796, 5, 30, 0, 0, 2796, 2797, 3, 312, 156, 0, 2797, 2798, 5, 31, 0, 0, 2798, 2808, 1, 0, 0, 0, 2799, 2808, 3, 344, 172, 0, 2800, 2801, 5, 171, 0, 0, 2801, 2802, 5, 36, 0, 0, 2802, 2803, 5, 30, 0, 0, 2803, 2804, 3, 312, 156, 0, 2804, 2805, 5, 31, 0, 0, 2805, 2808, 1, 0, 0, 0, 2806, 2808, 5, 55, 0, 0, 2807, 2793, 1, 0, 0, 0, 2807, 2799, 1, 0, 0, 0, 2807, 2800, 1, 0, 0, 0, 2807, 2806, 1, 0, 0, 0, 2808, 351, 1, 0, 0, 0, 2809, 2810, 5, 50, 0, 0, 2810, 2814, 5, 40, 0, 0, 2811, 2813, 3, 356, 178, 0, 2812, 2811, 1, 0, 0, 0, 2813, 2816, 1, 0, 0, 0, 2814, 2812, 1, 0, 0, 0, 2814, 2815, 1, 0, 0, 0, 2815, 2817, 1, 0, 0, 0, 2816, 2814, 1, 0, 0, 0, 2817, 2818, 3, 2, 1, 0, 2818, 353, 1, 0, 0, 0, 2819, 2823, 5, 301, 0, 0, 2820, 2822, 3, 356, 178, 0, 2821, 2820, 1, 0, 0, 0, 2822, 2825, 1, 0, 0, 0, 2823, 2821, 1, 0, 0, 0, 2823, 2824, 1, 0, 0, 0, 2824, 2826, 1, 0, 0, 0, 2825, 2823, 1, 0, 0, 0, 2826, 2827, 3, 2, 1, 0, 2827, 355, 1, 0, 0, 0, 2828, 2844, 5, 52, 0, 0, 2829, 2844, 5, 51, 0, 0, 2830, 2844, 5, 172, 0, 0, 2831, 2832, 5, 62, 0, 0, 2832, 2844, 5, 51, 0, 0, 2833, 2834, 5, 62, 0, 0, 2834, 2844, 5, 52, 0, 0, 2835, 2836, 5, 62, 0, 0, 2836, 2844, 5, 63, 0, 0, 2837, 2838, 5, 62, 0, 0, 2838, 2844, 5, 64, 0, 0, 2839, 2840, 5, 62, 0, 0, 2840, 2844, 5, 65, 0, 0, 2841, 2842, 5, 62, 0, 0, 2842, 2844, 5, 66, 0, 0, 2843, 2828, 1, 0, 0, 0, 2843, 2829, 1, 0, 0, 0, 2843, 2830, 1, 0, 0, 0, 2843, 2831, 1, 0, 0, 0, 2843, 2833, 1, 0, 0, 0, 2843, 2835, 1, 0, 0, 0, 2843, 2837, 1, 0, 0, 0, 2843, 2839, 1, 0, 0, 0, 2843, 2841, 1, 0, 0, 0, 2844, 357, 1, 0, 0, 0, 2845, 2847, 3, 360, 180, 0, 2846, 2845, 1, 0, 0, 0, 2847, 2850, 1, 0, 0, 0, 2848, 2846, 1, 0, 0, 0, 2848, 2849, 1, 0, 0, 0, 2849, 359, 1, 0, 0, 0, 2850, 2848, 1, 0, 0, 0, 2851, 2852, 5, 21, 0, 0, 2852, 2865, 3, 2, 1, 0, 2853, 2854, 5, 50, 0, 0, 2854, 2855, 5, 40, 0, 0, 2855, 2865, 3, 140, 70, 0, 2856, 2857, 5, 25, 0, 0, 2857, 2858, 5, 40, 0, 0, 2858, 2865, 3, 2, 1, 0, 2859, 2865, 3, 196, 98, 0, 2860, 2861, 5, 50, 0, 0, 2861, 2865, 3, 32, 16, 0, 2862, 2865, 3, 342, 171, 0, 2863, 2865, 3, 40, 20, 0, 2864, 2851, 1, 0, 0, 0, 2864, 2853, 1, 0, 0, 0, 2864, 2856, 1, 0, 0, 0, 2864, 2859, 1, 0, 0, 0, 2864, 2860, 1, 0, 0, 0, 2864, 2862, 1, 0, 0, 0, 2864, 2863, 1, 0, 0, 0, 2865, 361, 1, 0, 0, 0, 2866, 2870, 5, 274, 0, 0, 2867, 2869, 3, 364, 182, 0, 2868, 2867, 1, 0, 0, 0, 2869, 2872, 1, 0, 0, 0, 2870, 2868, 1, 0, 0, 0, 2870, 2871, 1, 0, 0, 0, 2871, 2873, 1, 0, 0, 0, 2872, 2870, 1, 0, 0, 0, 2873, 2886, 3, 2, 1, 0, 2874, 2878, 5, 274, 0, 0, 2875, 2877, 3, 364, 182, 0, 2876, 2875, 1, 0, 0, 0, 2877, 2880, 1, 0, 0, 0, 2878, 2876, 1, 0, 0, 0, 2878, 2879, 1, 0, 0, 0, 2879, 2881, 1, 0, 0, 0, 2880, 2878, 1, 0, 0, 0, 2881, 2882, 3, 2, 1, 0, 2882, 2883, 5, 34, 0, 0, 2883, 2884, 3, 2, 1, 0, 2884, 2886, 1, 0, 0, 0, 2885, 2866, 1, 0, 0, 0, 2885, 2874, 1, 0, 0, 0, 2886, 363, 1, 0, 0, 0, 2887, 2888, 7, 15, 0, 0, 2888, 365, 1, 0, 0, 0, 2889, 2891, 3, 368, 184, 0, 2890, 2889, 1, 0, 0, 0, 2891, 2894, 1, 0, 0, 0, 2892, 2890, 1, 0, 0, 0, 2892, 2893, 1, 0, 0, 0, 2893, 367, 1, 0, 0, 0, 2894, 2892, 1, 0, 0, 0, 2895, 2896, 5, 21, 0, 0, 2896, 2897, 3, 2, 1, 0, 2897, 2898, 5, 44, 0, 0, 2898, 2899, 3, 32, 16, 0, 2899, 2906, 1, 0, 0, 0, 2900, 2901, 5, 25, 0, 0, 2901, 2902, 5, 40, 0, 0, 2902, 2906, 3, 2, 1, 0, 2903, 2906, 3, 342, 171, 0, 2904, 2906, 3, 40, 20, 0, 2905, 2895, 1, 0, 0, 0, 2905, 2900, 1, 0, 0, 0, 2905, 2903, 1, 0, 0, 0, 2905, 2904, 1, 0, 0, 0, 2906, 369, 1, 0, 0, 0, 172, 378, 383, 391, 399, 452, 493, 502, 526, 530, 548, 575, 598, 634, 640, 647, 649, 659, 661, 668, 679, 687, 708, 710, 726, 771, 776, 781, 786, 794, 904, 910, 926, 932, 938, 945, 1056, 1061, 1067, 1072, 1074, 1082, 1094, 1106, 1113, 1120, 1122, 1149, 1156, 1164, 1172, 1185, 1192, 1195, 1214, 1308, 1317, 1324, 1327, 1335, 1356, 1388, 1411, 1423, 1432, 1457, 1481, 1489, 1493, 1508, 1515, 1560, 1570, 1586, 1598, 1610, 1624, 1636, 1647, 1654, 1664, 1677, 1682, 1687, 1696, 1707, 1790, 1799, 1812, 1823, 1831, 1841, 1843, 1870, 1877, 1882, 1889, 1895, 1905, 1909, 1916, 1931, 1937, 1951, 1964, 1972, 1979, 1983, 1988, 2004, 2009, 2011, 2024, 2050, 2057, 2059, 2064, 2070, 2099, 2104, 2127, 2132, 2196, 2205, 2218, 2229, 2240, 2243, 2250, 2262, 2276, 2290, 2298, 2318, 2330, 2335, 2344, 2346, 2353, 2363, 2431, 2508, 2513, 2521, 2671, 2675, 2677, 2682, 2684, 2690, 2696, 2702, 2708, 2714, 2720, 2726, 2733, 2738, 2744, 2771, 2785, 2790, 2807, 2814, 2823, 2843, 2848, 2864, 2870, 2878, 2885, 2892, 2905] \ No newline at end of file +[4, 1, 305, 3692, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 2, 82, 7, 82, 2, 83, 7, 83, 2, 84, 7, 84, 2, 85, 7, 85, 2, 86, 7, 86, 2, 87, 7, 87, 2, 88, 7, 88, 2, 89, 7, 89, 2, 90, 7, 90, 2, 91, 7, 91, 2, 92, 7, 92, 2, 93, 7, 93, 2, 94, 7, 94, 2, 95, 7, 95, 2, 96, 7, 96, 2, 97, 7, 97, 2, 98, 7, 98, 2, 99, 7, 99, 2, 100, 7, 100, 2, 101, 7, 101, 2, 102, 7, 102, 2, 103, 7, 103, 2, 104, 7, 104, 2, 105, 7, 105, 2, 106, 7, 106, 2, 107, 7, 107, 2, 108, 7, 108, 2, 109, 7, 109, 2, 110, 7, 110, 2, 111, 7, 111, 2, 112, 7, 112, 2, 113, 7, 113, 2, 114, 7, 114, 2, 115, 7, 115, 2, 116, 7, 116, 2, 117, 7, 117, 2, 118, 7, 118, 2, 119, 7, 119, 2, 120, 7, 120, 2, 121, 7, 121, 2, 122, 7, 122, 2, 123, 7, 123, 2, 124, 7, 124, 2, 125, 7, 125, 2, 126, 7, 126, 2, 127, 7, 127, 2, 128, 7, 128, 2, 129, 7, 129, 2, 130, 7, 130, 2, 131, 7, 131, 2, 132, 7, 132, 2, 133, 7, 133, 2, 134, 7, 134, 2, 135, 7, 135, 2, 136, 7, 136, 2, 137, 7, 137, 2, 138, 7, 138, 2, 139, 7, 139, 2, 140, 7, 140, 2, 141, 7, 141, 2, 142, 7, 142, 2, 143, 7, 143, 2, 144, 7, 144, 2, 145, 7, 145, 2, 146, 7, 146, 2, 147, 7, 147, 2, 148, 7, 148, 2, 149, 7, 149, 2, 150, 7, 150, 2, 151, 7, 151, 2, 152, 7, 152, 2, 153, 7, 153, 2, 154, 7, 154, 2, 155, 7, 155, 2, 156, 7, 156, 2, 157, 7, 157, 2, 158, 7, 158, 2, 159, 7, 159, 2, 160, 7, 160, 2, 161, 7, 161, 2, 162, 7, 162, 2, 163, 7, 163, 2, 164, 7, 164, 2, 165, 7, 165, 2, 166, 7, 166, 2, 167, 7, 167, 2, 168, 7, 168, 2, 169, 7, 169, 2, 170, 7, 170, 2, 171, 7, 171, 2, 172, 7, 172, 2, 173, 7, 173, 2, 174, 7, 174, 2, 175, 7, 175, 2, 176, 7, 176, 2, 177, 7, 177, 2, 178, 7, 178, 2, 179, 7, 179, 2, 180, 7, 180, 2, 181, 7, 181, 2, 182, 7, 182, 2, 183, 7, 183, 2, 184, 7, 184, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 379, 8, 1, 10, 1, 12, 1, 382, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 389, 8, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 5, 3, 396, 8, 3, 10, 3, 12, 3, 399, 9, 3, 1, 3, 1, 3, 1, 3, 1, 4, 5, 4, 405, 8, 4, 10, 4, 12, 4, 408, 9, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 496, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 547, 8, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 5, 15, 556, 8, 15, 10, 15, 12, 15, 559, 9, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 588, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 595, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 613, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 645, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 673, 8, 22, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 713, 8, 23, 1, 24, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 3, 25, 724, 8, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 27, 5, 27, 734, 8, 27, 10, 27, 12, 27, 737, 9, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 1, 28, 5, 28, 747, 8, 28, 10, 28, 12, 28, 750, 9, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 3, 30, 757, 8, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 1, 31, 3, 31, 779, 8, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 3, 32, 792, 8, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 34, 5, 34, 806, 8, 34, 10, 34, 12, 34, 809, 9, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 37, 1, 37, 1, 38, 1, 38, 1, 38, 1, 38, 5, 38, 830, 8, 38, 10, 38, 12, 38, 833, 9, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 905, 8, 39, 1, 40, 1, 40, 1, 40, 1, 40, 1, 40, 3, 40, 912, 8, 40, 1, 41, 1, 41, 1, 41, 1, 41, 1, 41, 3, 41, 919, 8, 41, 1, 42, 5, 42, 922, 8, 42, 10, 42, 12, 42, 925, 9, 42, 1, 43, 1, 43, 1, 43, 1, 43, 5, 43, 931, 8, 43, 10, 43, 12, 43, 934, 9, 43, 1, 43, 1, 43, 1, 43, 1, 44, 1, 44, 1, 45, 1, 45, 1, 45, 3, 45, 944, 8, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 953, 8, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 964, 8, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 975, 8, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 988, 8, 45, 1, 45, 1, 45, 3, 45, 992, 8, 45, 1, 46, 1, 46, 1, 46, 1, 46, 5, 46, 998, 8, 46, 10, 46, 12, 46, 1001, 9, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 1, 46, 3, 46, 1016, 8, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 3, 48, 1023, 8, 48, 1, 49, 1, 49, 1, 50, 1, 50, 1, 50, 5, 50, 1030, 8, 50, 10, 50, 12, 50, 1033, 9, 50, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 3, 51, 1060, 8, 51, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 3, 52, 1138, 8, 52, 3, 52, 1140, 8, 52, 1, 53, 1, 53, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 3, 54, 1154, 8, 54, 1, 54, 1, 54, 5, 54, 1158, 8, 54, 10, 54, 12, 54, 1161, 9, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 1, 54, 3, 54, 1169, 8, 54, 3, 54, 1171, 8, 54, 1, 55, 1, 55, 1, 55, 1, 55, 1, 55, 5, 55, 1178, 8, 55, 10, 55, 12, 55, 1181, 9, 55, 1, 55, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 56, 1, 56, 5, 56, 1192, 8, 56, 10, 56, 12, 56, 1195, 9, 56, 1, 56, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 5, 57, 1206, 8, 57, 10, 57, 12, 57, 1209, 9, 57, 1, 57, 1, 57, 1, 57, 1, 57, 1, 57, 3, 57, 1216, 8, 57, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 1, 58, 3, 58, 1224, 8, 58, 1, 58, 1, 58, 3, 58, 1228, 8, 58, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 3, 59, 1267, 8, 59, 1, 60, 1, 60, 1, 60, 1, 60, 5, 60, 1273, 8, 60, 10, 60, 12, 60, 1276, 9, 60, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 5, 61, 1284, 8, 61, 10, 61, 12, 61, 1287, 9, 61, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 1, 62, 3, 62, 1300, 8, 62, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 1, 63, 3, 63, 1319, 8, 63, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 1, 64, 5, 64, 1327, 8, 64, 10, 64, 12, 64, 1330, 9, 64, 3, 64, 1332, 8, 64, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 1, 65, 3, 65, 1356, 8, 65, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 1, 66, 3, 66, 1503, 8, 66, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 1, 67, 3, 67, 1513, 8, 67, 1, 68, 1, 68, 1, 68, 1, 68, 1, 68, 5, 68, 1520, 8, 68, 10, 68, 12, 68, 1523, 9, 68, 3, 68, 1525, 8, 68, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 1, 69, 3, 69, 1607, 8, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 70, 5, 70, 1614, 8, 70, 10, 70, 12, 70, 1617, 9, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 1, 71, 3, 71, 1648, 8, 71, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 1, 72, 3, 72, 1708, 8, 72, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 1, 73, 3, 73, 1748, 8, 73, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 1, 74, 3, 74, 1764, 8, 74, 1, 75, 1, 75, 1, 75, 1, 75, 1, 76, 1, 76, 1, 76, 1, 76, 3, 76, 1774, 8, 76, 1, 76, 1, 76, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 3, 77, 1804, 8, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 1, 77, 3, 77, 1832, 8, 77, 1, 78, 1, 78, 1, 78, 1, 78, 1, 78, 5, 78, 1839, 8, 78, 10, 78, 12, 78, 1842, 9, 78, 1, 78, 1, 78, 1, 78, 3, 78, 1847, 8, 78, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 1, 79, 3, 79, 1864, 8, 79, 1, 80, 1, 80, 1, 80, 1, 80, 5, 80, 1870, 8, 80, 10, 80, 12, 80, 1873, 9, 80, 1, 80, 1, 80, 1, 80, 1, 81, 1, 81, 1, 81, 1, 81, 1, 81, 1, 82, 1, 82, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 1, 83, 3, 83, 1930, 8, 83, 1, 84, 1, 84, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 3, 85, 1940, 8, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 3, 85, 1958, 8, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 1, 85, 3, 85, 1976, 8, 85, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 1, 86, 3, 86, 1995, 8, 86, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 1, 87, 3, 87, 2016, 8, 87, 1, 88, 1, 88, 1, 88, 1, 88, 1, 88, 1, 88, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 1, 89, 3, 89, 2035, 8, 89, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 1, 90, 3, 90, 2050, 8, 90, 1, 91, 1, 91, 1, 91, 1, 91, 5, 91, 2056, 8, 91, 10, 91, 12, 91, 2059, 9, 91, 1, 91, 1, 91, 1, 91, 1, 92, 1, 92, 1, 92, 1, 92, 1, 92, 1, 92, 3, 92, 2070, 8, 92, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 1, 93, 3, 93, 2090, 8, 93, 1, 94, 1, 94, 1, 94, 5, 94, 2095, 8, 94, 10, 94, 12, 94, 2098, 9, 94, 1, 95, 1, 95, 3, 95, 2102, 8, 95, 1, 95, 1, 95, 1, 95, 1, 96, 1, 96, 1, 96, 1, 96, 5, 96, 2111, 8, 96, 10, 96, 12, 96, 2114, 9, 96, 1, 96, 1, 96, 1, 96, 1, 97, 1, 97, 1, 97, 1, 97, 1, 97, 1, 98, 3, 98, 2125, 8, 98, 1, 98, 1, 98, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 5, 100, 2233, 8, 100, 10, 100, 12, 100, 2236, 9, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 5, 100, 2245, 8, 100, 10, 100, 12, 100, 2248, 9, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 5, 100, 2261, 8, 100, 10, 100, 12, 100, 2264, 9, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 5, 100, 2275, 8, 100, 10, 100, 12, 100, 2278, 9, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 3, 100, 2286, 8, 100, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 5, 101, 2299, 8, 101, 10, 101, 12, 101, 2302, 9, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 101, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 1, 102, 3, 102, 2344, 8, 102, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 1, 103, 3, 103, 2355, 8, 103, 1, 104, 1, 104, 1, 104, 1, 104, 1, 104, 3, 104, 2362, 8, 104, 1, 105, 1, 105, 1, 105, 1, 105, 1, 105, 1, 105, 3, 105, 2370, 8, 105, 1, 106, 1, 106, 1, 106, 1, 106, 5, 106, 2376, 8, 106, 10, 106, 12, 106, 2379, 9, 106, 1, 106, 1, 106, 1, 106, 1, 106, 1, 106, 1, 106, 1, 106, 1, 106, 5, 106, 2389, 8, 106, 10, 106, 12, 106, 2392, 9, 106, 1, 106, 1, 106, 1, 106, 3, 106, 2397, 8, 106, 1, 107, 1, 107, 1, 107, 1, 107, 3, 107, 2403, 8, 107, 1, 108, 5, 108, 2406, 8, 108, 10, 108, 12, 108, 2409, 9, 108, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 1, 109, 3, 109, 2437, 8, 109, 1, 110, 1, 110, 1, 110, 1, 110, 5, 110, 2443, 8, 110, 10, 110, 12, 110, 2446, 9, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 110, 1, 111, 1, 111, 1, 111, 1, 111, 3, 111, 2459, 8, 111, 1, 112, 5, 112, 2462, 8, 112, 10, 112, 12, 112, 2465, 9, 112, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 1, 113, 3, 113, 2489, 8, 113, 1, 114, 1, 114, 1, 114, 1, 114, 1, 114, 1, 114, 1, 114, 3, 114, 2498, 8, 114, 1, 115, 1, 115, 1, 115, 1, 115, 1, 115, 1, 115, 1, 115, 4, 115, 2507, 8, 115, 11, 115, 12, 115, 2508, 1, 115, 1, 115, 3, 115, 2513, 8, 115, 1, 116, 1, 116, 1, 116, 5, 116, 2518, 8, 116, 10, 116, 12, 116, 2521, 9, 116, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 1, 117, 3, 117, 2540, 8, 117, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 5, 118, 2549, 8, 118, 10, 118, 12, 118, 2552, 9, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 1, 118, 5, 118, 2564, 8, 118, 10, 118, 12, 118, 2567, 9, 118, 1, 118, 1, 118, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 1, 119, 3, 119, 2613, 8, 119, 1, 120, 1, 120, 1, 120, 1, 120, 1, 120, 1, 120, 1, 120, 1, 120, 3, 120, 2623, 8, 120, 3, 120, 2625, 8, 120, 1, 120, 1, 120, 1, 120, 5, 120, 2630, 8, 120, 10, 120, 12, 120, 2633, 9, 120, 1, 120, 1, 120, 1, 120, 3, 120, 2638, 8, 120, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 1, 121, 3, 121, 2682, 8, 121, 1, 122, 1, 122, 1, 122, 1, 122, 1, 122, 1, 122, 1, 122, 3, 122, 2691, 8, 122, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 1, 123, 3, 123, 2731, 8, 123, 1, 124, 5, 124, 2734, 8, 124, 10, 124, 12, 124, 2737, 9, 124, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 1, 125, 3, 125, 2776, 8, 125, 1, 126, 1, 126, 3, 126, 2780, 8, 126, 1, 126, 1, 126, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 1, 127, 3, 127, 2790, 8, 127, 1, 128, 1, 128, 1, 128, 1, 128, 1, 128, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 1, 129, 3, 129, 2812, 8, 129, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 5, 130, 2822, 8, 130, 10, 130, 12, 130, 2825, 9, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 5, 130, 2833, 8, 130, 10, 130, 12, 130, 2836, 9, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 5, 130, 2848, 8, 130, 10, 130, 12, 130, 2851, 9, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 5, 130, 2861, 8, 130, 10, 130, 12, 130, 2864, 9, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 1, 130, 5, 130, 2874, 8, 130, 10, 130, 12, 130, 2877, 9, 130, 3, 130, 2879, 8, 130, 1, 131, 1, 131, 1, 131, 1, 131, 1, 132, 1, 132, 1, 132, 1, 132, 1, 132, 1, 132, 3, 132, 2891, 8, 132, 1, 133, 1, 133, 1, 133, 1, 133, 1, 134, 1, 134, 1, 134, 1, 135, 1, 135, 1, 135, 4, 135, 2903, 8, 135, 11, 135, 12, 135, 2904, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 1, 136, 3, 136, 2923, 8, 136, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 1, 137, 3, 137, 2941, 8, 137, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 1, 138, 3, 138, 2955, 8, 138, 1, 139, 1, 139, 1, 139, 1, 140, 1, 140, 1, 141, 1, 141, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 1, 142, 3, 142, 2979, 8, 142, 1, 143, 1, 143, 1, 143, 1, 144, 1, 144, 1, 144, 1, 144, 1, 144, 1, 144, 1, 144, 1, 144, 1, 144, 1, 144, 3, 144, 2994, 8, 144, 1, 145, 1, 145, 1, 145, 1, 145, 1, 145, 3, 145, 3001, 8, 145, 1, 146, 1, 146, 1, 146, 1, 146, 1, 146, 4, 146, 3008, 8, 146, 11, 146, 12, 146, 3009, 3, 146, 3012, 8, 146, 1, 147, 1, 147, 1, 147, 5, 147, 3017, 8, 147, 10, 147, 12, 147, 3020, 9, 147, 1, 147, 1, 147, 1, 148, 1, 148, 1, 148, 1, 148, 1, 148, 1, 148, 3, 148, 3030, 8, 148, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 1, 149, 3, 149, 3080, 8, 149, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 1, 150, 3, 150, 3172, 8, 150, 1, 151, 1, 151, 1, 151, 5, 151, 3177, 8, 151, 10, 151, 12, 151, 3180, 9, 151, 1, 152, 1, 152, 1, 153, 1, 153, 1, 153, 1, 153, 1, 153, 1, 153, 1, 153, 1, 153, 3, 153, 3192, 8, 153, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 1, 154, 3, 154, 3365, 8, 154, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 1, 155, 5, 155, 3373, 8, 155, 10, 155, 12, 155, 3376, 9, 155, 1, 156, 1, 156, 1, 156, 1, 156, 1, 156, 1, 156, 5, 156, 3384, 8, 156, 10, 156, 12, 156, 3387, 9, 156, 1, 157, 1, 157, 1, 157, 5, 157, 3392, 8, 157, 10, 157, 12, 157, 3395, 9, 157, 1, 158, 1, 158, 1, 158, 5, 158, 3400, 8, 158, 10, 158, 12, 158, 3403, 9, 158, 1, 159, 1, 159, 1, 159, 5, 159, 3408, 8, 159, 10, 159, 12, 159, 3411, 9, 159, 1, 160, 1, 160, 1, 160, 5, 160, 3416, 8, 160, 10, 160, 12, 160, 3419, 9, 160, 1, 161, 1, 161, 1, 161, 5, 161, 3424, 8, 161, 10, 161, 12, 161, 3427, 9, 161, 1, 162, 1, 162, 1, 162, 1, 162, 5, 162, 3433, 8, 162, 10, 162, 12, 162, 3436, 9, 162, 1, 163, 1, 163, 1, 163, 5, 163, 3441, 8, 163, 10, 163, 12, 163, 3444, 9, 163, 1, 164, 1, 164, 1, 164, 1, 164, 1, 164, 1, 164, 1, 164, 1, 164, 3, 164, 3454, 8, 164, 1, 165, 1, 165, 1, 165, 5, 165, 3459, 8, 165, 10, 165, 12, 165, 3462, 9, 165, 1, 166, 1, 166, 1, 166, 1, 166, 1, 166, 1, 166, 1, 166, 1, 166, 1, 166, 3, 166, 3473, 8, 166, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 1, 167, 3, 167, 3507, 8, 167, 1, 168, 1, 168, 1, 168, 1, 168, 1, 168, 1, 168, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 1, 169, 3, 169, 3529, 8, 169, 1, 170, 1, 170, 1, 170, 5, 170, 3534, 8, 170, 10, 170, 12, 170, 3537, 9, 170, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 1, 171, 3, 171, 3558, 8, 171, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 172, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 173, 1, 174, 1, 174, 1, 174, 1, 174, 1, 174, 1, 175, 1, 175, 1, 175, 5, 175, 3580, 8, 175, 10, 175, 12, 175, 3583, 9, 175, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 1, 176, 3, 176, 3600, 8, 176, 1, 177, 1, 177, 1, 177, 5, 177, 3605, 8, 177, 10, 177, 12, 177, 3608, 9, 177, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 1, 178, 3, 178, 3635, 8, 178, 1, 179, 1, 179, 1, 179, 1, 179, 1, 179, 1, 179, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 1, 180, 3, 180, 3655, 8, 180, 1, 181, 1, 181, 1, 181, 5, 181, 3660, 8, 181, 10, 181, 12, 181, 3663, 9, 181, 1, 182, 1, 182, 1, 183, 1, 183, 1, 183, 5, 183, 3670, 8, 183, 10, 183, 12, 183, 3673, 9, 183, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 1, 184, 3, 184, 3690, 8, 184, 1, 184, 0, 0, 185, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 0, 17, 6, 0, 1, 15, 199, 199, 243, 243, 247, 247, 264, 264, 289, 289, 5, 0, 16, 16, 199, 199, 243, 243, 264, 264, 288, 289, 1, 0, 263, 264, 1, 0, 173, 174, 1, 0, 37, 38, 2, 0, 45, 47, 186, 187, 1, 0, 73, 74, 3, 0, 2, 2, 61, 61, 77, 83, 2, 0, 229, 229, 260, 261, 1, 0, 95, 96, 1, 0, 97, 111, 1, 0, 188, 189, 1, 0, 184, 186, 1, 0, 184, 189, 2, 0, 173, 173, 289, 290, 1, 0, 167, 168, 1, 0, 51, 52, 4131, 0, 370, 1, 0, 0, 0, 2, 388, 1, 0, 0, 0, 4, 390, 1, 0, 0, 0, 6, 397, 1, 0, 0, 0, 8, 406, 1, 0, 0, 0, 10, 495, 1, 0, 0, 0, 12, 497, 1, 0, 0, 0, 14, 501, 1, 0, 0, 0, 16, 505, 1, 0, 0, 0, 18, 510, 1, 0, 0, 0, 20, 514, 1, 0, 0, 0, 22, 518, 1, 0, 0, 0, 24, 526, 1, 0, 0, 0, 26, 546, 1, 0, 0, 0, 28, 548, 1, 0, 0, 0, 30, 550, 1, 0, 0, 0, 32, 562, 1, 0, 0, 0, 34, 564, 1, 0, 0, 0, 36, 587, 1, 0, 0, 0, 38, 594, 1, 0, 0, 0, 40, 612, 1, 0, 0, 0, 42, 644, 1, 0, 0, 0, 44, 672, 1, 0, 0, 0, 46, 712, 1, 0, 0, 0, 48, 714, 1, 0, 0, 0, 50, 723, 1, 0, 0, 0, 52, 725, 1, 0, 0, 0, 54, 735, 1, 0, 0, 0, 56, 748, 1, 0, 0, 0, 58, 751, 1, 0, 0, 0, 60, 754, 1, 0, 0, 0, 62, 778, 1, 0, 0, 0, 64, 791, 1, 0, 0, 0, 66, 793, 1, 0, 0, 0, 68, 807, 1, 0, 0, 0, 70, 812, 1, 0, 0, 0, 72, 814, 1, 0, 0, 0, 74, 821, 1, 0, 0, 0, 76, 825, 1, 0, 0, 0, 78, 904, 1, 0, 0, 0, 80, 911, 1, 0, 0, 0, 82, 918, 1, 0, 0, 0, 84, 923, 1, 0, 0, 0, 86, 932, 1, 0, 0, 0, 88, 938, 1, 0, 0, 0, 90, 991, 1, 0, 0, 0, 92, 993, 1, 0, 0, 0, 94, 1017, 1, 0, 0, 0, 96, 1022, 1, 0, 0, 0, 98, 1024, 1, 0, 0, 0, 100, 1031, 1, 0, 0, 0, 102, 1059, 1, 0, 0, 0, 104, 1139, 1, 0, 0, 0, 106, 1141, 1, 0, 0, 0, 108, 1170, 1, 0, 0, 0, 110, 1172, 1, 0, 0, 0, 112, 1186, 1, 0, 0, 0, 114, 1215, 1, 0, 0, 0, 116, 1227, 1, 0, 0, 0, 118, 1266, 1, 0, 0, 0, 120, 1274, 1, 0, 0, 0, 122, 1285, 1, 0, 0, 0, 124, 1299, 1, 0, 0, 0, 126, 1318, 1, 0, 0, 0, 128, 1331, 1, 0, 0, 0, 130, 1355, 1, 0, 0, 0, 132, 1502, 1, 0, 0, 0, 134, 1512, 1, 0, 0, 0, 136, 1524, 1, 0, 0, 0, 138, 1606, 1, 0, 0, 0, 140, 1608, 1, 0, 0, 0, 142, 1647, 1, 0, 0, 0, 144, 1707, 1, 0, 0, 0, 146, 1747, 1, 0, 0, 0, 148, 1763, 1, 0, 0, 0, 150, 1765, 1, 0, 0, 0, 152, 1769, 1, 0, 0, 0, 154, 1831, 1, 0, 0, 0, 156, 1846, 1, 0, 0, 0, 158, 1863, 1, 0, 0, 0, 160, 1871, 1, 0, 0, 0, 162, 1877, 1, 0, 0, 0, 164, 1882, 1, 0, 0, 0, 166, 1929, 1, 0, 0, 0, 168, 1931, 1, 0, 0, 0, 170, 1975, 1, 0, 0, 0, 172, 1994, 1, 0, 0, 0, 174, 2015, 1, 0, 0, 0, 176, 2017, 1, 0, 0, 0, 178, 2034, 1, 0, 0, 0, 180, 2049, 1, 0, 0, 0, 182, 2057, 1, 0, 0, 0, 184, 2069, 1, 0, 0, 0, 186, 2089, 1, 0, 0, 0, 188, 2096, 1, 0, 0, 0, 190, 2099, 1, 0, 0, 0, 192, 2112, 1, 0, 0, 0, 194, 2118, 1, 0, 0, 0, 196, 2124, 1, 0, 0, 0, 198, 2128, 1, 0, 0, 0, 200, 2285, 1, 0, 0, 0, 202, 2287, 1, 0, 0, 0, 204, 2343, 1, 0, 0, 0, 206, 2354, 1, 0, 0, 0, 208, 2361, 1, 0, 0, 0, 210, 2369, 1, 0, 0, 0, 212, 2396, 1, 0, 0, 0, 214, 2402, 1, 0, 0, 0, 216, 2407, 1, 0, 0, 0, 218, 2436, 1, 0, 0, 0, 220, 2438, 1, 0, 0, 0, 222, 2458, 1, 0, 0, 0, 224, 2463, 1, 0, 0, 0, 226, 2488, 1, 0, 0, 0, 228, 2497, 1, 0, 0, 0, 230, 2512, 1, 0, 0, 0, 232, 2519, 1, 0, 0, 0, 234, 2539, 1, 0, 0, 0, 236, 2541, 1, 0, 0, 0, 238, 2612, 1, 0, 0, 0, 240, 2637, 1, 0, 0, 0, 242, 2681, 1, 0, 0, 0, 244, 2690, 1, 0, 0, 0, 246, 2730, 1, 0, 0, 0, 248, 2735, 1, 0, 0, 0, 250, 2775, 1, 0, 0, 0, 252, 2777, 1, 0, 0, 0, 254, 2783, 1, 0, 0, 0, 256, 2791, 1, 0, 0, 0, 258, 2811, 1, 0, 0, 0, 260, 2878, 1, 0, 0, 0, 262, 2880, 1, 0, 0, 0, 264, 2890, 1, 0, 0, 0, 266, 2892, 1, 0, 0, 0, 268, 2896, 1, 0, 0, 0, 270, 2902, 1, 0, 0, 0, 272, 2922, 1, 0, 0, 0, 274, 2940, 1, 0, 0, 0, 276, 2954, 1, 0, 0, 0, 278, 2956, 1, 0, 0, 0, 280, 2959, 1, 0, 0, 0, 282, 2961, 1, 0, 0, 0, 284, 2978, 1, 0, 0, 0, 286, 2980, 1, 0, 0, 0, 288, 2993, 1, 0, 0, 0, 290, 3000, 1, 0, 0, 0, 292, 3011, 1, 0, 0, 0, 294, 3018, 1, 0, 0, 0, 296, 3029, 1, 0, 0, 0, 298, 3079, 1, 0, 0, 0, 300, 3171, 1, 0, 0, 0, 302, 3178, 1, 0, 0, 0, 304, 3181, 1, 0, 0, 0, 306, 3191, 1, 0, 0, 0, 308, 3364, 1, 0, 0, 0, 310, 3374, 1, 0, 0, 0, 312, 3385, 1, 0, 0, 0, 314, 3393, 1, 0, 0, 0, 316, 3401, 1, 0, 0, 0, 318, 3409, 1, 0, 0, 0, 320, 3417, 1, 0, 0, 0, 322, 3425, 1, 0, 0, 0, 324, 3434, 1, 0, 0, 0, 326, 3442, 1, 0, 0, 0, 328, 3453, 1, 0, 0, 0, 330, 3460, 1, 0, 0, 0, 332, 3472, 1, 0, 0, 0, 334, 3506, 1, 0, 0, 0, 336, 3508, 1, 0, 0, 0, 338, 3528, 1, 0, 0, 0, 340, 3535, 1, 0, 0, 0, 342, 3557, 1, 0, 0, 0, 344, 3559, 1, 0, 0, 0, 346, 3565, 1, 0, 0, 0, 348, 3571, 1, 0, 0, 0, 350, 3581, 1, 0, 0, 0, 352, 3599, 1, 0, 0, 0, 354, 3606, 1, 0, 0, 0, 356, 3634, 1, 0, 0, 0, 358, 3636, 1, 0, 0, 0, 360, 3654, 1, 0, 0, 0, 362, 3661, 1, 0, 0, 0, 364, 3664, 1, 0, 0, 0, 366, 3671, 1, 0, 0, 0, 368, 3689, 1, 0, 0, 0, 370, 371, 7, 0, 0, 0, 371, 1, 1, 0, 0, 0, 372, 373, 5, 288, 0, 0, 373, 389, 6, 1, -1, 0, 374, 375, 3, 4, 2, 0, 375, 376, 6, 1, -1, 0, 376, 377, 5, 265, 0, 0, 377, 379, 1, 0, 0, 0, 378, 374, 1, 0, 0, 0, 379, 382, 1, 0, 0, 0, 380, 378, 1, 0, 0, 0, 380, 381, 1, 0, 0, 0, 381, 383, 1, 0, 0, 0, 382, 380, 1, 0, 0, 0, 383, 384, 3, 4, 2, 0, 384, 385, 6, 1, -1, 0, 385, 389, 1, 0, 0, 0, 386, 387, 5, 264, 0, 0, 387, 389, 6, 1, -1, 0, 388, 372, 1, 0, 0, 0, 388, 380, 1, 0, 0, 0, 388, 386, 1, 0, 0, 0, 389, 3, 1, 0, 0, 0, 390, 391, 7, 1, 0, 0, 391, 5, 1, 0, 0, 0, 392, 393, 5, 263, 0, 0, 393, 394, 6, 3, -1, 0, 394, 396, 5, 266, 0, 0, 395, 392, 1, 0, 0, 0, 396, 399, 1, 0, 0, 0, 397, 395, 1, 0, 0, 0, 397, 398, 1, 0, 0, 0, 398, 400, 1, 0, 0, 0, 399, 397, 1, 0, 0, 0, 400, 401, 5, 263, 0, 0, 401, 402, 6, 3, -1, 0, 402, 7, 1, 0, 0, 0, 403, 405, 3, 10, 5, 0, 404, 403, 1, 0, 0, 0, 405, 408, 1, 0, 0, 0, 406, 404, 1, 0, 0, 0, 406, 407, 1, 0, 0, 0, 407, 9, 1, 0, 0, 0, 408, 406, 1, 0, 0, 0, 409, 410, 3, 76, 38, 0, 410, 411, 5, 17, 0, 0, 411, 412, 3, 84, 42, 0, 412, 413, 5, 18, 0, 0, 413, 496, 1, 0, 0, 0, 414, 415, 3, 74, 37, 0, 415, 416, 5, 17, 0, 0, 416, 417, 3, 8, 4, 0, 417, 418, 5, 18, 0, 0, 418, 496, 1, 0, 0, 0, 419, 420, 3, 236, 118, 0, 420, 421, 5, 17, 0, 0, 421, 422, 3, 248, 124, 0, 422, 423, 5, 18, 0, 0, 423, 496, 1, 0, 0, 0, 424, 496, 3, 202, 101, 0, 425, 426, 6, 5, -1, 0, 426, 427, 3, 286, 143, 0, 427, 428, 6, 5, -1, 0, 428, 496, 1, 0, 0, 0, 429, 430, 6, 5, -1, 0, 430, 431, 3, 72, 36, 0, 431, 432, 6, 5, -1, 0, 432, 496, 1, 0, 0, 0, 433, 434, 6, 5, -1, 0, 434, 435, 3, 66, 33, 0, 435, 436, 6, 5, -1, 0, 436, 496, 1, 0, 0, 0, 437, 438, 6, 5, -1, 0, 438, 439, 3, 90, 45, 0, 439, 440, 6, 5, -1, 0, 440, 496, 1, 0, 0, 0, 441, 442, 6, 5, -1, 0, 442, 443, 3, 92, 46, 0, 443, 444, 6, 5, -1, 0, 444, 496, 1, 0, 0, 0, 445, 446, 6, 5, -1, 0, 446, 447, 3, 22, 11, 0, 447, 448, 6, 5, -1, 0, 448, 496, 1, 0, 0, 0, 449, 450, 6, 5, -1, 0, 450, 451, 3, 336, 168, 0, 451, 452, 6, 5, -1, 0, 452, 496, 1, 0, 0, 0, 453, 454, 6, 5, -1, 0, 454, 455, 3, 344, 172, 0, 455, 456, 6, 5, -1, 0, 456, 496, 1, 0, 0, 0, 457, 458, 6, 5, -1, 0, 458, 459, 3, 358, 179, 0, 459, 460, 6, 5, -1, 0, 460, 496, 1, 0, 0, 0, 461, 462, 6, 5, -1, 0, 462, 463, 3, 64, 32, 0, 463, 464, 6, 5, -1, 0, 464, 496, 1, 0, 0, 0, 465, 466, 6, 5, -1, 0, 466, 467, 3, 154, 77, 0, 467, 468, 6, 5, -1, 0, 468, 496, 1, 0, 0, 0, 469, 470, 3, 332, 166, 0, 470, 471, 6, 5, -1, 0, 471, 496, 1, 0, 0, 0, 472, 473, 6, 5, -1, 0, 473, 496, 3, 12, 6, 0, 474, 475, 6, 5, -1, 0, 475, 496, 3, 14, 7, 0, 476, 477, 6, 5, -1, 0, 477, 496, 3, 16, 8, 0, 478, 479, 6, 5, -1, 0, 479, 496, 3, 18, 9, 0, 480, 481, 6, 5, -1, 0, 481, 496, 3, 20, 10, 0, 482, 483, 6, 5, -1, 0, 483, 484, 3, 26, 13, 0, 484, 485, 6, 5, -1, 0, 485, 496, 1, 0, 0, 0, 486, 487, 6, 5, -1, 0, 487, 488, 3, 42, 21, 0, 488, 489, 6, 5, -1, 0, 489, 496, 1, 0, 0, 0, 490, 491, 6, 5, -1, 0, 491, 496, 3, 40, 20, 0, 492, 496, 3, 30, 15, 0, 493, 494, 6, 5, -1, 0, 494, 496, 3, 24, 12, 0, 495, 409, 1, 0, 0, 0, 495, 414, 1, 0, 0, 0, 495, 419, 1, 0, 0, 0, 495, 424, 1, 0, 0, 0, 495, 425, 1, 0, 0, 0, 495, 429, 1, 0, 0, 0, 495, 433, 1, 0, 0, 0, 495, 437, 1, 0, 0, 0, 495, 441, 1, 0, 0, 0, 495, 445, 1, 0, 0, 0, 495, 449, 1, 0, 0, 0, 495, 453, 1, 0, 0, 0, 495, 457, 1, 0, 0, 0, 495, 461, 1, 0, 0, 0, 495, 465, 1, 0, 0, 0, 495, 469, 1, 0, 0, 0, 495, 472, 1, 0, 0, 0, 495, 474, 1, 0, 0, 0, 495, 476, 1, 0, 0, 0, 495, 478, 1, 0, 0, 0, 495, 480, 1, 0, 0, 0, 495, 482, 1, 0, 0, 0, 495, 486, 1, 0, 0, 0, 495, 490, 1, 0, 0, 0, 495, 492, 1, 0, 0, 0, 495, 493, 1, 0, 0, 0, 496, 11, 1, 0, 0, 0, 497, 498, 5, 19, 0, 0, 498, 499, 3, 32, 16, 0, 499, 500, 6, 6, -1, 0, 500, 13, 1, 0, 0, 0, 501, 502, 5, 20, 0, 0, 502, 503, 3, 32, 16, 0, 503, 504, 6, 7, -1, 0, 504, 15, 1, 0, 0, 0, 505, 506, 5, 21, 0, 0, 506, 507, 5, 22, 0, 0, 507, 508, 3, 32, 16, 0, 508, 509, 6, 8, -1, 0, 509, 17, 1, 0, 0, 0, 510, 511, 5, 23, 0, 0, 511, 512, 3, 34, 17, 0, 512, 513, 6, 9, -1, 0, 513, 19, 1, 0, 0, 0, 514, 515, 5, 24, 0, 0, 515, 516, 3, 34, 17, 0, 516, 517, 6, 10, -1, 0, 517, 21, 1, 0, 0, 0, 518, 519, 5, 25, 0, 0, 519, 520, 3, 100, 50, 0, 520, 521, 3, 2, 1, 0, 521, 522, 5, 17, 0, 0, 522, 523, 3, 122, 61, 0, 523, 524, 5, 18, 0, 0, 524, 525, 6, 11, -1, 0, 525, 23, 1, 0, 0, 0, 526, 527, 5, 26, 0, 0, 527, 25, 1, 0, 0, 0, 528, 529, 5, 27, 0, 0, 529, 530, 3, 28, 14, 0, 530, 531, 6, 13, -1, 0, 531, 547, 1, 0, 0, 0, 532, 533, 5, 27, 0, 0, 533, 534, 3, 28, 14, 0, 534, 535, 5, 28, 0, 0, 535, 536, 3, 28, 14, 0, 536, 537, 6, 13, -1, 0, 537, 547, 1, 0, 0, 0, 538, 539, 5, 27, 0, 0, 539, 540, 3, 28, 14, 0, 540, 541, 5, 28, 0, 0, 541, 542, 3, 28, 14, 0, 542, 543, 5, 28, 0, 0, 543, 544, 3, 28, 14, 0, 544, 545, 6, 13, -1, 0, 545, 547, 1, 0, 0, 0, 546, 528, 1, 0, 0, 0, 546, 532, 1, 0, 0, 0, 546, 538, 1, 0, 0, 0, 547, 27, 1, 0, 0, 0, 548, 549, 7, 2, 0, 0, 549, 29, 1, 0, 0, 0, 550, 551, 5, 29, 0, 0, 551, 557, 5, 17, 0, 0, 552, 553, 3, 118, 59, 0, 553, 554, 6, 15, -1, 0, 554, 556, 1, 0, 0, 0, 555, 552, 1, 0, 0, 0, 556, 559, 1, 0, 0, 0, 557, 555, 1, 0, 0, 0, 557, 558, 1, 0, 0, 0, 558, 560, 1, 0, 0, 0, 559, 557, 1, 0, 0, 0, 560, 561, 5, 18, 0, 0, 561, 31, 1, 0, 0, 0, 562, 563, 5, 173, 0, 0, 563, 33, 1, 0, 0, 0, 564, 565, 7, 3, 0, 0, 565, 35, 1, 0, 0, 0, 566, 567, 5, 175, 0, 0, 567, 588, 6, 18, -1, 0, 568, 569, 3, 32, 16, 0, 569, 570, 5, 265, 0, 0, 570, 571, 6, 18, -1, 0, 571, 588, 1, 0, 0, 0, 572, 573, 3, 32, 16, 0, 573, 574, 6, 18, -1, 0, 574, 588, 1, 0, 0, 0, 575, 576, 5, 188, 0, 0, 576, 577, 5, 30, 0, 0, 577, 578, 3, 32, 16, 0, 578, 579, 5, 31, 0, 0, 579, 580, 6, 18, -1, 0, 580, 588, 1, 0, 0, 0, 581, 582, 5, 189, 0, 0, 582, 583, 5, 30, 0, 0, 583, 584, 3, 34, 17, 0, 584, 585, 5, 31, 0, 0, 585, 586, 6, 18, -1, 0, 586, 588, 1, 0, 0, 0, 587, 566, 1, 0, 0, 0, 587, 568, 1, 0, 0, 0, 587, 572, 1, 0, 0, 0, 587, 575, 1, 0, 0, 0, 587, 581, 1, 0, 0, 0, 588, 37, 1, 0, 0, 0, 589, 590, 3, 32, 16, 0, 590, 591, 6, 19, -1, 0, 591, 595, 1, 0, 0, 0, 592, 593, 5, 262, 0, 0, 593, 595, 6, 19, -1, 0, 594, 589, 1, 0, 0, 0, 594, 592, 1, 0, 0, 0, 595, 39, 1, 0, 0, 0, 596, 597, 5, 267, 0, 0, 597, 613, 5, 289, 0, 0, 598, 599, 5, 267, 0, 0, 599, 600, 5, 289, 0, 0, 600, 613, 5, 263, 0, 0, 601, 602, 5, 268, 0, 0, 602, 613, 5, 289, 0, 0, 603, 604, 5, 269, 0, 0, 604, 613, 5, 289, 0, 0, 605, 606, 5, 270, 0, 0, 606, 613, 5, 289, 0, 0, 607, 613, 5, 271, 0, 0, 608, 613, 5, 272, 0, 0, 609, 610, 5, 273, 0, 0, 610, 613, 5, 263, 0, 0, 611, 613, 5, 32, 0, 0, 612, 596, 1, 0, 0, 0, 612, 598, 1, 0, 0, 0, 612, 601, 1, 0, 0, 0, 612, 603, 1, 0, 0, 0, 612, 605, 1, 0, 0, 0, 612, 607, 1, 0, 0, 0, 612, 608, 1, 0, 0, 0, 612, 609, 1, 0, 0, 0, 612, 611, 1, 0, 0, 0, 613, 41, 1, 0, 0, 0, 614, 615, 5, 33, 0, 0, 615, 616, 3, 140, 70, 0, 616, 617, 5, 34, 0, 0, 617, 618, 3, 2, 1, 0, 618, 619, 6, 21, -1, 0, 619, 645, 1, 0, 0, 0, 620, 621, 5, 33, 0, 0, 621, 622, 3, 118, 59, 0, 622, 623, 5, 34, 0, 0, 623, 624, 3, 2, 1, 0, 624, 625, 6, 21, -1, 0, 625, 645, 1, 0, 0, 0, 626, 627, 5, 33, 0, 0, 627, 628, 3, 178, 89, 0, 628, 629, 5, 34, 0, 0, 629, 630, 3, 2, 1, 0, 630, 631, 6, 21, -1, 0, 631, 645, 1, 0, 0, 0, 632, 633, 5, 33, 0, 0, 633, 634, 3, 44, 22, 0, 634, 635, 5, 34, 0, 0, 635, 636, 3, 2, 1, 0, 636, 637, 6, 21, -1, 0, 637, 645, 1, 0, 0, 0, 638, 639, 5, 33, 0, 0, 639, 640, 3, 46, 23, 0, 640, 641, 5, 34, 0, 0, 641, 642, 3, 2, 1, 0, 642, 643, 6, 21, -1, 0, 643, 645, 1, 0, 0, 0, 644, 614, 1, 0, 0, 0, 644, 620, 1, 0, 0, 0, 644, 626, 1, 0, 0, 0, 644, 632, 1, 0, 0, 0, 644, 638, 1, 0, 0, 0, 645, 43, 1, 0, 0, 0, 646, 647, 5, 35, 0, 0, 647, 648, 3, 48, 24, 0, 648, 649, 6, 22, -1, 0, 649, 673, 1, 0, 0, 0, 650, 651, 5, 35, 0, 0, 651, 652, 3, 48, 24, 0, 652, 653, 5, 36, 0, 0, 653, 654, 3, 6, 3, 0, 654, 655, 6, 22, -1, 0, 655, 673, 1, 0, 0, 0, 656, 657, 5, 35, 0, 0, 657, 658, 3, 48, 24, 0, 658, 659, 5, 36, 0, 0, 659, 660, 5, 17, 0, 0, 660, 661, 3, 52, 26, 0, 661, 662, 5, 18, 0, 0, 662, 663, 6, 22, -1, 0, 663, 673, 1, 0, 0, 0, 664, 665, 5, 35, 0, 0, 665, 666, 3, 48, 24, 0, 666, 667, 5, 36, 0, 0, 667, 668, 5, 30, 0, 0, 668, 669, 3, 302, 151, 0, 669, 670, 5, 31, 0, 0, 670, 671, 6, 22, -1, 0, 671, 673, 1, 0, 0, 0, 672, 646, 1, 0, 0, 0, 672, 650, 1, 0, 0, 0, 672, 656, 1, 0, 0, 0, 672, 664, 1, 0, 0, 0, 673, 45, 1, 0, 0, 0, 674, 675, 5, 35, 0, 0, 675, 676, 5, 30, 0, 0, 676, 677, 3, 50, 25, 0, 677, 678, 5, 31, 0, 0, 678, 679, 3, 48, 24, 0, 679, 680, 6, 23, -1, 0, 680, 713, 1, 0, 0, 0, 681, 682, 5, 35, 0, 0, 682, 683, 5, 30, 0, 0, 683, 684, 3, 50, 25, 0, 684, 685, 5, 31, 0, 0, 685, 686, 3, 48, 24, 0, 686, 687, 5, 36, 0, 0, 687, 688, 3, 6, 3, 0, 688, 689, 6, 23, -1, 0, 689, 713, 1, 0, 0, 0, 690, 691, 5, 35, 0, 0, 691, 692, 5, 30, 0, 0, 692, 693, 3, 50, 25, 0, 693, 694, 5, 31, 0, 0, 694, 695, 3, 48, 24, 0, 695, 696, 5, 36, 0, 0, 696, 697, 5, 17, 0, 0, 697, 698, 3, 52, 26, 0, 698, 699, 5, 18, 0, 0, 699, 700, 6, 23, -1, 0, 700, 713, 1, 0, 0, 0, 701, 702, 5, 35, 0, 0, 702, 703, 5, 30, 0, 0, 703, 704, 3, 50, 25, 0, 704, 705, 5, 31, 0, 0, 705, 706, 3, 48, 24, 0, 706, 707, 5, 36, 0, 0, 707, 708, 5, 30, 0, 0, 708, 709, 3, 302, 151, 0, 709, 710, 5, 31, 0, 0, 710, 711, 6, 23, -1, 0, 711, 713, 1, 0, 0, 0, 712, 674, 1, 0, 0, 0, 712, 681, 1, 0, 0, 0, 712, 690, 1, 0, 0, 0, 712, 701, 1, 0, 0, 0, 713, 47, 1, 0, 0, 0, 714, 715, 3, 170, 85, 0, 715, 716, 6, 24, -1, 0, 716, 49, 1, 0, 0, 0, 717, 718, 3, 126, 63, 0, 718, 719, 6, 25, -1, 0, 719, 724, 1, 0, 0, 0, 720, 721, 3, 178, 89, 0, 721, 722, 6, 25, -1, 0, 722, 724, 1, 0, 0, 0, 723, 717, 1, 0, 0, 0, 723, 720, 1, 0, 0, 0, 724, 51, 1, 0, 0, 0, 725, 726, 3, 54, 27, 0, 726, 727, 3, 56, 28, 0, 727, 728, 6, 26, -1, 0, 728, 53, 1, 0, 0, 0, 729, 730, 3, 308, 154, 0, 730, 731, 6, 27, -1, 0, 731, 734, 1, 0, 0, 0, 732, 734, 3, 40, 20, 0, 733, 729, 1, 0, 0, 0, 733, 732, 1, 0, 0, 0, 734, 737, 1, 0, 0, 0, 735, 733, 1, 0, 0, 0, 735, 736, 1, 0, 0, 0, 736, 55, 1, 0, 0, 0, 737, 735, 1, 0, 0, 0, 738, 739, 3, 58, 29, 0, 739, 740, 3, 60, 30, 0, 740, 741, 3, 2, 1, 0, 741, 742, 5, 36, 0, 0, 742, 743, 3, 308, 154, 0, 743, 744, 6, 28, -1, 0, 744, 747, 1, 0, 0, 0, 745, 747, 3, 40, 20, 0, 746, 738, 1, 0, 0, 0, 746, 745, 1, 0, 0, 0, 747, 750, 1, 0, 0, 0, 748, 746, 1, 0, 0, 0, 748, 749, 1, 0, 0, 0, 749, 57, 1, 0, 0, 0, 750, 748, 1, 0, 0, 0, 751, 752, 7, 4, 0, 0, 752, 753, 6, 29, -1, 0, 753, 59, 1, 0, 0, 0, 754, 756, 3, 62, 31, 0, 755, 757, 5, 261, 0, 0, 756, 755, 1, 0, 0, 0, 756, 757, 1, 0, 0, 0, 757, 758, 1, 0, 0, 0, 758, 759, 6, 30, -1, 0, 759, 61, 1, 0, 0, 0, 760, 761, 3, 146, 73, 0, 761, 762, 6, 31, -1, 0, 762, 779, 1, 0, 0, 0, 763, 764, 3, 2, 1, 0, 764, 765, 6, 31, -1, 0, 765, 779, 1, 0, 0, 0, 766, 767, 5, 196, 0, 0, 767, 779, 6, 31, -1, 0, 768, 769, 5, 197, 0, 0, 769, 779, 6, 31, -1, 0, 770, 771, 5, 202, 0, 0, 771, 772, 5, 39, 0, 0, 772, 773, 5, 264, 0, 0, 773, 779, 6, 31, -1, 0, 774, 775, 5, 202, 0, 0, 775, 776, 3, 118, 59, 0, 776, 777, 6, 31, -1, 0, 777, 779, 1, 0, 0, 0, 778, 760, 1, 0, 0, 0, 778, 763, 1, 0, 0, 0, 778, 766, 1, 0, 0, 0, 778, 768, 1, 0, 0, 0, 778, 770, 1, 0, 0, 0, 778, 774, 1, 0, 0, 0, 779, 63, 1, 0, 0, 0, 780, 781, 5, 198, 0, 0, 781, 782, 5, 40, 0, 0, 782, 783, 3, 2, 1, 0, 783, 784, 6, 32, -1, 0, 784, 792, 1, 0, 0, 0, 785, 786, 5, 198, 0, 0, 786, 787, 3, 2, 1, 0, 787, 788, 6, 32, -1, 0, 788, 792, 1, 0, 0, 0, 789, 790, 5, 198, 0, 0, 790, 792, 6, 32, -1, 0, 791, 780, 1, 0, 0, 0, 791, 785, 1, 0, 0, 0, 791, 789, 1, 0, 0, 0, 792, 65, 1, 0, 0, 0, 793, 794, 5, 41, 0, 0, 794, 795, 5, 42, 0, 0, 795, 796, 3, 32, 16, 0, 796, 797, 5, 43, 0, 0, 797, 798, 3, 68, 34, 0, 798, 799, 5, 44, 0, 0, 799, 800, 3, 0, 0, 0, 800, 801, 6, 33, -1, 0, 801, 67, 1, 0, 0, 0, 802, 803, 3, 70, 35, 0, 803, 804, 6, 34, -1, 0, 804, 806, 1, 0, 0, 0, 805, 802, 1, 0, 0, 0, 806, 809, 1, 0, 0, 0, 807, 805, 1, 0, 0, 0, 807, 808, 1, 0, 0, 0, 808, 810, 1, 0, 0, 0, 809, 807, 1, 0, 0, 0, 810, 811, 6, 34, -1, 0, 811, 69, 1, 0, 0, 0, 812, 813, 7, 5, 0, 0, 813, 71, 1, 0, 0, 0, 814, 815, 5, 48, 0, 0, 815, 816, 5, 36, 0, 0, 816, 817, 5, 30, 0, 0, 817, 818, 3, 302, 151, 0, 818, 819, 5, 31, 0, 0, 819, 820, 6, 36, -1, 0, 820, 73, 1, 0, 0, 0, 821, 822, 5, 49, 0, 0, 822, 823, 3, 2, 1, 0, 823, 824, 6, 37, -1, 0, 824, 75, 1, 0, 0, 0, 825, 831, 5, 50, 0, 0, 826, 827, 3, 78, 39, 0, 827, 828, 6, 38, -1, 0, 828, 830, 1, 0, 0, 0, 829, 826, 1, 0, 0, 0, 830, 833, 1, 0, 0, 0, 831, 829, 1, 0, 0, 0, 831, 832, 1, 0, 0, 0, 832, 834, 1, 0, 0, 0, 833, 831, 1, 0, 0, 0, 834, 835, 3, 2, 1, 0, 835, 836, 3, 184, 92, 0, 836, 837, 3, 80, 40, 0, 837, 838, 3, 82, 41, 0, 838, 839, 6, 38, -1, 0, 839, 77, 1, 0, 0, 0, 840, 841, 5, 51, 0, 0, 841, 905, 6, 39, -1, 0, 842, 843, 5, 52, 0, 0, 843, 905, 6, 39, -1, 0, 844, 845, 5, 199, 0, 0, 845, 905, 6, 39, -1, 0, 846, 847, 5, 202, 0, 0, 847, 905, 6, 39, -1, 0, 848, 849, 5, 221, 0, 0, 849, 905, 6, 39, -1, 0, 850, 851, 5, 53, 0, 0, 851, 905, 6, 39, -1, 0, 852, 853, 5, 54, 0, 0, 853, 905, 6, 39, -1, 0, 854, 855, 5, 55, 0, 0, 855, 905, 6, 39, -1, 0, 856, 857, 5, 56, 0, 0, 857, 905, 6, 39, -1, 0, 858, 859, 5, 244, 0, 0, 859, 905, 6, 39, -1, 0, 860, 861, 5, 15, 0, 0, 861, 905, 6, 39, -1, 0, 862, 863, 5, 224, 0, 0, 863, 905, 6, 39, -1, 0, 864, 865, 5, 57, 0, 0, 865, 905, 6, 39, -1, 0, 866, 867, 5, 58, 0, 0, 867, 905, 6, 39, -1, 0, 868, 869, 5, 59, 0, 0, 869, 905, 6, 39, -1, 0, 870, 871, 5, 60, 0, 0, 871, 905, 6, 39, -1, 0, 872, 873, 5, 61, 0, 0, 873, 905, 6, 39, -1, 0, 874, 875, 5, 62, 0, 0, 875, 876, 5, 51, 0, 0, 876, 905, 6, 39, -1, 0, 877, 878, 5, 62, 0, 0, 878, 879, 5, 52, 0, 0, 879, 905, 6, 39, -1, 0, 880, 881, 5, 62, 0, 0, 881, 882, 5, 63, 0, 0, 882, 905, 6, 39, -1, 0, 883, 884, 5, 62, 0, 0, 884, 885, 5, 64, 0, 0, 885, 905, 6, 39, -1, 0, 886, 887, 5, 62, 0, 0, 887, 888, 5, 65, 0, 0, 888, 905, 6, 39, -1, 0, 889, 890, 5, 62, 0, 0, 890, 891, 5, 66, 0, 0, 891, 905, 6, 39, -1, 0, 892, 893, 5, 67, 0, 0, 893, 905, 6, 39, -1, 0, 894, 895, 5, 68, 0, 0, 895, 905, 6, 39, -1, 0, 896, 897, 5, 69, 0, 0, 897, 905, 6, 39, -1, 0, 898, 899, 5, 70, 0, 0, 899, 900, 5, 30, 0, 0, 900, 901, 3, 32, 16, 0, 901, 902, 5, 31, 0, 0, 902, 903, 6, 39, -1, 0, 903, 905, 1, 0, 0, 0, 904, 840, 1, 0, 0, 0, 904, 842, 1, 0, 0, 0, 904, 844, 1, 0, 0, 0, 904, 846, 1, 0, 0, 0, 904, 848, 1, 0, 0, 0, 904, 850, 1, 0, 0, 0, 904, 852, 1, 0, 0, 0, 904, 854, 1, 0, 0, 0, 904, 856, 1, 0, 0, 0, 904, 858, 1, 0, 0, 0, 904, 860, 1, 0, 0, 0, 904, 862, 1, 0, 0, 0, 904, 864, 1, 0, 0, 0, 904, 866, 1, 0, 0, 0, 904, 868, 1, 0, 0, 0, 904, 870, 1, 0, 0, 0, 904, 872, 1, 0, 0, 0, 904, 874, 1, 0, 0, 0, 904, 877, 1, 0, 0, 0, 904, 880, 1, 0, 0, 0, 904, 883, 1, 0, 0, 0, 904, 886, 1, 0, 0, 0, 904, 889, 1, 0, 0, 0, 904, 892, 1, 0, 0, 0, 904, 894, 1, 0, 0, 0, 904, 896, 1, 0, 0, 0, 904, 898, 1, 0, 0, 0, 905, 79, 1, 0, 0, 0, 906, 912, 1, 0, 0, 0, 907, 908, 5, 71, 0, 0, 908, 909, 3, 126, 63, 0, 909, 910, 6, 40, -1, 0, 910, 912, 1, 0, 0, 0, 911, 906, 1, 0, 0, 0, 911, 907, 1, 0, 0, 0, 912, 81, 1, 0, 0, 0, 913, 919, 1, 0, 0, 0, 914, 915, 5, 72, 0, 0, 915, 916, 3, 86, 43, 0, 916, 917, 6, 41, -1, 0, 917, 919, 1, 0, 0, 0, 918, 913, 1, 0, 0, 0, 918, 914, 1, 0, 0, 0, 919, 83, 1, 0, 0, 0, 920, 922, 3, 200, 100, 0, 921, 920, 1, 0, 0, 0, 922, 925, 1, 0, 0, 0, 923, 921, 1, 0, 0, 0, 923, 924, 1, 0, 0, 0, 924, 85, 1, 0, 0, 0, 925, 923, 1, 0, 0, 0, 926, 927, 3, 126, 63, 0, 927, 928, 6, 43, -1, 0, 928, 929, 5, 28, 0, 0, 929, 931, 1, 0, 0, 0, 930, 926, 1, 0, 0, 0, 931, 934, 1, 0, 0, 0, 932, 930, 1, 0, 0, 0, 932, 933, 1, 0, 0, 0, 933, 935, 1, 0, 0, 0, 934, 932, 1, 0, 0, 0, 935, 936, 3, 126, 63, 0, 936, 937, 6, 43, -1, 0, 937, 87, 1, 0, 0, 0, 938, 939, 7, 6, 0, 0, 939, 89, 1, 0, 0, 0, 940, 941, 3, 88, 44, 0, 941, 943, 3, 32, 16, 0, 942, 944, 7, 2, 0, 0, 943, 942, 1, 0, 0, 0, 943, 944, 1, 0, 0, 0, 944, 945, 1, 0, 0, 0, 945, 946, 6, 45, -1, 0, 946, 992, 1, 0, 0, 0, 947, 948, 3, 88, 44, 0, 948, 949, 3, 32, 16, 0, 949, 950, 5, 75, 0, 0, 950, 952, 3, 32, 16, 0, 951, 953, 7, 2, 0, 0, 952, 951, 1, 0, 0, 0, 952, 953, 1, 0, 0, 0, 953, 954, 1, 0, 0, 0, 954, 955, 6, 45, -1, 0, 955, 992, 1, 0, 0, 0, 956, 957, 3, 88, 44, 0, 957, 958, 3, 32, 16, 0, 958, 959, 5, 75, 0, 0, 959, 960, 3, 32, 16, 0, 960, 961, 5, 28, 0, 0, 961, 963, 3, 32, 16, 0, 962, 964, 7, 2, 0, 0, 963, 962, 1, 0, 0, 0, 963, 964, 1, 0, 0, 0, 964, 965, 1, 0, 0, 0, 965, 966, 6, 45, -1, 0, 966, 992, 1, 0, 0, 0, 967, 968, 3, 88, 44, 0, 968, 969, 3, 32, 16, 0, 969, 970, 5, 28, 0, 0, 970, 971, 3, 32, 16, 0, 971, 972, 5, 75, 0, 0, 972, 974, 3, 32, 16, 0, 973, 975, 7, 2, 0, 0, 974, 973, 1, 0, 0, 0, 974, 975, 1, 0, 0, 0, 975, 976, 1, 0, 0, 0, 976, 977, 6, 45, -1, 0, 977, 992, 1, 0, 0, 0, 978, 979, 3, 88, 44, 0, 979, 980, 3, 32, 16, 0, 980, 981, 5, 28, 0, 0, 981, 982, 3, 32, 16, 0, 982, 983, 5, 75, 0, 0, 983, 984, 3, 32, 16, 0, 984, 985, 5, 28, 0, 0, 985, 987, 3, 32, 16, 0, 986, 988, 7, 2, 0, 0, 987, 986, 1, 0, 0, 0, 987, 988, 1, 0, 0, 0, 988, 989, 1, 0, 0, 0, 989, 990, 6, 45, -1, 0, 990, 992, 1, 0, 0, 0, 991, 940, 1, 0, 0, 0, 991, 947, 1, 0, 0, 0, 991, 956, 1, 0, 0, 0, 991, 967, 1, 0, 0, 0, 991, 978, 1, 0, 0, 0, 992, 91, 1, 0, 0, 0, 993, 999, 5, 21, 0, 0, 994, 995, 3, 94, 47, 0, 995, 996, 6, 46, -1, 0, 996, 998, 1, 0, 0, 0, 997, 994, 1, 0, 0, 0, 998, 1001, 1, 0, 0, 0, 999, 997, 1, 0, 0, 0, 999, 1000, 1, 0, 0, 0, 1000, 1002, 1, 0, 0, 0, 1001, 999, 1, 0, 0, 0, 1002, 1003, 3, 2, 1, 0, 1003, 1004, 6, 46, -1, 0, 1004, 1005, 3, 96, 48, 0, 1005, 1015, 6, 46, -1, 0, 1006, 1007, 5, 180, 0, 0, 1007, 1008, 5, 36, 0, 0, 1008, 1009, 5, 30, 0, 0, 1009, 1010, 3, 302, 151, 0, 1010, 1011, 5, 31, 0, 0, 1011, 1012, 6, 46, -1, 0, 1012, 1013, 3, 96, 48, 0, 1013, 1014, 6, 46, -1, 0, 1014, 1016, 1, 0, 0, 0, 1015, 1006, 1, 0, 0, 0, 1015, 1016, 1, 0, 0, 0, 1016, 93, 1, 0, 0, 0, 1017, 1018, 5, 76, 0, 0, 1018, 95, 1, 0, 0, 0, 1019, 1023, 1, 0, 0, 0, 1020, 1021, 5, 298, 0, 0, 1021, 1023, 6, 48, -1, 0, 1022, 1019, 1, 0, 0, 0, 1022, 1020, 1, 0, 0, 0, 1023, 97, 1, 0, 0, 0, 1024, 1025, 7, 7, 0, 0, 1025, 99, 1, 0, 0, 0, 1026, 1027, 3, 98, 49, 0, 1027, 1028, 6, 50, -1, 0, 1028, 1030, 1, 0, 0, 0, 1029, 1026, 1, 0, 0, 0, 1030, 1033, 1, 0, 0, 0, 1031, 1029, 1, 0, 0, 0, 1031, 1032, 1, 0, 0, 0, 1032, 101, 1, 0, 0, 0, 1033, 1031, 1, 0, 0, 0, 1034, 1060, 3, 104, 52, 0, 1035, 1036, 5, 280, 0, 0, 1036, 1037, 3, 170, 85, 0, 1037, 1038, 6, 51, -1, 0, 1038, 1060, 1, 0, 0, 0, 1039, 1040, 5, 286, 0, 0, 1040, 1041, 3, 180, 90, 0, 1041, 1042, 6, 51, -1, 0, 1042, 1060, 1, 0, 0, 0, 1043, 1044, 5, 286, 0, 0, 1044, 1045, 3, 176, 88, 0, 1045, 1046, 6, 51, -1, 0, 1046, 1060, 1, 0, 0, 0, 1047, 1048, 5, 284, 0, 0, 1048, 1049, 3, 126, 63, 0, 1049, 1050, 6, 51, -1, 0, 1050, 1060, 1, 0, 0, 0, 1051, 1052, 5, 281, 0, 0, 1052, 1053, 3, 106, 53, 0, 1053, 1054, 6, 51, -1, 0, 1054, 1060, 1, 0, 0, 0, 1055, 1056, 5, 287, 0, 0, 1056, 1057, 3, 50, 25, 0, 1057, 1058, 6, 51, -1, 0, 1058, 1060, 1, 0, 0, 0, 1059, 1034, 1, 0, 0, 0, 1059, 1035, 1, 0, 0, 0, 1059, 1039, 1, 0, 0, 0, 1059, 1043, 1, 0, 0, 0, 1059, 1047, 1, 0, 0, 0, 1059, 1051, 1, 0, 0, 0, 1059, 1055, 1, 0, 0, 0, 1060, 103, 1, 0, 0, 0, 1061, 1062, 5, 275, 0, 0, 1062, 1140, 6, 52, -1, 0, 1063, 1064, 5, 276, 0, 0, 1064, 1065, 3, 32, 16, 0, 1065, 1066, 6, 52, -1, 0, 1066, 1140, 1, 0, 0, 0, 1067, 1068, 5, 276, 0, 0, 1068, 1069, 3, 0, 0, 0, 1069, 1070, 6, 52, -1, 0, 1070, 1140, 1, 0, 0, 0, 1071, 1072, 5, 277, 0, 0, 1072, 1073, 3, 32, 16, 0, 1073, 1074, 6, 52, -1, 0, 1074, 1140, 1, 0, 0, 0, 1075, 1076, 5, 278, 0, 0, 1076, 1077, 3, 34, 17, 0, 1077, 1078, 6, 52, -1, 0, 1078, 1140, 1, 0, 0, 0, 1079, 1080, 5, 279, 0, 0, 1080, 1081, 3, 36, 18, 0, 1081, 1082, 6, 52, -1, 0, 1082, 1140, 1, 0, 0, 0, 1083, 1084, 5, 279, 0, 0, 1084, 1085, 3, 34, 17, 0, 1085, 1086, 6, 52, -1, 0, 1086, 1140, 1, 0, 0, 0, 1087, 1088, 5, 279, 0, 0, 1088, 1089, 5, 30, 0, 0, 1089, 1090, 3, 302, 151, 0, 1090, 1091, 5, 31, 0, 0, 1091, 1092, 6, 52, -1, 0, 1092, 1140, 1, 0, 0, 0, 1093, 1094, 5, 279, 0, 0, 1094, 1095, 5, 84, 0, 0, 1095, 1096, 5, 30, 0, 0, 1096, 1097, 3, 302, 151, 0, 1097, 1098, 5, 31, 0, 0, 1098, 1099, 6, 52, -1, 0, 1099, 1140, 1, 0, 0, 0, 1100, 1101, 5, 282, 0, 0, 1101, 1102, 3, 32, 16, 0, 1102, 1103, 6, 52, -1, 0, 1103, 1140, 1, 0, 0, 0, 1104, 1105, 5, 282, 0, 0, 1105, 1106, 3, 0, 0, 0, 1106, 1107, 6, 52, -1, 0, 1107, 1140, 1, 0, 0, 0, 1108, 1109, 5, 285, 0, 0, 1109, 1110, 3, 6, 3, 0, 1110, 1111, 6, 52, -1, 0, 1111, 1140, 1, 0, 0, 0, 1112, 1113, 5, 285, 0, 0, 1113, 1114, 5, 224, 0, 0, 1114, 1115, 5, 30, 0, 0, 1115, 1116, 3, 6, 3, 0, 1116, 1117, 5, 31, 0, 0, 1117, 1118, 6, 52, -1, 0, 1118, 1140, 1, 0, 0, 0, 1119, 1120, 5, 285, 0, 0, 1120, 1121, 5, 84, 0, 0, 1121, 1122, 5, 30, 0, 0, 1122, 1123, 3, 302, 151, 0, 1123, 1124, 5, 31, 0, 0, 1124, 1125, 6, 52, -1, 0, 1125, 1140, 1, 0, 0, 0, 1126, 1127, 5, 287, 0, 0, 1127, 1128, 3, 32, 16, 0, 1128, 1129, 6, 52, -1, 0, 1129, 1140, 1, 0, 0, 0, 1130, 1131, 5, 283, 0, 0, 1131, 1137, 6, 52, -1, 0, 1132, 1133, 5, 30, 0, 0, 1133, 1134, 3, 108, 54, 0, 1134, 1135, 5, 31, 0, 0, 1135, 1138, 1, 0, 0, 0, 1136, 1138, 5, 85, 0, 0, 1137, 1132, 1, 0, 0, 0, 1137, 1136, 1, 0, 0, 0, 1138, 1140, 1, 0, 0, 0, 1139, 1061, 1, 0, 0, 0, 1139, 1063, 1, 0, 0, 0, 1139, 1067, 1, 0, 0, 0, 1139, 1071, 1, 0, 0, 0, 1139, 1075, 1, 0, 0, 0, 1139, 1079, 1, 0, 0, 0, 1139, 1083, 1, 0, 0, 0, 1139, 1087, 1, 0, 0, 0, 1139, 1093, 1, 0, 0, 0, 1139, 1100, 1, 0, 0, 0, 1139, 1104, 1, 0, 0, 0, 1139, 1108, 1, 0, 0, 0, 1139, 1112, 1, 0, 0, 0, 1139, 1119, 1, 0, 0, 0, 1139, 1126, 1, 0, 0, 0, 1139, 1130, 1, 0, 0, 0, 1140, 105, 1, 0, 0, 0, 1141, 1142, 3, 172, 86, 0, 1142, 1143, 3, 140, 70, 0, 1143, 1144, 3, 114, 57, 0, 1144, 1145, 6, 53, -1, 0, 1145, 107, 1, 0, 0, 0, 1146, 1171, 1, 0, 0, 0, 1147, 1148, 3, 0, 0, 0, 1148, 1149, 6, 54, -1, 0, 1149, 1154, 1, 0, 0, 0, 1150, 1151, 3, 32, 16, 0, 1151, 1152, 6, 54, -1, 0, 1152, 1154, 1, 0, 0, 0, 1153, 1147, 1, 0, 0, 0, 1153, 1150, 1, 0, 0, 0, 1154, 1155, 1, 0, 0, 0, 1155, 1156, 5, 28, 0, 0, 1156, 1158, 1, 0, 0, 0, 1157, 1153, 1, 0, 0, 0, 1158, 1161, 1, 0, 0, 0, 1159, 1157, 1, 0, 0, 0, 1159, 1160, 1, 0, 0, 0, 1160, 1168, 1, 0, 0, 0, 1161, 1159, 1, 0, 0, 0, 1162, 1163, 3, 0, 0, 0, 1163, 1164, 6, 54, -1, 0, 1164, 1169, 1, 0, 0, 0, 1165, 1166, 3, 32, 16, 0, 1166, 1167, 6, 54, -1, 0, 1167, 1169, 1, 0, 0, 0, 1168, 1162, 1, 0, 0, 0, 1168, 1165, 1, 0, 0, 0, 1169, 1171, 1, 0, 0, 0, 1170, 1146, 1, 0, 0, 0, 1170, 1159, 1, 0, 0, 0, 1171, 109, 1, 0, 0, 0, 1172, 1179, 5, 86, 0, 0, 1173, 1174, 3, 140, 70, 0, 1174, 1175, 6, 55, -1, 0, 1175, 1176, 5, 28, 0, 0, 1176, 1178, 1, 0, 0, 0, 1177, 1173, 1, 0, 0, 0, 1178, 1181, 1, 0, 0, 0, 1179, 1177, 1, 0, 0, 0, 1179, 1180, 1, 0, 0, 0, 1180, 1182, 1, 0, 0, 0, 1181, 1179, 1, 0, 0, 0, 1182, 1183, 3, 140, 70, 0, 1183, 1184, 6, 55, -1, 0, 1184, 1185, 5, 87, 0, 0, 1185, 111, 1, 0, 0, 0, 1186, 1193, 5, 42, 0, 0, 1187, 1188, 3, 148, 74, 0, 1188, 1189, 6, 56, -1, 0, 1189, 1190, 5, 28, 0, 0, 1190, 1192, 1, 0, 0, 0, 1191, 1187, 1, 0, 0, 0, 1192, 1195, 1, 0, 0, 0, 1193, 1191, 1, 0, 0, 0, 1193, 1194, 1, 0, 0, 0, 1194, 1196, 1, 0, 0, 0, 1195, 1193, 1, 0, 0, 0, 1196, 1197, 3, 148, 74, 0, 1197, 1198, 6, 56, -1, 0, 1198, 1199, 5, 43, 0, 0, 1199, 113, 1, 0, 0, 0, 1200, 1207, 5, 30, 0, 0, 1201, 1202, 3, 116, 58, 0, 1202, 1203, 6, 57, -1, 0, 1203, 1204, 5, 28, 0, 0, 1204, 1206, 1, 0, 0, 0, 1205, 1201, 1, 0, 0, 0, 1206, 1209, 1, 0, 0, 0, 1207, 1205, 1, 0, 0, 0, 1207, 1208, 1, 0, 0, 0, 1208, 1210, 1, 0, 0, 0, 1209, 1207, 1, 0, 0, 0, 1210, 1211, 3, 116, 58, 0, 1211, 1212, 6, 57, -1, 0, 1212, 1213, 5, 31, 0, 0, 1213, 1216, 1, 0, 0, 0, 1214, 1216, 5, 85, 0, 0, 1215, 1200, 1, 0, 0, 0, 1215, 1214, 1, 0, 0, 0, 1216, 115, 1, 0, 0, 0, 1217, 1218, 5, 177, 0, 0, 1218, 1228, 6, 58, -1, 0, 1219, 1220, 3, 232, 116, 0, 1220, 1221, 3, 140, 70, 0, 1221, 1223, 3, 228, 114, 0, 1222, 1224, 3, 0, 0, 0, 1223, 1222, 1, 0, 0, 0, 1223, 1224, 1, 0, 0, 0, 1224, 1225, 1, 0, 0, 0, 1225, 1226, 6, 58, -1, 0, 1226, 1228, 1, 0, 0, 0, 1227, 1217, 1, 0, 0, 0, 1227, 1219, 1, 0, 0, 0, 1228, 117, 1, 0, 0, 0, 1229, 1230, 5, 42, 0, 0, 1230, 1231, 3, 2, 1, 0, 1231, 1232, 5, 43, 0, 0, 1232, 1233, 3, 120, 60, 0, 1233, 1234, 6, 59, -1, 0, 1234, 1267, 1, 0, 0, 0, 1235, 1236, 5, 42, 0, 0, 1236, 1237, 3, 176, 88, 0, 1237, 1238, 5, 43, 0, 0, 1238, 1239, 3, 120, 60, 0, 1239, 1240, 6, 59, -1, 0, 1240, 1267, 1, 0, 0, 0, 1241, 1242, 5, 42, 0, 0, 1242, 1243, 5, 262, 0, 0, 1243, 1244, 5, 43, 0, 0, 1244, 1245, 3, 120, 60, 0, 1245, 1246, 6, 59, -1, 0, 1246, 1267, 1, 0, 0, 0, 1247, 1248, 5, 42, 0, 0, 1248, 1249, 5, 198, 0, 0, 1249, 1250, 3, 2, 1, 0, 1250, 1251, 5, 43, 0, 0, 1251, 1252, 3, 120, 60, 0, 1252, 1253, 6, 59, -1, 0, 1253, 1267, 1, 0, 0, 0, 1254, 1255, 3, 120, 60, 0, 1255, 1256, 6, 59, -1, 0, 1256, 1267, 1, 0, 0, 0, 1257, 1258, 3, 176, 88, 0, 1258, 1259, 6, 59, -1, 0, 1259, 1267, 1, 0, 0, 0, 1260, 1261, 5, 257, 0, 0, 1261, 1267, 6, 59, -1, 0, 1262, 1263, 5, 258, 0, 0, 1263, 1267, 6, 59, -1, 0, 1264, 1265, 5, 259, 0, 0, 1265, 1267, 6, 59, -1, 0, 1266, 1229, 1, 0, 0, 0, 1266, 1235, 1, 0, 0, 0, 1266, 1241, 1, 0, 0, 0, 1266, 1247, 1, 0, 0, 0, 1266, 1254, 1, 0, 0, 0, 1266, 1257, 1, 0, 0, 0, 1266, 1260, 1, 0, 0, 0, 1266, 1262, 1, 0, 0, 0, 1266, 1264, 1, 0, 0, 0, 1267, 119, 1, 0, 0, 0, 1268, 1269, 3, 2, 1, 0, 1269, 1270, 6, 60, -1, 0, 1270, 1271, 5, 88, 0, 0, 1271, 1273, 1, 0, 0, 0, 1272, 1268, 1, 0, 0, 0, 1273, 1276, 1, 0, 0, 0, 1274, 1272, 1, 0, 0, 0, 1274, 1275, 1, 0, 0, 0, 1275, 1277, 1, 0, 0, 0, 1276, 1274, 1, 0, 0, 0, 1277, 1278, 3, 2, 1, 0, 1278, 1279, 6, 60, -1, 0, 1279, 121, 1, 0, 0, 0, 1280, 1281, 3, 124, 62, 0, 1281, 1282, 6, 61, -1, 0, 1282, 1284, 1, 0, 0, 0, 1283, 1280, 1, 0, 0, 0, 1284, 1287, 1, 0, 0, 0, 1285, 1283, 1, 0, 0, 0, 1285, 1286, 1, 0, 0, 0, 1286, 123, 1, 0, 0, 0, 1287, 1285, 1, 0, 0, 0, 1288, 1289, 5, 180, 0, 0, 1289, 1290, 5, 89, 0, 0, 1290, 1291, 3, 32, 16, 0, 1291, 1292, 6, 62, -1, 0, 1292, 1300, 1, 0, 0, 0, 1293, 1294, 3, 154, 77, 0, 1294, 1295, 6, 62, -1, 0, 1295, 1300, 1, 0, 0, 0, 1296, 1297, 3, 334, 167, 0, 1297, 1298, 6, 62, -1, 0, 1298, 1300, 1, 0, 0, 0, 1299, 1288, 1, 0, 0, 0, 1299, 1293, 1, 0, 0, 0, 1299, 1296, 1, 0, 0, 0, 1300, 125, 1, 0, 0, 0, 1301, 1302, 3, 118, 59, 0, 1302, 1303, 6, 63, -1, 0, 1303, 1319, 1, 0, 0, 0, 1304, 1305, 5, 42, 0, 0, 1305, 1306, 3, 2, 1, 0, 1306, 1307, 5, 43, 0, 0, 1307, 1308, 6, 63, -1, 0, 1308, 1319, 1, 0, 0, 0, 1309, 1310, 5, 42, 0, 0, 1310, 1311, 5, 198, 0, 0, 1311, 1312, 3, 2, 1, 0, 1312, 1313, 5, 43, 0, 0, 1313, 1314, 6, 63, -1, 0, 1314, 1319, 1, 0, 0, 0, 1315, 1316, 3, 140, 70, 0, 1316, 1317, 6, 63, -1, 0, 1317, 1319, 1, 0, 0, 0, 1318, 1301, 1, 0, 0, 0, 1318, 1304, 1, 0, 0, 0, 1318, 1309, 1, 0, 0, 0, 1318, 1315, 1, 0, 0, 0, 1319, 127, 1, 0, 0, 0, 1320, 1332, 1, 0, 0, 0, 1321, 1322, 3, 132, 66, 0, 1322, 1328, 6, 64, -1, 0, 1323, 1324, 3, 130, 65, 0, 1324, 1325, 6, 64, -1, 0, 1325, 1327, 1, 0, 0, 0, 1326, 1323, 1, 0, 0, 0, 1327, 1330, 1, 0, 0, 0, 1328, 1326, 1, 0, 0, 0, 1328, 1329, 1, 0, 0, 0, 1329, 1332, 1, 0, 0, 0, 1330, 1328, 1, 0, 0, 0, 1331, 1320, 1, 0, 0, 0, 1331, 1321, 1, 0, 0, 0, 1332, 129, 1, 0, 0, 0, 1333, 1334, 5, 262, 0, 0, 1334, 1356, 6, 65, -1, 0, 1335, 1336, 5, 261, 0, 0, 1336, 1356, 6, 65, -1, 0, 1337, 1338, 5, 42, 0, 0, 1338, 1339, 3, 32, 16, 0, 1339, 1340, 5, 43, 0, 0, 1340, 1341, 6, 65, -1, 0, 1341, 1356, 1, 0, 0, 0, 1342, 1343, 5, 42, 0, 0, 1343, 1344, 3, 32, 16, 0, 1344, 1345, 5, 266, 0, 0, 1345, 1346, 3, 32, 16, 0, 1346, 1347, 5, 43, 0, 0, 1347, 1348, 6, 65, -1, 0, 1348, 1356, 1, 0, 0, 0, 1349, 1350, 5, 42, 0, 0, 1350, 1351, 5, 266, 0, 0, 1351, 1352, 3, 32, 16, 0, 1352, 1353, 5, 43, 0, 0, 1353, 1354, 6, 65, -1, 0, 1354, 1356, 1, 0, 0, 0, 1355, 1333, 1, 0, 0, 0, 1355, 1335, 1, 0, 0, 0, 1355, 1337, 1, 0, 0, 0, 1355, 1342, 1, 0, 0, 0, 1355, 1349, 1, 0, 0, 0, 1356, 131, 1, 0, 0, 0, 1357, 1503, 6, 66, -1, 0, 1358, 1359, 5, 203, 0, 0, 1359, 1360, 5, 30, 0, 0, 1360, 1361, 3, 6, 3, 0, 1361, 1362, 5, 28, 0, 0, 1362, 1363, 3, 6, 3, 0, 1363, 1364, 5, 28, 0, 0, 1364, 1365, 3, 6, 3, 0, 1365, 1366, 5, 28, 0, 0, 1366, 1367, 3, 6, 3, 0, 1367, 1368, 5, 31, 0, 0, 1368, 1369, 6, 66, -1, 0, 1369, 1503, 1, 0, 0, 0, 1370, 1371, 5, 203, 0, 0, 1371, 1372, 5, 30, 0, 0, 1372, 1373, 3, 6, 3, 0, 1373, 1374, 5, 28, 0, 0, 1374, 1375, 3, 6, 3, 0, 1375, 1376, 5, 31, 0, 0, 1376, 1377, 6, 66, -1, 0, 1377, 1503, 1, 0, 0, 0, 1378, 1379, 5, 204, 0, 0, 1379, 1380, 5, 205, 0, 0, 1380, 1381, 5, 42, 0, 0, 1381, 1382, 3, 32, 16, 0, 1382, 1383, 5, 43, 0, 0, 1383, 1384, 6, 66, -1, 0, 1384, 1503, 1, 0, 0, 0, 1385, 1386, 5, 204, 0, 0, 1386, 1387, 5, 206, 0, 0, 1387, 1388, 5, 42, 0, 0, 1388, 1389, 3, 32, 16, 0, 1389, 1390, 5, 43, 0, 0, 1390, 1391, 3, 128, 64, 0, 1391, 1392, 6, 66, -1, 0, 1392, 1503, 1, 0, 0, 0, 1393, 1394, 5, 207, 0, 0, 1394, 1503, 6, 66, -1, 0, 1395, 1396, 5, 208, 0, 0, 1396, 1503, 6, 66, -1, 0, 1397, 1398, 5, 209, 0, 0, 1398, 1503, 6, 66, -1, 0, 1399, 1400, 5, 201, 0, 0, 1400, 1503, 6, 66, -1, 0, 1401, 1402, 5, 183, 0, 0, 1402, 1503, 6, 66, -1, 0, 1403, 1404, 5, 184, 0, 0, 1404, 1503, 6, 66, -1, 0, 1405, 1406, 5, 185, 0, 0, 1406, 1503, 6, 66, -1, 0, 1407, 1408, 5, 186, 0, 0, 1408, 1503, 6, 66, -1, 0, 1409, 1410, 5, 187, 0, 0, 1410, 1503, 6, 66, -1, 0, 1411, 1412, 5, 188, 0, 0, 1412, 1503, 6, 66, -1, 0, 1413, 1414, 5, 189, 0, 0, 1414, 1503, 6, 66, -1, 0, 1415, 1416, 5, 210, 0, 0, 1416, 1503, 6, 66, -1, 0, 1417, 1418, 5, 190, 0, 0, 1418, 1503, 6, 66, -1, 0, 1419, 1420, 5, 191, 0, 0, 1420, 1503, 6, 66, -1, 0, 1421, 1422, 5, 192, 0, 0, 1422, 1503, 6, 66, -1, 0, 1423, 1424, 5, 193, 0, 0, 1424, 1503, 6, 66, -1, 0, 1425, 1426, 5, 211, 0, 0, 1426, 1503, 6, 66, -1, 0, 1427, 1428, 5, 212, 0, 0, 1428, 1503, 6, 66, -1, 0, 1429, 1430, 5, 213, 0, 0, 1430, 1503, 6, 66, -1, 0, 1431, 1432, 5, 214, 0, 0, 1432, 1503, 6, 66, -1, 0, 1433, 1434, 5, 215, 0, 0, 1434, 1503, 6, 66, -1, 0, 1435, 1436, 5, 216, 0, 0, 1436, 1503, 6, 66, -1, 0, 1437, 1438, 5, 217, 0, 0, 1438, 1503, 6, 66, -1, 0, 1439, 1440, 5, 218, 0, 0, 1440, 1441, 3, 134, 67, 0, 1441, 1442, 6, 66, -1, 0, 1442, 1503, 1, 0, 0, 0, 1443, 1444, 5, 219, 0, 0, 1444, 1445, 3, 134, 67, 0, 1445, 1446, 6, 66, -1, 0, 1446, 1503, 1, 0, 0, 0, 1447, 1448, 5, 220, 0, 0, 1448, 1503, 6, 66, -1, 0, 1449, 1450, 5, 221, 0, 0, 1450, 1451, 3, 134, 67, 0, 1451, 1452, 6, 66, -1, 0, 1452, 1503, 1, 0, 0, 0, 1453, 1454, 5, 222, 0, 0, 1454, 1455, 3, 136, 68, 0, 1455, 1456, 6, 66, -1, 0, 1456, 1503, 1, 0, 0, 0, 1457, 1458, 5, 222, 0, 0, 1458, 1459, 3, 136, 68, 0, 1459, 1460, 5, 28, 0, 0, 1460, 1461, 3, 6, 3, 0, 1461, 1462, 6, 66, -1, 0, 1462, 1503, 1, 0, 0, 0, 1463, 1464, 5, 194, 0, 0, 1464, 1503, 6, 66, -1, 0, 1465, 1466, 5, 195, 0, 0, 1466, 1503, 6, 66, -1, 0, 1467, 1468, 5, 90, 0, 0, 1468, 1469, 5, 184, 0, 0, 1469, 1503, 6, 66, -1, 0, 1470, 1471, 5, 90, 0, 0, 1471, 1472, 5, 185, 0, 0, 1472, 1503, 6, 66, -1, 0, 1473, 1474, 5, 90, 0, 0, 1474, 1475, 5, 186, 0, 0, 1475, 1503, 6, 66, -1, 0, 1476, 1477, 5, 90, 0, 0, 1477, 1478, 5, 187, 0, 0, 1478, 1503, 6, 66, -1, 0, 1479, 1480, 5, 62, 0, 0, 1480, 1481, 5, 220, 0, 0, 1481, 1503, 6, 66, -1, 0, 1482, 1483, 5, 223, 0, 0, 1483, 1503, 6, 66, -1, 0, 1484, 1485, 5, 224, 0, 0, 1485, 1486, 5, 213, 0, 0, 1486, 1503, 6, 66, -1, 0, 1487, 1488, 5, 225, 0, 0, 1488, 1503, 6, 66, -1, 0, 1489, 1490, 5, 207, 0, 0, 1490, 1491, 5, 183, 0, 0, 1491, 1503, 6, 66, -1, 0, 1492, 1493, 5, 226, 0, 0, 1493, 1503, 6, 66, -1, 0, 1494, 1495, 5, 228, 0, 0, 1495, 1503, 6, 66, -1, 0, 1496, 1497, 5, 34, 0, 0, 1497, 1498, 5, 227, 0, 0, 1498, 1503, 6, 66, -1, 0, 1499, 1500, 3, 2, 1, 0, 1500, 1501, 6, 66, -1, 0, 1501, 1503, 1, 0, 0, 0, 1502, 1357, 1, 0, 0, 0, 1502, 1358, 1, 0, 0, 0, 1502, 1370, 1, 0, 0, 0, 1502, 1378, 1, 0, 0, 0, 1502, 1385, 1, 0, 0, 0, 1502, 1393, 1, 0, 0, 0, 1502, 1395, 1, 0, 0, 0, 1502, 1397, 1, 0, 0, 0, 1502, 1399, 1, 0, 0, 0, 1502, 1401, 1, 0, 0, 0, 1502, 1403, 1, 0, 0, 0, 1502, 1405, 1, 0, 0, 0, 1502, 1407, 1, 0, 0, 0, 1502, 1409, 1, 0, 0, 0, 1502, 1411, 1, 0, 0, 0, 1502, 1413, 1, 0, 0, 0, 1502, 1415, 1, 0, 0, 0, 1502, 1417, 1, 0, 0, 0, 1502, 1419, 1, 0, 0, 0, 1502, 1421, 1, 0, 0, 0, 1502, 1423, 1, 0, 0, 0, 1502, 1425, 1, 0, 0, 0, 1502, 1427, 1, 0, 0, 0, 1502, 1429, 1, 0, 0, 0, 1502, 1431, 1, 0, 0, 0, 1502, 1433, 1, 0, 0, 0, 1502, 1435, 1, 0, 0, 0, 1502, 1437, 1, 0, 0, 0, 1502, 1439, 1, 0, 0, 0, 1502, 1443, 1, 0, 0, 0, 1502, 1447, 1, 0, 0, 0, 1502, 1449, 1, 0, 0, 0, 1502, 1453, 1, 0, 0, 0, 1502, 1457, 1, 0, 0, 0, 1502, 1463, 1, 0, 0, 0, 1502, 1465, 1, 0, 0, 0, 1502, 1467, 1, 0, 0, 0, 1502, 1470, 1, 0, 0, 0, 1502, 1473, 1, 0, 0, 0, 1502, 1476, 1, 0, 0, 0, 1502, 1479, 1, 0, 0, 0, 1502, 1482, 1, 0, 0, 0, 1502, 1484, 1, 0, 0, 0, 1502, 1487, 1, 0, 0, 0, 1502, 1489, 1, 0, 0, 0, 1502, 1492, 1, 0, 0, 0, 1502, 1494, 1, 0, 0, 0, 1502, 1496, 1, 0, 0, 0, 1502, 1499, 1, 0, 0, 0, 1503, 133, 1, 0, 0, 0, 1504, 1513, 1, 0, 0, 0, 1505, 1506, 5, 30, 0, 0, 1506, 1507, 5, 91, 0, 0, 1507, 1508, 5, 36, 0, 0, 1508, 1509, 3, 32, 16, 0, 1509, 1510, 5, 31, 0, 0, 1510, 1511, 6, 67, -1, 0, 1511, 1513, 1, 0, 0, 0, 1512, 1504, 1, 0, 0, 0, 1512, 1505, 1, 0, 0, 0, 1513, 135, 1, 0, 0, 0, 1514, 1525, 1, 0, 0, 0, 1515, 1516, 3, 138, 69, 0, 1516, 1521, 6, 68, -1, 0, 1517, 1518, 7, 8, 0, 0, 1518, 1520, 6, 68, -1, 0, 1519, 1517, 1, 0, 0, 0, 1520, 1523, 1, 0, 0, 0, 1521, 1519, 1, 0, 0, 0, 1521, 1522, 1, 0, 0, 0, 1522, 1525, 1, 0, 0, 0, 1523, 1521, 1, 0, 0, 0, 1524, 1514, 1, 0, 0, 0, 1524, 1515, 1, 0, 0, 0, 1525, 137, 1, 0, 0, 0, 1526, 1527, 5, 178, 0, 0, 1527, 1607, 6, 69, -1, 0, 1528, 1529, 5, 207, 0, 0, 1529, 1607, 6, 69, -1, 0, 1530, 1531, 5, 208, 0, 0, 1531, 1607, 6, 69, -1, 0, 1532, 1533, 5, 201, 0, 0, 1533, 1607, 6, 69, -1, 0, 1534, 1535, 5, 183, 0, 0, 1535, 1607, 6, 69, -1, 0, 1536, 1537, 5, 184, 0, 0, 1537, 1607, 6, 69, -1, 0, 1538, 1539, 5, 185, 0, 0, 1539, 1607, 6, 69, -1, 0, 1540, 1541, 5, 186, 0, 0, 1541, 1607, 6, 69, -1, 0, 1542, 1543, 5, 187, 0, 0, 1543, 1607, 6, 69, -1, 0, 1544, 1545, 5, 188, 0, 0, 1545, 1607, 6, 69, -1, 0, 1546, 1547, 5, 189, 0, 0, 1547, 1607, 6, 69, -1, 0, 1548, 1549, 5, 190, 0, 0, 1549, 1607, 6, 69, -1, 0, 1550, 1551, 5, 191, 0, 0, 1551, 1607, 6, 69, -1, 0, 1552, 1553, 5, 192, 0, 0, 1553, 1607, 6, 69, -1, 0, 1554, 1555, 5, 193, 0, 0, 1555, 1607, 6, 69, -1, 0, 1556, 1557, 5, 262, 0, 0, 1557, 1607, 6, 69, -1, 0, 1558, 1559, 5, 211, 0, 0, 1559, 1607, 6, 69, -1, 0, 1560, 1561, 5, 212, 0, 0, 1561, 1607, 6, 69, -1, 0, 1562, 1563, 5, 213, 0, 0, 1563, 1607, 6, 69, -1, 0, 1564, 1565, 5, 214, 0, 0, 1565, 1607, 6, 69, -1, 0, 1566, 1567, 5, 215, 0, 0, 1567, 1607, 6, 69, -1, 0, 1568, 1569, 5, 218, 0, 0, 1569, 1607, 6, 69, -1, 0, 1570, 1571, 5, 219, 0, 0, 1571, 1607, 6, 69, -1, 0, 1572, 1573, 5, 222, 0, 0, 1573, 1607, 6, 69, -1, 0, 1574, 1575, 5, 194, 0, 0, 1575, 1607, 6, 69, -1, 0, 1576, 1577, 5, 195, 0, 0, 1577, 1607, 6, 69, -1, 0, 1578, 1579, 5, 210, 0, 0, 1579, 1607, 6, 69, -1, 0, 1580, 1581, 5, 230, 0, 0, 1581, 1607, 6, 69, -1, 0, 1582, 1583, 5, 231, 0, 0, 1583, 1607, 6, 69, -1, 0, 1584, 1585, 5, 232, 0, 0, 1585, 1607, 6, 69, -1, 0, 1586, 1587, 5, 233, 0, 0, 1587, 1607, 6, 69, -1, 0, 1588, 1589, 5, 234, 0, 0, 1589, 1607, 6, 69, -1, 0, 1590, 1591, 5, 235, 0, 0, 1591, 1607, 6, 69, -1, 0, 1592, 1593, 5, 236, 0, 0, 1593, 1607, 6, 69, -1, 0, 1594, 1595, 5, 237, 0, 0, 1595, 1607, 6, 69, -1, 0, 1596, 1597, 5, 238, 0, 0, 1597, 1607, 6, 69, -1, 0, 1598, 1599, 5, 239, 0, 0, 1599, 1607, 6, 69, -1, 0, 1600, 1601, 5, 240, 0, 0, 1601, 1607, 6, 69, -1, 0, 1602, 1603, 5, 241, 0, 0, 1603, 1607, 6, 69, -1, 0, 1604, 1605, 5, 242, 0, 0, 1605, 1607, 6, 69, -1, 0, 1606, 1526, 1, 0, 0, 0, 1606, 1528, 1, 0, 0, 0, 1606, 1530, 1, 0, 0, 0, 1606, 1532, 1, 0, 0, 0, 1606, 1534, 1, 0, 0, 0, 1606, 1536, 1, 0, 0, 0, 1606, 1538, 1, 0, 0, 0, 1606, 1540, 1, 0, 0, 0, 1606, 1542, 1, 0, 0, 0, 1606, 1544, 1, 0, 0, 0, 1606, 1546, 1, 0, 0, 0, 1606, 1548, 1, 0, 0, 0, 1606, 1550, 1, 0, 0, 0, 1606, 1552, 1, 0, 0, 0, 1606, 1554, 1, 0, 0, 0, 1606, 1556, 1, 0, 0, 0, 1606, 1558, 1, 0, 0, 0, 1606, 1560, 1, 0, 0, 0, 1606, 1562, 1, 0, 0, 0, 1606, 1564, 1, 0, 0, 0, 1606, 1566, 1, 0, 0, 0, 1606, 1568, 1, 0, 0, 0, 1606, 1570, 1, 0, 0, 0, 1606, 1572, 1, 0, 0, 0, 1606, 1574, 1, 0, 0, 0, 1606, 1576, 1, 0, 0, 0, 1606, 1578, 1, 0, 0, 0, 1606, 1580, 1, 0, 0, 0, 1606, 1582, 1, 0, 0, 0, 1606, 1584, 1, 0, 0, 0, 1606, 1586, 1, 0, 0, 0, 1606, 1588, 1, 0, 0, 0, 1606, 1590, 1, 0, 0, 0, 1606, 1592, 1, 0, 0, 0, 1606, 1594, 1, 0, 0, 0, 1606, 1596, 1, 0, 0, 0, 1606, 1598, 1, 0, 0, 0, 1606, 1600, 1, 0, 0, 0, 1606, 1602, 1, 0, 0, 0, 1606, 1604, 1, 0, 0, 0, 1607, 139, 1, 0, 0, 0, 1608, 1609, 3, 144, 72, 0, 1609, 1615, 6, 70, -1, 0, 1610, 1611, 3, 142, 71, 0, 1611, 1612, 6, 70, -1, 0, 1612, 1614, 1, 0, 0, 0, 1613, 1610, 1, 0, 0, 0, 1614, 1617, 1, 0, 0, 0, 1615, 1613, 1, 0, 0, 0, 1615, 1616, 1, 0, 0, 0, 1616, 141, 1, 0, 0, 0, 1617, 1615, 1, 0, 0, 0, 1618, 1619, 5, 261, 0, 0, 1619, 1648, 6, 71, -1, 0, 1620, 1621, 5, 42, 0, 0, 1621, 1622, 5, 43, 0, 0, 1622, 1648, 6, 71, -1, 0, 1623, 1624, 3, 112, 56, 0, 1624, 1625, 6, 71, -1, 0, 1625, 1648, 1, 0, 0, 0, 1626, 1627, 5, 260, 0, 0, 1627, 1648, 6, 71, -1, 0, 1628, 1629, 5, 262, 0, 0, 1629, 1648, 6, 71, -1, 0, 1630, 1631, 5, 92, 0, 0, 1631, 1648, 6, 71, -1, 0, 1632, 1633, 5, 93, 0, 0, 1633, 1634, 5, 30, 0, 0, 1634, 1635, 3, 126, 63, 0, 1635, 1636, 5, 31, 0, 0, 1636, 1637, 6, 71, -1, 0, 1637, 1648, 1, 0, 0, 0, 1638, 1639, 5, 94, 0, 0, 1639, 1640, 5, 30, 0, 0, 1640, 1641, 3, 126, 63, 0, 1641, 1642, 5, 31, 0, 0, 1642, 1643, 6, 71, -1, 0, 1643, 1648, 1, 0, 0, 0, 1644, 1645, 3, 110, 55, 0, 1645, 1646, 6, 71, -1, 0, 1646, 1648, 1, 0, 0, 0, 1647, 1618, 1, 0, 0, 0, 1647, 1620, 1, 0, 0, 0, 1647, 1623, 1, 0, 0, 0, 1647, 1626, 1, 0, 0, 0, 1647, 1628, 1, 0, 0, 0, 1647, 1630, 1, 0, 0, 0, 1647, 1632, 1, 0, 0, 0, 1647, 1638, 1, 0, 0, 0, 1647, 1644, 1, 0, 0, 0, 1648, 143, 1, 0, 0, 0, 1649, 1650, 5, 39, 0, 0, 1650, 1651, 3, 118, 59, 0, 1651, 1652, 6, 72, -1, 0, 1652, 1708, 1, 0, 0, 0, 1653, 1654, 5, 197, 0, 0, 1654, 1708, 6, 72, -1, 0, 1655, 1656, 5, 199, 0, 0, 1656, 1657, 5, 39, 0, 0, 1657, 1658, 3, 118, 59, 0, 1658, 1659, 6, 72, -1, 0, 1659, 1708, 1, 0, 0, 0, 1660, 1661, 5, 200, 0, 0, 1661, 1662, 3, 118, 59, 0, 1662, 1663, 6, 72, -1, 0, 1663, 1708, 1, 0, 0, 0, 1664, 1665, 5, 226, 0, 0, 1665, 1666, 3, 172, 86, 0, 1666, 1667, 3, 140, 70, 0, 1667, 1668, 5, 262, 0, 0, 1668, 1669, 3, 114, 57, 0, 1669, 1670, 6, 72, -1, 0, 1670, 1708, 1, 0, 0, 0, 1671, 1672, 5, 253, 0, 0, 1672, 1673, 3, 32, 16, 0, 1673, 1674, 6, 72, -1, 0, 1674, 1708, 1, 0, 0, 0, 1675, 1676, 5, 252, 0, 0, 1676, 1677, 3, 32, 16, 0, 1677, 1678, 6, 72, -1, 0, 1678, 1708, 1, 0, 0, 0, 1679, 1680, 5, 253, 0, 0, 1680, 1681, 3, 2, 1, 0, 1681, 1682, 6, 72, -1, 0, 1682, 1708, 1, 0, 0, 0, 1683, 1684, 5, 252, 0, 0, 1684, 1685, 3, 2, 1, 0, 1685, 1686, 6, 72, -1, 0, 1686, 1708, 1, 0, 0, 0, 1687, 1688, 5, 254, 0, 0, 1688, 1708, 6, 72, -1, 0, 1689, 1690, 5, 201, 0, 0, 1690, 1708, 6, 72, -1, 0, 1691, 1692, 3, 150, 75, 0, 1692, 1693, 6, 72, -1, 0, 1693, 1708, 1, 0, 0, 0, 1694, 1695, 3, 152, 76, 0, 1695, 1696, 6, 72, -1, 0, 1696, 1708, 1, 0, 0, 0, 1697, 1698, 3, 146, 73, 0, 1698, 1699, 6, 72, -1, 0, 1699, 1708, 1, 0, 0, 0, 1700, 1701, 3, 2, 1, 0, 1701, 1702, 6, 72, -1, 0, 1702, 1708, 1, 0, 0, 0, 1703, 1704, 5, 177, 0, 0, 1704, 1705, 3, 140, 70, 0, 1705, 1706, 6, 72, -1, 0, 1706, 1708, 1, 0, 0, 0, 1707, 1649, 1, 0, 0, 0, 1707, 1653, 1, 0, 0, 0, 1707, 1655, 1, 0, 0, 0, 1707, 1660, 1, 0, 0, 0, 1707, 1664, 1, 0, 0, 0, 1707, 1671, 1, 0, 0, 0, 1707, 1675, 1, 0, 0, 0, 1707, 1679, 1, 0, 0, 0, 1707, 1683, 1, 0, 0, 0, 1707, 1687, 1, 0, 0, 0, 1707, 1689, 1, 0, 0, 0, 1707, 1691, 1, 0, 0, 0, 1707, 1694, 1, 0, 0, 0, 1707, 1697, 1, 0, 0, 0, 1707, 1700, 1, 0, 0, 0, 1707, 1703, 1, 0, 0, 0, 1708, 145, 1, 0, 0, 0, 1709, 1710, 5, 181, 0, 0, 1710, 1748, 6, 73, -1, 0, 1711, 1712, 5, 182, 0, 0, 1712, 1748, 6, 73, -1, 0, 1713, 1714, 5, 183, 0, 0, 1714, 1748, 6, 73, -1, 0, 1715, 1716, 5, 184, 0, 0, 1716, 1748, 6, 73, -1, 0, 1717, 1718, 5, 185, 0, 0, 1718, 1748, 6, 73, -1, 0, 1719, 1720, 5, 186, 0, 0, 1720, 1748, 6, 73, -1, 0, 1721, 1722, 5, 187, 0, 0, 1722, 1748, 6, 73, -1, 0, 1723, 1724, 5, 188, 0, 0, 1724, 1748, 6, 73, -1, 0, 1725, 1726, 5, 189, 0, 0, 1726, 1748, 6, 73, -1, 0, 1727, 1728, 5, 190, 0, 0, 1728, 1748, 6, 73, -1, 0, 1729, 1730, 5, 191, 0, 0, 1730, 1748, 6, 73, -1, 0, 1731, 1732, 5, 192, 0, 0, 1732, 1748, 6, 73, -1, 0, 1733, 1734, 5, 193, 0, 0, 1734, 1748, 6, 73, -1, 0, 1735, 1736, 5, 90, 0, 0, 1736, 1737, 5, 184, 0, 0, 1737, 1748, 6, 73, -1, 0, 1738, 1739, 5, 90, 0, 0, 1739, 1740, 5, 185, 0, 0, 1740, 1748, 6, 73, -1, 0, 1741, 1742, 5, 90, 0, 0, 1742, 1743, 5, 186, 0, 0, 1743, 1748, 6, 73, -1, 0, 1744, 1745, 5, 90, 0, 0, 1745, 1746, 5, 187, 0, 0, 1746, 1748, 6, 73, -1, 0, 1747, 1709, 1, 0, 0, 0, 1747, 1711, 1, 0, 0, 0, 1747, 1713, 1, 0, 0, 0, 1747, 1715, 1, 0, 0, 0, 1747, 1717, 1, 0, 0, 0, 1747, 1719, 1, 0, 0, 0, 1747, 1721, 1, 0, 0, 0, 1747, 1723, 1, 0, 0, 0, 1747, 1725, 1, 0, 0, 0, 1747, 1727, 1, 0, 0, 0, 1747, 1729, 1, 0, 0, 0, 1747, 1731, 1, 0, 0, 0, 1747, 1733, 1, 0, 0, 0, 1747, 1735, 1, 0, 0, 0, 1747, 1738, 1, 0, 0, 0, 1747, 1741, 1, 0, 0, 0, 1747, 1744, 1, 0, 0, 0, 1748, 147, 1, 0, 0, 0, 1749, 1764, 1, 0, 0, 0, 1750, 1764, 5, 177, 0, 0, 1751, 1752, 3, 32, 16, 0, 1752, 1753, 6, 74, -1, 0, 1753, 1764, 1, 0, 0, 0, 1754, 1755, 3, 32, 16, 0, 1755, 1756, 5, 177, 0, 0, 1756, 1757, 3, 32, 16, 0, 1757, 1758, 6, 74, -1, 0, 1758, 1764, 1, 0, 0, 0, 1759, 1760, 3, 32, 16, 0, 1760, 1761, 5, 177, 0, 0, 1761, 1762, 6, 74, -1, 0, 1762, 1764, 1, 0, 0, 0, 1763, 1749, 1, 0, 0, 0, 1763, 1750, 1, 0, 0, 0, 1763, 1751, 1, 0, 0, 0, 1763, 1754, 1, 0, 0, 0, 1763, 1759, 1, 0, 0, 0, 1764, 149, 1, 0, 0, 0, 1765, 1766, 5, 1, 0, 0, 1766, 1767, 5, 194, 0, 0, 1767, 1768, 6, 75, -1, 0, 1768, 151, 1, 0, 0, 0, 1769, 1773, 5, 1, 0, 0, 1770, 1771, 5, 90, 0, 0, 1771, 1774, 5, 194, 0, 0, 1772, 1774, 5, 195, 0, 0, 1773, 1770, 1, 0, 0, 0, 1773, 1772, 1, 0, 0, 0, 1774, 1775, 1, 0, 0, 0, 1775, 1776, 6, 76, -1, 0, 1776, 153, 1, 0, 0, 0, 1777, 1778, 5, 294, 0, 0, 1778, 1779, 3, 168, 84, 0, 1779, 1780, 3, 126, 63, 0, 1780, 1781, 5, 30, 0, 0, 1781, 1782, 3, 160, 80, 0, 1782, 1783, 5, 31, 0, 0, 1783, 1784, 6, 77, -1, 0, 1784, 1832, 1, 0, 0, 0, 1785, 1786, 5, 294, 0, 0, 1786, 1787, 3, 168, 84, 0, 1787, 1788, 3, 126, 63, 0, 1788, 1789, 5, 36, 0, 0, 1789, 1790, 5, 17, 0, 0, 1790, 1791, 3, 52, 26, 0, 1791, 1792, 5, 18, 0, 0, 1792, 1793, 6, 77, -1, 0, 1793, 1832, 1, 0, 0, 0, 1794, 1795, 5, 294, 0, 0, 1795, 1796, 3, 168, 84, 0, 1796, 1797, 3, 126, 63, 0, 1797, 1798, 6, 77, -1, 0, 1798, 1832, 1, 0, 0, 0, 1799, 1800, 5, 295, 0, 0, 1800, 1801, 3, 168, 84, 0, 1801, 1803, 5, 36, 0, 0, 1802, 1804, 5, 84, 0, 0, 1803, 1802, 1, 0, 0, 0, 1803, 1804, 1, 0, 0, 0, 1804, 1805, 1, 0, 0, 0, 1805, 1806, 5, 30, 0, 0, 1806, 1807, 3, 302, 151, 0, 1807, 1808, 5, 31, 0, 0, 1808, 1809, 6, 77, -1, 0, 1809, 1832, 1, 0, 0, 0, 1810, 1811, 5, 295, 0, 0, 1811, 1812, 3, 168, 84, 0, 1812, 1813, 5, 84, 0, 0, 1813, 1814, 5, 30, 0, 0, 1814, 1815, 3, 302, 151, 0, 1815, 1816, 5, 31, 0, 0, 1816, 1817, 6, 77, -1, 0, 1817, 1832, 1, 0, 0, 0, 1818, 1819, 5, 295, 0, 0, 1819, 1820, 3, 168, 84, 0, 1820, 1821, 3, 6, 3, 0, 1821, 1822, 6, 77, -1, 0, 1822, 1832, 1, 0, 0, 0, 1823, 1824, 5, 295, 0, 0, 1824, 1825, 3, 168, 84, 0, 1825, 1826, 5, 36, 0, 0, 1826, 1827, 5, 17, 0, 0, 1827, 1828, 3, 156, 78, 0, 1828, 1829, 5, 18, 0, 0, 1829, 1830, 6, 77, -1, 0, 1830, 1832, 1, 0, 0, 0, 1831, 1777, 1, 0, 0, 0, 1831, 1785, 1, 0, 0, 0, 1831, 1794, 1, 0, 0, 0, 1831, 1799, 1, 0, 0, 0, 1831, 1810, 1, 0, 0, 0, 1831, 1818, 1, 0, 0, 0, 1831, 1823, 1, 0, 0, 0, 1832, 155, 1, 0, 0, 0, 1833, 1847, 1, 0, 0, 0, 1834, 1835, 3, 158, 79, 0, 1835, 1836, 6, 78, -1, 0, 1836, 1837, 5, 28, 0, 0, 1837, 1839, 1, 0, 0, 0, 1838, 1834, 1, 0, 0, 0, 1839, 1842, 1, 0, 0, 0, 1840, 1838, 1, 0, 0, 0, 1840, 1841, 1, 0, 0, 0, 1841, 1843, 1, 0, 0, 0, 1842, 1840, 1, 0, 0, 0, 1843, 1844, 3, 158, 79, 0, 1844, 1845, 6, 78, -1, 0, 1845, 1847, 1, 0, 0, 0, 1846, 1833, 1, 0, 0, 0, 1846, 1840, 1, 0, 0, 0, 1847, 157, 1, 0, 0, 0, 1848, 1849, 5, 39, 0, 0, 1849, 1850, 5, 264, 0, 0, 1850, 1851, 5, 36, 0, 0, 1851, 1852, 5, 17, 0, 0, 1852, 1853, 3, 56, 28, 0, 1853, 1854, 5, 18, 0, 0, 1854, 1855, 6, 79, -1, 0, 1855, 1864, 1, 0, 0, 0, 1856, 1857, 3, 126, 63, 0, 1857, 1858, 5, 36, 0, 0, 1858, 1859, 5, 17, 0, 0, 1859, 1860, 3, 56, 28, 0, 1860, 1861, 5, 18, 0, 0, 1861, 1862, 6, 79, -1, 0, 1862, 1864, 1, 0, 0, 0, 1863, 1848, 1, 0, 0, 0, 1863, 1856, 1, 0, 0, 0, 1864, 159, 1, 0, 0, 0, 1865, 1866, 3, 162, 81, 0, 1866, 1867, 6, 80, -1, 0, 1867, 1868, 5, 28, 0, 0, 1868, 1870, 1, 0, 0, 0, 1869, 1865, 1, 0, 0, 0, 1870, 1873, 1, 0, 0, 0, 1871, 1869, 1, 0, 0, 0, 1871, 1872, 1, 0, 0, 0, 1872, 1874, 1, 0, 0, 0, 1873, 1871, 1, 0, 0, 0, 1874, 1875, 3, 162, 81, 0, 1875, 1876, 6, 80, -1, 0, 1876, 161, 1, 0, 0, 0, 1877, 1878, 3, 6, 3, 0, 1878, 1879, 5, 36, 0, 0, 1879, 1880, 3, 166, 83, 0, 1880, 1881, 6, 81, -1, 0, 1881, 163, 1, 0, 0, 0, 1882, 1883, 7, 9, 0, 0, 1883, 165, 1, 0, 0, 0, 1884, 1885, 3, 164, 82, 0, 1885, 1886, 6, 83, -1, 0, 1886, 1930, 1, 0, 0, 0, 1887, 1888, 3, 32, 16, 0, 1888, 1889, 6, 83, -1, 0, 1889, 1930, 1, 0, 0, 0, 1890, 1891, 5, 186, 0, 0, 1891, 1892, 5, 30, 0, 0, 1892, 1893, 3, 32, 16, 0, 1893, 1894, 5, 31, 0, 0, 1894, 1895, 6, 83, -1, 0, 1895, 1930, 1, 0, 0, 0, 1896, 1897, 3, 6, 3, 0, 1897, 1898, 6, 83, -1, 0, 1898, 1930, 1, 0, 0, 0, 1899, 1900, 3, 118, 59, 0, 1900, 1901, 5, 30, 0, 0, 1901, 1902, 5, 184, 0, 0, 1902, 1903, 5, 75, 0, 0, 1903, 1904, 3, 32, 16, 0, 1904, 1905, 5, 31, 0, 0, 1905, 1906, 6, 83, -1, 0, 1906, 1930, 1, 0, 0, 0, 1907, 1908, 3, 118, 59, 0, 1908, 1909, 5, 30, 0, 0, 1909, 1910, 5, 185, 0, 0, 1910, 1911, 5, 75, 0, 0, 1911, 1912, 3, 32, 16, 0, 1912, 1913, 5, 31, 0, 0, 1913, 1914, 6, 83, -1, 0, 1914, 1930, 1, 0, 0, 0, 1915, 1916, 3, 118, 59, 0, 1916, 1917, 5, 30, 0, 0, 1917, 1918, 5, 186, 0, 0, 1918, 1919, 5, 75, 0, 0, 1919, 1920, 3, 32, 16, 0, 1920, 1921, 5, 31, 0, 0, 1921, 1922, 6, 83, -1, 0, 1922, 1930, 1, 0, 0, 0, 1923, 1924, 3, 118, 59, 0, 1924, 1925, 5, 30, 0, 0, 1925, 1926, 3, 32, 16, 0, 1926, 1927, 5, 31, 0, 0, 1927, 1928, 6, 83, -1, 0, 1928, 1930, 1, 0, 0, 0, 1929, 1884, 1, 0, 0, 0, 1929, 1887, 1, 0, 0, 0, 1929, 1890, 1, 0, 0, 0, 1929, 1896, 1, 0, 0, 0, 1929, 1899, 1, 0, 0, 0, 1929, 1907, 1, 0, 0, 0, 1929, 1915, 1, 0, 0, 0, 1929, 1923, 1, 0, 0, 0, 1930, 167, 1, 0, 0, 0, 1931, 1932, 7, 10, 0, 0, 1932, 169, 1, 0, 0, 0, 1933, 1934, 3, 172, 86, 0, 1934, 1935, 3, 140, 70, 0, 1935, 1936, 3, 126, 63, 0, 1936, 1937, 5, 176, 0, 0, 1937, 1939, 3, 244, 122, 0, 1938, 1940, 3, 110, 55, 0, 1939, 1938, 1, 0, 0, 0, 1939, 1940, 1, 0, 0, 0, 1940, 1941, 1, 0, 0, 0, 1941, 1942, 3, 114, 57, 0, 1942, 1943, 6, 85, -1, 0, 1943, 1976, 1, 0, 0, 0, 1944, 1945, 3, 172, 86, 0, 1945, 1946, 3, 140, 70, 0, 1946, 1947, 3, 126, 63, 0, 1947, 1948, 5, 176, 0, 0, 1948, 1949, 3, 244, 122, 0, 1949, 1950, 3, 198, 99, 0, 1950, 1951, 3, 114, 57, 0, 1951, 1952, 6, 85, -1, 0, 1952, 1976, 1, 0, 0, 0, 1953, 1954, 3, 172, 86, 0, 1954, 1955, 3, 140, 70, 0, 1955, 1957, 3, 244, 122, 0, 1956, 1958, 3, 110, 55, 0, 1957, 1956, 1, 0, 0, 0, 1957, 1958, 1, 0, 0, 0, 1958, 1959, 1, 0, 0, 0, 1959, 1960, 3, 114, 57, 0, 1960, 1961, 6, 85, -1, 0, 1961, 1976, 1, 0, 0, 0, 1962, 1963, 3, 172, 86, 0, 1963, 1964, 3, 140, 70, 0, 1964, 1965, 3, 244, 122, 0, 1965, 1966, 3, 198, 99, 0, 1966, 1967, 3, 114, 57, 0, 1967, 1968, 6, 85, -1, 0, 1968, 1976, 1, 0, 0, 0, 1969, 1970, 3, 176, 88, 0, 1970, 1971, 6, 85, -1, 0, 1971, 1976, 1, 0, 0, 0, 1972, 1973, 3, 2, 1, 0, 1973, 1974, 6, 85, -1, 0, 1974, 1976, 1, 0, 0, 0, 1975, 1933, 1, 0, 0, 0, 1975, 1944, 1, 0, 0, 0, 1975, 1953, 1, 0, 0, 0, 1975, 1962, 1, 0, 0, 0, 1975, 1969, 1, 0, 0, 0, 1975, 1972, 1, 0, 0, 0, 1976, 171, 1, 0, 0, 0, 1977, 1978, 5, 243, 0, 0, 1978, 1979, 3, 172, 86, 0, 1979, 1980, 6, 86, -1, 0, 1980, 1995, 1, 0, 0, 0, 1981, 1982, 5, 244, 0, 0, 1982, 1983, 3, 172, 86, 0, 1983, 1984, 6, 86, -1, 0, 1984, 1995, 1, 0, 0, 0, 1985, 1986, 3, 174, 87, 0, 1986, 1987, 6, 86, -1, 0, 1987, 1995, 1, 0, 0, 0, 1988, 1989, 5, 112, 0, 0, 1989, 1990, 5, 30, 0, 0, 1990, 1991, 3, 32, 16, 0, 1991, 1992, 5, 31, 0, 0, 1992, 1993, 6, 86, -1, 0, 1993, 1995, 1, 0, 0, 0, 1994, 1977, 1, 0, 0, 0, 1994, 1981, 1, 0, 0, 0, 1994, 1985, 1, 0, 0, 0, 1994, 1988, 1, 0, 0, 0, 1995, 173, 1, 0, 0, 0, 1996, 2016, 1, 0, 0, 0, 1997, 1998, 5, 245, 0, 0, 1998, 2016, 6, 87, -1, 0, 1999, 2000, 5, 246, 0, 0, 2000, 2016, 6, 87, -1, 0, 2001, 2002, 5, 247, 0, 0, 2002, 2003, 5, 248, 0, 0, 2003, 2016, 6, 87, -1, 0, 2004, 2005, 5, 247, 0, 0, 2005, 2006, 5, 249, 0, 0, 2006, 2016, 6, 87, -1, 0, 2007, 2008, 5, 247, 0, 0, 2008, 2009, 5, 250, 0, 0, 2009, 2016, 6, 87, -1, 0, 2010, 2011, 5, 247, 0, 0, 2011, 2012, 5, 251, 0, 0, 2012, 2016, 6, 87, -1, 0, 2013, 2014, 5, 247, 0, 0, 2014, 2016, 6, 87, -1, 0, 2015, 1996, 1, 0, 0, 0, 2015, 1997, 1, 0, 0, 0, 2015, 1999, 1, 0, 0, 0, 2015, 2001, 1, 0, 0, 0, 2015, 2004, 1, 0, 0, 0, 2015, 2007, 1, 0, 0, 0, 2015, 2010, 1, 0, 0, 0, 2015, 2013, 1, 0, 0, 0, 2016, 175, 1, 0, 0, 0, 2017, 2018, 5, 113, 0, 0, 2018, 2019, 5, 30, 0, 0, 2019, 2020, 3, 32, 16, 0, 2020, 2021, 5, 31, 0, 0, 2021, 2022, 6, 88, -1, 0, 2022, 177, 1, 0, 0, 0, 2023, 2024, 5, 226, 0, 0, 2024, 2025, 3, 170, 85, 0, 2025, 2026, 6, 89, -1, 0, 2026, 2035, 1, 0, 0, 0, 2027, 2028, 5, 37, 0, 0, 2028, 2029, 3, 180, 90, 0, 2029, 2030, 6, 89, -1, 0, 2030, 2035, 1, 0, 0, 0, 2031, 2032, 3, 176, 88, 0, 2032, 2033, 6, 89, -1, 0, 2033, 2035, 1, 0, 0, 0, 2034, 2023, 1, 0, 0, 0, 2034, 2027, 1, 0, 0, 0, 2034, 2031, 1, 0, 0, 0, 2035, 179, 1, 0, 0, 0, 2036, 2037, 3, 140, 70, 0, 2037, 2038, 3, 126, 63, 0, 2038, 2039, 5, 176, 0, 0, 2039, 2040, 3, 2, 1, 0, 2040, 2041, 6, 90, -1, 0, 2041, 2050, 1, 0, 0, 0, 2042, 2043, 3, 140, 70, 0, 2043, 2044, 3, 2, 1, 0, 2044, 2045, 6, 90, -1, 0, 2045, 2050, 1, 0, 0, 0, 2046, 2047, 3, 2, 1, 0, 2047, 2048, 6, 90, -1, 0, 2048, 2050, 1, 0, 0, 0, 2049, 2036, 1, 0, 0, 0, 2049, 2042, 1, 0, 0, 0, 2049, 2046, 1, 0, 0, 0, 2050, 181, 1, 0, 0, 0, 2051, 2052, 3, 126, 63, 0, 2052, 2053, 6, 91, -1, 0, 2053, 2054, 5, 28, 0, 0, 2054, 2056, 1, 0, 0, 0, 2055, 2051, 1, 0, 0, 0, 2056, 2059, 1, 0, 0, 0, 2057, 2055, 1, 0, 0, 0, 2057, 2058, 1, 0, 0, 0, 2058, 2060, 1, 0, 0, 0, 2059, 2057, 1, 0, 0, 0, 2060, 2061, 3, 126, 63, 0, 2061, 2062, 6, 91, -1, 0, 2062, 183, 1, 0, 0, 0, 2063, 2070, 1, 0, 0, 0, 2064, 2065, 5, 86, 0, 0, 2065, 2066, 3, 192, 96, 0, 2066, 2067, 5, 87, 0, 0, 2067, 2068, 6, 92, -1, 0, 2068, 2070, 1, 0, 0, 0, 2069, 2063, 1, 0, 0, 0, 2069, 2064, 1, 0, 0, 0, 2070, 185, 1, 0, 0, 0, 2071, 2072, 5, 266, 0, 0, 2072, 2090, 6, 93, -1, 0, 2073, 2074, 5, 114, 0, 0, 2074, 2090, 6, 93, -1, 0, 2075, 2076, 5, 39, 0, 0, 2076, 2090, 6, 93, -1, 0, 2077, 2078, 5, 200, 0, 0, 2078, 2090, 6, 93, -1, 0, 2079, 2080, 5, 115, 0, 0, 2080, 2090, 6, 93, -1, 0, 2081, 2082, 5, 116, 0, 0, 2082, 2090, 6, 93, -1, 0, 2083, 2084, 5, 70, 0, 0, 2084, 2085, 5, 30, 0, 0, 2085, 2086, 3, 32, 16, 0, 2086, 2087, 5, 31, 0, 0, 2087, 2088, 6, 93, -1, 0, 2088, 2090, 1, 0, 0, 0, 2089, 2071, 1, 0, 0, 0, 2089, 2073, 1, 0, 0, 0, 2089, 2075, 1, 0, 0, 0, 2089, 2077, 1, 0, 0, 0, 2089, 2079, 1, 0, 0, 0, 2089, 2081, 1, 0, 0, 0, 2089, 2083, 1, 0, 0, 0, 2090, 187, 1, 0, 0, 0, 2091, 2092, 3, 186, 93, 0, 2092, 2093, 6, 94, -1, 0, 2093, 2095, 1, 0, 0, 0, 2094, 2091, 1, 0, 0, 0, 2095, 2098, 1, 0, 0, 0, 2096, 2094, 1, 0, 0, 0, 2096, 2097, 1, 0, 0, 0, 2097, 189, 1, 0, 0, 0, 2098, 2096, 1, 0, 0, 0, 2099, 2101, 3, 188, 94, 0, 2100, 2102, 3, 194, 97, 0, 2101, 2100, 1, 0, 0, 0, 2101, 2102, 1, 0, 0, 0, 2102, 2103, 1, 0, 0, 0, 2103, 2104, 3, 2, 1, 0, 2104, 2105, 6, 95, -1, 0, 2105, 191, 1, 0, 0, 0, 2106, 2107, 3, 190, 95, 0, 2107, 2108, 6, 96, -1, 0, 2108, 2109, 5, 28, 0, 0, 2109, 2111, 1, 0, 0, 0, 2110, 2106, 1, 0, 0, 0, 2111, 2114, 1, 0, 0, 0, 2112, 2110, 1, 0, 0, 0, 2112, 2113, 1, 0, 0, 0, 2113, 2115, 1, 0, 0, 0, 2114, 2112, 1, 0, 0, 0, 2115, 2116, 3, 190, 95, 0, 2116, 2117, 6, 96, -1, 0, 2117, 193, 1, 0, 0, 0, 2118, 2119, 5, 30, 0, 0, 2119, 2120, 3, 182, 91, 0, 2120, 2121, 5, 31, 0, 0, 2121, 2122, 6, 97, -1, 0, 2122, 195, 1, 0, 0, 0, 2123, 2125, 3, 198, 99, 0, 2124, 2123, 1, 0, 0, 0, 2124, 2125, 1, 0, 0, 0, 2125, 2126, 1, 0, 0, 0, 2126, 2127, 6, 98, -1, 0, 2127, 197, 1, 0, 0, 0, 2128, 2129, 5, 86, 0, 0, 2129, 2130, 5, 42, 0, 0, 2130, 2131, 3, 32, 16, 0, 2131, 2132, 5, 43, 0, 0, 2132, 2133, 5, 87, 0, 0, 2133, 2134, 6, 99, -1, 0, 2134, 199, 1, 0, 0, 0, 2135, 2136, 3, 236, 118, 0, 2136, 2137, 5, 17, 0, 0, 2137, 2138, 3, 248, 124, 0, 2138, 2139, 5, 18, 0, 0, 2139, 2286, 1, 0, 0, 0, 2140, 2141, 3, 76, 38, 0, 2141, 2142, 5, 17, 0, 0, 2142, 2143, 3, 84, 42, 0, 2143, 2144, 5, 18, 0, 0, 2144, 2286, 1, 0, 0, 0, 2145, 2146, 3, 212, 106, 0, 2146, 2147, 6, 100, -1, 0, 2147, 2148, 5, 17, 0, 0, 2148, 2149, 3, 216, 108, 0, 2149, 2150, 5, 18, 0, 0, 2150, 2286, 1, 0, 0, 0, 2151, 2152, 3, 220, 110, 0, 2152, 2153, 6, 100, -1, 0, 2153, 2154, 5, 17, 0, 0, 2154, 2155, 3, 224, 112, 0, 2155, 2156, 5, 18, 0, 0, 2156, 2286, 1, 0, 0, 0, 2157, 2286, 3, 202, 101, 0, 2158, 2159, 3, 286, 143, 0, 2159, 2160, 6, 100, -1, 0, 2160, 2286, 1, 0, 0, 0, 2161, 2162, 3, 154, 77, 0, 2162, 2163, 6, 100, -1, 0, 2163, 2286, 1, 0, 0, 0, 2164, 2165, 3, 90, 45, 0, 2165, 2166, 6, 100, -1, 0, 2166, 2286, 1, 0, 0, 0, 2167, 2168, 3, 332, 166, 0, 2168, 2169, 6, 100, -1, 0, 2169, 2286, 1, 0, 0, 0, 2170, 2171, 5, 117, 0, 0, 2171, 2172, 3, 32, 16, 0, 2172, 2173, 6, 100, -1, 0, 2173, 2286, 1, 0, 0, 0, 2174, 2175, 5, 118, 0, 0, 2175, 2176, 3, 32, 16, 0, 2176, 2177, 6, 100, -1, 0, 2177, 2286, 1, 0, 0, 0, 2178, 2179, 3, 348, 174, 0, 2179, 2180, 5, 17, 0, 0, 2180, 2181, 3, 354, 177, 0, 2181, 2182, 5, 18, 0, 0, 2182, 2183, 6, 100, -1, 0, 2183, 2286, 1, 0, 0, 0, 2184, 2185, 5, 302, 0, 0, 2185, 2186, 3, 126, 63, 0, 2186, 2187, 5, 176, 0, 0, 2187, 2188, 3, 244, 122, 0, 2188, 2189, 5, 119, 0, 0, 2189, 2190, 3, 172, 86, 0, 2190, 2191, 3, 140, 70, 0, 2191, 2192, 3, 126, 63, 0, 2192, 2193, 5, 176, 0, 0, 2193, 2194, 3, 244, 122, 0, 2194, 2195, 3, 114, 57, 0, 2195, 2196, 6, 100, -1, 0, 2196, 2286, 1, 0, 0, 0, 2197, 2198, 5, 302, 0, 0, 2198, 2199, 5, 226, 0, 0, 2199, 2200, 3, 172, 86, 0, 2200, 2201, 3, 140, 70, 0, 2201, 2202, 3, 126, 63, 0, 2202, 2203, 5, 176, 0, 0, 2203, 2204, 3, 244, 122, 0, 2204, 2205, 3, 196, 98, 0, 2205, 2206, 3, 114, 57, 0, 2206, 2207, 5, 119, 0, 0, 2207, 2208, 5, 226, 0, 0, 2208, 2209, 3, 172, 86, 0, 2209, 2210, 3, 140, 70, 0, 2210, 2211, 3, 126, 63, 0, 2211, 2212, 5, 176, 0, 0, 2212, 2213, 3, 244, 122, 0, 2213, 2214, 3, 196, 98, 0, 2214, 2215, 3, 114, 57, 0, 2215, 2216, 6, 100, -1, 0, 2216, 2286, 1, 0, 0, 0, 2217, 2218, 3, 26, 13, 0, 2218, 2219, 6, 100, -1, 0, 2219, 2286, 1, 0, 0, 0, 2220, 2221, 3, 40, 20, 0, 2221, 2222, 6, 100, -1, 0, 2222, 2286, 1, 0, 0, 0, 2223, 2224, 5, 255, 0, 0, 2224, 2225, 5, 196, 0, 0, 2225, 2226, 5, 42, 0, 0, 2226, 2227, 3, 32, 16, 0, 2227, 2228, 5, 43, 0, 0, 2228, 2234, 6, 100, -1, 0, 2229, 2230, 3, 332, 166, 0, 2230, 2231, 6, 100, -1, 0, 2231, 2233, 1, 0, 0, 0, 2232, 2229, 1, 0, 0, 0, 2233, 2236, 1, 0, 0, 0, 2234, 2232, 1, 0, 0, 0, 2234, 2235, 1, 0, 0, 0, 2235, 2286, 1, 0, 0, 0, 2236, 2234, 1, 0, 0, 0, 2237, 2238, 5, 255, 0, 0, 2238, 2239, 5, 196, 0, 0, 2239, 2240, 3, 2, 1, 0, 2240, 2246, 6, 100, -1, 0, 2241, 2242, 3, 332, 166, 0, 2242, 2243, 6, 100, -1, 0, 2243, 2245, 1, 0, 0, 0, 2244, 2241, 1, 0, 0, 0, 2245, 2248, 1, 0, 0, 0, 2246, 2244, 1, 0, 0, 0, 2246, 2247, 1, 0, 0, 0, 2247, 2286, 1, 0, 0, 0, 2248, 2246, 1, 0, 0, 0, 2249, 2250, 5, 255, 0, 0, 2250, 2251, 5, 256, 0, 0, 2251, 2252, 5, 42, 0, 0, 2252, 2253, 3, 32, 16, 0, 2253, 2254, 5, 43, 0, 0, 2254, 2255, 5, 28, 0, 0, 2255, 2256, 3, 126, 63, 0, 2256, 2262, 6, 100, -1, 0, 2257, 2258, 3, 332, 166, 0, 2258, 2259, 6, 100, -1, 0, 2259, 2261, 1, 0, 0, 0, 2260, 2257, 1, 0, 0, 0, 2261, 2264, 1, 0, 0, 0, 2262, 2260, 1, 0, 0, 0, 2262, 2263, 1, 0, 0, 0, 2263, 2286, 1, 0, 0, 0, 2264, 2262, 1, 0, 0, 0, 2265, 2266, 5, 255, 0, 0, 2266, 2267, 5, 256, 0, 0, 2267, 2268, 3, 2, 1, 0, 2268, 2269, 5, 28, 0, 0, 2269, 2270, 3, 126, 63, 0, 2270, 2276, 6, 100, -1, 0, 2271, 2272, 3, 332, 166, 0, 2272, 2273, 6, 100, -1, 0, 2273, 2275, 1, 0, 0, 0, 2274, 2271, 1, 0, 0, 0, 2275, 2278, 1, 0, 0, 0, 2276, 2274, 1, 0, 0, 0, 2276, 2277, 1, 0, 0, 0, 2277, 2286, 1, 0, 0, 0, 2278, 2276, 1, 0, 0, 0, 2279, 2280, 5, 120, 0, 0, 2280, 2281, 5, 196, 0, 0, 2281, 2282, 3, 126, 63, 0, 2282, 2283, 3, 44, 22, 0, 2283, 2284, 6, 100, -1, 0, 2284, 2286, 1, 0, 0, 0, 2285, 2135, 1, 0, 0, 0, 2285, 2140, 1, 0, 0, 0, 2285, 2145, 1, 0, 0, 0, 2285, 2151, 1, 0, 0, 0, 2285, 2157, 1, 0, 0, 0, 2285, 2158, 1, 0, 0, 0, 2285, 2161, 1, 0, 0, 0, 2285, 2164, 1, 0, 0, 0, 2285, 2167, 1, 0, 0, 0, 2285, 2170, 1, 0, 0, 0, 2285, 2174, 1, 0, 0, 0, 2285, 2178, 1, 0, 0, 0, 2285, 2184, 1, 0, 0, 0, 2285, 2197, 1, 0, 0, 0, 2285, 2217, 1, 0, 0, 0, 2285, 2220, 1, 0, 0, 0, 2285, 2223, 1, 0, 0, 0, 2285, 2237, 1, 0, 0, 0, 2285, 2249, 1, 0, 0, 0, 2285, 2265, 1, 0, 0, 0, 2285, 2279, 1, 0, 0, 0, 2286, 201, 1, 0, 0, 0, 2287, 2288, 5, 121, 0, 0, 2288, 2300, 3, 210, 105, 0, 2289, 2290, 3, 204, 102, 0, 2290, 2291, 6, 101, -1, 0, 2291, 2299, 1, 0, 0, 0, 2292, 2293, 5, 122, 0, 0, 2293, 2294, 5, 30, 0, 0, 2294, 2295, 3, 230, 115, 0, 2295, 2296, 5, 31, 0, 0, 2296, 2297, 6, 101, -1, 0, 2297, 2299, 1, 0, 0, 0, 2298, 2289, 1, 0, 0, 0, 2298, 2292, 1, 0, 0, 0, 2299, 2302, 1, 0, 0, 0, 2300, 2298, 1, 0, 0, 0, 2300, 2301, 1, 0, 0, 0, 2301, 2303, 1, 0, 0, 0, 2302, 2300, 1, 0, 0, 0, 2303, 2304, 3, 140, 70, 0, 2304, 2305, 3, 2, 1, 0, 2305, 2306, 3, 206, 103, 0, 2306, 2307, 3, 208, 104, 0, 2307, 2308, 6, 101, -1, 0, 2308, 203, 1, 0, 0, 0, 2309, 2310, 5, 123, 0, 0, 2310, 2344, 6, 102, -1, 0, 2311, 2312, 5, 51, 0, 0, 2312, 2344, 6, 102, -1, 0, 2313, 2314, 5, 52, 0, 0, 2314, 2344, 6, 102, -1, 0, 2315, 2316, 5, 63, 0, 0, 2316, 2344, 6, 102, -1, 0, 2317, 2318, 5, 124, 0, 0, 2318, 2344, 6, 102, -1, 0, 2319, 2320, 5, 69, 0, 0, 2320, 2344, 6, 102, -1, 0, 2321, 2322, 5, 68, 0, 0, 2322, 2344, 6, 102, -1, 0, 2323, 2324, 5, 64, 0, 0, 2324, 2344, 6, 102, -1, 0, 2325, 2326, 5, 65, 0, 0, 2326, 2344, 6, 102, -1, 0, 2327, 2328, 5, 66, 0, 0, 2328, 2344, 6, 102, -1, 0, 2329, 2330, 5, 125, 0, 0, 2330, 2344, 6, 102, -1, 0, 2331, 2332, 5, 126, 0, 0, 2332, 2344, 6, 102, -1, 0, 2333, 2334, 5, 127, 0, 0, 2334, 2344, 6, 102, -1, 0, 2335, 2336, 5, 16, 0, 0, 2336, 2344, 6, 102, -1, 0, 2337, 2338, 5, 70, 0, 0, 2338, 2339, 5, 30, 0, 0, 2339, 2340, 3, 32, 16, 0, 2340, 2341, 5, 31, 0, 0, 2341, 2342, 6, 102, -1, 0, 2342, 2344, 1, 0, 0, 0, 2343, 2309, 1, 0, 0, 0, 2343, 2311, 1, 0, 0, 0, 2343, 2313, 1, 0, 0, 0, 2343, 2315, 1, 0, 0, 0, 2343, 2317, 1, 0, 0, 0, 2343, 2319, 1, 0, 0, 0, 2343, 2321, 1, 0, 0, 0, 2343, 2323, 1, 0, 0, 0, 2343, 2325, 1, 0, 0, 0, 2343, 2327, 1, 0, 0, 0, 2343, 2329, 1, 0, 0, 0, 2343, 2331, 1, 0, 0, 0, 2343, 2333, 1, 0, 0, 0, 2343, 2335, 1, 0, 0, 0, 2343, 2337, 1, 0, 0, 0, 2344, 205, 1, 0, 0, 0, 2345, 2355, 1, 0, 0, 0, 2346, 2347, 5, 44, 0, 0, 2347, 2348, 3, 0, 0, 0, 2348, 2349, 6, 103, -1, 0, 2349, 2355, 1, 0, 0, 0, 2350, 2351, 5, 44, 0, 0, 2351, 2352, 3, 32, 16, 0, 2352, 2353, 6, 103, -1, 0, 2353, 2355, 1, 0, 0, 0, 2354, 2345, 1, 0, 0, 0, 2354, 2346, 1, 0, 0, 0, 2354, 2350, 1, 0, 0, 0, 2355, 207, 1, 0, 0, 0, 2356, 2362, 1, 0, 0, 0, 2357, 2358, 5, 36, 0, 0, 2358, 2359, 3, 306, 153, 0, 2359, 2360, 6, 104, -1, 0, 2360, 2362, 1, 0, 0, 0, 2361, 2356, 1, 0, 0, 0, 2361, 2357, 1, 0, 0, 0, 2362, 209, 1, 0, 0, 0, 2363, 2370, 1, 0, 0, 0, 2364, 2365, 5, 42, 0, 0, 2365, 2366, 3, 32, 16, 0, 2366, 2367, 5, 43, 0, 0, 2367, 2368, 6, 105, -1, 0, 2368, 2370, 1, 0, 0, 0, 2369, 2363, 1, 0, 0, 0, 2369, 2364, 1, 0, 0, 0, 2370, 211, 1, 0, 0, 0, 2371, 2377, 5, 128, 0, 0, 2372, 2373, 3, 214, 107, 0, 2373, 2374, 6, 106, -1, 0, 2374, 2376, 1, 0, 0, 0, 2375, 2372, 1, 0, 0, 0, 2376, 2379, 1, 0, 0, 0, 2377, 2375, 1, 0, 0, 0, 2377, 2378, 1, 0, 0, 0, 2378, 2380, 1, 0, 0, 0, 2379, 2377, 1, 0, 0, 0, 2380, 2381, 3, 126, 63, 0, 2381, 2382, 3, 2, 1, 0, 2382, 2383, 6, 106, -1, 0, 2383, 2397, 1, 0, 0, 0, 2384, 2390, 5, 128, 0, 0, 2385, 2386, 3, 214, 107, 0, 2386, 2387, 6, 106, -1, 0, 2387, 2389, 1, 0, 0, 0, 2388, 2385, 1, 0, 0, 0, 2389, 2392, 1, 0, 0, 0, 2390, 2388, 1, 0, 0, 0, 2390, 2391, 1, 0, 0, 0, 2391, 2393, 1, 0, 0, 0, 2392, 2390, 1, 0, 0, 0, 2393, 2394, 3, 2, 1, 0, 2394, 2395, 6, 106, -1, 0, 2395, 2397, 1, 0, 0, 0, 2396, 2371, 1, 0, 0, 0, 2396, 2384, 1, 0, 0, 0, 2397, 213, 1, 0, 0, 0, 2398, 2399, 5, 69, 0, 0, 2399, 2403, 6, 107, -1, 0, 2400, 2401, 5, 68, 0, 0, 2401, 2403, 6, 107, -1, 0, 2402, 2398, 1, 0, 0, 0, 2402, 2400, 1, 0, 0, 0, 2403, 215, 1, 0, 0, 0, 2404, 2406, 3, 218, 109, 0, 2405, 2404, 1, 0, 0, 0, 2406, 2409, 1, 0, 0, 0, 2407, 2405, 1, 0, 0, 0, 2407, 2408, 1, 0, 0, 0, 2408, 217, 1, 0, 0, 0, 2409, 2407, 1, 0, 0, 0, 2410, 2411, 5, 129, 0, 0, 2411, 2412, 3, 170, 85, 0, 2412, 2413, 6, 109, -1, 0, 2413, 2437, 1, 0, 0, 0, 2414, 2415, 5, 130, 0, 0, 2415, 2416, 3, 170, 85, 0, 2416, 2417, 6, 109, -1, 0, 2417, 2437, 1, 0, 0, 0, 2418, 2419, 5, 131, 0, 0, 2419, 2420, 3, 170, 85, 0, 2420, 2421, 6, 109, -1, 0, 2421, 2437, 1, 0, 0, 0, 2422, 2423, 5, 132, 0, 0, 2423, 2424, 3, 170, 85, 0, 2424, 2425, 6, 109, -1, 0, 2425, 2437, 1, 0, 0, 0, 2426, 2427, 3, 90, 45, 0, 2427, 2428, 6, 109, -1, 0, 2428, 2437, 1, 0, 0, 0, 2429, 2430, 3, 332, 166, 0, 2430, 2431, 6, 109, -1, 0, 2431, 2437, 1, 0, 0, 0, 2432, 2433, 3, 26, 13, 0, 2433, 2434, 6, 109, -1, 0, 2434, 2437, 1, 0, 0, 0, 2435, 2437, 3, 40, 20, 0, 2436, 2410, 1, 0, 0, 0, 2436, 2414, 1, 0, 0, 0, 2436, 2418, 1, 0, 0, 0, 2436, 2422, 1, 0, 0, 0, 2436, 2426, 1, 0, 0, 0, 2436, 2429, 1, 0, 0, 0, 2436, 2432, 1, 0, 0, 0, 2436, 2435, 1, 0, 0, 0, 2437, 219, 1, 0, 0, 0, 2438, 2444, 5, 133, 0, 0, 2439, 2440, 3, 222, 111, 0, 2440, 2441, 6, 110, -1, 0, 2441, 2443, 1, 0, 0, 0, 2442, 2439, 1, 0, 0, 0, 2443, 2446, 1, 0, 0, 0, 2444, 2442, 1, 0, 0, 0, 2444, 2445, 1, 0, 0, 0, 2445, 2447, 1, 0, 0, 0, 2446, 2444, 1, 0, 0, 0, 2447, 2448, 3, 172, 86, 0, 2448, 2449, 3, 140, 70, 0, 2449, 2450, 3, 2, 1, 0, 2450, 2451, 3, 114, 57, 0, 2451, 2452, 3, 208, 104, 0, 2452, 2453, 6, 110, -1, 0, 2453, 221, 1, 0, 0, 0, 2454, 2455, 5, 69, 0, 0, 2455, 2459, 6, 111, -1, 0, 2456, 2457, 5, 68, 0, 0, 2457, 2459, 6, 111, -1, 0, 2458, 2454, 1, 0, 0, 0, 2458, 2456, 1, 0, 0, 0, 2459, 223, 1, 0, 0, 0, 2460, 2462, 3, 226, 113, 0, 2461, 2460, 1, 0, 0, 0, 2462, 2465, 1, 0, 0, 0, 2463, 2461, 1, 0, 0, 0, 2463, 2464, 1, 0, 0, 0, 2464, 225, 1, 0, 0, 0, 2465, 2463, 1, 0, 0, 0, 2466, 2467, 5, 134, 0, 0, 2467, 2468, 3, 170, 85, 0, 2468, 2469, 6, 113, -1, 0, 2469, 2489, 1, 0, 0, 0, 2470, 2471, 5, 135, 0, 0, 2471, 2472, 3, 170, 85, 0, 2472, 2473, 6, 113, -1, 0, 2473, 2489, 1, 0, 0, 0, 2474, 2475, 5, 132, 0, 0, 2475, 2476, 3, 170, 85, 0, 2476, 2477, 6, 113, -1, 0, 2477, 2489, 1, 0, 0, 0, 2478, 2479, 3, 332, 166, 0, 2479, 2480, 6, 113, -1, 0, 2480, 2489, 1, 0, 0, 0, 2481, 2482, 3, 90, 45, 0, 2482, 2483, 6, 113, -1, 0, 2483, 2489, 1, 0, 0, 0, 2484, 2485, 3, 26, 13, 0, 2485, 2486, 6, 113, -1, 0, 2486, 2489, 1, 0, 0, 0, 2487, 2489, 3, 40, 20, 0, 2488, 2466, 1, 0, 0, 0, 2488, 2470, 1, 0, 0, 0, 2488, 2474, 1, 0, 0, 0, 2488, 2478, 1, 0, 0, 0, 2488, 2481, 1, 0, 0, 0, 2488, 2484, 1, 0, 0, 0, 2488, 2487, 1, 0, 0, 0, 2489, 227, 1, 0, 0, 0, 2490, 2498, 6, 114, -1, 0, 2491, 2492, 5, 122, 0, 0, 2492, 2493, 5, 30, 0, 0, 2493, 2494, 3, 230, 115, 0, 2494, 2495, 5, 31, 0, 0, 2495, 2496, 6, 114, -1, 0, 2496, 2498, 1, 0, 0, 0, 2497, 2490, 1, 0, 0, 0, 2497, 2491, 1, 0, 0, 0, 2498, 229, 1, 0, 0, 0, 2499, 2500, 3, 128, 64, 0, 2500, 2501, 6, 115, -1, 0, 2501, 2513, 1, 0, 0, 0, 2502, 2506, 5, 17, 0, 0, 2503, 2504, 3, 304, 152, 0, 2504, 2505, 6, 115, -1, 0, 2505, 2507, 1, 0, 0, 0, 2506, 2503, 1, 0, 0, 0, 2507, 2508, 1, 0, 0, 0, 2508, 2506, 1, 0, 0, 0, 2508, 2509, 1, 0, 0, 0, 2509, 2510, 1, 0, 0, 0, 2510, 2511, 5, 18, 0, 0, 2511, 2513, 1, 0, 0, 0, 2512, 2499, 1, 0, 0, 0, 2512, 2502, 1, 0, 0, 0, 2513, 231, 1, 0, 0, 0, 2514, 2515, 3, 234, 117, 0, 2515, 2516, 6, 116, -1, 0, 2516, 2518, 1, 0, 0, 0, 2517, 2514, 1, 0, 0, 0, 2518, 2521, 1, 0, 0, 0, 2519, 2517, 1, 0, 0, 0, 2519, 2520, 1, 0, 0, 0, 2520, 233, 1, 0, 0, 0, 2521, 2519, 1, 0, 0, 0, 2522, 2523, 5, 42, 0, 0, 2523, 2524, 5, 136, 0, 0, 2524, 2525, 5, 43, 0, 0, 2525, 2540, 6, 117, -1, 0, 2526, 2527, 5, 42, 0, 0, 2527, 2528, 5, 137, 0, 0, 2528, 2529, 5, 43, 0, 0, 2529, 2540, 6, 117, -1, 0, 2530, 2531, 5, 42, 0, 0, 2531, 2532, 5, 138, 0, 0, 2532, 2533, 5, 43, 0, 0, 2533, 2540, 6, 117, -1, 0, 2534, 2535, 5, 42, 0, 0, 2535, 2536, 3, 32, 16, 0, 2536, 2537, 5, 43, 0, 0, 2537, 2538, 6, 117, -1, 0, 2538, 2540, 1, 0, 0, 0, 2539, 2522, 1, 0, 0, 0, 2539, 2526, 1, 0, 0, 0, 2539, 2530, 1, 0, 0, 0, 2539, 2534, 1, 0, 0, 0, 2540, 235, 1, 0, 0, 0, 2541, 2550, 5, 139, 0, 0, 2542, 2543, 3, 238, 119, 0, 2543, 2544, 6, 118, -1, 0, 2544, 2549, 1, 0, 0, 0, 2545, 2546, 3, 240, 120, 0, 2546, 2547, 6, 118, -1, 0, 2547, 2549, 1, 0, 0, 0, 2548, 2542, 1, 0, 0, 0, 2548, 2545, 1, 0, 0, 0, 2549, 2552, 1, 0, 0, 0, 2550, 2548, 1, 0, 0, 0, 2550, 2551, 1, 0, 0, 0, 2551, 2553, 1, 0, 0, 0, 2552, 2550, 1, 0, 0, 0, 2553, 2554, 3, 172, 86, 0, 2554, 2555, 3, 232, 116, 0, 2555, 2556, 3, 140, 70, 0, 2556, 2557, 3, 228, 114, 0, 2557, 2558, 3, 244, 122, 0, 2558, 2559, 3, 184, 92, 0, 2559, 2565, 3, 114, 57, 0, 2560, 2561, 3, 246, 123, 0, 2561, 2562, 6, 118, -1, 0, 2562, 2564, 1, 0, 0, 0, 2563, 2560, 1, 0, 0, 0, 2564, 2567, 1, 0, 0, 0, 2565, 2563, 1, 0, 0, 0, 2565, 2566, 1, 0, 0, 0, 2566, 2568, 1, 0, 0, 0, 2567, 2565, 1, 0, 0, 0, 2568, 2569, 6, 118, -1, 0, 2569, 237, 1, 0, 0, 0, 2570, 2571, 5, 123, 0, 0, 2571, 2613, 6, 119, -1, 0, 2572, 2573, 5, 51, 0, 0, 2573, 2613, 6, 119, -1, 0, 2574, 2575, 5, 52, 0, 0, 2575, 2613, 6, 119, -1, 0, 2576, 2577, 5, 63, 0, 0, 2577, 2613, 6, 119, -1, 0, 2578, 2579, 5, 140, 0, 0, 2579, 2613, 6, 119, -1, 0, 2580, 2581, 5, 68, 0, 0, 2581, 2613, 6, 119, -1, 0, 2582, 2583, 5, 141, 0, 0, 2583, 2613, 6, 119, -1, 0, 2584, 2585, 5, 142, 0, 0, 2585, 2613, 6, 119, -1, 0, 2586, 2587, 5, 54, 0, 0, 2587, 2613, 6, 119, -1, 0, 2588, 2589, 5, 64, 0, 0, 2589, 2613, 6, 119, -1, 0, 2590, 2591, 5, 65, 0, 0, 2591, 2613, 6, 119, -1, 0, 2592, 2593, 5, 66, 0, 0, 2593, 2613, 6, 119, -1, 0, 2594, 2595, 5, 125, 0, 0, 2595, 2613, 6, 119, -1, 0, 2596, 2597, 5, 143, 0, 0, 2597, 2613, 6, 119, -1, 0, 2598, 2599, 5, 144, 0, 0, 2599, 2613, 6, 119, -1, 0, 2600, 2601, 5, 69, 0, 0, 2601, 2613, 6, 119, -1, 0, 2602, 2603, 5, 145, 0, 0, 2603, 2613, 6, 119, -1, 0, 2604, 2605, 5, 146, 0, 0, 2605, 2613, 6, 119, -1, 0, 2606, 2607, 5, 70, 0, 0, 2607, 2608, 5, 30, 0, 0, 2608, 2609, 3, 32, 16, 0, 2609, 2610, 5, 31, 0, 0, 2610, 2611, 6, 119, -1, 0, 2611, 2613, 1, 0, 0, 0, 2612, 2570, 1, 0, 0, 0, 2612, 2572, 1, 0, 0, 0, 2612, 2574, 1, 0, 0, 0, 2612, 2576, 1, 0, 0, 0, 2612, 2578, 1, 0, 0, 0, 2612, 2580, 1, 0, 0, 0, 2612, 2582, 1, 0, 0, 0, 2612, 2584, 1, 0, 0, 0, 2612, 2586, 1, 0, 0, 0, 2612, 2588, 1, 0, 0, 0, 2612, 2590, 1, 0, 0, 0, 2612, 2592, 1, 0, 0, 0, 2612, 2594, 1, 0, 0, 0, 2612, 2596, 1, 0, 0, 0, 2612, 2598, 1, 0, 0, 0, 2612, 2600, 1, 0, 0, 0, 2612, 2602, 1, 0, 0, 0, 2612, 2604, 1, 0, 0, 0, 2612, 2606, 1, 0, 0, 0, 2613, 239, 1, 0, 0, 0, 2614, 2615, 5, 147, 0, 0, 2615, 2624, 5, 30, 0, 0, 2616, 2617, 3, 6, 3, 0, 2617, 2622, 6, 120, -1, 0, 2618, 2619, 5, 34, 0, 0, 2619, 2620, 3, 6, 3, 0, 2620, 2621, 6, 120, -1, 0, 2621, 2623, 1, 0, 0, 0, 2622, 2618, 1, 0, 0, 0, 2622, 2623, 1, 0, 0, 0, 2623, 2625, 1, 0, 0, 0, 2624, 2616, 1, 0, 0, 0, 2624, 2625, 1, 0, 0, 0, 2625, 2631, 1, 0, 0, 0, 2626, 2627, 3, 242, 121, 0, 2627, 2628, 6, 120, -1, 0, 2628, 2630, 1, 0, 0, 0, 2629, 2626, 1, 0, 0, 0, 2630, 2633, 1, 0, 0, 0, 2631, 2629, 1, 0, 0, 0, 2631, 2632, 1, 0, 0, 0, 2632, 2634, 1, 0, 0, 0, 2633, 2631, 1, 0, 0, 0, 2634, 2638, 5, 31, 0, 0, 2635, 2636, 5, 147, 0, 0, 2636, 2638, 5, 85, 0, 0, 2637, 2614, 1, 0, 0, 0, 2637, 2635, 1, 0, 0, 0, 2638, 241, 1, 0, 0, 0, 2639, 2640, 5, 148, 0, 0, 2640, 2682, 6, 121, -1, 0, 2641, 2642, 5, 224, 0, 0, 2642, 2682, 6, 121, -1, 0, 2643, 2644, 5, 57, 0, 0, 2644, 2682, 6, 121, -1, 0, 2645, 2646, 5, 58, 0, 0, 2646, 2682, 6, 121, -1, 0, 2647, 2648, 5, 149, 0, 0, 2648, 2682, 6, 121, -1, 0, 2649, 2650, 5, 150, 0, 0, 2650, 2682, 6, 121, -1, 0, 2651, 2652, 5, 248, 0, 0, 2652, 2682, 6, 121, -1, 0, 2653, 2654, 5, 249, 0, 0, 2654, 2682, 6, 121, -1, 0, 2655, 2656, 5, 250, 0, 0, 2656, 2682, 6, 121, -1, 0, 2657, 2658, 5, 251, 0, 0, 2658, 2682, 6, 121, -1, 0, 2659, 2660, 5, 151, 0, 0, 2660, 2661, 5, 75, 0, 0, 2661, 2662, 5, 152, 0, 0, 2662, 2682, 6, 121, -1, 0, 2663, 2664, 5, 151, 0, 0, 2664, 2665, 5, 75, 0, 0, 2665, 2666, 5, 153, 0, 0, 2666, 2682, 6, 121, -1, 0, 2667, 2668, 5, 154, 0, 0, 2668, 2669, 5, 75, 0, 0, 2669, 2670, 5, 152, 0, 0, 2670, 2682, 6, 121, -1, 0, 2671, 2672, 5, 154, 0, 0, 2672, 2673, 5, 75, 0, 0, 2673, 2674, 5, 153, 0, 0, 2674, 2682, 6, 121, -1, 0, 2675, 2676, 5, 70, 0, 0, 2676, 2677, 5, 30, 0, 0, 2677, 2678, 3, 32, 16, 0, 2678, 2679, 5, 31, 0, 0, 2679, 2680, 6, 121, -1, 0, 2680, 2682, 1, 0, 0, 0, 2681, 2639, 1, 0, 0, 0, 2681, 2641, 1, 0, 0, 0, 2681, 2643, 1, 0, 0, 0, 2681, 2645, 1, 0, 0, 0, 2681, 2647, 1, 0, 0, 0, 2681, 2649, 1, 0, 0, 0, 2681, 2651, 1, 0, 0, 0, 2681, 2653, 1, 0, 0, 0, 2681, 2655, 1, 0, 0, 0, 2681, 2657, 1, 0, 0, 0, 2681, 2659, 1, 0, 0, 0, 2681, 2663, 1, 0, 0, 0, 2681, 2667, 1, 0, 0, 0, 2681, 2671, 1, 0, 0, 0, 2681, 2675, 1, 0, 0, 0, 2682, 243, 1, 0, 0, 0, 2683, 2684, 5, 116, 0, 0, 2684, 2691, 6, 122, -1, 0, 2685, 2686, 5, 155, 0, 0, 2686, 2691, 6, 122, -1, 0, 2687, 2688, 3, 2, 1, 0, 2688, 2689, 6, 122, -1, 0, 2689, 2691, 1, 0, 0, 0, 2690, 2683, 1, 0, 0, 0, 2690, 2685, 1, 0, 0, 0, 2690, 2687, 1, 0, 0, 0, 2691, 245, 1, 0, 0, 0, 2692, 2693, 5, 1, 0, 0, 2693, 2731, 6, 123, -1, 0, 2694, 2695, 5, 2, 0, 0, 2695, 2731, 6, 123, -1, 0, 2696, 2697, 5, 156, 0, 0, 2697, 2731, 6, 123, -1, 0, 2698, 2699, 5, 3, 0, 0, 2699, 2731, 6, 123, -1, 0, 2700, 2701, 5, 4, 0, 0, 2701, 2731, 6, 123, -1, 0, 2702, 2703, 5, 247, 0, 0, 2703, 2731, 6, 123, -1, 0, 2704, 2705, 5, 5, 0, 0, 2705, 2731, 6, 123, -1, 0, 2706, 2707, 5, 6, 0, 0, 2707, 2731, 6, 123, -1, 0, 2708, 2709, 5, 7, 0, 0, 2709, 2731, 6, 123, -1, 0, 2710, 2711, 5, 8, 0, 0, 2711, 2731, 6, 123, -1, 0, 2712, 2713, 5, 9, 0, 0, 2713, 2731, 6, 123, -1, 0, 2714, 2715, 5, 10, 0, 0, 2715, 2731, 6, 123, -1, 0, 2716, 2717, 5, 11, 0, 0, 2717, 2731, 6, 123, -1, 0, 2718, 2719, 5, 12, 0, 0, 2719, 2731, 6, 123, -1, 0, 2720, 2721, 5, 13, 0, 0, 2721, 2731, 6, 123, -1, 0, 2722, 2723, 5, 14, 0, 0, 2723, 2731, 6, 123, -1, 0, 2724, 2725, 5, 70, 0, 0, 2725, 2726, 5, 30, 0, 0, 2726, 2727, 3, 32, 16, 0, 2727, 2728, 5, 31, 0, 0, 2728, 2729, 6, 123, -1, 0, 2729, 2731, 1, 0, 0, 0, 2730, 2692, 1, 0, 0, 0, 2730, 2694, 1, 0, 0, 0, 2730, 2696, 1, 0, 0, 0, 2730, 2698, 1, 0, 0, 0, 2730, 2700, 1, 0, 0, 0, 2730, 2702, 1, 0, 0, 0, 2730, 2704, 1, 0, 0, 0, 2730, 2706, 1, 0, 0, 0, 2730, 2708, 1, 0, 0, 0, 2730, 2710, 1, 0, 0, 0, 2730, 2712, 1, 0, 0, 0, 2730, 2714, 1, 0, 0, 0, 2730, 2716, 1, 0, 0, 0, 2730, 2718, 1, 0, 0, 0, 2730, 2720, 1, 0, 0, 0, 2730, 2722, 1, 0, 0, 0, 2730, 2724, 1, 0, 0, 0, 2731, 247, 1, 0, 0, 0, 2732, 2734, 3, 250, 125, 0, 2733, 2732, 1, 0, 0, 0, 2734, 2737, 1, 0, 0, 0, 2735, 2733, 1, 0, 0, 0, 2735, 2736, 1, 0, 0, 0, 2736, 249, 1, 0, 0, 0, 2737, 2735, 1, 0, 0, 0, 2738, 2776, 3, 102, 51, 0, 2739, 2740, 5, 296, 0, 0, 2740, 2741, 3, 32, 16, 0, 2741, 2742, 6, 125, -1, 0, 2742, 2776, 1, 0, 0, 0, 2743, 2776, 3, 268, 134, 0, 2744, 2745, 5, 297, 0, 0, 2745, 2746, 3, 32, 16, 0, 2746, 2747, 6, 125, -1, 0, 2747, 2776, 1, 0, 0, 0, 2748, 2749, 5, 298, 0, 0, 2749, 2776, 6, 125, -1, 0, 2750, 2751, 5, 299, 0, 0, 2751, 2776, 6, 125, -1, 0, 2752, 2776, 3, 262, 131, 0, 2753, 2776, 3, 266, 133, 0, 2754, 2776, 3, 252, 126, 0, 2755, 2756, 3, 286, 143, 0, 2756, 2757, 6, 125, -1, 0, 2757, 2776, 1, 0, 0, 0, 2758, 2759, 3, 154, 77, 0, 2759, 2760, 6, 125, -1, 0, 2760, 2776, 1, 0, 0, 0, 2761, 2762, 3, 90, 45, 0, 2762, 2763, 6, 125, -1, 0, 2763, 2776, 1, 0, 0, 0, 2764, 2765, 3, 26, 13, 0, 2765, 2766, 6, 125, -1, 0, 2766, 2776, 1, 0, 0, 0, 2767, 2768, 3, 264, 132, 0, 2768, 2769, 6, 125, -1, 0, 2769, 2776, 1, 0, 0, 0, 2770, 2776, 3, 40, 20, 0, 2771, 2776, 3, 254, 127, 0, 2772, 2776, 3, 256, 128, 0, 2773, 2776, 3, 258, 129, 0, 2774, 2776, 3, 260, 130, 0, 2775, 2738, 1, 0, 0, 0, 2775, 2739, 1, 0, 0, 0, 2775, 2743, 1, 0, 0, 0, 2775, 2744, 1, 0, 0, 0, 2775, 2748, 1, 0, 0, 0, 2775, 2750, 1, 0, 0, 0, 2775, 2752, 1, 0, 0, 0, 2775, 2753, 1, 0, 0, 0, 2775, 2754, 1, 0, 0, 0, 2775, 2755, 1, 0, 0, 0, 2775, 2758, 1, 0, 0, 0, 2775, 2761, 1, 0, 0, 0, 2775, 2764, 1, 0, 0, 0, 2775, 2767, 1, 0, 0, 0, 2775, 2770, 1, 0, 0, 0, 2775, 2771, 1, 0, 0, 0, 2775, 2772, 1, 0, 0, 0, 2775, 2773, 1, 0, 0, 0, 2775, 2774, 1, 0, 0, 0, 2776, 251, 1, 0, 0, 0, 2777, 2779, 5, 300, 0, 0, 2778, 2780, 5, 157, 0, 0, 2779, 2778, 1, 0, 0, 0, 2779, 2780, 1, 0, 0, 0, 2780, 2781, 1, 0, 0, 0, 2781, 2782, 3, 114, 57, 0, 2782, 253, 1, 0, 0, 0, 2783, 2784, 5, 301, 0, 0, 2784, 2785, 5, 42, 0, 0, 2785, 2786, 3, 32, 16, 0, 2786, 2789, 5, 43, 0, 0, 2787, 2788, 5, 34, 0, 0, 2788, 2790, 3, 0, 0, 0, 2789, 2787, 1, 0, 0, 0, 2789, 2790, 1, 0, 0, 0, 2790, 255, 1, 0, 0, 0, 2791, 2792, 5, 303, 0, 0, 2792, 2793, 3, 32, 16, 0, 2793, 2794, 5, 75, 0, 0, 2794, 2795, 3, 32, 16, 0, 2795, 257, 1, 0, 0, 0, 2796, 2797, 5, 302, 0, 0, 2797, 2798, 3, 126, 63, 0, 2798, 2799, 5, 176, 0, 0, 2799, 2800, 3, 244, 122, 0, 2800, 2812, 1, 0, 0, 0, 2801, 2802, 5, 302, 0, 0, 2802, 2803, 5, 226, 0, 0, 2803, 2804, 3, 172, 86, 0, 2804, 2805, 3, 140, 70, 0, 2805, 2806, 3, 126, 63, 0, 2806, 2807, 5, 176, 0, 0, 2807, 2808, 3, 244, 122, 0, 2808, 2809, 3, 196, 98, 0, 2809, 2810, 3, 114, 57, 0, 2810, 2812, 1, 0, 0, 0, 2811, 2796, 1, 0, 0, 0, 2811, 2801, 1, 0, 0, 0, 2812, 259, 1, 0, 0, 0, 2813, 2814, 5, 255, 0, 0, 2814, 2815, 5, 196, 0, 0, 2815, 2816, 5, 42, 0, 0, 2816, 2817, 3, 32, 16, 0, 2817, 2823, 5, 43, 0, 0, 2818, 2819, 3, 332, 166, 0, 2819, 2820, 6, 130, -1, 0, 2820, 2822, 1, 0, 0, 0, 2821, 2818, 1, 0, 0, 0, 2822, 2825, 1, 0, 0, 0, 2823, 2821, 1, 0, 0, 0, 2823, 2824, 1, 0, 0, 0, 2824, 2879, 1, 0, 0, 0, 2825, 2823, 1, 0, 0, 0, 2826, 2827, 5, 255, 0, 0, 2827, 2828, 5, 196, 0, 0, 2828, 2834, 3, 2, 1, 0, 2829, 2830, 3, 332, 166, 0, 2830, 2831, 6, 130, -1, 0, 2831, 2833, 1, 0, 0, 0, 2832, 2829, 1, 0, 0, 0, 2833, 2836, 1, 0, 0, 0, 2834, 2832, 1, 0, 0, 0, 2834, 2835, 1, 0, 0, 0, 2835, 2879, 1, 0, 0, 0, 2836, 2834, 1, 0, 0, 0, 2837, 2838, 5, 255, 0, 0, 2838, 2839, 5, 256, 0, 0, 2839, 2840, 5, 42, 0, 0, 2840, 2841, 3, 32, 16, 0, 2841, 2842, 5, 43, 0, 0, 2842, 2843, 5, 28, 0, 0, 2843, 2849, 3, 126, 63, 0, 2844, 2845, 3, 332, 166, 0, 2845, 2846, 6, 130, -1, 0, 2846, 2848, 1, 0, 0, 0, 2847, 2844, 1, 0, 0, 0, 2848, 2851, 1, 0, 0, 0, 2849, 2847, 1, 0, 0, 0, 2849, 2850, 1, 0, 0, 0, 2850, 2879, 1, 0, 0, 0, 2851, 2849, 1, 0, 0, 0, 2852, 2853, 5, 255, 0, 0, 2853, 2854, 5, 256, 0, 0, 2854, 2855, 3, 2, 1, 0, 2855, 2856, 5, 28, 0, 0, 2856, 2862, 3, 126, 63, 0, 2857, 2858, 3, 332, 166, 0, 2858, 2859, 6, 130, -1, 0, 2859, 2861, 1, 0, 0, 0, 2860, 2857, 1, 0, 0, 0, 2861, 2864, 1, 0, 0, 0, 2862, 2860, 1, 0, 0, 0, 2862, 2863, 1, 0, 0, 0, 2863, 2879, 1, 0, 0, 0, 2864, 2862, 1, 0, 0, 0, 2865, 2866, 5, 255, 0, 0, 2866, 2867, 5, 42, 0, 0, 2867, 2868, 3, 32, 16, 0, 2868, 2869, 5, 43, 0, 0, 2869, 2875, 3, 208, 104, 0, 2870, 2871, 3, 332, 166, 0, 2871, 2872, 6, 130, -1, 0, 2872, 2874, 1, 0, 0, 0, 2873, 2870, 1, 0, 0, 0, 2874, 2877, 1, 0, 0, 0, 2875, 2873, 1, 0, 0, 0, 2875, 2876, 1, 0, 0, 0, 2876, 2879, 1, 0, 0, 0, 2877, 2875, 1, 0, 0, 0, 2878, 2813, 1, 0, 0, 0, 2878, 2826, 1, 0, 0, 0, 2878, 2837, 1, 0, 0, 0, 2878, 2852, 1, 0, 0, 0, 2878, 2865, 1, 0, 0, 0, 2879, 261, 1, 0, 0, 0, 2880, 2881, 3, 0, 0, 0, 2881, 2882, 5, 75, 0, 0, 2882, 2883, 6, 131, -1, 0, 2883, 263, 1, 0, 0, 0, 2884, 2885, 3, 44, 22, 0, 2885, 2886, 6, 132, -1, 0, 2886, 2891, 1, 0, 0, 0, 2887, 2888, 3, 46, 23, 0, 2888, 2889, 6, 132, -1, 0, 2889, 2891, 1, 0, 0, 0, 2890, 2884, 1, 0, 0, 0, 2890, 2887, 1, 0, 0, 0, 2891, 265, 1, 0, 0, 0, 2892, 2893, 5, 17, 0, 0, 2893, 2894, 3, 248, 124, 0, 2894, 2895, 5, 18, 0, 0, 2895, 267, 1, 0, 0, 0, 2896, 2897, 3, 272, 136, 0, 2897, 2898, 3, 270, 135, 0, 2898, 269, 1, 0, 0, 0, 2899, 2900, 3, 274, 137, 0, 2900, 2901, 6, 135, -1, 0, 2901, 2903, 1, 0, 0, 0, 2902, 2899, 1, 0, 0, 0, 2903, 2904, 1, 0, 0, 0, 2904, 2902, 1, 0, 0, 0, 2904, 2905, 1, 0, 0, 0, 2905, 271, 1, 0, 0, 0, 2906, 2907, 5, 158, 0, 0, 2907, 2908, 3, 266, 133, 0, 2908, 2909, 6, 136, -1, 0, 2909, 2923, 1, 0, 0, 0, 2910, 2911, 5, 158, 0, 0, 2911, 2912, 3, 0, 0, 0, 2912, 2913, 5, 159, 0, 0, 2913, 2914, 3, 0, 0, 0, 2914, 2915, 6, 136, -1, 0, 2915, 2923, 1, 0, 0, 0, 2916, 2917, 5, 158, 0, 0, 2917, 2918, 3, 32, 16, 0, 2918, 2919, 5, 159, 0, 0, 2919, 2920, 3, 32, 16, 0, 2920, 2921, 6, 136, -1, 0, 2921, 2923, 1, 0, 0, 0, 2922, 2906, 1, 0, 0, 0, 2922, 2910, 1, 0, 0, 0, 2922, 2916, 1, 0, 0, 0, 2923, 273, 1, 0, 0, 0, 2924, 2925, 3, 278, 139, 0, 2925, 2926, 3, 284, 142, 0, 2926, 2927, 6, 137, -1, 0, 2927, 2941, 1, 0, 0, 0, 2928, 2929, 3, 276, 138, 0, 2929, 2930, 3, 284, 142, 0, 2930, 2931, 6, 137, -1, 0, 2931, 2941, 1, 0, 0, 0, 2932, 2933, 3, 280, 140, 0, 2933, 2934, 3, 284, 142, 0, 2934, 2935, 6, 137, -1, 0, 2935, 2941, 1, 0, 0, 0, 2936, 2937, 3, 282, 141, 0, 2937, 2938, 3, 284, 142, 0, 2938, 2939, 6, 137, -1, 0, 2939, 2941, 1, 0, 0, 0, 2940, 2924, 1, 0, 0, 0, 2940, 2928, 1, 0, 0, 0, 2940, 2932, 1, 0, 0, 0, 2940, 2936, 1, 0, 0, 0, 2941, 275, 1, 0, 0, 0, 2942, 2943, 5, 160, 0, 0, 2943, 2944, 3, 266, 133, 0, 2944, 2945, 6, 138, -1, 0, 2945, 2955, 1, 0, 0, 0, 2946, 2947, 5, 160, 0, 0, 2947, 2948, 3, 0, 0, 0, 2948, 2949, 6, 138, -1, 0, 2949, 2955, 1, 0, 0, 0, 2950, 2951, 5, 160, 0, 0, 2951, 2952, 3, 32, 16, 0, 2952, 2953, 6, 138, -1, 0, 2953, 2955, 1, 0, 0, 0, 2954, 2942, 1, 0, 0, 0, 2954, 2946, 1, 0, 0, 0, 2954, 2950, 1, 0, 0, 0, 2955, 277, 1, 0, 0, 0, 2956, 2957, 5, 161, 0, 0, 2957, 2958, 3, 126, 63, 0, 2958, 279, 1, 0, 0, 0, 2959, 2960, 5, 162, 0, 0, 2960, 281, 1, 0, 0, 0, 2961, 2962, 5, 163, 0, 0, 2962, 283, 1, 0, 0, 0, 2963, 2964, 3, 266, 133, 0, 2964, 2965, 6, 142, -1, 0, 2965, 2979, 1, 0, 0, 0, 2966, 2967, 5, 164, 0, 0, 2967, 2968, 3, 0, 0, 0, 2968, 2969, 5, 159, 0, 0, 2969, 2970, 3, 0, 0, 0, 2970, 2971, 6, 142, -1, 0, 2971, 2979, 1, 0, 0, 0, 2972, 2973, 5, 164, 0, 0, 2973, 2974, 3, 32, 16, 0, 2974, 2975, 5, 159, 0, 0, 2975, 2976, 3, 32, 16, 0, 2976, 2977, 6, 142, -1, 0, 2977, 2979, 1, 0, 0, 0, 2978, 2963, 1, 0, 0, 0, 2978, 2966, 1, 0, 0, 0, 2978, 2972, 1, 0, 0, 0, 2979, 285, 1, 0, 0, 0, 2980, 2981, 3, 288, 144, 0, 2981, 2982, 3, 292, 146, 0, 2982, 287, 1, 0, 0, 0, 2983, 2984, 5, 165, 0, 0, 2984, 2985, 3, 290, 145, 0, 2985, 2986, 3, 0, 0, 0, 2986, 2987, 5, 36, 0, 0, 2987, 2988, 6, 144, -1, 0, 2988, 2994, 1, 0, 0, 0, 2989, 2990, 5, 165, 0, 0, 2990, 2991, 3, 290, 145, 0, 2991, 2992, 6, 144, -1, 0, 2992, 2994, 1, 0, 0, 0, 2993, 2983, 1, 0, 0, 0, 2993, 2989, 1, 0, 0, 0, 2994, 289, 1, 0, 0, 0, 2995, 3001, 1, 0, 0, 0, 2996, 2997, 5, 166, 0, 0, 2997, 3001, 6, 145, -1, 0, 2998, 2999, 5, 2, 0, 0, 2999, 3001, 6, 145, -1, 0, 3000, 2995, 1, 0, 0, 0, 3000, 2996, 1, 0, 0, 0, 3000, 2998, 1, 0, 0, 0, 3001, 291, 1, 0, 0, 0, 3002, 3003, 5, 17, 0, 0, 3003, 3004, 3, 294, 147, 0, 3004, 3005, 5, 18, 0, 0, 3005, 3012, 1, 0, 0, 0, 3006, 3008, 3, 298, 149, 0, 3007, 3006, 1, 0, 0, 0, 3008, 3009, 1, 0, 0, 0, 3009, 3007, 1, 0, 0, 0, 3009, 3010, 1, 0, 0, 0, 3010, 3012, 1, 0, 0, 0, 3011, 3002, 1, 0, 0, 0, 3011, 3007, 1, 0, 0, 0, 3012, 293, 1, 0, 0, 0, 3013, 3014, 3, 298, 149, 0, 3014, 3015, 5, 28, 0, 0, 3015, 3017, 1, 0, 0, 0, 3016, 3013, 1, 0, 0, 0, 3017, 3020, 1, 0, 0, 0, 3018, 3016, 1, 0, 0, 0, 3018, 3019, 1, 0, 0, 0, 3019, 3021, 1, 0, 0, 0, 3020, 3018, 1, 0, 0, 0, 3021, 3022, 3, 298, 149, 0, 3022, 295, 1, 0, 0, 0, 3023, 3030, 1, 0, 0, 0, 3024, 3025, 5, 42, 0, 0, 3025, 3026, 3, 32, 16, 0, 3026, 3027, 5, 43, 0, 0, 3027, 3028, 6, 148, -1, 0, 3028, 3030, 1, 0, 0, 0, 3029, 3023, 1, 0, 0, 0, 3029, 3024, 1, 0, 0, 0, 3030, 297, 1, 0, 0, 0, 3031, 3032, 5, 181, 0, 0, 3032, 3033, 5, 262, 0, 0, 3033, 3034, 5, 30, 0, 0, 3034, 3035, 3, 6, 3, 0, 3035, 3036, 5, 31, 0, 0, 3036, 3037, 6, 149, -1, 0, 3037, 3080, 1, 0, 0, 0, 3038, 3039, 5, 260, 0, 0, 3039, 3040, 5, 30, 0, 0, 3040, 3041, 3, 0, 0, 0, 3041, 3042, 5, 31, 0, 0, 3042, 3043, 6, 149, -1, 0, 3043, 3080, 1, 0, 0, 0, 3044, 3045, 5, 260, 0, 0, 3045, 3046, 3, 0, 0, 0, 3046, 3047, 6, 149, -1, 0, 3047, 3080, 1, 0, 0, 0, 3048, 3049, 5, 84, 0, 0, 3049, 3050, 5, 30, 0, 0, 3050, 3051, 3, 302, 151, 0, 3051, 3052, 5, 31, 0, 0, 3052, 3053, 6, 149, -1, 0, 3053, 3080, 1, 0, 0, 0, 3054, 3055, 7, 11, 0, 0, 3055, 3056, 5, 30, 0, 0, 3056, 3057, 3, 36, 18, 0, 3057, 3058, 5, 31, 0, 0, 3058, 3059, 3, 296, 148, 0, 3059, 3060, 6, 149, -1, 0, 3060, 3080, 1, 0, 0, 0, 3061, 3062, 5, 187, 0, 0, 3062, 3063, 5, 30, 0, 0, 3063, 3064, 3, 34, 17, 0, 3064, 3065, 5, 31, 0, 0, 3065, 3066, 3, 296, 148, 0, 3066, 3067, 6, 149, -1, 0, 3067, 3080, 1, 0, 0, 0, 3068, 3069, 7, 12, 0, 0, 3069, 3070, 5, 30, 0, 0, 3070, 3071, 3, 32, 16, 0, 3071, 3072, 5, 31, 0, 0, 3072, 3073, 3, 296, 148, 0, 3073, 3074, 6, 149, -1, 0, 3074, 3080, 1, 0, 0, 0, 3075, 3076, 7, 13, 0, 0, 3076, 3077, 3, 296, 148, 0, 3077, 3078, 6, 149, -1, 0, 3078, 3080, 1, 0, 0, 0, 3079, 3031, 1, 0, 0, 0, 3079, 3038, 1, 0, 0, 0, 3079, 3044, 1, 0, 0, 0, 3079, 3048, 1, 0, 0, 0, 3079, 3054, 1, 0, 0, 0, 3079, 3061, 1, 0, 0, 0, 3079, 3068, 1, 0, 0, 0, 3079, 3075, 1, 0, 0, 0, 3080, 299, 1, 0, 0, 0, 3081, 3082, 5, 188, 0, 0, 3082, 3083, 5, 30, 0, 0, 3083, 3084, 3, 36, 18, 0, 3084, 3085, 5, 31, 0, 0, 3085, 3086, 6, 150, -1, 0, 3086, 3172, 1, 0, 0, 0, 3087, 3088, 5, 189, 0, 0, 3088, 3089, 5, 30, 0, 0, 3089, 3090, 3, 36, 18, 0, 3090, 3091, 5, 31, 0, 0, 3091, 3092, 6, 150, -1, 0, 3092, 3172, 1, 0, 0, 0, 3093, 3094, 5, 188, 0, 0, 3094, 3095, 5, 30, 0, 0, 3095, 3096, 3, 32, 16, 0, 3096, 3097, 5, 31, 0, 0, 3097, 3098, 6, 150, -1, 0, 3098, 3172, 1, 0, 0, 0, 3099, 3100, 5, 189, 0, 0, 3100, 3101, 5, 30, 0, 0, 3101, 3102, 3, 34, 17, 0, 3102, 3103, 5, 31, 0, 0, 3103, 3104, 6, 150, -1, 0, 3104, 3172, 1, 0, 0, 0, 3105, 3106, 5, 187, 0, 0, 3106, 3107, 5, 30, 0, 0, 3107, 3108, 3, 34, 17, 0, 3108, 3109, 5, 31, 0, 0, 3109, 3110, 6, 150, -1, 0, 3110, 3172, 1, 0, 0, 0, 3111, 3112, 5, 186, 0, 0, 3112, 3113, 5, 30, 0, 0, 3113, 3114, 3, 32, 16, 0, 3114, 3115, 5, 31, 0, 0, 3115, 3116, 6, 150, -1, 0, 3116, 3172, 1, 0, 0, 0, 3117, 3118, 5, 185, 0, 0, 3118, 3119, 5, 30, 0, 0, 3119, 3120, 3, 32, 16, 0, 3120, 3121, 5, 31, 0, 0, 3121, 3122, 6, 150, -1, 0, 3122, 3172, 1, 0, 0, 0, 3123, 3124, 5, 184, 0, 0, 3124, 3125, 5, 30, 0, 0, 3125, 3126, 3, 32, 16, 0, 3126, 3127, 5, 31, 0, 0, 3127, 3128, 6, 150, -1, 0, 3128, 3172, 1, 0, 0, 0, 3129, 3130, 5, 193, 0, 0, 3130, 3131, 5, 30, 0, 0, 3131, 3132, 3, 34, 17, 0, 3132, 3133, 5, 31, 0, 0, 3133, 3134, 6, 150, -1, 0, 3134, 3172, 1, 0, 0, 0, 3135, 3136, 5, 192, 0, 0, 3136, 3137, 5, 30, 0, 0, 3137, 3138, 3, 32, 16, 0, 3138, 3139, 5, 31, 0, 0, 3139, 3140, 6, 150, -1, 0, 3140, 3172, 1, 0, 0, 0, 3141, 3142, 5, 191, 0, 0, 3142, 3143, 5, 30, 0, 0, 3143, 3144, 3, 32, 16, 0, 3144, 3145, 5, 31, 0, 0, 3145, 3146, 6, 150, -1, 0, 3146, 3172, 1, 0, 0, 0, 3147, 3148, 5, 190, 0, 0, 3148, 3149, 5, 30, 0, 0, 3149, 3150, 3, 32, 16, 0, 3150, 3151, 5, 31, 0, 0, 3151, 3152, 6, 150, -1, 0, 3152, 3172, 1, 0, 0, 0, 3153, 3154, 5, 181, 0, 0, 3154, 3155, 5, 30, 0, 0, 3155, 3156, 3, 32, 16, 0, 3156, 3157, 5, 31, 0, 0, 3157, 3158, 6, 150, -1, 0, 3158, 3172, 1, 0, 0, 0, 3159, 3160, 5, 183, 0, 0, 3160, 3161, 5, 30, 0, 0, 3161, 3162, 3, 164, 82, 0, 3162, 3163, 5, 31, 0, 0, 3163, 3164, 6, 150, -1, 0, 3164, 3172, 1, 0, 0, 0, 3165, 3166, 5, 84, 0, 0, 3166, 3167, 5, 30, 0, 0, 3167, 3168, 3, 302, 151, 0, 3168, 3169, 5, 31, 0, 0, 3169, 3170, 6, 150, -1, 0, 3170, 3172, 1, 0, 0, 0, 3171, 3081, 1, 0, 0, 0, 3171, 3087, 1, 0, 0, 0, 3171, 3093, 1, 0, 0, 0, 3171, 3099, 1, 0, 0, 0, 3171, 3105, 1, 0, 0, 0, 3171, 3111, 1, 0, 0, 0, 3171, 3117, 1, 0, 0, 0, 3171, 3123, 1, 0, 0, 0, 3171, 3129, 1, 0, 0, 0, 3171, 3135, 1, 0, 0, 0, 3171, 3141, 1, 0, 0, 0, 3171, 3147, 1, 0, 0, 0, 3171, 3153, 1, 0, 0, 0, 3171, 3159, 1, 0, 0, 0, 3171, 3165, 1, 0, 0, 0, 3172, 301, 1, 0, 0, 0, 3173, 3174, 3, 304, 152, 0, 3174, 3175, 6, 151, -1, 0, 3175, 3177, 1, 0, 0, 0, 3176, 3173, 1, 0, 0, 0, 3177, 3180, 1, 0, 0, 0, 3178, 3176, 1, 0, 0, 0, 3178, 3179, 1, 0, 0, 0, 3179, 303, 1, 0, 0, 0, 3180, 3178, 1, 0, 0, 0, 3181, 3182, 7, 14, 0, 0, 3182, 305, 1, 0, 0, 0, 3183, 3184, 3, 300, 150, 0, 3184, 3185, 6, 153, -1, 0, 3185, 3192, 1, 0, 0, 0, 3186, 3187, 3, 6, 3, 0, 3187, 3188, 6, 153, -1, 0, 3188, 3192, 1, 0, 0, 0, 3189, 3190, 5, 179, 0, 0, 3190, 3192, 6, 153, -1, 0, 3191, 3183, 1, 0, 0, 0, 3191, 3186, 1, 0, 0, 0, 3191, 3189, 1, 0, 0, 0, 3192, 307, 1, 0, 0, 0, 3193, 3194, 3, 300, 150, 0, 3194, 3195, 6, 154, -1, 0, 3195, 3365, 1, 0, 0, 0, 3196, 3197, 5, 182, 0, 0, 3197, 3198, 5, 30, 0, 0, 3198, 3199, 5, 179, 0, 0, 3199, 3200, 5, 31, 0, 0, 3200, 3365, 6, 154, -1, 0, 3201, 3202, 5, 182, 0, 0, 3202, 3203, 5, 30, 0, 0, 3203, 3204, 5, 264, 0, 0, 3204, 3205, 5, 31, 0, 0, 3205, 3365, 6, 154, -1, 0, 3206, 3207, 5, 196, 0, 0, 3207, 3208, 5, 30, 0, 0, 3208, 3209, 5, 39, 0, 0, 3209, 3210, 5, 264, 0, 0, 3210, 3211, 5, 31, 0, 0, 3211, 3365, 6, 154, -1, 0, 3212, 3213, 5, 196, 0, 0, 3213, 3214, 5, 30, 0, 0, 3214, 3215, 3, 118, 59, 0, 3215, 3216, 5, 31, 0, 0, 3216, 3217, 6, 154, -1, 0, 3217, 3365, 1, 0, 0, 0, 3218, 3219, 5, 196, 0, 0, 3219, 3220, 5, 30, 0, 0, 3220, 3221, 5, 179, 0, 0, 3221, 3222, 5, 31, 0, 0, 3222, 3365, 6, 154, -1, 0, 3223, 3224, 5, 197, 0, 0, 3224, 3225, 5, 30, 0, 0, 3225, 3226, 3, 308, 154, 0, 3226, 3227, 5, 31, 0, 0, 3227, 3228, 6, 154, -1, 0, 3228, 3365, 1, 0, 0, 0, 3229, 3230, 5, 188, 0, 0, 3230, 3231, 5, 42, 0, 0, 3231, 3232, 3, 32, 16, 0, 3232, 3233, 5, 43, 0, 0, 3233, 3234, 5, 30, 0, 0, 3234, 3235, 3, 310, 155, 0, 3235, 3236, 5, 31, 0, 0, 3236, 3237, 6, 154, -1, 0, 3237, 3365, 1, 0, 0, 0, 3238, 3239, 5, 189, 0, 0, 3239, 3240, 5, 42, 0, 0, 3240, 3241, 3, 32, 16, 0, 3241, 3242, 5, 43, 0, 0, 3242, 3243, 5, 30, 0, 0, 3243, 3244, 3, 312, 156, 0, 3244, 3245, 5, 31, 0, 0, 3245, 3246, 6, 154, -1, 0, 3246, 3365, 1, 0, 0, 0, 3247, 3248, 5, 187, 0, 0, 3248, 3249, 5, 42, 0, 0, 3249, 3250, 3, 32, 16, 0, 3250, 3251, 5, 43, 0, 0, 3251, 3252, 5, 30, 0, 0, 3252, 3253, 3, 314, 157, 0, 3253, 3254, 5, 31, 0, 0, 3254, 3255, 6, 154, -1, 0, 3255, 3365, 1, 0, 0, 0, 3256, 3257, 5, 186, 0, 0, 3257, 3258, 5, 42, 0, 0, 3258, 3259, 3, 32, 16, 0, 3259, 3260, 5, 43, 0, 0, 3260, 3261, 5, 30, 0, 0, 3261, 3262, 3, 316, 158, 0, 3262, 3263, 5, 31, 0, 0, 3263, 3264, 6, 154, -1, 0, 3264, 3365, 1, 0, 0, 0, 3265, 3266, 5, 185, 0, 0, 3266, 3267, 5, 42, 0, 0, 3267, 3268, 3, 32, 16, 0, 3268, 3269, 5, 43, 0, 0, 3269, 3270, 5, 30, 0, 0, 3270, 3271, 3, 318, 159, 0, 3271, 3272, 5, 31, 0, 0, 3272, 3273, 6, 154, -1, 0, 3273, 3365, 1, 0, 0, 0, 3274, 3275, 5, 184, 0, 0, 3275, 3276, 5, 42, 0, 0, 3276, 3277, 3, 32, 16, 0, 3277, 3278, 5, 43, 0, 0, 3278, 3279, 5, 30, 0, 0, 3279, 3280, 3, 320, 160, 0, 3280, 3281, 5, 31, 0, 0, 3281, 3282, 6, 154, -1, 0, 3282, 3365, 1, 0, 0, 0, 3283, 3284, 5, 193, 0, 0, 3284, 3285, 5, 42, 0, 0, 3285, 3286, 3, 32, 16, 0, 3286, 3287, 5, 43, 0, 0, 3287, 3288, 5, 30, 0, 0, 3288, 3289, 3, 314, 157, 0, 3289, 3290, 5, 31, 0, 0, 3290, 3291, 6, 154, -1, 0, 3291, 3365, 1, 0, 0, 0, 3292, 3293, 5, 192, 0, 0, 3293, 3294, 5, 42, 0, 0, 3294, 3295, 3, 32, 16, 0, 3295, 3296, 5, 43, 0, 0, 3296, 3297, 5, 30, 0, 0, 3297, 3298, 3, 316, 158, 0, 3298, 3299, 5, 31, 0, 0, 3299, 3300, 6, 154, -1, 0, 3300, 3365, 1, 0, 0, 0, 3301, 3302, 5, 191, 0, 0, 3302, 3303, 5, 42, 0, 0, 3303, 3304, 3, 32, 16, 0, 3304, 3305, 5, 43, 0, 0, 3305, 3306, 5, 30, 0, 0, 3306, 3307, 3, 318, 159, 0, 3307, 3308, 5, 31, 0, 0, 3308, 3309, 6, 154, -1, 0, 3309, 3365, 1, 0, 0, 0, 3310, 3311, 5, 190, 0, 0, 3311, 3312, 5, 42, 0, 0, 3312, 3313, 3, 32, 16, 0, 3313, 3314, 5, 43, 0, 0, 3314, 3315, 5, 30, 0, 0, 3315, 3316, 3, 320, 160, 0, 3316, 3317, 5, 31, 0, 0, 3317, 3318, 6, 154, -1, 0, 3318, 3365, 1, 0, 0, 0, 3319, 3320, 5, 181, 0, 0, 3320, 3321, 5, 42, 0, 0, 3321, 3322, 3, 32, 16, 0, 3322, 3323, 5, 43, 0, 0, 3323, 3324, 5, 30, 0, 0, 3324, 3325, 3, 318, 159, 0, 3325, 3326, 5, 31, 0, 0, 3326, 3327, 6, 154, -1, 0, 3327, 3365, 1, 0, 0, 0, 3328, 3329, 5, 183, 0, 0, 3329, 3330, 5, 42, 0, 0, 3330, 3331, 3, 32, 16, 0, 3331, 3332, 5, 43, 0, 0, 3332, 3333, 5, 30, 0, 0, 3333, 3334, 3, 322, 161, 0, 3334, 3335, 5, 31, 0, 0, 3335, 3336, 6, 154, -1, 0, 3336, 3365, 1, 0, 0, 0, 3337, 3338, 5, 182, 0, 0, 3338, 3339, 5, 42, 0, 0, 3339, 3340, 3, 32, 16, 0, 3340, 3341, 5, 43, 0, 0, 3341, 3342, 5, 30, 0, 0, 3342, 3343, 3, 324, 162, 0, 3343, 3344, 5, 31, 0, 0, 3344, 3345, 6, 154, -1, 0, 3345, 3365, 1, 0, 0, 0, 3346, 3347, 5, 196, 0, 0, 3347, 3348, 5, 42, 0, 0, 3348, 3349, 3, 32, 16, 0, 3349, 3350, 5, 43, 0, 0, 3350, 3351, 5, 30, 0, 0, 3351, 3352, 3, 326, 163, 0, 3352, 3353, 5, 31, 0, 0, 3353, 3354, 6, 154, -1, 0, 3354, 3365, 1, 0, 0, 0, 3355, 3356, 5, 197, 0, 0, 3356, 3357, 5, 42, 0, 0, 3357, 3358, 3, 32, 16, 0, 3358, 3359, 5, 43, 0, 0, 3359, 3360, 5, 30, 0, 0, 3360, 3361, 3, 330, 165, 0, 3361, 3362, 5, 31, 0, 0, 3362, 3363, 6, 154, -1, 0, 3363, 3365, 1, 0, 0, 0, 3364, 3193, 1, 0, 0, 0, 3364, 3196, 1, 0, 0, 0, 3364, 3201, 1, 0, 0, 0, 3364, 3206, 1, 0, 0, 0, 3364, 3212, 1, 0, 0, 0, 3364, 3218, 1, 0, 0, 0, 3364, 3223, 1, 0, 0, 0, 3364, 3229, 1, 0, 0, 0, 3364, 3238, 1, 0, 0, 0, 3364, 3247, 1, 0, 0, 0, 3364, 3256, 1, 0, 0, 0, 3364, 3265, 1, 0, 0, 0, 3364, 3274, 1, 0, 0, 0, 3364, 3283, 1, 0, 0, 0, 3364, 3292, 1, 0, 0, 0, 3364, 3301, 1, 0, 0, 0, 3364, 3310, 1, 0, 0, 0, 3364, 3319, 1, 0, 0, 0, 3364, 3328, 1, 0, 0, 0, 3364, 3337, 1, 0, 0, 0, 3364, 3346, 1, 0, 0, 0, 3364, 3355, 1, 0, 0, 0, 3365, 309, 1, 0, 0, 0, 3366, 3367, 3, 36, 18, 0, 3367, 3368, 6, 155, -1, 0, 3368, 3373, 1, 0, 0, 0, 3369, 3370, 3, 32, 16, 0, 3370, 3371, 6, 155, -1, 0, 3371, 3373, 1, 0, 0, 0, 3372, 3366, 1, 0, 0, 0, 3372, 3369, 1, 0, 0, 0, 3373, 3376, 1, 0, 0, 0, 3374, 3372, 1, 0, 0, 0, 3374, 3375, 1, 0, 0, 0, 3375, 311, 1, 0, 0, 0, 3376, 3374, 1, 0, 0, 0, 3377, 3378, 3, 36, 18, 0, 3378, 3379, 6, 156, -1, 0, 3379, 3384, 1, 0, 0, 0, 3380, 3381, 3, 34, 17, 0, 3381, 3382, 6, 156, -1, 0, 3382, 3384, 1, 0, 0, 0, 3383, 3377, 1, 0, 0, 0, 3383, 3380, 1, 0, 0, 0, 3384, 3387, 1, 0, 0, 0, 3385, 3383, 1, 0, 0, 0, 3385, 3386, 1, 0, 0, 0, 3386, 313, 1, 0, 0, 0, 3387, 3385, 1, 0, 0, 0, 3388, 3389, 3, 34, 17, 0, 3389, 3390, 6, 157, -1, 0, 3390, 3392, 1, 0, 0, 0, 3391, 3388, 1, 0, 0, 0, 3392, 3395, 1, 0, 0, 0, 3393, 3391, 1, 0, 0, 0, 3393, 3394, 1, 0, 0, 0, 3394, 315, 1, 0, 0, 0, 3395, 3393, 1, 0, 0, 0, 3396, 3397, 3, 32, 16, 0, 3397, 3398, 6, 158, -1, 0, 3398, 3400, 1, 0, 0, 0, 3399, 3396, 1, 0, 0, 0, 3400, 3403, 1, 0, 0, 0, 3401, 3399, 1, 0, 0, 0, 3401, 3402, 1, 0, 0, 0, 3402, 317, 1, 0, 0, 0, 3403, 3401, 1, 0, 0, 0, 3404, 3405, 3, 32, 16, 0, 3405, 3406, 6, 159, -1, 0, 3406, 3408, 1, 0, 0, 0, 3407, 3404, 1, 0, 0, 0, 3408, 3411, 1, 0, 0, 0, 3409, 3407, 1, 0, 0, 0, 3409, 3410, 1, 0, 0, 0, 3410, 319, 1, 0, 0, 0, 3411, 3409, 1, 0, 0, 0, 3412, 3413, 3, 32, 16, 0, 3413, 3414, 6, 160, -1, 0, 3414, 3416, 1, 0, 0, 0, 3415, 3412, 1, 0, 0, 0, 3416, 3419, 1, 0, 0, 0, 3417, 3415, 1, 0, 0, 0, 3417, 3418, 1, 0, 0, 0, 3418, 321, 1, 0, 0, 0, 3419, 3417, 1, 0, 0, 0, 3420, 3421, 3, 164, 82, 0, 3421, 3422, 6, 161, -1, 0, 3422, 3424, 1, 0, 0, 0, 3423, 3420, 1, 0, 0, 0, 3424, 3427, 1, 0, 0, 0, 3425, 3423, 1, 0, 0, 0, 3425, 3426, 1, 0, 0, 0, 3426, 323, 1, 0, 0, 0, 3427, 3425, 1, 0, 0, 0, 3428, 3429, 5, 179, 0, 0, 3429, 3433, 6, 162, -1, 0, 3430, 3431, 5, 264, 0, 0, 3431, 3433, 6, 162, -1, 0, 3432, 3428, 1, 0, 0, 0, 3432, 3430, 1, 0, 0, 0, 3433, 3436, 1, 0, 0, 0, 3434, 3432, 1, 0, 0, 0, 3434, 3435, 1, 0, 0, 0, 3435, 325, 1, 0, 0, 0, 3436, 3434, 1, 0, 0, 0, 3437, 3438, 3, 328, 164, 0, 3438, 3439, 6, 163, -1, 0, 3439, 3441, 1, 0, 0, 0, 3440, 3437, 1, 0, 0, 0, 3441, 3444, 1, 0, 0, 0, 3442, 3440, 1, 0, 0, 0, 3442, 3443, 1, 0, 0, 0, 3443, 327, 1, 0, 0, 0, 3444, 3442, 1, 0, 0, 0, 3445, 3446, 5, 179, 0, 0, 3446, 3454, 6, 164, -1, 0, 3447, 3448, 5, 39, 0, 0, 3448, 3449, 5, 264, 0, 0, 3449, 3454, 6, 164, -1, 0, 3450, 3451, 3, 118, 59, 0, 3451, 3452, 6, 164, -1, 0, 3452, 3454, 1, 0, 0, 0, 3453, 3445, 1, 0, 0, 0, 3453, 3447, 1, 0, 0, 0, 3453, 3450, 1, 0, 0, 0, 3454, 329, 1, 0, 0, 0, 3455, 3456, 3, 308, 154, 0, 3456, 3457, 6, 165, -1, 0, 3457, 3459, 1, 0, 0, 0, 3458, 3455, 1, 0, 0, 0, 3459, 3462, 1, 0, 0, 0, 3460, 3458, 1, 0, 0, 0, 3460, 3461, 1, 0, 0, 0, 3461, 331, 1, 0, 0, 0, 3462, 3460, 1, 0, 0, 0, 3463, 3464, 3, 44, 22, 0, 3464, 3465, 6, 166, -1, 0, 3465, 3473, 1, 0, 0, 0, 3466, 3467, 3, 46, 23, 0, 3467, 3468, 6, 166, -1, 0, 3468, 3473, 1, 0, 0, 0, 3469, 3470, 3, 2, 1, 0, 3470, 3471, 6, 166, -1, 0, 3471, 3473, 1, 0, 0, 0, 3472, 3463, 1, 0, 0, 0, 3472, 3466, 1, 0, 0, 0, 3472, 3469, 1, 0, 0, 0, 3473, 333, 1, 0, 0, 0, 3474, 3475, 7, 15, 0, 0, 3475, 3476, 5, 36, 0, 0, 3476, 3477, 5, 30, 0, 0, 3477, 3478, 3, 302, 151, 0, 3478, 3479, 5, 31, 0, 0, 3479, 3480, 6, 167, -1, 0, 3480, 3507, 1, 0, 0, 0, 3481, 3482, 5, 169, 0, 0, 3482, 3483, 3, 38, 19, 0, 3483, 3484, 5, 75, 0, 0, 3484, 3485, 3, 38, 19, 0, 3485, 3486, 5, 75, 0, 0, 3486, 3487, 3, 38, 19, 0, 3487, 3488, 5, 75, 0, 0, 3488, 3489, 3, 38, 19, 0, 3489, 3490, 6, 167, -1, 0, 3490, 3507, 1, 0, 0, 0, 3491, 3492, 5, 170, 0, 0, 3492, 3493, 3, 6, 3, 0, 3493, 3494, 6, 167, -1, 0, 3494, 3507, 1, 0, 0, 0, 3495, 3496, 5, 170, 0, 0, 3496, 3497, 5, 36, 0, 0, 3497, 3498, 5, 30, 0, 0, 3498, 3499, 3, 302, 151, 0, 3499, 3500, 5, 31, 0, 0, 3500, 3501, 6, 167, -1, 0, 3501, 3507, 1, 0, 0, 0, 3502, 3503, 3, 332, 166, 0, 3503, 3504, 6, 167, -1, 0, 3504, 3507, 1, 0, 0, 0, 3505, 3507, 3, 40, 20, 0, 3506, 3474, 1, 0, 0, 0, 3506, 3481, 1, 0, 0, 0, 3506, 3491, 1, 0, 0, 0, 3506, 3495, 1, 0, 0, 0, 3506, 3502, 1, 0, 0, 0, 3506, 3505, 1, 0, 0, 0, 3507, 335, 1, 0, 0, 0, 3508, 3509, 3, 338, 169, 0, 3509, 3510, 5, 17, 0, 0, 3510, 3511, 3, 340, 170, 0, 3511, 3512, 5, 18, 0, 0, 3512, 3513, 6, 168, -1, 0, 3513, 337, 1, 0, 0, 0, 3514, 3515, 5, 25, 0, 0, 3515, 3516, 5, 40, 0, 0, 3516, 3517, 3, 100, 50, 0, 3517, 3518, 3, 2, 1, 0, 3518, 3519, 6, 169, -1, 0, 3519, 3529, 1, 0, 0, 0, 3520, 3521, 5, 25, 0, 0, 3521, 3522, 5, 40, 0, 0, 3522, 3523, 3, 100, 50, 0, 3523, 3524, 3, 2, 1, 0, 3524, 3525, 5, 34, 0, 0, 3525, 3526, 3, 2, 1, 0, 3526, 3527, 6, 169, -1, 0, 3527, 3529, 1, 0, 0, 0, 3528, 3514, 1, 0, 0, 0, 3528, 3520, 1, 0, 0, 0, 3529, 339, 1, 0, 0, 0, 3530, 3531, 3, 342, 171, 0, 3531, 3532, 6, 170, -1, 0, 3532, 3534, 1, 0, 0, 0, 3533, 3530, 1, 0, 0, 0, 3534, 3537, 1, 0, 0, 0, 3535, 3533, 1, 0, 0, 0, 3535, 3536, 1, 0, 0, 0, 3536, 341, 1, 0, 0, 0, 3537, 3535, 1, 0, 0, 0, 3538, 3539, 5, 180, 0, 0, 3539, 3540, 5, 36, 0, 0, 3540, 3541, 5, 30, 0, 0, 3541, 3542, 3, 302, 151, 0, 3542, 3543, 5, 31, 0, 0, 3543, 3544, 6, 171, -1, 0, 3544, 3558, 1, 0, 0, 0, 3545, 3546, 3, 334, 167, 0, 3546, 3547, 6, 171, -1, 0, 3547, 3558, 1, 0, 0, 0, 3548, 3549, 5, 171, 0, 0, 3549, 3550, 5, 36, 0, 0, 3550, 3551, 5, 30, 0, 0, 3551, 3552, 3, 302, 151, 0, 3552, 3553, 5, 31, 0, 0, 3553, 3554, 6, 171, -1, 0, 3554, 3558, 1, 0, 0, 0, 3555, 3556, 5, 55, 0, 0, 3556, 3558, 6, 171, -1, 0, 3557, 3538, 1, 0, 0, 0, 3557, 3545, 1, 0, 0, 0, 3557, 3548, 1, 0, 0, 0, 3557, 3555, 1, 0, 0, 0, 3558, 343, 1, 0, 0, 0, 3559, 3560, 3, 346, 173, 0, 3560, 3561, 5, 17, 0, 0, 3561, 3562, 3, 354, 177, 0, 3562, 3563, 5, 18, 0, 0, 3563, 3564, 6, 172, -1, 0, 3564, 345, 1, 0, 0, 0, 3565, 3566, 5, 50, 0, 0, 3566, 3567, 5, 40, 0, 0, 3567, 3568, 3, 350, 175, 0, 3568, 3569, 3, 2, 1, 0, 3569, 3570, 6, 173, -1, 0, 3570, 347, 1, 0, 0, 0, 3571, 3572, 5, 301, 0, 0, 3572, 3573, 3, 350, 175, 0, 3573, 3574, 3, 2, 1, 0, 3574, 3575, 6, 174, -1, 0, 3575, 349, 1, 0, 0, 0, 3576, 3577, 3, 352, 176, 0, 3577, 3578, 6, 175, -1, 0, 3578, 3580, 1, 0, 0, 0, 3579, 3576, 1, 0, 0, 0, 3580, 3583, 1, 0, 0, 0, 3581, 3579, 1, 0, 0, 0, 3581, 3582, 1, 0, 0, 0, 3582, 351, 1, 0, 0, 0, 3583, 3581, 1, 0, 0, 0, 3584, 3600, 5, 52, 0, 0, 3585, 3600, 5, 51, 0, 0, 3586, 3600, 5, 172, 0, 0, 3587, 3588, 5, 62, 0, 0, 3588, 3600, 5, 51, 0, 0, 3589, 3590, 5, 62, 0, 0, 3590, 3600, 5, 52, 0, 0, 3591, 3592, 5, 62, 0, 0, 3592, 3600, 5, 63, 0, 0, 3593, 3594, 5, 62, 0, 0, 3594, 3600, 5, 64, 0, 0, 3595, 3596, 5, 62, 0, 0, 3596, 3600, 5, 65, 0, 0, 3597, 3598, 5, 62, 0, 0, 3598, 3600, 5, 66, 0, 0, 3599, 3584, 1, 0, 0, 0, 3599, 3585, 1, 0, 0, 0, 3599, 3586, 1, 0, 0, 0, 3599, 3587, 1, 0, 0, 0, 3599, 3589, 1, 0, 0, 0, 3599, 3591, 1, 0, 0, 0, 3599, 3593, 1, 0, 0, 0, 3599, 3595, 1, 0, 0, 0, 3599, 3597, 1, 0, 0, 0, 3600, 353, 1, 0, 0, 0, 3601, 3602, 3, 356, 178, 0, 3602, 3603, 6, 177, -1, 0, 3603, 3605, 1, 0, 0, 0, 3604, 3601, 1, 0, 0, 0, 3605, 3608, 1, 0, 0, 0, 3606, 3604, 1, 0, 0, 0, 3606, 3607, 1, 0, 0, 0, 3607, 355, 1, 0, 0, 0, 3608, 3606, 1, 0, 0, 0, 3609, 3610, 5, 21, 0, 0, 3610, 3611, 3, 2, 1, 0, 3611, 3612, 6, 178, -1, 0, 3612, 3635, 1, 0, 0, 0, 3613, 3614, 5, 50, 0, 0, 3614, 3615, 5, 40, 0, 0, 3615, 3616, 3, 120, 60, 0, 3616, 3617, 6, 178, -1, 0, 3617, 3635, 1, 0, 0, 0, 3618, 3619, 5, 25, 0, 0, 3619, 3620, 5, 40, 0, 0, 3620, 3621, 3, 2, 1, 0, 3621, 3622, 6, 178, -1, 0, 3622, 3635, 1, 0, 0, 0, 3623, 3624, 3, 176, 88, 0, 3624, 3625, 6, 178, -1, 0, 3625, 3635, 1, 0, 0, 0, 3626, 3627, 5, 50, 0, 0, 3627, 3628, 3, 32, 16, 0, 3628, 3629, 6, 178, -1, 0, 3629, 3635, 1, 0, 0, 0, 3630, 3631, 3, 332, 166, 0, 3631, 3632, 6, 178, -1, 0, 3632, 3635, 1, 0, 0, 0, 3633, 3635, 3, 40, 20, 0, 3634, 3609, 1, 0, 0, 0, 3634, 3613, 1, 0, 0, 0, 3634, 3618, 1, 0, 0, 0, 3634, 3623, 1, 0, 0, 0, 3634, 3626, 1, 0, 0, 0, 3634, 3630, 1, 0, 0, 0, 3634, 3633, 1, 0, 0, 0, 3635, 357, 1, 0, 0, 0, 3636, 3637, 3, 360, 180, 0, 3637, 3638, 5, 17, 0, 0, 3638, 3639, 3, 366, 183, 0, 3639, 3640, 5, 18, 0, 0, 3640, 3641, 6, 179, -1, 0, 3641, 359, 1, 0, 0, 0, 3642, 3643, 5, 274, 0, 0, 3643, 3644, 3, 362, 181, 0, 3644, 3645, 3, 2, 1, 0, 3645, 3646, 6, 180, -1, 0, 3646, 3655, 1, 0, 0, 0, 3647, 3648, 5, 274, 0, 0, 3648, 3649, 3, 362, 181, 0, 3649, 3650, 3, 2, 1, 0, 3650, 3651, 5, 34, 0, 0, 3651, 3652, 3, 2, 1, 0, 3652, 3653, 6, 180, -1, 0, 3653, 3655, 1, 0, 0, 0, 3654, 3642, 1, 0, 0, 0, 3654, 3647, 1, 0, 0, 0, 3655, 361, 1, 0, 0, 0, 3656, 3657, 3, 364, 182, 0, 3657, 3658, 6, 181, -1, 0, 3658, 3660, 1, 0, 0, 0, 3659, 3656, 1, 0, 0, 0, 3660, 3663, 1, 0, 0, 0, 3661, 3659, 1, 0, 0, 0, 3661, 3662, 1, 0, 0, 0, 3662, 363, 1, 0, 0, 0, 3663, 3661, 1, 0, 0, 0, 3664, 3665, 7, 16, 0, 0, 3665, 365, 1, 0, 0, 0, 3666, 3667, 3, 368, 184, 0, 3667, 3668, 6, 183, -1, 0, 3668, 3670, 1, 0, 0, 0, 3669, 3666, 1, 0, 0, 0, 3670, 3673, 1, 0, 0, 0, 3671, 3669, 1, 0, 0, 0, 3671, 3672, 1, 0, 0, 0, 3672, 367, 1, 0, 0, 0, 3673, 3671, 1, 0, 0, 0, 3674, 3675, 5, 21, 0, 0, 3675, 3676, 3, 2, 1, 0, 3676, 3677, 5, 44, 0, 0, 3677, 3678, 3, 32, 16, 0, 3678, 3679, 6, 184, -1, 0, 3679, 3690, 1, 0, 0, 0, 3680, 3681, 5, 25, 0, 0, 3681, 3682, 5, 40, 0, 0, 3682, 3683, 3, 2, 1, 0, 3683, 3684, 6, 184, -1, 0, 3684, 3690, 1, 0, 0, 0, 3685, 3686, 3, 332, 166, 0, 3686, 3687, 6, 184, -1, 0, 3687, 3690, 1, 0, 0, 0, 3688, 3690, 3, 40, 20, 0, 3689, 3674, 1, 0, 0, 0, 3689, 3680, 1, 0, 0, 0, 3689, 3685, 1, 0, 0, 0, 3689, 3688, 1, 0, 0, 0, 3690, 369, 1, 0, 0, 0, 183, 380, 388, 397, 406, 495, 546, 557, 587, 594, 612, 644, 672, 712, 723, 733, 735, 746, 748, 756, 778, 791, 807, 831, 904, 911, 918, 923, 932, 943, 952, 963, 974, 987, 991, 999, 1015, 1022, 1031, 1059, 1137, 1139, 1153, 1159, 1168, 1170, 1179, 1193, 1207, 1215, 1223, 1227, 1266, 1274, 1285, 1299, 1318, 1328, 1331, 1355, 1502, 1512, 1521, 1524, 1606, 1615, 1647, 1707, 1747, 1763, 1773, 1803, 1831, 1840, 1846, 1863, 1871, 1929, 1939, 1957, 1975, 1994, 2015, 2034, 2049, 2057, 2069, 2089, 2096, 2101, 2112, 2124, 2234, 2246, 2262, 2276, 2285, 2298, 2300, 2343, 2354, 2361, 2369, 2377, 2390, 2396, 2402, 2407, 2436, 2444, 2458, 2463, 2488, 2497, 2508, 2512, 2519, 2539, 2548, 2550, 2565, 2612, 2622, 2624, 2631, 2637, 2681, 2690, 2730, 2735, 2775, 2779, 2789, 2811, 2823, 2834, 2849, 2862, 2875, 2878, 2890, 2904, 2922, 2940, 2954, 2978, 2993, 3000, 3009, 3011, 3018, 3029, 3079, 3171, 3178, 3191, 3364, 3372, 3374, 3383, 3385, 3393, 3401, 3409, 3417, 3425, 3432, 3434, 3442, 3453, 3460, 3472, 3506, 3528, 3535, 3557, 3581, 3599, 3606, 3634, 3654, 3661, 3671, 3689] \ No newline at end of file diff --git a/src/tools/ilasm/src/ILAssembler/gen/CILBaseVisitor.cs b/src/tools/ilasm/src/ILAssembler/gen/CILBaseVisitor.cs deleted file mode 100644 index c63f1eb59ad7f8..00000000000000 --- a/src/tools/ilasm/src/ILAssembler/gen/CILBaseVisitor.cs +++ /dev/null @@ -1,2012 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.13.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from CIL.g4 by ANTLR 4.13.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -namespace ILAssembler { -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using IToken = Antlr4.Runtime.IToken; -using ParserRuleContext = Antlr4.Runtime.ParserRuleContext; - -/// -/// This class provides an empty implementation of , -/// which can be extended to create a visitor which only needs to handle a subset -/// of the available methods. -/// -/// The return type of the visit operation. -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] -[System.Diagnostics.DebuggerNonUserCode] -[System.CLSCompliant(false)] -public partial class CILBaseVisitor : AbstractParseTreeVisitor, ICILVisitor { - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitId([NotNull] CILParser.IdContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDottedName([NotNull] CILParser.DottedNameContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDottedNamePart([NotNull] CILParser.DottedNamePartContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCompQstring([NotNull] CILParser.CompQstringContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDecls([NotNull] CILParser.DeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDecl([NotNull] CILParser.DeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSubsystem([NotNull] CILParser.SubsystemContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCorflags([NotNull] CILParser.CorflagsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAlignment([NotNull] CILParser.AlignmentContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitImagebase([NotNull] CILParser.ImagebaseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitStackreserve([NotNull] CILParser.StackreserveContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssemblyBlock([NotNull] CILParser.AssemblyBlockContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMscorlib([NotNull] CILParser.MscorlibContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitLanguageDecl([NotNull] CILParser.LanguageDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitLanguageString([NotNull] CILParser.LanguageStringContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTypelist([NotNull] CILParser.TypelistContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInt32([NotNull] CILParser.Int32Context context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInt64([NotNull] CILParser.Int64Context context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFloat64([NotNull] CILParser.Float64Context context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitIntOrWildcard([NotNull] CILParser.IntOrWildcardContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCompControl([NotNull] CILParser.CompControlContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTypedefDecl([NotNull] CILParser.TypedefDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomDescr([NotNull] CILParser.CustomDescrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomDescrWithOwner([NotNull] CILParser.CustomDescrWithOwnerContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomType([NotNull] CILParser.CustomTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitOwnerType([NotNull] CILParser.OwnerTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomBlobDescr([NotNull] CILParser.CustomBlobDescrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomBlobArgs([NotNull] CILParser.CustomBlobArgsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomBlobNVPairs([NotNull] CILParser.CustomBlobNVPairsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFieldOrProp([NotNull] CILParser.FieldOrPropContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSerializType([NotNull] CILParser.SerializTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSerializTypeElement([NotNull] CILParser.SerializTypeElementContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitModuleHead([NotNull] CILParser.ModuleHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVtfixupDecl([NotNull] CILParser.VtfixupDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVtfixupAttr([NotNull] CILParser.VtfixupAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVtableDecl([NotNull] CILParser.VtableDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNameSpaceHead([NotNull] CILParser.NameSpaceHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitClassHead([NotNull] CILParser.ClassHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitClassAttr([NotNull] CILParser.ClassAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExtendsClause([NotNull] CILParser.ExtendsClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitImplClause([NotNull] CILParser.ImplClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitClassDecls([NotNull] CILParser.ClassDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitImplList([NotNull] CILParser.ImplListContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitEsHead([NotNull] CILParser.EsHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExtSourceSpec([NotNull] CILParser.ExtSourceSpecContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFileDecl([NotNull] CILParser.FileDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFileAttr([NotNull] CILParser.FileAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFileEntry([NotNull] CILParser.FileEntryContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAsmAttrAny([NotNull] CILParser.AsmAttrAnyContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAsmAttr([NotNull] CILParser.AsmAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_none([NotNull] CILParser.Instr_noneContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_var([NotNull] CILParser.Instr_varContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_i([NotNull] CILParser.Instr_iContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_i8([NotNull] CILParser.Instr_i8Context context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_r([NotNull] CILParser.Instr_rContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_brtarget([NotNull] CILParser.Instr_brtargetContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_method([NotNull] CILParser.Instr_methodContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_field([NotNull] CILParser.Instr_fieldContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_type([NotNull] CILParser.Instr_typeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_string([NotNull] CILParser.Instr_stringContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_sig([NotNull] CILParser.Instr_sigContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_tok([NotNull] CILParser.Instr_tokContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr_switch([NotNull] CILParser.Instr_switchContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInstr([NotNull] CILParser.InstrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitLabels([NotNull] CILParser.LabelsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTypeArgs([NotNull] CILParser.TypeArgsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBounds([NotNull] CILParser.BoundsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSigArgs([NotNull] CILParser.SigArgsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSigArg([NotNull] CILParser.SigArgContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitClassName([NotNull] CILParser.ClassNameContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSlashedName([NotNull] CILParser.SlashedNameContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssemblyDecls([NotNull] CILParser.AssemblyDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssemblyDecl([NotNull] CILParser.AssemblyDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTypeSpec([NotNull] CILParser.TypeSpecContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNativeType([NotNull] CILParser.NativeTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the PointerNativeType - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPointerNativeType([NotNull] CILParser.PointerNativeTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the PointerArrayTypeNoSizeData - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPointerArrayTypeNoSizeData([NotNull] CILParser.PointerArrayTypeNoSizeDataContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the PointerArrayTypeSize - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPointerArrayTypeSize([NotNull] CILParser.PointerArrayTypeSizeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the PointerArrayTypeSizeParamIndex - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPointerArrayTypeSizeParamIndex([NotNull] CILParser.PointerArrayTypeSizeParamIndexContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the PointerArrayTypeParamIndex - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPointerArrayTypeParamIndex([NotNull] CILParser.PointerArrayTypeParamIndexContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNativeTypeElement([NotNull] CILParser.NativeTypeElementContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitIidParamIndex([NotNull] CILParser.IidParamIndexContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVariantType([NotNull] CILParser.VariantTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVariantTypeElement([NotNull] CILParser.VariantTypeElementContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitType([NotNull] CILParser.TypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the SZArrayModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSZArrayModifier([NotNull] CILParser.SZArrayModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the ArrayModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitArrayModifier([NotNull] CILParser.ArrayModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the ByRefModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitByRefModifier([NotNull] CILParser.ByRefModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the PtrModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPtrModifier([NotNull] CILParser.PtrModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the PinnedModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPinnedModifier([NotNull] CILParser.PinnedModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the RequiredModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitRequiredModifier([NotNull] CILParser.RequiredModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the OptionalModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitOptionalModifier([NotNull] CILParser.OptionalModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the GenericArgumentsModifier - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitGenericArgumentsModifier([NotNull] CILParser.GenericArgumentsModifierContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitElementType([NotNull] CILParser.ElementTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSimpleType([NotNull] CILParser.SimpleTypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBound([NotNull] CILParser.BoundContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNativeInt([NotNull] CILParser.NativeIntContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNativeUint([NotNull] CILParser.NativeUintContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSecDecl([NotNull] CILParser.SecDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSecAttrSetBlob([NotNull] CILParser.SecAttrSetBlobContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSecAttrBlob([NotNull] CILParser.SecAttrBlobContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNameValPairs([NotNull] CILParser.NameValPairsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNameValPair([NotNull] CILParser.NameValPairContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTruefalse([NotNull] CILParser.TruefalseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCaValue([NotNull] CILParser.CaValueContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSecAction([NotNull] CILParser.SecActionContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethodRef([NotNull] CILParser.MethodRefContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCallConv([NotNull] CILParser.CallConvContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCallKind([NotNull] CILParser.CallKindContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMdtoken([NotNull] CILParser.MdtokenContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMemberRef([NotNull] CILParser.MemberRefContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFieldRef([NotNull] CILParser.FieldRefContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTypeList([NotNull] CILParser.TypeListContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTyparsClause([NotNull] CILParser.TyparsClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTyparAttrib([NotNull] CILParser.TyparAttribContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTyparAttribs([NotNull] CILParser.TyparAttribsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTypar([NotNull] CILParser.TyparContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTypars([NotNull] CILParser.TyparsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTyBound([NotNull] CILParser.TyBoundContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitGenArity([NotNull] CILParser.GenArityContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitGenArityNotEmpty([NotNull] CILParser.GenArityNotEmptyContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitClassDecl([NotNull] CILParser.ClassDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFieldDecl([NotNull] CILParser.FieldDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFieldAttr([NotNull] CILParser.FieldAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAtOpt([NotNull] CILParser.AtOptContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitInitOpt([NotNull] CILParser.InitOptContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitRepeatOpt([NotNull] CILParser.RepeatOptContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitEventHead([NotNull] CILParser.EventHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitEventAttr([NotNull] CILParser.EventAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitEventDecls([NotNull] CILParser.EventDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitEventDecl([NotNull] CILParser.EventDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPropHead([NotNull] CILParser.PropHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPropAttr([NotNull] CILParser.PropAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPropDecls([NotNull] CILParser.PropDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPropDecl([NotNull] CILParser.PropDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMarshalClause([NotNull] CILParser.MarshalClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMarshalBlob([NotNull] CILParser.MarshalBlobContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitParamAttr([NotNull] CILParser.ParamAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitParamAttrElement([NotNull] CILParser.ParamAttrElementContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethodHead([NotNull] CILParser.MethodHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethAttr([NotNull] CILParser.MethAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPinvImpl([NotNull] CILParser.PinvImplContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPinvAttr([NotNull] CILParser.PinvAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethodName([NotNull] CILParser.MethodNameContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitImplAttr([NotNull] CILParser.ImplAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethodDecls([NotNull] CILParser.MethodDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethodDecl([NotNull] CILParser.MethodDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitLabelDecl([NotNull] CILParser.LabelDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomDescrInMethodBody([NotNull] CILParser.CustomDescrInMethodBodyContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitScopeBlock([NotNull] CILParser.ScopeBlockContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSehBlock([NotNull] CILParser.SehBlockContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSehClauses([NotNull] CILParser.SehClausesContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTryBlock([NotNull] CILParser.TryBlockContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSehClause([NotNull] CILParser.SehClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFilterClause([NotNull] CILParser.FilterClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCatchClause([NotNull] CILParser.CatchClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFinallyClause([NotNull] CILParser.FinallyClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFaultClause([NotNull] CILParser.FaultClauseContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitHandlerBlock([NotNull] CILParser.HandlerBlockContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDataDecl([NotNull] CILParser.DataDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDdHead([NotNull] CILParser.DdHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitTls([NotNull] CILParser.TlsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDdBody([NotNull] CILParser.DdBodyContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDdItemList([NotNull] CILParser.DdItemListContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDdItemCount([NotNull] CILParser.DdItemCountContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDdItem([NotNull] CILParser.DdItemContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFieldSerInit([NotNull] CILParser.FieldSerInitContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBytes([NotNull] CILParser.BytesContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitHexbyte([NotNull] CILParser.HexbyteContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFieldInit([NotNull] CILParser.FieldInitContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSerInit([NotNull] CILParser.SerInitContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitF32seq([NotNull] CILParser.F32seqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitF64seq([NotNull] CILParser.F64seqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitI64seq([NotNull] CILParser.I64seqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitI32seq([NotNull] CILParser.I32seqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitI16seq([NotNull] CILParser.I16seqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitI8seq([NotNull] CILParser.I8seqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBoolSeq([NotNull] CILParser.BoolSeqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSqstringSeq([NotNull] CILParser.SqstringSeqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitClassSeq([NotNull] CILParser.ClassSeqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitClassSeqElement([NotNull] CILParser.ClassSeqElementContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitObjSeq([NotNull] CILParser.ObjSeqContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCustomAttrDecl([NotNull] CILParser.CustomAttrDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAsmOrRefDecl([NotNull] CILParser.AsmOrRefDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssemblyRefHead([NotNull] CILParser.AssemblyRefHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssemblyRefDecls([NotNull] CILParser.AssemblyRefDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssemblyRefDecl([NotNull] CILParser.AssemblyRefDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExptypeHead([NotNull] CILParser.ExptypeHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExportHead([NotNull] CILParser.ExportHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExptAttr([NotNull] CILParser.ExptAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExptypeDecls([NotNull] CILParser.ExptypeDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExptypeDecl([NotNull] CILParser.ExptypeDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitManifestResHead([NotNull] CILParser.ManifestResHeadContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitManresAttr([NotNull] CILParser.ManresAttrContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitManifestResDecls([NotNull] CILParser.ManifestResDeclsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitManifestResDecl([NotNull] CILParser.ManifestResDeclContext context) { return VisitChildren(context); } -} -} // namespace ILAssembler diff --git a/src/tools/ilasm/src/ILAssembler/gen/CILParser.cs b/src/tools/ilasm/src/ILAssembler/gen/CILParser.cs index 0f956c8e6f6b69..defd58f42a67ed 100644 --- a/src/tools/ilasm/src/ILAssembler/gen/CILParser.cs +++ b/src/tools/ilasm/src/ILAssembler/gen/CILParser.cs @@ -20,6 +20,9 @@ #pragma warning disable 419 namespace ILAssembler { + +#nullable enable annotations + using System; using System.IO; using System.Text; @@ -98,48 +101,48 @@ public const int RULE_ownerType = 25, RULE_customBlobDescr = 26, RULE_customBlobArgs = 27, RULE_customBlobNVPairs = 28, RULE_fieldOrProp = 29, RULE_serializType = 30, RULE_serializTypeElement = 31, RULE_moduleHead = 32, RULE_vtfixupDecl = 33, - RULE_vtfixupAttr = 34, RULE_vtableDecl = 35, RULE_nameSpaceHead = 36, - RULE_classHead = 37, RULE_classAttr = 38, RULE_extendsClause = 39, RULE_implClause = 40, - RULE_classDecls = 41, RULE_implList = 42, RULE_esHead = 43, RULE_extSourceSpec = 44, - RULE_fileDecl = 45, RULE_fileAttr = 46, RULE_fileEntry = 47, RULE_asmAttrAny = 48, - RULE_asmAttr = 49, RULE_instr_none = 50, RULE_instr_var = 51, RULE_instr_i = 52, - RULE_instr_i8 = 53, RULE_instr_r = 54, RULE_instr_brtarget = 55, RULE_instr_method = 56, - RULE_instr_field = 57, RULE_instr_type = 58, RULE_instr_string = 59, RULE_instr_sig = 60, - RULE_instr_tok = 61, RULE_instr_switch = 62, RULE_instr = 63, RULE_labels = 64, - RULE_typeArgs = 65, RULE_bounds = 66, RULE_sigArgs = 67, RULE_sigArg = 68, - RULE_className = 69, RULE_slashedName = 70, RULE_assemblyDecls = 71, RULE_assemblyDecl = 72, - RULE_typeSpec = 73, RULE_nativeType = 74, RULE_nativeTypeArrayPointerInfo = 75, - RULE_nativeTypeElement = 76, RULE_iidParamIndex = 77, RULE_variantType = 78, - RULE_variantTypeElement = 79, RULE_type = 80, RULE_typeModifiers = 81, - RULE_elementType = 82, RULE_simpleType = 83, RULE_bound = 84, RULE_nativeInt = 85, - RULE_nativeUint = 86, RULE_secDecl = 87, RULE_secAttrSetBlob = 88, RULE_secAttrBlob = 89, - RULE_nameValPairs = 90, RULE_nameValPair = 91, RULE_truefalse = 92, RULE_caValue = 93, - RULE_secAction = 94, RULE_methodRef = 95, RULE_callConv = 96, RULE_callKind = 97, - RULE_mdtoken = 98, RULE_memberRef = 99, RULE_fieldRef = 100, RULE_typeList = 101, - RULE_typarsClause = 102, RULE_typarAttrib = 103, RULE_typarAttribs = 104, - RULE_typar = 105, RULE_typars = 106, RULE_tyBound = 107, RULE_genArity = 108, - RULE_genArityNotEmpty = 109, RULE_classDecl = 110, RULE_fieldDecl = 111, - RULE_fieldAttr = 112, RULE_atOpt = 113, RULE_initOpt = 114, RULE_repeatOpt = 115, - RULE_eventHead = 116, RULE_eventAttr = 117, RULE_eventDecls = 118, RULE_eventDecl = 119, - RULE_propHead = 120, RULE_propAttr = 121, RULE_propDecls = 122, RULE_propDecl = 123, - RULE_marshalClause = 124, RULE_marshalBlob = 125, RULE_paramAttr = 126, - RULE_paramAttrElement = 127, RULE_methodHead = 128, RULE_methAttr = 129, - RULE_pinvImpl = 130, RULE_pinvAttr = 131, RULE_methodName = 132, RULE_implAttr = 133, - RULE_methodDecls = 134, RULE_methodDecl = 135, RULE_labelDecl = 136, RULE_customDescrInMethodBody = 137, - RULE_scopeBlock = 138, RULE_sehBlock = 139, RULE_sehClauses = 140, RULE_tryBlock = 141, - RULE_sehClause = 142, RULE_filterClause = 143, RULE_catchClause = 144, - RULE_finallyClause = 145, RULE_faultClause = 146, RULE_handlerBlock = 147, - RULE_dataDecl = 148, RULE_ddHead = 149, RULE_tls = 150, RULE_ddBody = 151, - RULE_ddItemList = 152, RULE_ddItemCount = 153, RULE_ddItem = 154, RULE_fieldSerInit = 155, - RULE_bytes = 156, RULE_hexbyte = 157, RULE_fieldInit = 158, RULE_serInit = 159, - RULE_f32seq = 160, RULE_f64seq = 161, RULE_i64seq = 162, RULE_i32seq = 163, - RULE_i16seq = 164, RULE_i8seq = 165, RULE_boolSeq = 166, RULE_sqstringSeq = 167, - RULE_classSeq = 168, RULE_classSeqElement = 169, RULE_objSeq = 170, RULE_customAttrDecl = 171, - RULE_asmOrRefDecl = 172, RULE_assemblyRefHead = 173, RULE_assemblyRefDecls = 174, - RULE_assemblyRefDecl = 175, RULE_exptypeHead = 176, RULE_exportHead = 177, - RULE_exptAttr = 178, RULE_exptypeDecls = 179, RULE_exptypeDecl = 180, - RULE_manifestResHead = 181, RULE_manresAttr = 182, RULE_manifestResDecls = 183, - RULE_manifestResDecl = 184; + RULE_vtfixupAttr = 34, RULE_vtfixupAttrElement = 35, RULE_vtableDecl = 36, + RULE_nameSpaceHead = 37, RULE_classHead = 38, RULE_classAttr = 39, RULE_extendsClause = 40, + RULE_implClause = 41, RULE_classDecls = 42, RULE_implList = 43, RULE_esHead = 44, + RULE_extSourceSpec = 45, RULE_fileDecl = 46, RULE_fileAttr = 47, RULE_fileEntry = 48, + RULE_asmAttrAny = 49, RULE_asmAttr = 50, RULE_instr = 51, RULE_simpleInstr = 52, + RULE_calliSignature = 53, RULE_labels = 54, RULE_typeArgs = 55, RULE_bounds = 56, + RULE_sigArgs = 57, RULE_sigArg = 58, RULE_className = 59, RULE_slashedName = 60, + RULE_assemblyDecls = 61, RULE_assemblyDecl = 62, RULE_typeSpec = 63, RULE_nativeType = 64, + RULE_nativeTypeArrayPointerInfo = 65, RULE_nativeTypeElement = 66, RULE_iidParamIndex = 67, + RULE_variantType = 68, RULE_variantTypeElement = 69, RULE_type = 70, RULE_typeModifiers = 71, + RULE_elementType = 72, RULE_simpleType = 73, RULE_bound = 74, RULE_nativeInt = 75, + RULE_nativeUint = 76, RULE_secDecl = 77, RULE_secAttrSetBlob = 78, RULE_secAttrBlob = 79, + RULE_nameValPairs = 80, RULE_nameValPair = 81, RULE_truefalse = 82, RULE_caValue = 83, + RULE_secAction = 84, RULE_methodRef = 85, RULE_callConv = 86, RULE_callKind = 87, + RULE_mdtoken = 88, RULE_memberRef = 89, RULE_fieldRef = 90, RULE_typeList = 91, + RULE_typarsClause = 92, RULE_typarAttrib = 93, RULE_typarAttribs = 94, + RULE_typar = 95, RULE_typars = 96, RULE_tyBound = 97, RULE_genArity = 98, + RULE_genArityNotEmpty = 99, RULE_classDecl = 100, RULE_fieldDecl = 101, + RULE_fieldAttr = 102, RULE_atOpt = 103, RULE_initOpt = 104, RULE_repeatOpt = 105, + RULE_eventHead = 106, RULE_eventAttr = 107, RULE_eventDecls = 108, RULE_eventDecl = 109, + RULE_propHead = 110, RULE_propAttr = 111, RULE_propDecls = 112, RULE_propDecl = 113, + RULE_marshalClause = 114, RULE_marshalBlob = 115, RULE_paramAttr = 116, + RULE_paramAttrElement = 117, RULE_methodHead = 118, RULE_methAttr = 119, + RULE_pinvImpl = 120, RULE_pinvAttr = 121, RULE_methodName = 122, RULE_implAttr = 123, + RULE_methodDecls = 124, RULE_methodDecl = 125, RULE_localsDecl = 126, + RULE_exportDecl = 127, RULE_vtentryDecl = 128, RULE_overrideDecl = 129, + RULE_parameterDecl = 130, RULE_labelDecl = 131, RULE_customDescrInMethodBody = 132, + RULE_scopeBlock = 133, RULE_sehBlock = 134, RULE_sehClauses = 135, RULE_tryBlock = 136, + RULE_sehClause = 137, RULE_filterClause = 138, RULE_catchClause = 139, + RULE_finallyClause = 140, RULE_faultClause = 141, RULE_handlerBlock = 142, + RULE_dataDecl = 143, RULE_ddHead = 144, RULE_tls = 145, RULE_ddBody = 146, + RULE_ddItemList = 147, RULE_ddItemCount = 148, RULE_ddItem = 149, RULE_fieldSerInit = 150, + RULE_bytes = 151, RULE_hexbyte = 152, RULE_fieldInit = 153, RULE_serInit = 154, + RULE_f32seq = 155, RULE_f64seq = 156, RULE_i64seq = 157, RULE_i32seq = 158, + RULE_i16seq = 159, RULE_i8seq = 160, RULE_boolSeq = 161, RULE_sqstringSeq = 162, + RULE_classSeq = 163, RULE_classSeqElement = 164, RULE_objSeq = 165, RULE_customAttrDecl = 166, + RULE_asmOrRefDecl = 167, RULE_assemblyRefBlock = 168, RULE_assemblyRefHead = 169, + RULE_assemblyRefDecls = 170, RULE_assemblyRefDecl = 171, RULE_exptypeBlock = 172, + RULE_exptypeHead = 173, RULE_exportHead = 174, RULE_exptAttrs = 175, RULE_exptAttr = 176, + RULE_exptypeDecls = 177, RULE_exptypeDecl = 178, RULE_manifestResBlock = 179, + RULE_manifestResHead = 180, RULE_manresAttrs = 181, RULE_manresAttr = 182, + RULE_manifestResDecls = 183, RULE_manifestResDecl = 184; public static readonly string[] ruleNames = { "id", "dottedName", "dottedNamePart", "compQstring", "decls", "decl", "subsystem", "corflags", "alignment", "imagebase", "stackreserve", "assemblyBlock", @@ -147,34 +150,35 @@ public const int "float64", "intOrWildcard", "compControl", "typedefDecl", "customDescr", "customDescrWithOwner", "customType", "ownerType", "customBlobDescr", "customBlobArgs", "customBlobNVPairs", "fieldOrProp", "serializType", - "serializTypeElement", "moduleHead", "vtfixupDecl", "vtfixupAttr", "vtableDecl", - "nameSpaceHead", "classHead", "classAttr", "extendsClause", "implClause", - "classDecls", "implList", "esHead", "extSourceSpec", "fileDecl", "fileAttr", - "fileEntry", "asmAttrAny", "asmAttr", "instr_none", "instr_var", "instr_i", - "instr_i8", "instr_r", "instr_brtarget", "instr_method", "instr_field", - "instr_type", "instr_string", "instr_sig", "instr_tok", "instr_switch", - "instr", "labels", "typeArgs", "bounds", "sigArgs", "sigArg", "className", - "slashedName", "assemblyDecls", "assemblyDecl", "typeSpec", "nativeType", - "nativeTypeArrayPointerInfo", "nativeTypeElement", "iidParamIndex", "variantType", - "variantTypeElement", "type", "typeModifiers", "elementType", "simpleType", - "bound", "nativeInt", "nativeUint", "secDecl", "secAttrSetBlob", "secAttrBlob", - "nameValPairs", "nameValPair", "truefalse", "caValue", "secAction", "methodRef", - "callConv", "callKind", "mdtoken", "memberRef", "fieldRef", "typeList", - "typarsClause", "typarAttrib", "typarAttribs", "typar", "typars", "tyBound", - "genArity", "genArityNotEmpty", "classDecl", "fieldDecl", "fieldAttr", - "atOpt", "initOpt", "repeatOpt", "eventHead", "eventAttr", "eventDecls", - "eventDecl", "propHead", "propAttr", "propDecls", "propDecl", "marshalClause", - "marshalBlob", "paramAttr", "paramAttrElement", "methodHead", "methAttr", - "pinvImpl", "pinvAttr", "methodName", "implAttr", "methodDecls", "methodDecl", - "labelDecl", "customDescrInMethodBody", "scopeBlock", "sehBlock", "sehClauses", - "tryBlock", "sehClause", "filterClause", "catchClause", "finallyClause", - "faultClause", "handlerBlock", "dataDecl", "ddHead", "tls", "ddBody", - "ddItemList", "ddItemCount", "ddItem", "fieldSerInit", "bytes", "hexbyte", - "fieldInit", "serInit", "f32seq", "f64seq", "i64seq", "i32seq", "i16seq", - "i8seq", "boolSeq", "sqstringSeq", "classSeq", "classSeqElement", "objSeq", - "customAttrDecl", "asmOrRefDecl", "assemblyRefHead", "assemblyRefDecls", - "assemblyRefDecl", "exptypeHead", "exportHead", "exptAttr", "exptypeDecls", - "exptypeDecl", "manifestResHead", "manresAttr", "manifestResDecls", "manifestResDecl" + "serializTypeElement", "moduleHead", "vtfixupDecl", "vtfixupAttr", "vtfixupAttrElement", + "vtableDecl", "nameSpaceHead", "classHead", "classAttr", "extendsClause", + "implClause", "classDecls", "implList", "esHead", "extSourceSpec", "fileDecl", + "fileAttr", "fileEntry", "asmAttrAny", "asmAttr", "instr", "simpleInstr", + "calliSignature", "labels", "typeArgs", "bounds", "sigArgs", "sigArg", + "className", "slashedName", "assemblyDecls", "assemblyDecl", "typeSpec", + "nativeType", "nativeTypeArrayPointerInfo", "nativeTypeElement", "iidParamIndex", + "variantType", "variantTypeElement", "type", "typeModifiers", "elementType", + "simpleType", "bound", "nativeInt", "nativeUint", "secDecl", "secAttrSetBlob", + "secAttrBlob", "nameValPairs", "nameValPair", "truefalse", "caValue", + "secAction", "methodRef", "callConv", "callKind", "mdtoken", "memberRef", + "fieldRef", "typeList", "typarsClause", "typarAttrib", "typarAttribs", + "typar", "typars", "tyBound", "genArity", "genArityNotEmpty", "classDecl", + "fieldDecl", "fieldAttr", "atOpt", "initOpt", "repeatOpt", "eventHead", + "eventAttr", "eventDecls", "eventDecl", "propHead", "propAttr", "propDecls", + "propDecl", "marshalClause", "marshalBlob", "paramAttr", "paramAttrElement", + "methodHead", "methAttr", "pinvImpl", "pinvAttr", "methodName", "implAttr", + "methodDecls", "methodDecl", "localsDecl", "exportDecl", "vtentryDecl", + "overrideDecl", "parameterDecl", "labelDecl", "customDescrInMethodBody", + "scopeBlock", "sehBlock", "sehClauses", "tryBlock", "sehClause", "filterClause", + "catchClause", "finallyClause", "faultClause", "handlerBlock", "dataDecl", + "ddHead", "tls", "ddBody", "ddItemList", "ddItemCount", "ddItem", "fieldSerInit", + "bytes", "hexbyte", "fieldInit", "serInit", "f32seq", "f64seq", "i64seq", + "i32seq", "i16seq", "i8seq", "boolSeq", "sqstringSeq", "classSeq", "classSeqElement", + "objSeq", "customAttrDecl", "asmOrRefDecl", "assemblyRefBlock", "assemblyRefHead", + "assemblyRefDecls", "assemblyRefDecl", "exptypeBlock", "exptypeHead", + "exportHead", "exptAttrs", "exptAttr", "exptypeDecls", "exptypeDecl", + "manifestResBlock", "manifestResHead", "manresAttrs", "manresAttr", "manifestResDecls", + "manifestResDecl" }; private static readonly string[] _LiteralNames = { @@ -290,6 +294,9 @@ static CILParser() { } } + + internal GrammarActions Actions { get; set; } = null!; + public CILParser(ITokenStream input) : this(input, Console.Out, Console.Error) { } public CILParser(ITokenStream input, TextWriter output, TextWriter errorOutput) @@ -309,12 +316,6 @@ public IdContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_id; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitId(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -348,6 +349,12 @@ public IdContext id() { } public partial class DottedNameContext : ParserRuleContext { + public string Value; + public CILParser.DottedNameBuilder Builder; + public IToken direct; + public DottedNamePartContext part; + public DottedNamePartContext tail; + public IToken quoted; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DOTTEDNAME() { return GetToken(CILParser.DOTTEDNAME, 0); } [System.Diagnostics.DebuggerNonUserCode] public DottedNamePartContext[] dottedNamePart() { return GetRuleContexts(); @@ -365,62 +372,61 @@ public DottedNameContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_dottedName; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDottedName(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public DottedNameContext dottedName() { DottedNameContext _localctx = new DottedNameContext(Context, State); EnterRule(_localctx, 2, RULE_dottedName); + _localctx.Builder = new CILParser.DottedNameBuilder(); try { int _alt; - State = 383; + State = 388; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,1,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { State = 372; - Match(DOTTEDNAME); + _localctx.direct = Match(DOTTEDNAME); + Actions.AddDottedNameToken(_localctx.Builder, _localctx.direct); } break; case 2: EnterOuterAlt(_localctx, 2); { { - State = 378; + State = 380; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,0,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 373; - dottedNamePart(); State = 374; + _localctx.part = dottedNamePart(); + Actions.AddDottedNamePart(_localctx.Builder, _localctx.part.Value); + State = 376; Match(DOT); } } } - State = 380; + State = 382; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,0,Context); } - State = 381; - dottedNamePart(); + State = 383; + _localctx.tail = dottedNamePart(); + Actions.AddDottedNamePart(_localctx.Builder, _localctx.tail.Value); } } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 382; - Match(SQSTRING); + State = 386; + _localctx.quoted = Match(SQSTRING); + Actions.AddDottedNameToken(_localctx.Builder, _localctx.quoted); } break; } @@ -431,12 +437,14 @@ public DottedNameContext dottedName() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.EndDottedName(_localctx.Builder); ExitRule(); } return _localctx; } public partial class DottedNamePartContext : ParserRuleContext { + public string Value; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(CILParser.ID, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VALUE() { return GetToken(CILParser.VALUE, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTANCE() { return GetToken(CILParser.INSTANCE, 0); } @@ -447,23 +455,18 @@ public DottedNamePartContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_dottedNamePart; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDottedNamePart(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public DottedNamePartContext dottedNamePart() { DottedNamePartContext _localctx = new DottedNamePartContext(Context, State); EnterRule(_localctx, 4, RULE_dottedNamePart); + _localctx.Value = string.Empty; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 385; + State = 390; _la = TokenStream.LA(1); if ( !(_la==T__15 || _la==VALUE || _la==INSTANCE || ((((_la - 264)) & ~0x3f) == 0 && ((1L << (_la - 264)) & 50331649L) != 0)) ) { ErrorHandler.RecoverInline(this); @@ -473,6 +476,8 @@ public DottedNamePartContext dottedNamePart() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = Actions.ParseDottedNamePart(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -486,6 +491,10 @@ public DottedNamePartContext dottedNamePart() { } public partial class CompQstringContext : ParserRuleContext { + public string Value; + public System.Text.StringBuilder Builder; + public IToken head; + public IToken tail; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] QSTRING() { return GetTokens(CILParser.QSTRING); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode QSTRING(int i) { return GetToken(CILParser.QSTRING, i); @@ -499,42 +508,39 @@ public CompQstringContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_compQstring; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCompQstring(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CompQstringContext compQstring() { CompQstringContext _localctx = new CompQstringContext(Context, State); EnterRule(_localctx, 6, RULE_compQstring); + _localctx.Builder = new System.Text.StringBuilder(); try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 391; + State = 397; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,2,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 387; - Match(QSTRING); - State = 388; + State = 392; + _localctx.head = Match(QSTRING); + Actions.AddComposedStringPart(_localctx.Builder, _localctx.head); + State = 394; Match(PLUS); } } } - State = 393; + State = 399; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,2,Context); } - State = 394; - Match(QSTRING); + State = 400; + _localctx.tail = Match(QSTRING); + Actions.AddComposedStringPart(_localctx.Builder, _localctx.tail); } } catch (RecognitionException re) { @@ -543,6 +549,7 @@ public CompQstringContext compQstring() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.EndComposedString(_localctx.Builder); ExitRule(); } return _localctx; @@ -560,12 +567,6 @@ public DeclsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_decls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -576,17 +577,17 @@ public DeclsContext decls() { try { EnterOuterAlt(_localctx, 1); { - State = 399; + State = 406; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1972571905523712L) != 0) || ((((_la - 73)) & ~0x3f) == 0 && ((1L << (_la - 73)) & 281474976710659L) != 0) || ((((_la - 139)) & ~0x3f) == 0 && ((1L << (_la - 139)) & 1729382256977379329L) != 0) || ((((_la - 243)) & ~0x3f) == 0 && ((1L << (_la - 243)) & 6860956837609473L) != 0)) { { { - State = 396; + State = 403; decl(); } } - State = 401; + State = 408; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -604,6 +605,20 @@ public DeclsContext decls() { } public partial class DeclContext : ParserRuleContext { + public DataDeclContext data; + public VtableDeclContext vtable; + public VtfixupDeclContext vtfixup; + public ExtSourceSpecContext source; + public FileDeclContext file; + public AssemblyBlockContext assembly; + public AssemblyRefBlockContext assemblyReference; + public ExptypeBlockContext exportedType; + public ManifestResBlockContext resource; + public ModuleHeadContext module; + public SecDeclContext security; + public CustomAttrDeclContext attribute; + public LanguageDeclContext language; + public TypedefDeclContext typedef; [System.Diagnostics.DebuggerNonUserCode] public ClassHeadContext classHead() { return GetRuleContext(0); } @@ -643,23 +658,14 @@ [System.Diagnostics.DebuggerNonUserCode] public FileDeclContext fileDecl() { [System.Diagnostics.DebuggerNonUserCode] public AssemblyBlockContext assemblyBlock() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public AssemblyRefHeadContext assemblyRefHead() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public AssemblyRefDeclsContext assemblyRefDecls() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ExptypeHeadContext exptypeHead() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ExptypeDeclsContext exptypeDecls() { - return GetRuleContext(0); + [System.Diagnostics.DebuggerNonUserCode] public AssemblyRefBlockContext assemblyRefBlock() { + return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ManifestResHeadContext manifestResHead() { - return GetRuleContext(0); + [System.Diagnostics.DebuggerNonUserCode] public ExptypeBlockContext exptypeBlock() { + return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ManifestResDeclsContext manifestResDecls() { - return GetRuleContext(0); + [System.Diagnostics.DebuggerNonUserCode] public ManifestResBlockContext manifestResBlock() { + return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public ModuleHeadContext moduleHead() { return GetRuleContext(0); @@ -705,12 +711,6 @@ public DeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_decl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -718,224 +718,240 @@ public DeclContext decl() { DeclContext _localctx = new DeclContext(Context, State); EnterRule(_localctx, 10, RULE_decl); try { - State = 452; + State = 495; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,4,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 402; + State = 409; classHead(); - State = 403; + State = 410; Match(T__16); - State = 404; + State = 411; classDecls(); - State = 405; + State = 412; Match(T__17); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 407; + State = 414; nameSpaceHead(); - State = 408; + State = 415; Match(T__16); - State = 409; + State = 416; decls(); - State = 410; + State = 417; Match(T__17); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 412; + State = 419; methodHead(); - State = 413; + State = 420; Match(T__16); - State = 414; + State = 421; methodDecls(); - State = 415; + State = 422; Match(T__17); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 417; + State = 424; fieldDecl(); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 418; - dataDecl(); + Actions.BeginTopLevelDirective(); + State = 426; + _localctx.data = dataDecl(); + Actions.ProcessTopLevelDataDeclaration(_localctx.data); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 419; - vtableDecl(); + Actions.BeginTopLevelDirective(); + State = 430; + _localctx.vtable = vtableDecl(); + Actions.ProcessTopLevelVTableDeclaration(_localctx.vtable); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 420; - vtfixupDecl(); + Actions.BeginTopLevelDirective(); + State = 434; + _localctx.vtfixup = vtfixupDecl(); + Actions.ProcessTopLevelVTableFixupDeclaration(_localctx.vtfixup); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 421; - extSourceSpec(); + Actions.BeginTopLevelDirective(); + State = 438; + _localctx.source = extSourceSpec(); + Actions.ProcessTopLevelSourceDirective(_localctx.source); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 422; - fileDecl(); + Actions.BeginTopLevelDirective(); + State = 442; + _localctx.file = fileDecl(); + Actions.ProcessTopLevelFileDeclaration(_localctx.file); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 423; - assemblyBlock(); + Actions.BeginTopLevelDirective(); + State = 446; + _localctx.assembly = assemblyBlock(); + Actions.ProcessTopLevelAssembly(_localctx.assembly); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 424; - assemblyRefHead(); - State = 425; - Match(T__16); - State = 426; - assemblyRefDecls(); - State = 427; - Match(T__17); + Actions.BeginTopLevelDirective(); + State = 450; + _localctx.assemblyReference = assemblyRefBlock(); + Actions.ProcessTopLevelAssemblyReference(_localctx.assemblyReference); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 429; - exptypeHead(); - State = 430; - Match(T__16); - State = 431; - exptypeDecls(); - State = 432; - Match(T__17); + Actions.BeginTopLevelDirective(); + State = 454; + _localctx.exportedType = exptypeBlock(); + Actions.ProcessTopLevelExportedType(_localctx.exportedType); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 434; - manifestResHead(); - State = 435; - Match(T__16); - State = 436; - manifestResDecls(); - State = 437; - Match(T__17); + Actions.BeginTopLevelDirective(); + State = 458; + _localctx.resource = manifestResBlock(); + Actions.ProcessTopLevelManifestResource(_localctx.resource); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 439; - moduleHead(); + Actions.BeginTopLevelDirective(); + State = 462; + _localctx.module = moduleHead(); + Actions.ProcessTopLevelModule(_localctx.module.Value, _localctx.module.HasName, _localctx.module.IsExternal); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 440; - secDecl(); + Actions.BeginTopLevelDirective(); + State = 466; + _localctx.security = secDecl(); + Actions.ProcessTopLevelSecurityDeclaration(_localctx.security); } break; case 16: EnterOuterAlt(_localctx, 16); { - State = 441; - customAttrDecl(); + State = 469; + _localctx.attribute = customAttrDecl(); + Actions.ProcessTopLevelCustomAttribute(_localctx.attribute); } break; case 17: EnterOuterAlt(_localctx, 17); { - State = 442; + Actions.BeginTopLevelDirective(); + State = 473; subsystem(); } break; case 18: EnterOuterAlt(_localctx, 18); { - State = 443; + Actions.BeginTopLevelDirective(); + State = 475; corflags(); } break; case 19: EnterOuterAlt(_localctx, 19); { - State = 444; + Actions.BeginTopLevelDirective(); + State = 477; alignment(); } break; case 20: EnterOuterAlt(_localctx, 20); { - State = 445; + Actions.BeginTopLevelDirective(); + State = 479; imagebase(); } break; case 21: EnterOuterAlt(_localctx, 21); { - State = 446; + Actions.BeginTopLevelDirective(); + State = 481; stackreserve(); } break; case 22: EnterOuterAlt(_localctx, 22); { - State = 447; - languageDecl(); + Actions.BeginTopLevelDirective(); + State = 483; + _localctx.language = languageDecl(); + Actions.ProcessTopLevelLanguageDirective(_localctx.language); } break; case 23: EnterOuterAlt(_localctx, 23); { - State = 448; - typedefDecl(); + Actions.BeginTopLevelDirective(); + State = 487; + _localctx.typedef = typedefDecl(); + Actions.ProcessTopLevelTypedef(_localctx.typedef); } break; case 24: EnterOuterAlt(_localctx, 24); { - State = 449; + Actions.BeginTopLevelDirective(); + State = 491; compControl(); } break; case 25: EnterOuterAlt(_localctx, 25); { - State = 450; + State = 492; typelist(); } break; case 26: EnterOuterAlt(_localctx, 26); { - State = 451; + Actions.BeginTopLevelDirective(); + State = 494; mscorlib(); } break; @@ -947,12 +963,14 @@ public DeclContext decl() { ErrorHandler.Recover(this, re); } finally { + Actions.EndDeclaration(_localctx); ExitRule(); } return _localctx; } public partial class SubsystemContext : ParserRuleContext { + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -961,12 +979,6 @@ public SubsystemContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_subsystem; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSubsystem(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -976,10 +988,11 @@ public SubsystemContext subsystem() { try { EnterOuterAlt(_localctx, 1); { - State = 454; + State = 497; Match(T__18); - State = 455; - int32(); + State = 498; + _localctx.value = int32(); + Actions.ProcessTopLevelSubsystem((_localctx.value!=null?(_localctx.value.Start):null)); } } catch (RecognitionException re) { @@ -994,6 +1007,7 @@ public SubsystemContext subsystem() { } public partial class CorflagsContext : ParserRuleContext { + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -1002,12 +1016,6 @@ public CorflagsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_corflags; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCorflags(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1017,10 +1025,11 @@ public CorflagsContext corflags() { try { EnterOuterAlt(_localctx, 1); { - State = 457; + State = 501; Match(T__19); - State = 458; - int32(); + State = 502; + _localctx.value = int32(); + Actions.ProcessTopLevelCorFlags((_localctx.value!=null?(_localctx.value.Start):null)); } } catch (RecognitionException re) { @@ -1035,6 +1044,7 @@ public CorflagsContext corflags() { } public partial class AlignmentContext : ParserRuleContext { + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -1043,12 +1053,6 @@ public AlignmentContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_alignment; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAlignment(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1058,12 +1062,13 @@ public AlignmentContext alignment() { try { EnterOuterAlt(_localctx, 1); { - State = 460; + State = 505; Match(T__20); - State = 461; + State = 506; Match(T__21); - State = 462; - int32(); + State = 507; + _localctx.value = int32(); + Actions.ProcessTopLevelAlignment((_localctx.value!=null?(_localctx.value.Start):null)); } } catch (RecognitionException re) { @@ -1078,6 +1083,7 @@ public AlignmentContext alignment() { } public partial class ImagebaseContext : ParserRuleContext { + public Int64Context value; [System.Diagnostics.DebuggerNonUserCode] public Int64Context int64() { return GetRuleContext(0); } @@ -1086,12 +1092,6 @@ public ImagebaseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_imagebase; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitImagebase(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1101,10 +1101,11 @@ public ImagebaseContext imagebase() { try { EnterOuterAlt(_localctx, 1); { - State = 464; + State = 510; Match(T__22); - State = 465; - int64(); + State = 511; + _localctx.value = int64(); + Actions.ProcessTopLevelImageBase((_localctx.value!=null?(_localctx.value.Start):null)); } } catch (RecognitionException re) { @@ -1119,6 +1120,7 @@ public ImagebaseContext imagebase() { } public partial class StackreserveContext : ParserRuleContext { + public Int64Context value; [System.Diagnostics.DebuggerNonUserCode] public Int64Context int64() { return GetRuleContext(0); } @@ -1127,12 +1129,6 @@ public StackreserveContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_stackreserve; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitStackreserve(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1142,10 +1138,11 @@ public StackreserveContext stackreserve() { try { EnterOuterAlt(_localctx, 1); { - State = 467; + State = 514; Match(T__23); - State = 468; - int64(); + State = 515; + _localctx.value = int64(); + Actions.ProcessTopLevelStackReserve((_localctx.value!=null?(_localctx.value.Start):null)); } } catch (RecognitionException re) { @@ -1160,6 +1157,12 @@ public StackreserveContext stackreserve() { } public partial class AssemblyBlockContext : ParserRuleContext { + public CILParser.AssemblyDefinitionValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public AsmAttrContext attributes; + public DottedNameContext name; + public AssemblyDeclsContext declarations; [System.Diagnostics.DebuggerNonUserCode] public AsmAttrContext asmAttr() { return GetRuleContext(0); } @@ -1174,33 +1177,32 @@ public AssemblyBlockContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_assemblyBlock; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssemblyBlock(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AssemblyBlockContext assemblyBlock() { AssemblyBlockContext _localctx = new AssemblyBlockContext(Context, State); EnterRule(_localctx, 22, RULE_assemblyBlock); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; try { EnterOuterAlt(_localctx, 1); { - State = 470; + State = 518; Match(T__24); - State = 471; - asmAttr(); - State = 472; - dottedName(); - State = 473; + State = 519; + _localctx.attributes = asmAttr(); + State = 520; + _localctx.name = dottedName(); + State = 521; Match(T__16); - State = 474; - assemblyDecls(); - State = 475; + State = 522; + _localctx.declarations = assemblyDecls(); + State = 523; Match(T__17); + _localctx.Value = Actions.CreateAssemblyDefinition( + _localctx.attributes.Value, + _localctx.name.Value, + _localctx.declarations.Value); } } catch (RecognitionException re) { @@ -1209,6 +1211,15 @@ public AssemblyBlockContext assemblyBlock() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } + ExitRule(); } return _localctx; @@ -1220,12 +1231,6 @@ public MscorlibContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_mscorlib; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMscorlib(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1235,7 +1240,7 @@ public MscorlibContext mscorlib() { try { EnterOuterAlt(_localctx, 1); { - State = 477; + State = 526; Match(T__25); } } @@ -1251,6 +1256,12 @@ public MscorlibContext mscorlib() { } public partial class LanguageDeclContext : ParserRuleContext { + public CILParser.LanguageDirectiveValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public LanguageStringContext language; + public LanguageStringContext vendor; + public LanguageStringContext documentType; [System.Diagnostics.DebuggerNonUserCode] public LanguageStringContext[] languageString() { return GetRuleContexts(); } @@ -1262,59 +1273,57 @@ public LanguageDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_languageDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitLanguageDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public LanguageDeclContext languageDecl() { LanguageDeclContext _localctx = new LanguageDeclContext(Context, State); EnterRule(_localctx, 26, RULE_languageDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; try { - State = 493; + State = 546; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,5,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 479; + State = 528; Match(T__26); - State = 480; - languageString(); + State = 529; + _localctx.language = languageString(); + _localctx.Value = Actions.CreateLanguageDirective(_localctx.language.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 481; + State = 532; Match(T__26); - State = 482; - languageString(); - State = 483; + State = 533; + _localctx.language = languageString(); + State = 534; Match(T__27); - State = 484; - languageString(); + State = 535; + _localctx.vendor = languageString(); + _localctx.Value = Actions.CreateLanguageDirective(_localctx.language.Value, _localctx.vendor.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 486; + State = 538; Match(T__26); - State = 487; - languageString(); - State = 488; + State = 539; + _localctx.language = languageString(); + State = 540; Match(T__27); - State = 489; - languageString(); - State = 490; + State = 541; + _localctx.vendor = languageString(); + State = 542; Match(T__27); - State = 491; - languageString(); + State = 543; + _localctx.documentType = languageString(); + _localctx.Value = Actions.CreateLanguageDirective(_localctx.language.Value, _localctx.vendor.Value, _localctx.documentType.Value); } break; } @@ -1325,12 +1334,14 @@ public LanguageDeclContext languageDecl() { ErrorHandler.Recover(this, re); } finally { + Actions.EndLanguageDirective(_localctx, _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; } public partial class LanguageStringContext : ParserRuleContext { + public string Value; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SQSTRING() { return GetToken(CILParser.SQSTRING, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode QSTRING() { return GetToken(CILParser.QSTRING, 0); } public LanguageStringContext(ParserRuleContext parent, int invokingState) @@ -1338,23 +1349,18 @@ public LanguageStringContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_languageString; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitLanguageString(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public LanguageStringContext languageString() { LanguageStringContext _localctx = new LanguageStringContext(Context, State); EnterRule(_localctx, 28, RULE_languageString); + _localctx.Value = string.Empty; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 495; + State = 548; _la = TokenStream.LA(1); if ( !(_la==QSTRING || _la==SQSTRING) ) { ErrorHandler.RecoverInline(this); @@ -1364,6 +1370,8 @@ public LanguageStringContext languageString() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = Actions.ParseLanguageString(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -1377,6 +1385,7 @@ public LanguageStringContext languageString() { } public partial class TypelistContext : ParserRuleContext { + public ClassNameContext name; [System.Diagnostics.DebuggerNonUserCode] public ClassNameContext[] className() { return GetRuleContexts(); } @@ -1388,41 +1397,37 @@ public TypelistContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typelist; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTypelist(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TypelistContext typelist() { TypelistContext _localctx = new TypelistContext(Context, State); EnterRule(_localctx, 30, RULE_typelist); + Actions.BeginTopLevelTypeList(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 497; + State = 550; Match(T__28); - State = 498; + State = 551; Match(T__16); - State = 502; + State = 557; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__15 || _la==T__41 || _la==T__112 || ((((_la - 199)) & ~0x3f) == 0 && ((1L << (_la - 199)) & 2017630225248026625L) != 0) || ((((_la - 264)) & ~0x3f) == 0 && ((1L << (_la - 264)) & 50331649L) != 0)) { { { - State = 499; - className(); + State = 552; + _localctx.name = className(); + Actions.ProcessTopLevelTypeListEntry(_localctx.name.Value); } } - State = 504; + State = 559; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 505; + State = 560; Match(T__17); } } @@ -1444,12 +1449,6 @@ public Int32Context(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_int32; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInt32(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1459,7 +1458,7 @@ public Int32Context int32() { try { EnterOuterAlt(_localctx, 1); { - State = 507; + State = 562; Match(INT32); } } @@ -1482,12 +1481,6 @@ public Int64Context(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_int64; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInt64(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1498,7 +1491,7 @@ public Int64Context int64() { try { EnterOuterAlt(_localctx, 1); { - State = 509; + State = 564; _la = TokenStream.LA(1); if ( !(_la==INT32 || _la==INT64) ) { ErrorHandler.RecoverInline(this); @@ -1521,11 +1514,17 @@ public Int64Context int64() { } public partial class Float64Context : ParserRuleContext { + public double Value; + public IToken @decimal; + public Int32Context trailing; + public Int32Context integer; + public Int32Context singleBits; + public Int64Context doubleBits; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT64() { return GetToken(CILParser.FLOAT64, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DOT() { return GetToken(CILParser.DOT, 0); } [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DOT() { return GetToken(CILParser.DOT, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT32() { return GetToken(CILParser.FLOAT32, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT64_() { return GetToken(CILParser.FLOAT64_, 0); } [System.Diagnostics.DebuggerNonUserCode] public Int64Context int64() { @@ -1536,12 +1535,6 @@ public Float64Context(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_float64; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFloat64(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1549,56 +1542,61 @@ public Float64Context float64() { Float64Context _localctx = new Float64Context(Context, State); EnterRule(_localctx, 36, RULE_float64); try { - State = 526; + State = 587; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,7,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 511; - Match(FLOAT64); + State = 566; + _localctx.@decimal = Match(FLOAT64); + _localctx.Value = Actions.ParseFloatingLiteral(_localctx.@decimal); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 512; - int32(); - State = 513; + State = 568; + _localctx.trailing = int32(); + State = 569; Match(DOT); + _localctx.Value = Actions.ParseFloatingInteger((_localctx.trailing!=null?(_localctx.trailing.Start):null)); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 515; - int32(); + State = 572; + _localctx.integer = int32(); + _localctx.Value = Actions.ParseFloatingInteger((_localctx.integer!=null?(_localctx.integer.Start):null)); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 516; + State = 575; Match(FLOAT32); - State = 517; + State = 576; Match(T__29); - State = 518; - int32(); - State = 519; + State = 577; + _localctx.singleBits = int32(); + State = 578; Match(T__30); + _localctx.Value = Actions.ParseFloat32Bits((_localctx.singleBits!=null?(_localctx.singleBits.Start):null)); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 521; + State = 581; Match(FLOAT64_); - State = 522; + State = 582; Match(T__29); - State = 523; - int64(); - State = 524; + State = 583; + _localctx.doubleBits = int64(); + State = 584; Match(T__30); + _localctx.Value = Actions.ParseFloat64Bits((_localctx.doubleBits!=null?(_localctx.doubleBits.Start):null)); } break; } @@ -1615,6 +1613,8 @@ public Float64Context float64() { } public partial class IntOrWildcardContext : ParserRuleContext { + public int? Value; + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -1624,12 +1624,6 @@ public IntOrWildcardContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_intOrWildcard; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitIntOrWildcard(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1637,21 +1631,23 @@ public IntOrWildcardContext intOrWildcard() { IntOrWildcardContext _localctx = new IntOrWildcardContext(Context, State); EnterRule(_localctx, 38, RULE_intOrWildcard); try { - State = 530; + State = 594; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case INT32: EnterOuterAlt(_localctx, 1); { - State = 528; - int32(); + State = 589; + _localctx.value = int32(); + _localctx.Value = Actions.ParseInt32((_localctx.value!=null?(_localctx.value.Start):null)); } break; case PTR: EnterOuterAlt(_localctx, 2); { - State = 529; + State = 592; Match(PTR); + _localctx.Value = null; } break; default: @@ -1684,12 +1680,6 @@ public CompControlContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_compControl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCompControl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -1697,83 +1687,83 @@ public CompControlContext compControl() { CompControlContext _localctx = new CompControlContext(Context, State); EnterRule(_localctx, 40, RULE_compControl); try { - State = 548; + State = 612; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,9,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 532; + State = 596; Match(PP_DEFINE); - State = 533; + State = 597; Match(ID); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 534; + State = 598; Match(PP_DEFINE); - State = 535; + State = 599; Match(ID); - State = 536; + State = 600; Match(QSTRING); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 537; + State = 601; Match(PP_UNDEF); - State = 538; + State = 602; Match(ID); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 539; + State = 603; Match(PP_IFDEF); - State = 540; + State = 604; Match(ID); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 541; + State = 605; Match(PP_IFNDEF); - State = 542; + State = 606; Match(ID); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 543; + State = 607; Match(PP_ELSE); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 544; + State = 608; Match(PP_ENDIF); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 545; + State = 609; Match(PP_INCLUDE); - State = 546; + State = 610; Match(QSTRING); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 547; + State = 611; Match(T__31); } break; @@ -1791,6 +1781,15 @@ public CompControlContext compControl() { } public partial class TypedefDeclContext : ParserRuleContext { + public CILParser.TypedefDeclarationValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public TypeContext signature; + public DottedNameContext alias; + public ClassNameContext classType; + public MemberRefContext member; + public CustomDescrContext attribute; + public CustomDescrWithOwnerContext ownedAttribute; [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { return GetRuleContext(0); } @@ -1814,85 +1813,94 @@ public TypedefDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typedefDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTypedefDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TypedefDeclContext typedefDecl() { TypedefDeclContext _localctx = new TypedefDeclContext(Context, State); EnterRule(_localctx, 42, RULE_typedefDecl); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.TypedefDeclarationValue.Error; + try { - State = 575; + State = 644; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,10,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 550; + State = 614; Match(T__32); - State = 551; - type(); - State = 552; + State = 615; + _localctx.signature = type(); + State = 616; Match(T__33); - State = 553; - dottedName(); + State = 617; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateTypeSignatureTypedef(_localctx.signature.Value, _localctx.alias.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 555; + State = 620; Match(T__32); - State = 556; - className(); - State = 557; + State = 621; + _localctx.classType = className(); + State = 622; Match(T__33); - State = 558; - dottedName(); + State = 623; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateClassTypedef(_localctx.classType.Value, _localctx.alias.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 560; + State = 626; Match(T__32); - State = 561; - memberRef(); - State = 562; + State = 627; + _localctx.member = memberRef(); + State = 628; Match(T__33); - State = 563; - dottedName(); + State = 629; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateMemberTypedef(_localctx.member.Value, _localctx.alias.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 565; + State = 632; Match(T__32); - State = 566; - customDescr(); - State = 567; + State = 633; + _localctx.attribute = customDescr(); + State = 634; Match(T__33); - State = 568; - dottedName(); + State = 635; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateCustomAttributeTypedefDeclaration( + _localctx.attribute.Value, + (_localctx.attribute!=null?(_localctx.attribute.Start):null), + _localctx.alias.Value); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 570; + State = 638; Match(T__32); - State = 571; - customDescrWithOwner(); - State = 572; + State = 639; + _localctx.ownedAttribute = customDescrWithOwner(); + State = 640; Match(T__33); - State = 573; - dottedName(); + State = 641; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateCustomAttributeTypedefDeclaration( + _localctx.ownedAttribute.Value, + (_localctx.ownedAttribute!=null?(_localctx.ownedAttribute.Start):null), + _localctx.alias.Value); } break; } @@ -1903,12 +1911,24 @@ public TypedefDeclContext typedefDecl() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class CustomDescrContext : ParserRuleContext { + public CILParser.CustomAttributeDescriptorValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public CustomTypeContext constructor; + public CompQstringContext stringValue; + public CustomBlobDescrContext structuredValue; + public BytesContext rawValue; [System.Diagnostics.DebuggerNonUserCode] public CustomTypeContext customType() { return GetRuleContext(0); } @@ -1926,76 +1946,78 @@ public CustomDescrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_customDescr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomDescr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomDescrContext customDescr() { CustomDescrContext _localctx = new CustomDescrContext(Context, State); EnterRule(_localctx, 44, RULE_customDescr); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDescriptorValue.Error; + try { - State = 598; + State = 672; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,11,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 577; + State = 646; Match(T__34); - State = 578; - customType(); + State = 647; + _localctx.constructor = customType(); + _localctx.Value = Actions.CreateDefaultCustomAttribute(_localctx.constructor.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 579; + State = 650; Match(T__34); - State = 580; - customType(); - State = 581; + State = 651; + _localctx.constructor = customType(); + State = 652; Match(T__35); - State = 582; - compQstring(); + State = 653; + _localctx.stringValue = compQstring(); + _localctx.Value = Actions.CreateStringCustomAttribute(_localctx.constructor.Value, _localctx.stringValue.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 584; + State = 656; Match(T__34); - State = 585; - customType(); - State = 586; + State = 657; + _localctx.constructor = customType(); + State = 658; Match(T__35); - State = 587; + State = 659; Match(T__16); - State = 588; - customBlobDescr(); - State = 589; + State = 660; + _localctx.structuredValue = customBlobDescr(); + State = 661; Match(T__17); + _localctx.Value = Actions.CreateStructuredCustomAttribute(_localctx.constructor.Value, _localctx.structuredValue.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 591; + State = 664; Match(T__34); - State = 592; - customType(); - State = 593; + State = 665; + _localctx.constructor = customType(); + State = 666; Match(T__35); - State = 594; + State = 667; Match(T__29); - State = 595; - bytes(); - State = 596; + State = 668; + _localctx.rawValue = bytes(); + State = 669; Match(T__30); + _localctx.Value = Actions.CreateRawCustomAttribute(_localctx.constructor.Value, _localctx.rawValue.Value); } break; } @@ -2006,12 +2028,25 @@ public CustomDescrContext customDescr() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class CustomDescrWithOwnerContext : ParserRuleContext { + public CILParser.CustomAttributeDescriptorValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public OwnerTypeContext owner; + public CustomTypeContext constructor; + public CompQstringContext stringValue; + public CustomBlobDescrContext structuredValue; + public BytesContext rawValue; [System.Diagnostics.DebuggerNonUserCode] public OwnerTypeContext ownerType() { return GetRuleContext(0); } @@ -2032,100 +2067,102 @@ public CustomDescrWithOwnerContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_customDescrWithOwner; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomDescrWithOwner(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomDescrWithOwnerContext customDescrWithOwner() { CustomDescrWithOwnerContext _localctx = new CustomDescrWithOwnerContext(Context, State); EnterRule(_localctx, 46, RULE_customDescrWithOwner); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDescriptorValue.Error; + try { - State = 634; + State = 712; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,12,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 600; + State = 674; Match(T__34); - State = 601; + State = 675; Match(T__29); - State = 602; - ownerType(); - State = 603; + State = 676; + _localctx.owner = ownerType(); + State = 677; Match(T__30); - State = 604; - customType(); + State = 678; + _localctx.constructor = customType(); + _localctx.Value = Actions.CreateDefaultOwnedCustomAttribute(_localctx.owner.Value, _localctx.constructor.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 606; + State = 681; Match(T__34); - State = 607; + State = 682; Match(T__29); - State = 608; - ownerType(); - State = 609; + State = 683; + _localctx.owner = ownerType(); + State = 684; Match(T__30); - State = 610; - customType(); - State = 611; + State = 685; + _localctx.constructor = customType(); + State = 686; Match(T__35); - State = 612; - compQstring(); + State = 687; + _localctx.stringValue = compQstring(); + _localctx.Value = Actions.CreateStringOwnedCustomAttribute(_localctx.owner.Value, _localctx.constructor.Value, _localctx.stringValue.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 614; + State = 690; Match(T__34); - State = 615; + State = 691; Match(T__29); - State = 616; - ownerType(); - State = 617; + State = 692; + _localctx.owner = ownerType(); + State = 693; Match(T__30); - State = 618; - customType(); - State = 619; + State = 694; + _localctx.constructor = customType(); + State = 695; Match(T__35); - State = 620; + State = 696; Match(T__16); - State = 621; - customBlobDescr(); - State = 622; + State = 697; + _localctx.structuredValue = customBlobDescr(); + State = 698; Match(T__17); + _localctx.Value = Actions.CreateStructuredOwnedCustomAttribute(_localctx.owner.Value, _localctx.constructor.Value, _localctx.structuredValue.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 624; + State = 701; Match(T__34); - State = 625; + State = 702; Match(T__29); - State = 626; - ownerType(); - State = 627; + State = 703; + _localctx.owner = ownerType(); + State = 704; Match(T__30); - State = 628; - customType(); - State = 629; + State = 705; + _localctx.constructor = customType(); + State = 706; Match(T__35); - State = 630; + State = 707; Match(T__29); - State = 631; - bytes(); - State = 632; + State = 708; + _localctx.rawValue = bytes(); + State = 709; Match(T__30); + _localctx.Value = Actions.CreateRawOwnedCustomAttribute(_localctx.owner.Value, _localctx.constructor.Value, _localctx.rawValue.Value); } break; } @@ -2136,12 +2173,19 @@ public CustomDescrWithOwnerContext customDescrWithOwner() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class CustomTypeContext : ParserRuleContext { + public CILParser.MethodReferenceValue Value; + public MethodRefContext constructor; [System.Diagnostics.DebuggerNonUserCode] public MethodRefContext methodRef() { return GetRuleContext(0); } @@ -2150,23 +2194,19 @@ public CustomTypeContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_customType; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomType(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomTypeContext customType() { CustomTypeContext _localctx = new CustomTypeContext(Context, State); EnterRule(_localctx, 48, RULE_customType); + _localctx.Value = CILParser.MethodReferenceValue.Error; try { EnterOuterAlt(_localctx, 1); { - State = 636; - methodRef(); + State = 714; + _localctx.constructor = methodRef(); + _localctx.Value = Actions.CreateCustomAttributeType(_localctx.constructor.Value); } } catch (RecognitionException re) { @@ -2181,6 +2221,11 @@ public CustomTypeContext customType() { } public partial class OwnerTypeContext : ParserRuleContext { + public CILParser.OwnerTypeValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public TypeSpecContext typeValue; + public MemberRefContext member; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } @@ -2192,34 +2237,34 @@ public OwnerTypeContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_ownerType; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitOwnerType(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public OwnerTypeContext ownerType() { OwnerTypeContext _localctx = new OwnerTypeContext(Context, State); EnterRule(_localctx, 50, RULE_ownerType); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.OwnerTypeValue.Error; + try { - State = 640; + State = 723; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,13,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 638; - typeSpec(); + State = 717; + _localctx.typeValue = typeSpec(); + _localctx.Value = Actions.CreateTypeOwner(_localctx.typeValue.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 639; - memberRef(); + State = 720; + _localctx.member = memberRef(); + _localctx.Value = Actions.CreateMemberOwner(_localctx.member.Value); } break; } @@ -2230,12 +2275,20 @@ public OwnerTypeContext ownerType() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class CustomBlobDescrContext : ParserRuleContext { + public CILParser.CustomAttributeBlobValue Value; + public CustomBlobArgsContext arguments; + public CustomBlobNVPairsContext namedArguments; [System.Diagnostics.DebuggerNonUserCode] public CustomBlobArgsContext customBlobArgs() { return GetRuleContext(0); } @@ -2247,25 +2300,21 @@ public CustomBlobDescrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_customBlobDescr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomBlobDescr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomBlobDescrContext customBlobDescr() { CustomBlobDescrContext _localctx = new CustomBlobDescrContext(Context, State); EnterRule(_localctx, 52, RULE_customBlobDescr); + _localctx.Value = CILParser.CustomAttributeBlobValue.Error; try { EnterOuterAlt(_localctx, 1); { - State = 642; - customBlobArgs(); - State = 643; - customBlobNVPairs(); + State = 725; + _localctx.arguments = customBlobArgs(); + State = 726; + _localctx.namedArguments = customBlobNVPairs(); + _localctx.Value = Actions.CreateCustomAttributeBlob(_localctx.arguments.Value, _localctx.namedArguments.Value); } } catch (RecognitionException re) { @@ -2280,46 +2329,44 @@ public CustomBlobDescrContext customBlobDescr() { } public partial class CustomBlobArgsContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public SerInitContext[] serInit() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public SerInitContext serInit(int i) { - return GetRuleContext(i); - } + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public SerInitContext argument; [System.Diagnostics.DebuggerNonUserCode] public CompControlContext[] compControl() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public CompControlContext compControl(int i) { return GetRuleContext(i); } + [System.Diagnostics.DebuggerNonUserCode] public SerInitContext[] serInit() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public SerInitContext serInit(int i) { + return GetRuleContext(i); + } public CustomBlobArgsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_customBlobArgs; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomBlobArgs(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomBlobArgsContext customBlobArgs() { CustomBlobArgsContext _localctx = new CustomBlobArgsContext(Context, State); EnterRule(_localctx, 54, RULE_customBlobArgs); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 649; + State = 735; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,15,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { - State = 647; + State = 733; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__83: @@ -2339,8 +2386,9 @@ public CustomBlobArgsContext customBlobArgs() { case TYPE: case OBJECT: { - State = 645; - serInit(); + State = 729; + _localctx.argument = serInit(); + _localctx.Builder.Add(_localctx.argument.Value); } break; case T__31: @@ -2352,7 +2400,7 @@ public CustomBlobArgsContext customBlobArgs() { case PP_ENDIF: case PP_INCLUDE: { - State = 646; + State = 732; compControl(); } break; @@ -2361,7 +2409,7 @@ public CustomBlobArgsContext customBlobArgs() { } } } - State = 651; + State = 737; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,15,Context); } @@ -2373,12 +2421,25 @@ public CustomBlobArgsContext customBlobArgs() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class CustomBlobNVPairsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public FieldOrPropContext kind; + public SerializTypeContext argumentType; + public DottedNameContext name; + public SerInitContext value; + [System.Diagnostics.DebuggerNonUserCode] public CompControlContext[] compControl() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public CompControlContext compControl(int i) { + return GetRuleContext(i); + } [System.Diagnostics.DebuggerNonUserCode] public FieldOrPropContext[] fieldOrProp() { return GetRuleContexts(); } @@ -2403,54 +2464,48 @@ [System.Diagnostics.DebuggerNonUserCode] public SerInitContext[] serInit() { [System.Diagnostics.DebuggerNonUserCode] public SerInitContext serInit(int i) { return GetRuleContext(i); } - [System.Diagnostics.DebuggerNonUserCode] public CompControlContext[] compControl() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public CompControlContext compControl(int i) { - return GetRuleContext(i); - } public CustomBlobNVPairsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_customBlobNVPairs; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomBlobNVPairs(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomBlobNVPairsContext customBlobNVPairs() { CustomBlobNVPairsContext _localctx = new CustomBlobNVPairsContext(Context, State); EnterRule(_localctx, 56, RULE_customBlobNVPairs); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 661; + State = 748; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 416611827712L) != 0) || ((((_la - 267)) & ~0x3f) == 0 && ((1L << (_la - 267)) & 127L) != 0)) { { - State = 659; + State = 746; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__36: case T__37: { - State = 652; - fieldOrProp(); - State = 653; - serializType(); - State = 654; - dottedName(); - State = 655; + State = 738; + _localctx.kind = fieldOrProp(); + State = 739; + _localctx.argumentType = serializType(); + State = 740; + _localctx.name = dottedName(); + State = 741; Match(T__35); - State = 656; - serInit(); + State = 742; + _localctx.value = serInit(); + _localctx.Builder.Add(Actions.CreateCustomBlobNamedArgument( + _localctx.kind.Value, + _localctx.argumentType.Value, + _localctx.name.Value, + _localctx.value.Value)); } break; case T__31: @@ -2462,7 +2517,7 @@ public CustomBlobNVPairsContext customBlobNVPairs() { case PP_ENDIF: case PP_INCLUDE: { - State = 658; + State = 745; compControl(); } break; @@ -2470,7 +2525,7 @@ public CustomBlobNVPairsContext customBlobNVPairs() { throw new NoViableAltException(this); } } - State = 663; + State = 750; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -2482,23 +2537,20 @@ public CustomBlobNVPairsContext customBlobNVPairs() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class FieldOrPropContext : ParserRuleContext { + public byte Value; + public IToken kind; public FieldOrPropContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_fieldOrProp; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFieldOrProp(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -2509,15 +2561,17 @@ public FieldOrPropContext fieldOrProp() { try { EnterOuterAlt(_localctx, 1); { - State = 664; + State = 751; + _localctx.kind = TokenStream.LT(1); _la = TokenStream.LA(1); if ( !(_la==T__36 || _la==T__37) ) { - ErrorHandler.RecoverInline(this); + _localctx.kind = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } + _localctx.Value = Actions.GetCustomAttributeNamedArgumentKind(_localctx.kind); } } catch (RecognitionException re) { @@ -2532,6 +2586,9 @@ public FieldOrPropContext fieldOrProp() { } public partial class SerializTypeContext : ParserRuleContext { + public CILParser.SerializationTypeValue Value; + public SerializTypeElementContext element; + public IToken array; [System.Diagnostics.DebuggerNonUserCode] public SerializTypeElementContext serializTypeElement() { return GetRuleContext(0); } @@ -2541,34 +2598,30 @@ public SerializTypeContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_serializType; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSerializType(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SerializTypeContext serializType() { SerializTypeContext _localctx = new SerializTypeContext(Context, State); EnterRule(_localctx, 60, RULE_serializType); + _localctx.Value = CILParser.SerializationTypeValue.Error; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 666; - serializTypeElement(); - State = 668; + State = 754; + _localctx.element = serializTypeElement(); + State = 756; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==ARRAY_TYPE_NO_BOUNDS) { { - State = 667; - Match(ARRAY_TYPE_NO_BOUNDS); + State = 755; + _localctx.array = Match(ARRAY_TYPE_NO_BOUNDS); } } + _localctx.Value = Actions.CreateSerializationType(_localctx.element.Value, _localctx.array); } } catch (RecognitionException re) { @@ -2583,6 +2636,12 @@ public SerializTypeContext serializType() { } public partial class SerializTypeElementContext : ParserRuleContext { + public CILParser.SerializationTypeValue Value; + public SimpleTypeContext primitive; + public DottedNameContext alias; + public IToken simpleTypeToken; + public IToken quotedName; + public ClassNameContext classNameValue; [System.Diagnostics.DebuggerNonUserCode] public SimpleTypeContext simpleType() { return GetRuleContext(0); } @@ -2601,68 +2660,69 @@ public SerializTypeElementContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_serializTypeElement; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSerializTypeElement(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SerializTypeElementContext serializTypeElement() { SerializTypeElementContext _localctx = new SerializTypeElementContext(Context, State); EnterRule(_localctx, 62, RULE_serializTypeElement); + _localctx.Value = CILParser.SerializationTypeValue.Error; try { - State = 679; + State = 778; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,19,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 670; - simpleType(); + State = 760; + _localctx.primitive = simpleType(); + _localctx.Value = Actions.CreatePrimitiveSerializationType(_localctx.primitive.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 671; - dottedName(); + State = 763; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateSerializationTypeTypedef(_localctx, _localctx.alias.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 672; - Match(TYPE); + State = 766; + _localctx.simpleTypeToken = Match(TYPE); + _localctx.Value = Actions.CreateSimpleSerializationType(_localctx.simpleTypeToken); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 673; - Match(OBJECT); + State = 768; + _localctx.simpleTypeToken = Match(OBJECT); + _localctx.Value = Actions.CreateSimpleSerializationType(_localctx.simpleTypeToken); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 674; + State = 770; Match(ENUM); - State = 675; + State = 771; Match(T__38); - State = 676; - Match(SQSTRING); + State = 772; + _localctx.quotedName = Match(SQSTRING); + _localctx.Value = Actions.CreateEnumSerializationType(_localctx.quotedName); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 677; + State = 774; Match(ENUM); - State = 678; - className(); + State = 775; + _localctx.classNameValue = className(); + _localctx.Value = Actions.CreateEnumSerializationType(_localctx.classNameValue.Value); } break; } @@ -2679,6 +2739,10 @@ public SerializTypeElementContext serializTypeElement() { } public partial class ModuleHeadContext : ParserRuleContext { + public string? Value; + public bool HasName; + public bool IsExternal; + public DottedNameContext name; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MODULE() { return GetToken(CILParser.MODULE, 0); } [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); @@ -2688,47 +2752,45 @@ public ModuleHeadContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_moduleHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitModuleHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ModuleHeadContext moduleHead() { ModuleHeadContext _localctx = new ModuleHeadContext(Context, State); EnterRule(_localctx, 64, RULE_moduleHead); + _localctx.Value = null; try { - State = 687; + State = 791; ErrorHandler.Sync(this); switch ( Interpreter.AdaptivePredict(TokenStream,20,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 681; + State = 780; Match(MODULE); - State = 682; + State = 781; Match(T__39); - State = 683; - dottedName(); + State = 782; + _localctx.name = dottedName(); + Actions.SetModuleHeader(_localctx, _localctx.name.Value, true); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 684; + State = 785; Match(MODULE); - State = 685; - dottedName(); + State = 786; + _localctx.name = dottedName(); + Actions.SetModuleHeader(_localctx, _localctx.name.Value, false); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 686; + State = 789; Match(MODULE); + Actions.SetEmptyModuleHeader(_localctx); } break; } @@ -2745,6 +2807,12 @@ public ModuleHeadContext moduleHead() { } public partial class VtfixupDeclContext : ParserRuleContext { + public CILParser.VTableFixupValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public Int32Context count; + public VtfixupAttrContext attributes; + public IdContext label; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -2759,35 +2827,34 @@ public VtfixupDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_vtfixupDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitVtfixupDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public VtfixupDeclContext vtfixupDecl() { VtfixupDeclContext _localctx = new VtfixupDeclContext(Context, State); EnterRule(_localctx, 66, RULE_vtfixupDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; try { EnterOuterAlt(_localctx, 1); { - State = 689; + State = 793; Match(T__40); - State = 690; + State = 794; Match(T__41); - State = 691; - int32(); - State = 692; + State = 795; + _localctx.count = int32(); + State = 796; Match(T__42); - State = 693; - vtfixupAttr(0); - State = 694; + State = 797; + _localctx.attributes = vtfixupAttr(); + State = 798; Match(T__43); - State = 695; - id(); + State = 799; + _localctx.label = id(); + _localctx.Value = Actions.CreateVTableFixup( + (_localctx.count!=null?(_localctx.count.Start):null), + _localctx.attributes.Value, + (_localctx.label!=null?(_localctx.label.Start):null)); } } catch (RecognitionException re) { @@ -2796,119 +2863,105 @@ public VtfixupDeclContext vtfixupDecl() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } + ExitRule(); } return _localctx; } public partial class VtfixupAttrContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public VtfixupAttrContext vtfixupAttr() { - return GetRuleContext(0); + public ushort Value; + public VtfixupAttrElementContext attribute; + [System.Diagnostics.DebuggerNonUserCode] public VtfixupAttrElementContext[] vtfixupAttrElement() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public VtfixupAttrElementContext vtfixupAttrElement(int i) { + return GetRuleContext(i); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT32_() { return GetToken(CILParser.INT32_, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT64_() { return GetToken(CILParser.INT64_, 0); } public VtfixupAttrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_vtfixupAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitVtfixupAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public VtfixupAttrContext vtfixupAttr() { - return vtfixupAttr(0); - } - - private VtfixupAttrContext vtfixupAttr(int _p) { - ParserRuleContext _parentctx = Context; - int _parentState = State; - VtfixupAttrContext _localctx = new VtfixupAttrContext(Context, _parentState); - VtfixupAttrContext _prevctx = _localctx; - int _startState = 68; - EnterRecursionRule(_localctx, 68, RULE_vtfixupAttr, _p); + VtfixupAttrContext _localctx = new VtfixupAttrContext(Context, State); + EnterRule(_localctx, 68, RULE_vtfixupAttr); + _localctx.Value = 0; + int _la; try { - int _alt; EnterOuterAlt(_localctx, 1); { - { - } - Context.Stop = TokenStream.LT(-1); - State = 710; + State = 807; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,22,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( ParseListeners!=null ) - TriggerExitRuleEvent(); - _prevctx = _localctx; - { - State = 708; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,21,Context) ) { - case 1: - { - _localctx = new VtfixupAttrContext(_parentctx, _parentState); - PushNewRecursionContext(_localctx, _startState, RULE_vtfixupAttr); - State = 698; - if (!(Precpred(Context, 5))) throw new FailedPredicateException(this, "Precpred(Context, 5)"); - State = 699; - Match(INT32_); - } - break; - case 2: - { - _localctx = new VtfixupAttrContext(_parentctx, _parentState); - PushNewRecursionContext(_localctx, _startState, RULE_vtfixupAttr); - State = 700; - if (!(Precpred(Context, 4))) throw new FailedPredicateException(this, "Precpred(Context, 4)"); - State = 701; - Match(INT64_); - } - break; - case 3: - { - _localctx = new VtfixupAttrContext(_parentctx, _parentState); - PushNewRecursionContext(_localctx, _startState, RULE_vtfixupAttr); - State = 702; - if (!(Precpred(Context, 3))) throw new FailedPredicateException(this, "Precpred(Context, 3)"); - State = 703; - Match(T__44); - } - break; - case 4: - { - _localctx = new VtfixupAttrContext(_parentctx, _parentState); - PushNewRecursionContext(_localctx, _startState, RULE_vtfixupAttr); - State = 704; - if (!(Precpred(Context, 2))) throw new FailedPredicateException(this, "Precpred(Context, 2)"); - State = 705; - Match(T__45); - } - break; - case 5: - { - _localctx = new VtfixupAttrContext(_parentctx, _parentState); - PushNewRecursionContext(_localctx, _startState, RULE_vtfixupAttr); - State = 706; - if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)"); - State = 707; - Match(T__46); - } - break; - } - } + _la = TokenStream.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 246290604621824L) != 0) || _la==INT32_ || _la==INT64_) { + { + { + State = 802; + _localctx.attribute = vtfixupAttrElement(); + _localctx.Value = Actions.AddVTableFixupAttribute(_localctx.Value, _localctx.attribute.Value); } - State = 712; + } + State = 809; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,22,Context); + _la = TokenStream.LA(1); + } + _localctx.Value = Actions.CompleteVTableFixupAttributes(_localctx.Value); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class VtfixupAttrElementContext : ParserRuleContext { + public ushort Value; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT32_() { return GetToken(CILParser.INT32_, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT64_() { return GetToken(CILParser.INT64_, 0); } + public VtfixupAttrElementContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_vtfixupAttrElement; } } + } + + [RuleVersion(0)] + public VtfixupAttrElementContext vtfixupAttrElement() { + VtfixupAttrElementContext _localctx = new VtfixupAttrElementContext(Context, State); + EnterRule(_localctx, 70, RULE_vtfixupAttrElement); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 812; + _la = TokenStream.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 246290604621824L) != 0) || _la==INT32_ || _la==INT64_) ) { + ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = Actions.ParseVTableFixupAttribute(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -2916,12 +2969,16 @@ private VtfixupAttrContext vtfixupAttr(int _p) { ErrorHandler.Recover(this, re); } finally { - UnrollRecursionContexts(_parentctx); + ExitRule(); } return _localctx; } public partial class VtableDeclContext : ParserRuleContext { + public CILParser.RawVTableValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public BytesContext value; [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { return GetRuleContext(0); } @@ -2930,31 +2987,27 @@ public VtableDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_vtableDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitVtableDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public VtableDeclContext vtableDecl() { VtableDeclContext _localctx = new VtableDeclContext(Context, State); - EnterRule(_localctx, 70, RULE_vtableDecl); + EnterRule(_localctx, 72, RULE_vtableDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; try { EnterOuterAlt(_localctx, 1); { - State = 713; + State = 814; Match(T__47); - State = 714; + State = 815; Match(T__35); - State = 715; + State = 816; Match(T__29); - State = 716; - bytes(); - State = 717; + State = 817; + _localctx.value = bytes(); + State = 818; Match(T__30); + _localctx.Value = Actions.CreateRawVTable(_localctx.value.Value); } } catch (RecognitionException re) { @@ -2963,12 +3016,24 @@ public VtableDeclContext vtableDecl() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } + ExitRule(); } return _localctx; } public partial class NameSpaceHeadContext : ParserRuleContext { + public string Value; + public int InitialSyntaxErrorCount; + public DottedNameContext name; [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } @@ -2977,26 +3042,28 @@ public NameSpaceHeadContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_nameSpaceHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitNameSpaceHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public NameSpaceHeadContext nameSpaceHead() { NameSpaceHeadContext _localctx = new NameSpaceHeadContext(Context, State); - EnterRule(_localctx, 72, RULE_nameSpaceHead); + EnterRule(_localctx, 74, RULE_nameSpaceHead); + + Actions.PrepareNamespaceHeader(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = string.Empty; + try { EnterOuterAlt(_localctx, 1); { - State = 719; + State = 821; Match(T__48); - State = 720; - dottedName(); + State = 822; + _localctx.name = dottedName(); + _localctx.Value = _localctx.name.Value; } + Context.Stop = TokenStream.LT(-1); + Actions.BeginNamespace(_localctx, _localctx.Value, _localctx.InitialSyntaxErrorCount); } catch (RecognitionException re) { _localctx.exception = re; @@ -3010,6 +3077,14 @@ public NameSpaceHeadContext nameSpaceHead() { } public partial class ClassHeadContext : ParserRuleContext { + public CILParser.ClassHeaderValue Value; + public int InitialSyntaxErrorCount; + public CILParser.ClassHeaderBuilder Builder; + public ClassAttrContext attribute; + public DottedNameContext name; + public TyparsClauseContext genericParameters; + public ExtendsClauseContext baseType; + public ImplClauseContext interfaces; [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } @@ -3033,49 +3108,60 @@ public ClassHeadContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_classHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitClassHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ClassHeadContext classHead() { ClassHeadContext _localctx = new ClassHeadContext(Context, State); - EnterRule(_localctx, 74, RULE_classHead); + EnterRule(_localctx, 76, RULE_classHead); + + _localctx.Builder = Actions.PrepareClassHeader(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.ClassHeaderValue.Error; + try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 722; + State = 825; Match(T__49); - State = 726; + State = 831; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,23,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,22,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 723; - classAttr(); + State = 826; + _localctx.attribute = classAttr(); + Actions.AddClassHeaderAttribute(_localctx.Builder, _localctx.attribute.Value); } } } - State = 728; + State = 833; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,23,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,22,Context); } - State = 729; - dottedName(); - State = 730; - typarsClause(); - State = 731; - extendsClause(); - State = 732; - implClause(); + State = 834; + _localctx.name = dottedName(); + State = 835; + _localctx.genericParameters = typarsClause(); + State = 836; + _localctx.baseType = extendsClause(); + State = 837; + _localctx.interfaces = implClause(); + _localctx.Value = Actions.CreateClassHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + (_localctx.name!=null?(_localctx.name.Stop):null), + _localctx.name.Value, + _localctx.genericParameters.Value, + _localctx.baseType.Value, + _localctx.interfaces.Value); } + Context.Stop = TokenStream.LT(-1); + Actions.BeginType(_localctx, _localctx.Value); } catch (RecognitionException re) { _localctx.exception = re; @@ -3089,6 +3175,10 @@ public ClassHeadContext classHead() { } public partial class ClassAttrContext : ParserRuleContext { + public CILParser.ClassAttributeValue Value; + public IToken attribute; + public IToken visibility; + public Int32Context flags; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VALUE() { return GetToken(CILParser.VALUE, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ENUM() { return GetToken(CILParser.ENUM, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INTERFACE() { return GetToken(CILParser.INTERFACE, 0); } @@ -3102,227 +3192,249 @@ public ClassAttrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_classAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitClassAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ClassAttrContext classAttr() { ClassAttrContext _localctx = new ClassAttrContext(Context, State); - EnterRule(_localctx, 76, RULE_classAttr); + EnterRule(_localctx, 78, RULE_classAttr); + _localctx.Value = CILParser.ClassAttributeValue.Empty; try { - State = 771; + State = 904; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,24,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,23,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 734; - Match(T__50); + State = 840; + _localctx.attribute = Match(T__50); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 735; - Match(T__51); + State = 842; + _localctx.attribute = Match(T__51); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 736; - Match(VALUE); + State = 844; + _localctx.attribute = Match(VALUE); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 737; - Match(ENUM); + State = 846; + _localctx.attribute = Match(ENUM); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 738; - Match(INTERFACE); + State = 848; + _localctx.attribute = Match(INTERFACE); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 739; - Match(T__52); + State = 850; + _localctx.attribute = Match(T__52); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 740; - Match(T__53); + State = 852; + _localctx.attribute = Match(T__53); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 741; - Match(T__54); + State = 854; + _localctx.attribute = Match(T__54); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 742; - Match(T__55); + State = 856; + _localctx.attribute = Match(T__55); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 743; - Match(EXPLICIT); + State = 858; + _localctx.attribute = Match(EXPLICIT); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 744; - Match(T__14); + State = 860; + _localctx.attribute = Match(T__14); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 745; - Match(ANSI); + State = 862; + _localctx.attribute = Match(ANSI); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 746; - Match(T__56); + State = 864; + _localctx.attribute = Match(T__56); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 747; - Match(T__57); + State = 866; + _localctx.attribute = Match(T__57); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 748; - Match(T__58); + State = 868; + _localctx.attribute = Match(T__58); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 16: EnterOuterAlt(_localctx, 16); { - State = 749; - Match(T__59); + State = 870; + _localctx.attribute = Match(T__59); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 17: EnterOuterAlt(_localctx, 17); { - State = 750; - Match(T__60); + State = 872; + _localctx.attribute = Match(T__60); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 18: EnterOuterAlt(_localctx, 18); { - State = 751; + State = 874; Match(T__61); - State = 752; - Match(T__50); + State = 875; + _localctx.visibility = Match(T__50); + _localctx.Value = Actions.CreateNestedClassAttribute(_localctx.visibility); } break; case 19: EnterOuterAlt(_localctx, 19); { - State = 753; + State = 877; Match(T__61); - State = 754; - Match(T__51); + State = 878; + _localctx.visibility = Match(T__51); + _localctx.Value = Actions.CreateNestedClassAttribute(_localctx.visibility); } break; case 20: EnterOuterAlt(_localctx, 20); { - State = 755; + State = 880; Match(T__61); - State = 756; - Match(T__62); + State = 881; + _localctx.visibility = Match(T__62); + _localctx.Value = Actions.CreateNestedClassAttribute(_localctx.visibility); } break; case 21: EnterOuterAlt(_localctx, 21); { - State = 757; + State = 883; Match(T__61); - State = 758; - Match(T__63); + State = 884; + _localctx.visibility = Match(T__63); + _localctx.Value = Actions.CreateNestedClassAttribute(_localctx.visibility); } break; case 22: EnterOuterAlt(_localctx, 22); { - State = 759; + State = 886; Match(T__61); - State = 760; - Match(T__64); + State = 887; + _localctx.visibility = Match(T__64); + _localctx.Value = Actions.CreateNestedClassAttribute(_localctx.visibility); } break; case 23: EnterOuterAlt(_localctx, 23); { - State = 761; + State = 889; Match(T__61); - State = 762; - Match(T__65); + State = 890; + _localctx.visibility = Match(T__65); + _localctx.Value = Actions.CreateNestedClassAttribute(_localctx.visibility); } break; case 24: EnterOuterAlt(_localctx, 24); { - State = 763; - Match(T__66); + State = 892; + _localctx.attribute = Match(T__66); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 25: EnterOuterAlt(_localctx, 25); { - State = 764; - Match(T__67); + State = 894; + _localctx.attribute = Match(T__67); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 26: EnterOuterAlt(_localctx, 26); { - State = 765; - Match(T__68); + State = 896; + _localctx.attribute = Match(T__68); + _localctx.Value = Actions.CreateClassAttribute(_localctx.attribute); } break; case 27: EnterOuterAlt(_localctx, 27); { - State = 766; + State = 898; Match(T__69); - State = 767; + State = 899; Match(T__29); - State = 768; - int32(); - State = 769; + State = 900; + _localctx.flags = int32(); + State = 901; Match(T__30); + _localctx.Value = Actions.CreateRawClassAttribute((_localctx.flags!=null?(_localctx.flags.Start):null)); } break; } @@ -3339,6 +3451,8 @@ public ClassAttrContext classAttr() { } public partial class ExtendsClauseContext : ParserRuleContext { + public CILParser.TypeSpecificationValue? Value; + public TypeSpecContext baseType; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } @@ -3347,20 +3461,15 @@ public ExtendsClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_extendsClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitExtendsClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ExtendsClauseContext extendsClause() { ExtendsClauseContext _localctx = new ExtendsClauseContext(Context, State); - EnterRule(_localctx, 78, RULE_extendsClause); + EnterRule(_localctx, 80, RULE_extendsClause); + _localctx.Value = Actions.CreateEmptyClassBase(); try { - State = 776; + State = 911; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__16: @@ -3372,10 +3481,11 @@ public ExtendsClauseContext extendsClause() { case T__70: EnterOuterAlt(_localctx, 2); { - State = 774; + State = 907; Match(T__70); - State = 775; - typeSpec(); + State = 908; + _localctx.baseType = typeSpec(); + _localctx.Value = Actions.CreateClassBase(_localctx.baseType.Value); } break; default: @@ -3394,6 +3504,8 @@ public ExtendsClauseContext extendsClause() { } public partial class ImplClauseContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public ImplListContext interfaces; [System.Diagnostics.DebuggerNonUserCode] public ImplListContext implList() { return GetRuleContext(0); } @@ -3402,20 +3514,15 @@ public ImplClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_implClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitImplClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ImplClauseContext implClause() { ImplClauseContext _localctx = new ImplClauseContext(Context, State); - EnterRule(_localctx, 80, RULE_implClause); + EnterRule(_localctx, 82, RULE_implClause); + _localctx.Value = Actions.CreateEmptyInterfaceList(); try { - State = 781; + State = 918; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__16: @@ -3426,10 +3533,11 @@ public ImplClauseContext implClause() { case T__71: EnterOuterAlt(_localctx, 2); { - State = 779; + State = 914; Match(T__71); - State = 780; - implList(); + State = 915; + _localctx.interfaces = implList(); + _localctx.Value = _localctx.interfaces.Value; } break; default: @@ -3459,33 +3567,27 @@ public ClassDeclsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_classDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitClassDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ClassDeclsContext classDecls() { ClassDeclsContext _localctx = new ClassDeclsContext(Context, State); - EnterRule(_localctx, 82, RULE_classDecls); + EnterRule(_localctx, 84, RULE_classDecls); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 786; + State = 923; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1125938695831552L) != 0) || ((((_la - 73)) & ~0x3f) == 0 && ((1L << (_la - 73)) & 1189425290649010179L) != 0) || ((((_la - 139)) & ~0x3f) == 0 && ((1L << (_la - 139)) & 1152921504673955841L) != 0) || ((((_la - 243)) & ~0x3f) == 0 && ((1L << (_la - 243)) & 871552083145265153L) != 0)) { { { - State = 783; + State = 920; classDecl(); } } - State = 788; + State = 925; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -3503,6 +3605,10 @@ public ClassDeclsContext classDecls() { } public partial class ImplListContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public TypeSpecContext interfaceType; + public TypeSpecContext lastInterfaceType; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext[] typeSpec() { return GetRuleContexts(); } @@ -3514,42 +3620,39 @@ public ImplListContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_implList; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitImplList(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ImplListContext implList() { ImplListContext _localctx = new ImplListContext(Context, State); - EnterRule(_localctx, 84, RULE_implList); + EnterRule(_localctx, 86, RULE_implList); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 794; + State = 932; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,28,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,27,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 789; - typeSpec(); - State = 790; + State = 926; + _localctx.interfaceType = typeSpec(); + _localctx.Builder.Add(_localctx.interfaceType.Value); + State = 928; Match(T__27); } } } - State = 796; + State = 934; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,28,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,27,Context); } - State = 797; - typeSpec(); + State = 935; + _localctx.lastInterfaceType = typeSpec(); + _localctx.Builder.Add(_localctx.lastInterfaceType.Value); } } catch (RecognitionException re) { @@ -3558,34 +3661,30 @@ public ImplListContext implList() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class EsHeadContext : ParserRuleContext { + public bool AutoIncrement; public EsHeadContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_esHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitEsHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public EsHeadContext esHead() { EsHeadContext _localctx = new EsHeadContext(Context, State); - EnterRule(_localctx, 86, RULE_esHead); + EnterRule(_localctx, 88, RULE_esHead); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 799; + State = 938; _la = TokenStream.LA(1); if ( !(_la==T__72 || _la==T__73) ) { ErrorHandler.RecoverInline(this); @@ -3595,6 +3694,8 @@ public EsHeadContext esHead() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.AutoIncrement = Actions.IsAutoIncrementSourceDirective(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -3608,6 +3709,17 @@ public EsHeadContext esHead() { } public partial class ExtSourceSpecContext : ParserRuleContext { + public CILParser.SourceDirectiveValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public EsHeadContext head; + public Int32Context line; + public IToken path; + public Int32Context column; + public Int32Context startColumn; + public Int32Context endColumn; + public Int32Context startLine; + public Int32Context endLine; [System.Diagnostics.DebuggerNonUserCode] public EsHeadContext esHead() { return GetRuleContext(0); } @@ -3624,271 +3736,204 @@ public ExtSourceSpecContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_extSourceSpec; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitExtSourceSpec(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ExtSourceSpecContext extSourceSpec() { ExtSourceSpecContext _localctx = new ExtSourceSpecContext(Context, State); - EnterRule(_localctx, 88, RULE_extSourceSpec); + EnterRule(_localctx, 90, RULE_extSourceSpec); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + int _la; try { - State = 904; + State = 991; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,29,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,33,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 801; - esHead(); - State = 802; - int32(); - State = 803; - Match(SQSTRING); + State = 940; + _localctx.head = esHead(); + State = 941; + _localctx.line = int32(); + State = 943; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,28,Context) ) { + case 1: + { + State = 942; + _localctx.path = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==QSTRING || _la==SQSTRING) ) { + _localctx.path = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + break; + } + _localctx.Value = Actions.CreateSourceLine(_localctx.head.AutoIncrement, (_localctx.line!=null?(_localctx.line.Start):null), _localctx.path); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 805; - esHead(); - State = 806; - int32(); - } - break; - case 3: - EnterOuterAlt(_localctx, 3); - { - State = 808; - esHead(); - State = 809; - int32(); - State = 810; + State = 947; + _localctx.head = esHead(); + State = 948; + _localctx.line = int32(); + State = 949; Match(T__74); - State = 811; - int32(); - State = 812; - Match(SQSTRING); - } - break; - case 4: - EnterOuterAlt(_localctx, 4); - { - State = 814; - esHead(); - State = 815; - int32(); - State = 816; - Match(T__74); - State = 817; - int32(); + State = 950; + _localctx.column = int32(); + State = 952; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,29,Context) ) { + case 1: + { + State = 951; + _localctx.path = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==QSTRING || _la==SQSTRING) ) { + _localctx.path = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + break; } - break; - case 5: - EnterOuterAlt(_localctx, 5); - { - State = 819; - esHead(); - State = 820; - int32(); - State = 821; - Match(T__74); - State = 822; - int32(); - State = 823; - Match(T__27); - State = 824; - int32(); - State = 825; - Match(SQSTRING); + _localctx.Value = Actions.CreateSourceColumn(_localctx.head.AutoIncrement, (_localctx.line!=null?(_localctx.line.Start):null), (_localctx.column!=null?(_localctx.column.Start):null), _localctx.path); } break; - case 6: - EnterOuterAlt(_localctx, 6); + case 3: + EnterOuterAlt(_localctx, 3); { - State = 827; - esHead(); - State = 828; - int32(); - State = 829; + State = 956; + _localctx.head = esHead(); + State = 957; + _localctx.line = int32(); + State = 958; Match(T__74); - State = 830; - int32(); - State = 831; + State = 959; + _localctx.startColumn = int32(); + State = 960; Match(T__27); - State = 832; - int32(); + State = 961; + _localctx.endColumn = int32(); + State = 963; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,30,Context) ) { + case 1: + { + State = 962; + _localctx.path = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==QSTRING || _la==SQSTRING) ) { + _localctx.path = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + break; } - break; - case 7: - EnterOuterAlt(_localctx, 7); - { - State = 834; - esHead(); - State = 835; - int32(); - State = 836; - Match(T__27); - State = 837; - int32(); - State = 838; - Match(T__74); - State = 839; - int32(); - State = 840; - Match(SQSTRING); + _localctx.Value = Actions.CreateSourceColumnRange( + _localctx.head.AutoIncrement, + (_localctx.line!=null?(_localctx.line.Start):null), + (_localctx.startColumn!=null?(_localctx.startColumn.Start):null), + (_localctx.endColumn!=null?(_localctx.endColumn.Start):null), + _localctx.path); } break; - case 8: - EnterOuterAlt(_localctx, 8); + case 4: + EnterOuterAlt(_localctx, 4); { - State = 842; - esHead(); - State = 843; - int32(); - State = 844; + State = 967; + _localctx.head = esHead(); + State = 968; + _localctx.startLine = int32(); + State = 969; Match(T__27); - State = 845; - int32(); - State = 846; + State = 970; + _localctx.endLine = int32(); + State = 971; Match(T__74); - State = 847; - int32(); + State = 972; + _localctx.column = int32(); + State = 974; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,31,Context) ) { + case 1: + { + State = 973; + _localctx.path = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==QSTRING || _la==SQSTRING) ) { + _localctx.path = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + break; } - break; - case 9: - EnterOuterAlt(_localctx, 9); - { - State = 849; - esHead(); - State = 850; - int32(); - State = 851; - Match(T__27); - State = 852; - int32(); - State = 853; - Match(T__74); - State = 854; - int32(); - State = 855; - Match(T__27); - State = 856; - int32(); - State = 857; - Match(SQSTRING); + _localctx.Value = Actions.CreateSourceLineRange( + _localctx.head.AutoIncrement, + (_localctx.startLine!=null?(_localctx.startLine.Start):null), + (_localctx.endLine!=null?(_localctx.endLine.Start):null), + (_localctx.column!=null?(_localctx.column.Start):null), + _localctx.path); } break; - case 10: - EnterOuterAlt(_localctx, 10); + case 5: + EnterOuterAlt(_localctx, 5); { - State = 859; - esHead(); - State = 860; - int32(); - State = 861; - Match(T__27); - State = 862; - int32(); - State = 863; - Match(T__74); - State = 864; - int32(); - State = 865; + State = 978; + _localctx.head = esHead(); + State = 979; + _localctx.startLine = int32(); + State = 980; Match(T__27); - State = 866; - int32(); - } - break; - case 11: - EnterOuterAlt(_localctx, 11); - { - State = 868; - esHead(); - State = 869; - int32(); - State = 870; - Match(QSTRING); - } - break; - case 12: - EnterOuterAlt(_localctx, 12); - { - State = 872; - esHead(); - State = 873; - int32(); - State = 874; - Match(T__74); - State = 875; - int32(); - State = 876; - Match(QSTRING); - } - break; - case 13: - EnterOuterAlt(_localctx, 13); - { - State = 878; - esHead(); - State = 879; - int32(); - State = 880; + State = 981; + _localctx.endLine = int32(); + State = 982; Match(T__74); - State = 881; - int32(); - State = 882; - Match(T__27); - State = 883; - int32(); - State = 884; - Match(QSTRING); - } - break; - case 14: - EnterOuterAlt(_localctx, 14); - { - State = 886; - esHead(); - State = 887; - int32(); - State = 888; + State = 983; + _localctx.startColumn = int32(); + State = 984; Match(T__27); - State = 889; - int32(); - State = 890; - Match(T__74); - State = 891; - int32(); - State = 892; - Match(QSTRING); + State = 985; + _localctx.endColumn = int32(); + State = 987; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,32,Context) ) { + case 1: + { + State = 986; + _localctx.path = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==QSTRING || _la==SQSTRING) ) { + _localctx.path = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + } + break; } - break; - case 15: - EnterOuterAlt(_localctx, 15); - { - State = 894; - esHead(); - State = 895; - int32(); - State = 896; - Match(T__27); - State = 897; - int32(); - State = 898; - Match(T__74); - State = 899; - int32(); - State = 900; - Match(T__27); - State = 901; - int32(); - State = 902; - Match(QSTRING); + _localctx.Value = Actions.CreateSourceRange( + _localctx.head.AutoIncrement, + (_localctx.startLine!=null?(_localctx.startLine.Start):null), + (_localctx.endLine!=null?(_localctx.endLine.Start):null), + (_localctx.startColumn!=null?(_localctx.startColumn.Start):null), + (_localctx.endColumn!=null?(_localctx.endColumn.Start):null), + _localctx.path); } break; } @@ -3899,12 +3944,22 @@ public ExtSourceSpecContext extSourceSpec() { ErrorHandler.Recover(this, re); } finally { + Actions.EndSourceDirective(_localctx, _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; } public partial class FileDeclContext : ParserRuleContext { + public CILParser.FileDeclarationValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public CILParser.FileDeclarationBuilder Builder; + public FileAttrContext attribute; + public DottedNameContext name; + public FileEntryContext entry; + public BytesContext hash; + public FileEntryContext trailingEntry; [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } @@ -3915,99 +3970,79 @@ [System.Diagnostics.DebuggerNonUserCode] public FileEntryContext fileEntry(int i return GetRuleContext(i); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode HASH() { return GetToken(CILParser.HASH, 0); } - [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { - return GetRuleContext(0); - } [System.Diagnostics.DebuggerNonUserCode] public FileAttrContext[] fileAttr() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public FileAttrContext fileAttr(int i) { return GetRuleContext(i); } + [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { + return GetRuleContext(0); + } public FileDeclContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_fileDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFileDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FileDeclContext fileDecl() { FileDeclContext _localctx = new FileDeclContext(Context, State); - EnterRule(_localctx, 90, RULE_fileDecl); + EnterRule(_localctx, 92, RULE_fileDecl); + + _localctx.Builder = new CILParser.FileDeclarationBuilder(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + int _la; try { - State = 932; + EnterOuterAlt(_localctx, 1); + { + State = 993; + Match(T__20); + State = 999; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,32,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); + _la = TokenStream.LA(1); + while (_la==T__75) { { - State = 906; - Match(T__20); - State = 910; + { + State = 994; + _localctx.attribute = fileAttr(); + Actions.AddFileAttribute(_localctx.Builder, _localctx.attribute.Value); + } + } + State = 1001; ErrorHandler.Sync(this); _la = TokenStream.LA(1); - while (_la==T__75) { - { - { - State = 907; - fileAttr(); - } - } - State = 912; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 913; - dottedName(); - State = 914; - fileEntry(); - State = 915; + } + State = 1002; + _localctx.name = dottedName(); + Actions.SetFileName(_localctx.Builder, _localctx.name.Value); + State = 1004; + _localctx.entry = fileEntry(); + Actions.AddFileEntry(_localctx.Builder, _localctx.entry.Value); + State = 1015; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==HASH) { + { + State = 1006; Match(HASH); - State = 916; + State = 1007; Match(T__35); - State = 917; + State = 1008; Match(T__29); - State = 918; - bytes(); - State = 919; + State = 1009; + _localctx.hash = bytes(); + State = 1010; Match(T__30); - State = 920; - fileEntry(); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 922; - Match(T__20); - State = 926; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==T__75) { - { - { - State = 923; - fileAttr(); - } - } - State = 928; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); + Actions.SetFileHash(_localctx.Builder, _localctx.hash.Value); + State = 1012; + _localctx.trailingEntry = fileEntry(); + Actions.AddFileEntry(_localctx.Builder, _localctx.trailingEntry.Value); } - State = 929; - dottedName(); - State = 930; - fileEntry(); - } - break; + } + } } catch (RecognitionException re) { @@ -4016,35 +4051,33 @@ public FileDeclContext fileDecl() { ErrorHandler.Recover(this, re); } finally { + Actions.EndFileDeclaration(_localctx, _localctx.Builder, _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; } public partial class FileAttrContext : ParserRuleContext { + public bool Value; public FileAttrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_fileAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFileAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FileAttrContext fileAttr() { FileAttrContext _localctx = new FileAttrContext(Context, State); - EnterRule(_localctx, 92, RULE_fileAttr); + EnterRule(_localctx, 94, RULE_fileAttr); try { EnterOuterAlt(_localctx, 1); { - State = 934; + State = 1017; Match(T__75); } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = Actions.ParseFileAttribute(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -4058,26 +4091,23 @@ public FileAttrContext fileAttr() { } public partial class FileEntryContext : ParserRuleContext { + public bool Value; + public IToken entry; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ENTRYPOINT() { return GetToken(CILParser.ENTRYPOINT, 0); } public FileEntryContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_fileEntry; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFileEntry(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FileEntryContext fileEntry() { FileEntryContext _localctx = new FileEntryContext(Context, State); - EnterRule(_localctx, 94, RULE_fileEntry); + EnterRule(_localctx, 96, RULE_fileEntry); + _localctx.Value = false; try { - State = 938; + State = 1022; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__15: @@ -4127,8 +4157,9 @@ public FileEntryContext fileEntry() { case ENTRYPOINT: EnterOuterAlt(_localctx, 2); { - State = 937; - Match(ENTRYPOINT); + State = 1020; + _localctx.entry = Match(ENTRYPOINT); + _localctx.Value = Actions.ParseFileEntry(_localctx.entry); } break; default: @@ -4147,28 +4178,24 @@ public FileEntryContext fileEntry() { } public partial class AsmAttrAnyContext : ParserRuleContext { + public System.Reflection.AssemblyFlags Value; + public System.Reflection.AssemblyFlags Mask; public AsmAttrAnyContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_asmAttrAny; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAsmAttrAny(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AsmAttrAnyContext asmAttrAny() { AsmAttrAnyContext _localctx = new AsmAttrAnyContext(Context, State); - EnterRule(_localctx, 96, RULE_asmAttrAny); + EnterRule(_localctx, 98, RULE_asmAttrAny); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 940; + State = 1024; _la = TokenStream.LA(1); if ( !(_la==T__1 || _la==T__60 || ((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & 127L) != 0)) ) { ErrorHandler.RecoverInline(this); @@ -4178,6 +4205,8 @@ public AsmAttrAnyContext asmAttrAny() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + Actions.SetAssemblyAttribute(_localctx); } catch (RecognitionException re) { _localctx.exception = re; @@ -4191,6 +4220,8 @@ public AsmAttrAnyContext asmAttrAny() { } public partial class AsmAttrContext : ParserRuleContext { + public System.Reflection.AssemblyFlags Value; + public AsmAttrAnyContext attribute; [System.Diagnostics.DebuggerNonUserCode] public AsmAttrAnyContext[] asmAttrAny() { return GetRuleContexts(); } @@ -4202,33 +4233,32 @@ public AsmAttrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_asmAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAsmAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AsmAttrContext asmAttr() { AsmAttrContext _localctx = new AsmAttrContext(Context, State); - EnterRule(_localctx, 98, RULE_asmAttr); + EnterRule(_localctx, 100, RULE_asmAttr); + _localctx.Value = 0; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 945; + State = 1031; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__1 || _la==T__60 || ((((_la - 77)) & ~0x3f) == 0 && ((1L << (_la - 77)) & 127L) != 0)) { { { - State = 942; - asmAttrAny(); + State = 1026; + _localctx.attribute = asmAttrAny(); + _localctx.Value = Actions.AddAssemblyAttribute( + _localctx.Value, + _localctx.attribute.Value, + _localctx.attribute.Mask); } } - State = 947; + State = 1033; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -4245,67 +4275,122 @@ public AsmAttrContext asmAttr() { return _localctx; } - public partial class Instr_noneContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_NONE() { return GetToken(CILParser.INSTR_NONE, 0); } - public Instr_noneContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { + public partial class InstrContext : ParserRuleContext { + public IToken op; + public MethodRefContext methodOperand; + public FieldRefContext fieldOperand; + public MdtokenContext metadataOperand; + public TypeSpecContext typeOperand; + public CalliSignatureContext signatureOperand; + public OwnerTypeContext ownerOperand; + [System.Diagnostics.DebuggerNonUserCode] public SimpleInstrContext simpleInstr() { + return GetRuleContext(0); } - public override int RuleIndex { get { return RULE_instr_none; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_none(this); - else return visitor.VisitChildren(this); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_METHOD() { return GetToken(CILParser.INSTR_METHOD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public MethodRefContext methodRef() { + return GetRuleContext(0); } - } - - [RuleVersion(0)] - public Instr_noneContext instr_none() { - Instr_noneContext _localctx = new Instr_noneContext(Context, State); - EnterRule(_localctx, 100, RULE_instr_none); - try { - EnterOuterAlt(_localctx, 1); - { - State = 948; - Match(INSTR_NONE); - } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_FIELD() { return GetToken(CILParser.INSTR_FIELD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public FieldRefContext fieldRef() { + return GetRuleContext(0); } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); + [System.Diagnostics.DebuggerNonUserCode] public MdtokenContext mdtoken() { + return GetRuleContext(0); } - finally { - ExitRule(); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_TYPE() { return GetToken(CILParser.INSTR_TYPE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { + return GetRuleContext(0); } - return _localctx; - } - - public partial class Instr_varContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_VAR() { return GetToken(CILParser.INSTR_VAR, 0); } - public Instr_varContext(ParserRuleContext parent, int invokingState) + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_SIG() { return GetToken(CILParser.INSTR_SIG, 0); } + [System.Diagnostics.DebuggerNonUserCode] public CalliSignatureContext calliSignature() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_TOK() { return GetToken(CILParser.INSTR_TOK, 0); } + [System.Diagnostics.DebuggerNonUserCode] public OwnerTypeContext ownerType() { + return GetRuleContext(0); + } + public InstrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr_var; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_var(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_instr; } } } [RuleVersion(0)] - public Instr_varContext instr_var() { - Instr_varContext _localctx = new Instr_varContext(Context, State); - EnterRule(_localctx, 102, RULE_instr_var); - try { - EnterOuterAlt(_localctx, 1); - { - State = 950; - Match(INSTR_VAR); + public InstrContext instr() { + InstrContext _localctx = new InstrContext(Context, State); + EnterRule(_localctx, 102, RULE_instr); + try { + State = 1059; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,38,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); + { + State = 1034; + simpleInstr(); + } + break; + case 2: + EnterOuterAlt(_localctx, 2); + { + State = 1035; + _localctx.op = Match(INSTR_METHOD); + State = 1036; + _localctx.methodOperand = methodRef(); + Actions.EmitMethodReferenceInstruction(_localctx.op, _localctx.methodOperand); + } + break; + case 3: + EnterOuterAlt(_localctx, 3); + { + State = 1039; + _localctx.op = Match(INSTR_FIELD); + State = 1040; + _localctx.fieldOperand = fieldRef(); + Actions.EmitFieldReferenceInstruction(_localctx.op, _localctx.fieldOperand); + } + break; + case 4: + EnterOuterAlt(_localctx, 4); + { + State = 1043; + _localctx.op = Match(INSTR_FIELD); + State = 1044; + _localctx.metadataOperand = mdtoken(); + Actions.EmitMetadataTokenInstruction(_localctx.op, _localctx.metadataOperand); + } + break; + case 5: + EnterOuterAlt(_localctx, 5); + { + State = 1047; + _localctx.op = Match(INSTR_TYPE); + State = 1048; + _localctx.typeOperand = typeSpec(); + Actions.EmitTypeReferenceInstruction(_localctx.op, _localctx.typeOperand); + } + break; + case 6: + EnterOuterAlt(_localctx, 6); + { + State = 1051; + _localctx.op = Match(INSTR_SIG); + State = 1052; + _localctx.signatureOperand = calliSignature(); + Actions.EmitCalliInstruction(_localctx.op, _localctx.signatureOperand); + } + break; + case 7: + EnterOuterAlt(_localctx, 7); + { + State = 1055; + _localctx.op = Match(INSTR_TOK); + State = 1056; + _localctx.ownerOperand = ownerType(); + Actions.EmitOwnerTokenInstruction(_localctx.op, _localctx.ownerOperand); + } + break; } } catch (RecognitionException re) { @@ -4319,68 +4404,271 @@ public Instr_varContext instr_var() { return _localctx; } - public partial class Instr_iContext : ParserRuleContext { + public partial class SimpleInstrContext : ParserRuleContext { + public CILParser.SwitchInstructionBuilder SwitchBuilder; + public IToken op; + public Int32Context index; + public IdContext name; + public Int32Context value32; + public Int64Context value64; + public Float64Context value; + public Int64Context integerValue; + public BytesContext rawFloat; + public Int32Context offset; + public IdContext label; + public CompQstringContext userString; + public CompQstringContext ansiString; + public BytesContext rawString; + public Int32Context rawToken; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_NONE() { return GetToken(CILParser.INSTR_NONE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_VAR() { return GetToken(CILParser.INSTR_VAR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { + return GetRuleContext(0); + } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_I() { return GetToken(CILParser.INSTR_I, 0); } - public Instr_iContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_I8() { return GetToken(CILParser.INSTR_I8, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int64Context int64() { + return GetRuleContext(0); } - public override int RuleIndex { get { return RULE_instr_i; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_i(this); - else return visitor.VisitChildren(this); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_R() { return GetToken(CILParser.INSTR_R, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Float64Context float64() { + return GetRuleContext(0); } - } - - [RuleVersion(0)] - public Instr_iContext instr_i() { - Instr_iContext _localctx = new Instr_iContext(Context, State); - EnterRule(_localctx, 104, RULE_instr_i); - try { - EnterOuterAlt(_localctx, 1); - { - State = 952; - Match(INSTR_I); - } + [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { + return GetRuleContext(0); } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_BRTARGET() { return GetToken(CILParser.INSTR_BRTARGET, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_STRING() { return GetToken(CILParser.INSTR_STRING, 0); } + [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext compQstring() { + return GetRuleContext(0); } - finally { - ExitRule(); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANSI() { return GetToken(CILParser.ANSI, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_TOK() { return GetToken(CILParser.INSTR_TOK, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_SWITCH() { return GetToken(CILParser.INSTR_SWITCH, 0); } + [System.Diagnostics.DebuggerNonUserCode] public LabelsContext labels() { + return GetRuleContext(0); } - return _localctx; - } - - public partial class Instr_i8Context : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_I8() { return GetToken(CILParser.INSTR_I8, 0); } - public Instr_i8Context(ParserRuleContext parent, int invokingState) + public SimpleInstrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr_i8; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_i8(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_simpleInstr; } } } [RuleVersion(0)] - public Instr_i8Context instr_i8() { - Instr_i8Context _localctx = new Instr_i8Context(Context, State); - EnterRule(_localctx, 106, RULE_instr_i8); + public SimpleInstrContext simpleInstr() { + SimpleInstrContext _localctx = new SimpleInstrContext(Context, State); + EnterRule(_localctx, 104, RULE_simpleInstr); try { - EnterOuterAlt(_localctx, 1); - { - State = 954; - Match(INSTR_I8); + State = 1139; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,40,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); + { + State = 1061; + _localctx.op = Match(INSTR_NONE); + Actions.EmitNoOperandInstruction(_localctx.op); + } + break; + case 2: + EnterOuterAlt(_localctx, 2); + { + State = 1063; + _localctx.op = Match(INSTR_VAR); + State = 1064; + _localctx.index = int32(); + Actions.EmitVariableIndexInstruction(_localctx.op, (_localctx.index!=null?(_localctx.index.Start):null)); + } + break; + case 3: + EnterOuterAlt(_localctx, 3); + { + State = 1067; + _localctx.op = Match(INSTR_VAR); + State = 1068; + _localctx.name = id(); + Actions.EmitVariableNameInstruction(_localctx.op, (_localctx.name!=null?(_localctx.name.Start):null)); + } + break; + case 4: + EnterOuterAlt(_localctx, 4); + { + State = 1071; + _localctx.op = Match(INSTR_I); + State = 1072; + _localctx.value32 = int32(); + Actions.EmitInt32Instruction(_localctx.op, (_localctx.value32!=null?(_localctx.value32.Start):null)); + } + break; + case 5: + EnterOuterAlt(_localctx, 5); + { + State = 1075; + _localctx.op = Match(INSTR_I8); + State = 1076; + _localctx.value64 = int64(); + Actions.EmitInt64Instruction(_localctx.op, (_localctx.value64!=null?(_localctx.value64.Start):null)); + } + break; + case 6: + EnterOuterAlt(_localctx, 6); + { + State = 1079; + _localctx.op = Match(INSTR_R); + State = 1080; + _localctx.value = float64(); + Actions.EmitFloatingInstruction(_localctx.op, _localctx.value.Value); + } + break; + case 7: + EnterOuterAlt(_localctx, 7); + { + State = 1083; + _localctx.op = Match(INSTR_R); + State = 1084; + _localctx.integerValue = int64(); + Actions.EmitFloatingInstruction(_localctx.op, (_localctx.integerValue!=null?(_localctx.integerValue.Start):null)); + } + break; + case 8: + EnterOuterAlt(_localctx, 8); + { + State = 1087; + _localctx.op = Match(INSTR_R); + State = 1088; + Match(T__29); + State = 1089; + _localctx.rawFloat = bytes(); + State = 1090; + Match(T__30); + Actions.EmitRawFloatingInstruction(_localctx.op, _localctx.rawFloat.Value, (_localctx.rawFloat!=null?(_localctx.rawFloat.Start):null)); + } + break; + case 9: + EnterOuterAlt(_localctx, 9); + { + State = 1093; + _localctx.op = Match(INSTR_R); + State = 1094; + Match(T__83); + State = 1095; + Match(T__29); + State = 1096; + _localctx.rawFloat = bytes(); + State = 1097; + Match(T__30); + Actions.EmitRawFloatingInstruction(_localctx.op, _localctx.rawFloat.Value, (_localctx.rawFloat!=null?(_localctx.rawFloat.Start):null)); + } + break; + case 10: + EnterOuterAlt(_localctx, 10); + { + State = 1100; + _localctx.op = Match(INSTR_BRTARGET); + State = 1101; + _localctx.offset = int32(); + Actions.EmitBranchOffsetInstruction(_localctx.op, (_localctx.offset!=null?(_localctx.offset.Start):null)); + } + break; + case 11: + EnterOuterAlt(_localctx, 11); + { + State = 1104; + _localctx.op = Match(INSTR_BRTARGET); + State = 1105; + _localctx.label = id(); + Actions.EmitBranchLabelInstruction(_localctx.op, (_localctx.label!=null?(_localctx.label.Start):null)); + } + break; + case 12: + EnterOuterAlt(_localctx, 12); + { + State = 1108; + _localctx.op = Match(INSTR_STRING); + State = 1109; + _localctx.userString = compQstring(); + Actions.EmitStringInstruction(_localctx.op, _localctx.userString.Value); + } + break; + case 13: + EnterOuterAlt(_localctx, 13); + { + State = 1112; + _localctx.op = Match(INSTR_STRING); + State = 1113; + Match(ANSI); + State = 1114; + Match(T__29); + State = 1115; + _localctx.ansiString = compQstring(); + State = 1116; + Match(T__30); + Actions.EmitAnsiStringInstruction(_localctx.op, _localctx.ansiString.Value); + } + break; + case 14: + EnterOuterAlt(_localctx, 14); + { + State = 1119; + _localctx.op = Match(INSTR_STRING); + State = 1120; + Match(T__83); + State = 1121; + Match(T__29); + State = 1122; + _localctx.rawString = bytes(); + State = 1123; + Match(T__30); + Actions.EmitRawStringInstruction(_localctx.op, _localctx.rawString.Value); + } + break; + case 15: + EnterOuterAlt(_localctx, 15); + { + State = 1126; + _localctx.op = Match(INSTR_TOK); + State = 1127; + _localctx.rawToken = int32(); + Actions.EmitRawTokenInstruction(_localctx.op, (_localctx.rawToken!=null?(_localctx.rawToken.Start):null)); + } + break; + case 16: + EnterOuterAlt(_localctx, 16); + { + State = 1130; + _localctx.op = Match(INSTR_SWITCH); + _localctx.SwitchBuilder = Actions.CreateSwitchInstruction(_localctx.op); + State = 1137; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case T__29: + { + State = 1132; + Match(T__29); + State = 1133; + labels(_localctx.SwitchBuilder); + State = 1134; + Match(T__30); + } + break; + case T__84: + { + State = 1136; + Match(T__84); + } + break; + default: + throw new NoViableAltException(this); + } + } + break; } + Context.Stop = TokenStream.LT(-1); + Actions.CompleteSwitchInstruction(_localctx.SwitchBuilder); } catch (RecognitionException re) { _localctx.exception = re; @@ -4393,30 +4681,47 @@ public Instr_i8Context instr_i8() { return _localctx; } - public partial class Instr_rContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_R() { return GetToken(CILParser.INSTR_R, 0); } - public Instr_rContext(ParserRuleContext parent, int invokingState) + public partial class CalliSignatureContext : ParserRuleContext { + public CILParser.CalliSignatureValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public CallConvContext convention; + public TypeContext returnType; + public SigArgsContext arguments; + [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public SigArgsContext sigArgs() { + return GetRuleContext(0); + } + public CalliSignatureContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr_r; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_r(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_calliSignature; } } } [RuleVersion(0)] - public Instr_rContext instr_r() { - Instr_rContext _localctx = new Instr_rContext(Context, State); - EnterRule(_localctx, 108, RULE_instr_r); + public CalliSignatureContext calliSignature() { + CalliSignatureContext _localctx = new CalliSignatureContext(Context, State); + EnterRule(_localctx, 106, RULE_calliSignature); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CalliSignatureValue.Error; + try { EnterOuterAlt(_localctx, 1); { - State = 956; - Match(INSTR_R); + State = 1141; + _localctx.convention = callConv(); + State = 1142; + _localctx.returnType = type(); + State = 1143; + _localctx.arguments = sigArgs(); + _localctx.Value = Actions.CreateCalliSignature(_localctx.convention.Value, _localctx.returnType.Value, _localctx.arguments.Value); } } catch (RecognitionException re) { @@ -4425,72 +4730,178 @@ public Instr_rContext instr_r() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } - public partial class Instr_brtargetContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_BRTARGET() { return GetToken(CILParser.INSTR_BRTARGET, 0); } - public Instr_brtargetContext(ParserRuleContext parent, int invokingState) + public partial class LabelsContext : ParserRuleContext { + public CILParser.SwitchInstructionBuilder Builder; + public IdContext headLabel; + public Int32Context headOffset; + public IdContext tailLabel; + public Int32Context tailOffset; + [System.Diagnostics.DebuggerNonUserCode] public IdContext[] id() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public IdContext id(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32(int i) { + return GetRuleContext(i); + } + public LabelsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public LabelsContext(ParserRuleContext parent, int invokingState, CILParser.SwitchInstructionBuilder Builder) : base(parent, invokingState) { + this.Builder = Builder; } - public override int RuleIndex { get { return RULE_instr_brtarget; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_brtarget(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_labels; } } } [RuleVersion(0)] - public Instr_brtargetContext instr_brtarget() { - Instr_brtargetContext _localctx = new Instr_brtargetContext(Context, State); - EnterRule(_localctx, 110, RULE_instr_brtarget); + public LabelsContext labels(CILParser.SwitchInstructionBuilder Builder) { + LabelsContext _localctx = new LabelsContext(Context, State, Builder); + EnterRule(_localctx, 108, RULE_labels); try { - EnterOuterAlt(_localctx, 1); - { - State = 958; - Match(INSTR_BRTARGET); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Instr_methodContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_METHOD() { return GetToken(CILParser.INSTR_METHOD, 0); } - public Instr_methodContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_instr_method; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_method(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Instr_methodContext instr_method() { - Instr_methodContext _localctx = new Instr_methodContext(Context, State); - EnterRule(_localctx, 112, RULE_instr_method); - try { - EnterOuterAlt(_localctx, 1); - { - State = 960; - Match(INSTR_METHOD); + int _alt; + State = 1170; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case T__30: + EnterOuterAlt(_localctx, 1); + { + } + break; + case T__0: + case T__1: + case T__2: + case T__3: + case T__4: + case T__5: + case T__6: + case T__7: + case T__8: + case T__9: + case T__10: + case T__11: + case T__12: + case T__13: + case T__14: + case INT32: + case VALUE: + case INSTANCE: + case UNMANAGED: + case SQSTRING: + case ID: + EnterOuterAlt(_localctx, 2); + { + State = 1159; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,42,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + State = 1153; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case T__0: + case T__1: + case T__2: + case T__3: + case T__4: + case T__5: + case T__6: + case T__7: + case T__8: + case T__9: + case T__10: + case T__11: + case T__12: + case T__13: + case T__14: + case VALUE: + case INSTANCE: + case UNMANAGED: + case SQSTRING: + case ID: + { + State = 1147; + _localctx.headLabel = id(); + Actions.AddSwitchLabel(_localctx.Builder, (_localctx.headLabel!=null?(_localctx.headLabel.Start):null)); + } + break; + case INT32: + { + State = 1150; + _localctx.headOffset = int32(); + Actions.AddSwitchOffset(_localctx.Builder, (_localctx.headOffset!=null?(_localctx.headOffset.Start):null)); + } + break; + default: + throw new NoViableAltException(this); + } + State = 1155; + Match(T__27); + } + } + } + State = 1161; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,42,Context); + } + State = 1168; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case T__0: + case T__1: + case T__2: + case T__3: + case T__4: + case T__5: + case T__6: + case T__7: + case T__8: + case T__9: + case T__10: + case T__11: + case T__12: + case T__13: + case T__14: + case VALUE: + case INSTANCE: + case UNMANAGED: + case SQSTRING: + case ID: + { + State = 1162; + _localctx.tailLabel = id(); + Actions.AddSwitchLabel(_localctx.Builder, (_localctx.tailLabel!=null?(_localctx.tailLabel.Start):null)); + } + break; + case INT32: + { + State = 1165; + _localctx.tailOffset = int32(); + Actions.AddSwitchOffset(_localctx.Builder, (_localctx.tailOffset!=null?(_localctx.tailOffset.Start):null)); + } + break; + default: + throw new NoViableAltException(this); + } + } + break; + default: + throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -4504,30 +4915,59 @@ public Instr_methodContext instr_method() { return _localctx; } - public partial class Instr_fieldContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_FIELD() { return GetToken(CILParser.INSTR_FIELD, 0); } - public Instr_fieldContext(ParserRuleContext parent, int invokingState) + public partial class TypeArgsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public TypeContext argument; + public TypeContext lastArgument; + [System.Diagnostics.DebuggerNonUserCode] public TypeContext[] type() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public TypeContext type(int i) { + return GetRuleContext(i); + } + public TypeArgsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr_field; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_field(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_typeArgs; } } } [RuleVersion(0)] - public Instr_fieldContext instr_field() { - Instr_fieldContext _localctx = new Instr_fieldContext(Context, State); - EnterRule(_localctx, 114, RULE_instr_field); + public TypeArgsContext typeArgs() { + TypeArgsContext _localctx = new TypeArgsContext(Context, State); + EnterRule(_localctx, 110, RULE_typeArgs); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { + int _alt; EnterOuterAlt(_localctx, 1); { - State = 962; - Match(INSTR_FIELD); + State = 1172; + Match(T__85); + State = 1179; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,45,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + State = 1173; + _localctx.argument = type(); + _localctx.Builder.Add(_localctx.argument.Value); + State = 1175; + Match(T__27); + } + } + } + State = 1181; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,45,Context); + } + State = 1182; + _localctx.lastArgument = type(); + _localctx.Builder.Add(_localctx.lastArgument.Value); + State = 1184; + Match(T__86); } } catch (RecognitionException re) { @@ -4536,35 +4976,65 @@ public Instr_fieldContext instr_field() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } - public partial class Instr_typeContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_TYPE() { return GetToken(CILParser.INSTR_TYPE, 0); } - public Instr_typeContext(ParserRuleContext parent, int invokingState) + public partial class BoundsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public BoundContext item; + public BoundContext lastItem; + [System.Diagnostics.DebuggerNonUserCode] public BoundContext[] bound() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public BoundContext bound(int i) { + return GetRuleContext(i); + } + public BoundsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr_type; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_type(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_bounds; } } } [RuleVersion(0)] - public Instr_typeContext instr_type() { - Instr_typeContext _localctx = new Instr_typeContext(Context, State); - EnterRule(_localctx, 116, RULE_instr_type); + public BoundsContext bounds() { + BoundsContext _localctx = new BoundsContext(Context, State); + EnterRule(_localctx, 112, RULE_bounds); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { + int _alt; EnterOuterAlt(_localctx, 1); { - State = 964; - Match(INSTR_TYPE); + State = 1186; + Match(T__41); + State = 1193; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,46,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + State = 1187; + _localctx.item = bound(); + _localctx.Builder.Add(Actions.CreateArrayBound(_localctx.item)); + State = 1189; + Match(T__27); + } + } + } + State = 1195; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,46,Context); + } + State = 1196; + _localctx.lastItem = bound(); + _localctx.Builder.Add(Actions.CreateArrayBound(_localctx.lastItem)); + State = 1198; + Match(T__42); } } catch (RecognitionException re) { @@ -4573,35 +5043,80 @@ public Instr_typeContext instr_type() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } - public partial class Instr_stringContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_STRING() { return GetToken(CILParser.INSTR_STRING, 0); } - public Instr_stringContext(ParserRuleContext parent, int invokingState) + public partial class SigArgsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public SigArgContext argument; + public SigArgContext lastArgument; + [System.Diagnostics.DebuggerNonUserCode] public SigArgContext[] sigArg() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public SigArgContext sigArg(int i) { + return GetRuleContext(i); + } + public SigArgsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr_string; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_string(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_sigArgs; } } } [RuleVersion(0)] - public Instr_stringContext instr_string() { - Instr_stringContext _localctx = new Instr_stringContext(Context, State); - EnterRule(_localctx, 118, RULE_instr_string); + public SigArgsContext sigArgs() { + SigArgsContext _localctx = new SigArgsContext(Context, State); + EnterRule(_localctx, 114, RULE_sigArgs); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { - EnterOuterAlt(_localctx, 1); - { - State = 966; - Match(INSTR_STRING); + int _alt; + State = 1215; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case T__29: + EnterOuterAlt(_localctx, 1); + { + State = 1200; + Match(T__29); + State = 1207; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,47,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + State = 1201; + _localctx.argument = sigArg(); + _localctx.Builder.Add(_localctx.argument.Value); + State = 1203; + Match(T__27); + } + } + } + State = 1209; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,47,Context); + } + State = 1210; + _localctx.lastArgument = sigArg(); + _localctx.Builder.Add(_localctx.lastArgument.Value); + State = 1212; + Match(T__30); + } + break; + case T__84: + EnterOuterAlt(_localctx, 2); + { + State = 1214; + Match(T__84); + } + break; + default: + throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -4610,109 +5125,78 @@ public Instr_stringContext instr_string() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } - public partial class Instr_sigContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_SIG() { return GetToken(CILParser.INSTR_SIG, 0); } - public Instr_sigContext(ParserRuleContext parent, int invokingState) + public partial class SigArgContext : ParserRuleContext { + public CILParser.SignatureArgumentValue Value; + public ParamAttrContext attributes; + public TypeContext argumentType; + public MarshalClauseContext marshalling; + public IdContext name; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELLIPSIS() { return GetToken(CILParser.ELLIPSIS, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ParamAttrContext paramAttr() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public MarshalClauseContext marshalClause() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { + return GetRuleContext(0); + } + public SigArgContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr_sig; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_sig(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_sigArg; } } } [RuleVersion(0)] - public Instr_sigContext instr_sig() { - Instr_sigContext _localctx = new Instr_sigContext(Context, State); - EnterRule(_localctx, 120, RULE_instr_sig); + public SigArgContext sigArg() { + SigArgContext _localctx = new SigArgContext(Context, State); + EnterRule(_localctx, 116, RULE_sigArg); + _localctx.Value = CILParser.SignatureArgumentValue.Error; + int _la; try { - EnterOuterAlt(_localctx, 1); - { - State = 968; - Match(INSTR_SIG); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Instr_tokContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_TOK() { return GetToken(CILParser.INSTR_TOK, 0); } - public Instr_tokContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_instr_tok; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_tok(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public Instr_tokContext instr_tok() { - Instr_tokContext _localctx = new Instr_tokContext(Context, State); - EnterRule(_localctx, 122, RULE_instr_tok); - try { - EnterOuterAlt(_localctx, 1); - { - State = 970; - Match(INSTR_TOK); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class Instr_switchContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTR_SWITCH() { return GetToken(CILParser.INSTR_SWITCH, 0); } - public Instr_switchContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_instr_switch; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr_switch(this); - else return visitor.VisitChildren(this); - } - } + State = 1227; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,50,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); + { + State = 1217; + Match(ELLIPSIS); + _localctx.Value = Actions.CreateSentinelSignatureArgument(); + } + break; + case 2: + EnterOuterAlt(_localctx, 2); + { + State = 1219; + _localctx.attributes = paramAttr(); + State = 1220; + _localctx.argumentType = type(); + State = 1221; + _localctx.marshalling = marshalClause(); + State = 1223; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 65534L) != 0) || ((((_la - 199)) & ~0x3f) == 0 && ((1L << (_la - 199)) & 299067162755073L) != 0) || _la==SQSTRING || _la==ID) { + { + State = 1222; + _localctx.name = id(); + } + } - [RuleVersion(0)] - public Instr_switchContext instr_switch() { - Instr_switchContext _localctx = new Instr_switchContext(Context, State); - EnterRule(_localctx, 124, RULE_instr_switch); - try { - EnterOuterAlt(_localctx, 1); - { - State = 972; - Match(INSTR_SWITCH); + _localctx.Value = Actions.CreateSignatureArgument(_localctx.attributes.Value, _localctx.argumentType.Value, _localctx.marshalling.Value, _localctx.name); + } + break; } } catch (RecognitionException re) { @@ -4726,346 +5210,442 @@ public Instr_switchContext instr_switch() { return _localctx; } - public partial class InstrContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Instr_noneContext instr_none() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_varContext instr_var() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_iContext instr_i() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_i8Context instr_i8() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Int64Context int64() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_rContext instr_r() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Float64Context float64() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_brtargetContext instr_brtarget() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_methodContext instr_method() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public MethodRefContext methodRef() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_fieldContext instr_field() { - return GetRuleContext(0); + public partial class ClassNameContext : ParserRuleContext { + public CILParser.ClassNameValue Value; + public DottedNameContext assemblyName; + public SlashedNameContext typeName; + public MdtokenContext scopeToken; + public DottedNameContext moduleName; + public MdtokenContext typeToken; + [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { + return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public FieldRefContext fieldRef() { - return GetRuleContext(0); + [System.Diagnostics.DebuggerNonUserCode] public SlashedNameContext slashedName() { + return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public MdtokenContext mdtoken() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public Instr_typeContext instr_type() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_stringContext instr_string() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext compQstring() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANSI() { return GetToken(CILParser.ANSI, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Instr_sigContext instr_sig() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public SigArgsContext sigArgs() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_tokContext instr_tok() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public OwnerTypeContext ownerType() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public Instr_switchContext instr_switch() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public LabelsContext labels() { - return GetRuleContext(0); - } - public InstrContext(ParserRuleContext parent, int invokingState) + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MODULE() { return GetToken(CILParser.MODULE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode THIS() { return GetToken(CILParser.THIS, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BASE() { return GetToken(CILParser.BASE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NESTER() { return GetToken(CILParser.NESTER, 0); } + public ClassNameContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_instr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInstr(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_className; } } } [RuleVersion(0)] - public InstrContext instr() { - InstrContext _localctx = new InstrContext(Context, State); - EnterRule(_localctx, 126, RULE_instr); + public ClassNameContext className() { + ClassNameContext _localctx = new ClassNameContext(Context, State); + EnterRule(_localctx, 118, RULE_className); + _localctx.Value = CILParser.ClassNameValue.Error; try { - State = 1056; + State = 1266; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,35,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,51,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 974; - instr_none(); + State = 1229; + Match(T__41); + State = 1230; + _localctx.assemblyName = dottedName(); + State = 1231; + Match(T__42); + State = 1232; + _localctx.typeName = slashedName(); + _localctx.Value = Actions.CreateAssemblyQualifiedClassName(_localctx.assemblyName.Value, _localctx.typeName.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 975; - instr_var(); - State = 976; - int32(); + State = 1235; + Match(T__41); + State = 1236; + _localctx.scopeToken = mdtoken(); + State = 1237; + Match(T__42); + State = 1238; + _localctx.typeName = slashedName(); + _localctx.Value = Actions.CreateTokenQualifiedClassName(_localctx.scopeToken.Value, _localctx.typeName.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 978; - instr_var(); - State = 979; - id(); + State = 1241; + Match(T__41); + State = 1242; + Match(PTR); + State = 1243; + Match(T__42); + State = 1244; + _localctx.typeName = slashedName(); + _localctx.Value = Actions.CreatePointerQualifiedClassName(_localctx.typeName.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 981; - instr_i(); - State = 982; - int32(); + State = 1247; + Match(T__41); + State = 1248; + Match(MODULE); + State = 1249; + _localctx.moduleName = dottedName(); + State = 1250; + Match(T__42); + State = 1251; + _localctx.typeName = slashedName(); + _localctx.Value = Actions.CreateModuleQualifiedClassName(_localctx.Start, _localctx.moduleName.Value, _localctx.typeName.Value); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 984; - instr_i8(); - State = 985; - int64(); + State = 1254; + _localctx.typeName = slashedName(); + _localctx.Value = Actions.CreateUnqualifiedClassName(_localctx.typeName.Value); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 987; - instr_r(); - State = 988; - float64(); + State = 1257; + _localctx.typeToken = mdtoken(); + _localctx.Value = Actions.CreateTokenClassName(_localctx.typeToken.Value); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 990; - instr_r(); - State = 991; - int64(); + State = 1260; + Match(THIS); + _localctx.Value = Actions.CreateThisClassName(_localctx.Start); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 993; - instr_r(); - State = 994; - Match(T__29); - State = 995; - bytes(); - State = 996; - Match(T__30); + State = 1262; + Match(BASE); + _localctx.Value = Actions.CreateBaseClassName(_localctx.Start); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 998; - instr_r(); - State = 999; - Match(T__83); - State = 1000; - Match(T__29); - State = 1001; - bytes(); - State = 1002; - Match(T__30); - } - break; - case 10: - EnterOuterAlt(_localctx, 10); - { - State = 1004; - instr_brtarget(); - State = 1005; - int32(); - } - break; - case 11: - EnterOuterAlt(_localctx, 11); - { - State = 1007; - instr_brtarget(); - State = 1008; - id(); - } - break; - case 12: - EnterOuterAlt(_localctx, 12); - { - State = 1010; - instr_method(); - State = 1011; - methodRef(); + State = 1264; + Match(NESTER); + _localctx.Value = Actions.CreateNesterClassName(_localctx.Start); } break; - case 13: - EnterOuterAlt(_localctx, 13); - { - State = 1013; - instr_field(); - State = 1014; - fieldRef(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class SlashedNameContext : ParserRuleContext { + public CILParser.TypeName Value; + public CILParser.TypeName CurrentName; + public DottedNameContext part; + public DottedNameContext lastPart; + [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext[] dottedName() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName(int i) { + return GetRuleContext(i); + } + public SlashedNameContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_slashedName; } } + } + + [RuleVersion(0)] + public SlashedNameContext slashedName() { + SlashedNameContext _localctx = new SlashedNameContext(Context, State); + EnterRule(_localctx, 120, RULE_slashedName); + try { + int _alt; + EnterOuterAlt(_localctx, 1); + { + State = 1274; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,52,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + State = 1268; + _localctx.part = dottedName(); + _localctx.CurrentName = Actions.AddSlashedNamePart(_localctx.CurrentName, _localctx.part.Value); + State = 1270; + Match(T__87); + } + } } - break; - case 14: - EnterOuterAlt(_localctx, 14); + State = 1276; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,52,Context); + } + State = 1277; + _localctx.lastPart = dottedName(); + _localctx.CurrentName = Actions.AddSlashedNamePart(_localctx.CurrentName, _localctx.lastPart.Value); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + _localctx.Value = _localctx.CurrentName ?? new CILParser.TypeName(null, string.Empty); + ExitRule(); + } + return _localctx; + } + + public partial class AssemblyDeclsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public AssemblyDeclContext declaration; + [System.Diagnostics.DebuggerNonUserCode] public AssemblyDeclContext[] assemblyDecl() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public AssemblyDeclContext assemblyDecl(int i) { + return GetRuleContext(i); + } + public AssemblyDeclsContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_assemblyDecls; } } + } + + [RuleVersion(0)] + public AssemblyDeclsContext assemblyDecls() { + AssemblyDeclsContext _localctx = new AssemblyDeclsContext(Context, State); + EnterRule(_localctx, 122, RULE_assemblyDecls); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 1285; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 38654771200L) != 0) || ((((_la - 167)) & ~0x3f) == 0 && ((1L << (_la - 167)) & 4294975503L) != 0) || ((((_la - 243)) & ~0x3f) == 0 && ((1L << (_la - 243)) & 6860954690125825L) != 0)) { { - State = 1016; - instr_field(); - State = 1017; - mdtoken(); - } - break; - case 15: - EnterOuterAlt(_localctx, 15); { - State = 1019; - instr_type(); - State = 1020; - typeSpec(); + State = 1280; + _localctx.declaration = assemblyDecl(); + if (_localctx.declaration.Value is not null) _localctx.Builder.Add(_localctx.declaration.Value); } - break; - case 16: - EnterOuterAlt(_localctx, 16); - { - State = 1022; - instr_string(); - State = 1023; - compQstring(); } - break; - case 17: - EnterOuterAlt(_localctx, 17); + State = 1287; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + _localctx.Value = _localctx.Builder.ToImmutable(); + ExitRule(); + } + return _localctx; + } + + public partial class AssemblyDeclContext : ParserRuleContext { + public CILParser.AssemblyDeclarationValue? Value; + public Int32Context algorithm; + public SecDeclContext security; + public AsmOrRefDeclContext shared; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode HASH() { return GetToken(CILParser.HASH, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public SecDeclContext secDecl() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public AsmOrRefDeclContext asmOrRefDecl() { + return GetRuleContext(0); + } + public AssemblyDeclContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_assemblyDecl; } } + } + + [RuleVersion(0)] + public AssemblyDeclContext assemblyDecl() { + AssemblyDeclContext _localctx = new AssemblyDeclContext(Context, State); + EnterRule(_localctx, 124, RULE_assemblyDecl); + try { + State = 1299; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case HASH: + EnterOuterAlt(_localctx, 1); { - State = 1025; - instr_string(); - State = 1026; - Match(ANSI); - State = 1027; - Match(T__29); - State = 1028; - compQstring(); - State = 1029; - Match(T__30); + State = 1288; + Match(HASH); + State = 1289; + Match(T__88); + State = 1290; + _localctx.algorithm = int32(); + _localctx.Value = Actions.CreateAssemblyHashAlgorithmDeclaration((_localctx.algorithm!=null?(_localctx.algorithm.Start):null)); } break; - case 18: - EnterOuterAlt(_localctx, 18); + case PERMISSION: + case PERMISSIONSET: + EnterOuterAlt(_localctx, 2); { - State = 1031; - instr_string(); - State = 1032; - Match(T__83); - State = 1033; - Match(T__29); - State = 1034; - bytes(); - State = 1035; - Match(T__30); + State = 1293; + _localctx.security = secDecl(); + _localctx.Value = Actions.CreateAssemblySecurityDeclaration( + _localctx.security.Value, + (_localctx.security!=null?(_localctx.security.Start):null)); } break; - case 19: - EnterOuterAlt(_localctx, 19); + case T__15: + case T__31: + case T__34: + case T__166: + case T__167: + case T__168: + case T__169: + case VALUE: + case INSTANCE: + case SQSTRING: + case PP_DEFINE: + case PP_UNDEF: + case PP_IFDEF: + case PP_IFNDEF: + case PP_ELSE: + case PP_ENDIF: + case PP_INCLUDE: + case DOTTEDNAME: + case ID: + EnterOuterAlt(_localctx, 3); { - State = 1037; - instr_sig(); - State = 1038; - callConv(); - State = 1039; - type(); - State = 1040; - sigArgs(); + State = 1296; + _localctx.shared = asmOrRefDecl(); + _localctx.Value = _localctx.shared.Value; } break; - case 20: - EnterOuterAlt(_localctx, 20); + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class TypeSpecContext : ParserRuleContext { + public CILParser.TypeSpecificationValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public ClassNameContext classType; + public DottedNameContext assemblyName; + public DottedNameContext moduleName; + public TypeContext signatureType; + [System.Diagnostics.DebuggerNonUserCode] public ClassNameContext className() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MODULE() { return GetToken(CILParser.MODULE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { + return GetRuleContext(0); + } + public TypeSpecContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_typeSpec; } } + } + + [RuleVersion(0)] + public TypeSpecContext typeSpec() { + TypeSpecContext _localctx = new TypeSpecContext(Context, State); + EnterRule(_localctx, 126, RULE_typeSpec); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.TypeSpecificationValue.Error; + + try { + State = 1318; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,55,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); { - State = 1042; - instr_tok(); - State = 1043; - ownerType(); + State = 1301; + _localctx.classType = className(); + _localctx.Value = Actions.CreateClassTypeSpecification(_localctx.classType.Value); } break; - case 21: - EnterOuterAlt(_localctx, 21); + case 2: + EnterOuterAlt(_localctx, 2); { - State = 1045; - instr_tok(); - State = 1046; - int32(); + State = 1304; + Match(T__41); + State = 1305; + _localctx.assemblyName = dottedName(); + State = 1306; + Match(T__42); + _localctx.Value = Actions.CreateAssemblyTypeSpecification(_localctx.assemblyName.Value); } break; - case 22: - EnterOuterAlt(_localctx, 22); + case 3: + EnterOuterAlt(_localctx, 3); { - State = 1048; - instr_switch(); - State = 1049; - Match(T__29); - State = 1050; - labels(); - State = 1051; - Match(T__30); + State = 1309; + Match(T__41); + State = 1310; + Match(MODULE); + State = 1311; + _localctx.moduleName = dottedName(); + State = 1312; + Match(T__42); + _localctx.Value = Actions.CreateModuleTypeSpecification(_localctx.moduleName.Value); } break; - case 23: - EnterOuterAlt(_localctx, 23); + case 4: + EnterOuterAlt(_localctx, 4); { - State = 1053; - instr_switch(); - State = 1054; - Match(T__84); + State = 1315; + _localctx.signatureType = type(); + _localctx.Value = Actions.CreateSignatureTypeSpecification(_localctx.signatureType.Value); } break; } @@ -5076,168 +5656,77 @@ public InstrContext instr() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } - public partial class LabelsContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public IdContext[] id() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public IdContext id(int i) { - return GetRuleContext(i); + public partial class NativeTypeContext : ParserRuleContext { + public CILParser.NativeTypeValue Value; + public CILParser.NativeTypeBuilder Builder; + public NativeTypeElementContext element; + public NativeTypeArrayPointerInfoContext info; + [System.Diagnostics.DebuggerNonUserCode] public NativeTypeElementContext nativeTypeElement() { + return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { - return GetRuleContexts(); + [System.Diagnostics.DebuggerNonUserCode] public NativeTypeArrayPointerInfoContext[] nativeTypeArrayPointerInfo() { + return GetRuleContexts(); } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32(int i) { - return GetRuleContext(i); + [System.Diagnostics.DebuggerNonUserCode] public NativeTypeArrayPointerInfoContext nativeTypeArrayPointerInfo(int i) { + return GetRuleContext(i); } - public LabelsContext(ParserRuleContext parent, int invokingState) + public NativeTypeContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_labels; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitLabels(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_nativeType; } } } [RuleVersion(0)] - public LabelsContext labels() { - LabelsContext _localctx = new LabelsContext(Context, State); - EnterRule(_localctx, 128, RULE_labels); + public NativeTypeContext nativeType() { + NativeTypeContext _localctx = new NativeTypeContext(Context, State); + EnterRule(_localctx, 128, RULE_nativeType); + _localctx.Builder = new CILParser.NativeTypeBuilder(); try { int _alt; - State = 1074; + State = 1331; ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case T__30: + switch ( Interpreter.AdaptivePredict(TokenStream,57,Context) ) { + case 1: EnterOuterAlt(_localctx, 1); { } break; - case T__0: - case T__1: - case T__2: - case T__3: - case T__4: - case T__5: - case T__6: - case T__7: - case T__8: - case T__9: - case T__10: - case T__11: - case T__12: - case T__13: - case T__14: - case INT32: - case VALUE: - case INSTANCE: - case UNMANAGED: - case SQSTRING: - case ID: + case 2: EnterOuterAlt(_localctx, 2); { - State = 1067; + State = 1321; + _localctx.element = nativeTypeElement(); + Actions.SetNativeTypeElement(_localctx.Builder, _localctx.element.Value); + State = 1328; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,37,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,56,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1061; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case T__0: - case T__1: - case T__2: - case T__3: - case T__4: - case T__5: - case T__6: - case T__7: - case T__8: - case T__9: - case T__10: - case T__11: - case T__12: - case T__13: - case T__14: - case VALUE: - case INSTANCE: - case UNMANAGED: - case SQSTRING: - case ID: - { - State = 1059; - id(); - } - break; - case INT32: - { - State = 1060; - int32(); - } - break; - default: - throw new NoViableAltException(this); - } - State = 1063; - Match(T__27); + State = 1323; + _localctx.info = nativeTypeArrayPointerInfo(); + Actions.AddNativeTypeArrayPointerInfo(_localctx.Builder, _localctx.info.Value); } } } - State = 1069; + State = 1330; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,37,Context); - } - State = 1072; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case T__0: - case T__1: - case T__2: - case T__3: - case T__4: - case T__5: - case T__6: - case T__7: - case T__8: - case T__9: - case T__10: - case T__11: - case T__12: - case T__13: - case T__14: - case VALUE: - case INSTANCE: - case UNMANAGED: - case SQSTRING: - case ID: - { - State = 1070; - id(); - } - break; - case INT32: - { - State = 1071; - int32(); - } - break; - default: - throw new NoViableAltException(this); + _alt = Interpreter.AdaptivePredict(TokenStream,56,Context); } } break; - default: - throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -5246,128 +5735,134 @@ public LabelsContext labels() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.CreateNativeType(_localctx.Start, _localctx.Builder); ExitRule(); } return _localctx; } - public partial class TypeArgsContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public TypeContext[] type() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type(int i) { - return GetRuleContext(i); - } - public TypeArgsContext(ParserRuleContext parent, int invokingState) + public partial class NativeTypeArrayPointerInfoContext : ParserRuleContext { + public CILParser.NativeTypeArrayPointerInfoValue Value; + public NativeTypeArrayPointerInfoContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_typeArgs; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTypeArgs(this); - else return visitor.VisitChildren(this); + public override int RuleIndex { get { return RULE_nativeTypeArrayPointerInfo; } } + + public NativeTypeArrayPointerInfoContext() { } + public virtual void CopyFrom(NativeTypeArrayPointerInfoContext context) { + base.CopyFrom(context); + this.Value = context.Value; } } - - [RuleVersion(0)] - public TypeArgsContext typeArgs() { - TypeArgsContext _localctx = new TypeArgsContext(Context, State); - EnterRule(_localctx, 130, RULE_typeArgs); - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - State = 1076; - Match(T__85); - State = 1082; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,40,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - State = 1077; - type(); - State = 1078; - Match(T__27); - } - } - } - State = 1084; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,40,Context); - } - State = 1085; - type(); - State = 1086; - Match(T__86); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); + public partial class PointerArrayTypeSizeContext : NativeTypeArrayPointerInfoContext { + public Int32Context size; + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); } - return _localctx; + public PointerArrayTypeSizeContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } } - - public partial class BoundsContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public BoundContext[] bound() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public BoundContext bound(int i) { - return GetRuleContext(i); + public partial class PointerArrayTypeParamIndexContext : NativeTypeArrayPointerInfoContext { + public Int32Context parameterIndex; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PLUS() { return GetToken(CILParser.PLUS, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); } - public BoundsContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { + public PointerArrayTypeParamIndexContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } + } + public partial class PointerNativeTypeContext : NativeTypeArrayPointerInfoContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } + public PointerNativeTypeContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } + } + public partial class PointerArrayTypeSizeParamIndexContext : NativeTypeArrayPointerInfoContext { + public Int32Context size; + public Int32Context parameterIndex; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PLUS() { return GetToken(CILParser.PLUS, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { + return GetRuleContexts(); } - public override int RuleIndex { get { return RULE_bounds; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitBounds(this); - else return visitor.VisitChildren(this); + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32(int i) { + return GetRuleContext(i); } + public PointerArrayTypeSizeParamIndexContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } + } + public partial class PointerArrayTypeNoSizeDataContext : NativeTypeArrayPointerInfoContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ARRAY_TYPE_NO_BOUNDS() { return GetToken(CILParser.ARRAY_TYPE_NO_BOUNDS, 0); } + public PointerArrayTypeNoSizeDataContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } } [RuleVersion(0)] - public BoundsContext bounds() { - BoundsContext _localctx = new BoundsContext(Context, State); - EnterRule(_localctx, 132, RULE_bounds); + public NativeTypeArrayPointerInfoContext nativeTypeArrayPointerInfo() { + NativeTypeArrayPointerInfoContext _localctx = new NativeTypeArrayPointerInfoContext(Context, State); + EnterRule(_localctx, 130, RULE_nativeTypeArrayPointerInfo); + _localctx.Value = Actions.CreatePointerNativeType(); try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - State = 1088; - Match(T__41); - State = 1094; + State = 1355; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,41,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - State = 1089; - bound(); - State = 1090; - Match(T__27); - } - } + switch ( Interpreter.AdaptivePredict(TokenStream,58,Context) ) { + case 1: + _localctx = new PointerNativeTypeContext(_localctx); + EnterOuterAlt(_localctx, 1); + { + State = 1333; + Match(PTR); + _localctx.Value = Actions.CreatePointerNativeType(); } - State = 1096; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,41,Context); - } - State = 1097; - bound(); - State = 1098; - Match(T__42); + break; + case 2: + _localctx = new PointerArrayTypeNoSizeDataContext(_localctx); + EnterOuterAlt(_localctx, 2); + { + State = 1335; + Match(ARRAY_TYPE_NO_BOUNDS); + _localctx.Value = Actions.CreatePointerArrayTypeNoSizeData(); + } + break; + case 3: + _localctx = new PointerArrayTypeSizeContext(_localctx); + EnterOuterAlt(_localctx, 3); + { + State = 1337; + Match(T__41); + State = 1338; + ((PointerArrayTypeSizeContext)_localctx).size = int32(); + State = 1339; + Match(T__42); + _localctx.Value = Actions.CreatePointerArrayTypeSize((((PointerArrayTypeSizeContext)_localctx).size!=null?(((PointerArrayTypeSizeContext)_localctx).size.Start):null)); + } + break; + case 4: + _localctx = new PointerArrayTypeSizeParamIndexContext(_localctx); + EnterOuterAlt(_localctx, 4); + { + State = 1342; + Match(T__41); + State = 1343; + ((PointerArrayTypeSizeParamIndexContext)_localctx).size = int32(); + State = 1344; + Match(PLUS); + State = 1345; + ((PointerArrayTypeSizeParamIndexContext)_localctx).parameterIndex = int32(); + State = 1346; + Match(T__42); + _localctx.Value = Actions.CreatePointerArrayTypeSizeParamIndex((((PointerArrayTypeSizeParamIndexContext)_localctx).size!=null?(((PointerArrayTypeSizeParamIndexContext)_localctx).size.Start):null), (((PointerArrayTypeSizeParamIndexContext)_localctx).parameterIndex!=null?(((PointerArrayTypeSizeParamIndexContext)_localctx).parameterIndex.Start):null)); + } + break; + case 5: + _localctx = new PointerArrayTypeParamIndexContext(_localctx); + EnterOuterAlt(_localctx, 5); + { + State = 1349; + Match(T__41); + State = 1350; + Match(PLUS); + State = 1351; + ((PointerArrayTypeParamIndexContext)_localctx).parameterIndex = int32(); + State = 1352; + Match(T__42); + _localctx.Value = Actions.CreatePointerArrayTypeParamIndex((((PointerArrayTypeParamIndexContext)_localctx).parameterIndex!=null?(((PointerArrayTypeParamIndexContext)_localctx).parameterIndex.Start):null)); + } + break; } } catch (RecognitionException re) { @@ -5381,578 +5876,563 @@ public BoundsContext bounds() { return _localctx; } - public partial class SigArgsContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public SigArgContext[] sigArg() { - return GetRuleContexts(); + public partial class NativeTypeElementContext : ParserRuleContext { + public CILParser.NativeTypeElementValue Value; + public IToken marshalType; + public CompQstringContext guid; + public CompQstringContext nativeTypeName; + public CompQstringContext marshallerType; + public CompQstringContext cookie; + public Int32Context size; + public NativeTypeContext element; + public IidParamIndexContext index; + public VariantTypeContext variant; + public CompQstringContext userDefinedType; + public IToken unsignedMarshalType; + public IToken marshalBool; + public DottedNameContext alias; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CUSTOM() { return GetToken(CILParser.CUSTOM, 0); } + [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext[] compQstring() { + return GetRuleContexts(); } - [System.Diagnostics.DebuggerNonUserCode] public SigArgContext sigArg(int i) { - return GetRuleContext(i); + [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext compQstring(int i) { + return GetRuleContext(i); } - public SigArgsContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_sigArgs; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSigArgs(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public SigArgsContext sigArgs() { - SigArgsContext _localctx = new SigArgsContext(Context, State); - EnterRule(_localctx, 134, RULE_sigArgs); - try { - int _alt; - State = 1113; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case T__29: - EnterOuterAlt(_localctx, 1); - { - State = 1100; - Match(T__29); - State = 1106; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,42,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - State = 1101; - sigArg(); - State = 1102; - Match(T__27); - } - } - } - State = 1108; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,42,Context); - } - State = 1109; - sigArg(); - State = 1110; - Match(T__30); - } - break; - case T__84: - EnterOuterAlt(_localctx, 2); - { - State = 1112; - Match(T__84); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class SigArgContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELLIPSIS() { return GetToken(CILParser.ELLIPSIS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ParamAttrContext paramAttr() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public MarshalClauseContext marshalClause() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { - return GetRuleContext(0); - } - public SigArgContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_sigArg; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSigArg(this); - else return visitor.VisitChildren(this); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FIXED() { return GetToken(CILParser.FIXED, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SYSSTRING() { return GetToken(CILParser.SYSSTRING, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); } - } - - [RuleVersion(0)] - public SigArgContext sigArg() { - SigArgContext _localctx = new SigArgContext(Context, State); - EnterRule(_localctx, 136, RULE_sigArg); - int _la; - try { - State = 1122; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,45,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); - { - State = 1115; - Match(ELLIPSIS); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 1116; - paramAttr(); - State = 1117; - type(); - State = 1118; - marshalClause(); - State = 1120; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 65534L) != 0) || ((((_la - 199)) & ~0x3f) == 0 && ((1L << (_la - 199)) & 299067162755073L) != 0) || _la==SQSTRING || _la==ID) { - { - State = 1119; - id(); - } - } - - } - break; - } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ARRAY() { return GetToken(CILParser.ARRAY, 0); } + [System.Diagnostics.DebuggerNonUserCode] public NativeTypeContext nativeType() { + return GetRuleContext(0); } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIANT() { return GetToken(CILParser.VARIANT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CURRENCY() { return GetToken(CILParser.CURRENCY, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SYSCHAR() { return GetToken(CILParser.SYSCHAR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VOID() { return GetToken(CILParser.VOID, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOL() { return GetToken(CILParser.BOOL, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT8() { return GetToken(CILParser.INT8, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT16() { return GetToken(CILParser.INT16, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT32_() { return GetToken(CILParser.INT32_, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT64_() { return GetToken(CILParser.INT64_, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT32() { return GetToken(CILParser.FLOAT32, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT64_() { return GetToken(CILParser.FLOAT64_, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ERROR() { return GetToken(CILParser.ERROR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT8() { return GetToken(CILParser.UINT8, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT16() { return GetToken(CILParser.UINT16, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT32() { return GetToken(CILParser.UINT32, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT64() { return GetToken(CILParser.UINT64, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DECIMAL() { return GetToken(CILParser.DECIMAL, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DATE() { return GetToken(CILParser.DATE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BSTR() { return GetToken(CILParser.BSTR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPSTR() { return GetToken(CILParser.LPSTR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPWSTR() { return GetToken(CILParser.LPWSTR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPTSTR() { return GetToken(CILParser.LPTSTR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OBJECTREF() { return GetToken(CILParser.OBJECTREF, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IUNKNOWN() { return GetToken(CILParser.IUNKNOWN, 0); } + [System.Diagnostics.DebuggerNonUserCode] public IidParamIndexContext iidParamIndex() { + return GetRuleContext(0); } - finally { - ExitRule(); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IDISPATCH() { return GetToken(CILParser.IDISPATCH, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRUCT() { return GetToken(CILParser.STRUCT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INTERFACE() { return GetToken(CILParser.INTERFACE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SAFEARRAY() { return GetToken(CILParser.SAFEARRAY, 0); } + [System.Diagnostics.DebuggerNonUserCode] public VariantTypeContext variantType() { + return GetRuleContext(0); } - return _localctx; - } - - public partial class ClassNameContext : ParserRuleContext { + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(CILParser.INT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT() { return GetToken(CILParser.UINT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BYVALSTR() { return GetToken(CILParser.BYVALSTR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANSI() { return GetToken(CILParser.ANSI, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TBSTR() { return GetToken(CILParser.TBSTR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode METHOD() { return GetToken(CILParser.METHOD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPSTRUCT() { return GetToken(CILParser.LPSTRUCT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANY() { return GetToken(CILParser.ANY, 0); } [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public SlashedNameContext slashedName() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public MdtokenContext mdtoken() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MODULE() { return GetToken(CILParser.MODULE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode THIS() { return GetToken(CILParser.THIS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BASE() { return GetToken(CILParser.BASE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NESTER() { return GetToken(CILParser.NESTER, 0); } - public ClassNameContext(ParserRuleContext parent, int invokingState) + public NativeTypeElementContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_className; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitClassName(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_nativeTypeElement; } } } [RuleVersion(0)] - public ClassNameContext className() { - ClassNameContext _localctx = new ClassNameContext(Context, State); - EnterRule(_localctx, 138, RULE_className); + public NativeTypeElementContext nativeTypeElement() { + NativeTypeElementContext _localctx = new NativeTypeElementContext(Context, State); + EnterRule(_localctx, 132, RULE_nativeTypeElement); + _localctx.Value = CILParser.EmptyNativeTypeElementValue.Instance; try { - State = 1149; + State = 1502; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,46,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,59,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1124; - Match(T__41); - State = 1125; - dottedName(); - State = 1126; - Match(T__42); - State = 1127; - slashedName(); + _localctx.Value = Actions.CreateEmptyNativeType(); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1129; - Match(T__41); - State = 1130; - mdtoken(); - State = 1131; - Match(T__42); - State = 1132; - slashedName(); + State = 1358; + _localctx.marshalType = Match(CUSTOM); + State = 1359; + Match(T__29); + State = 1360; + _localctx.guid = compQstring(); + State = 1361; + Match(T__27); + State = 1362; + _localctx.nativeTypeName = compQstring(); + State = 1363; + Match(T__27); + State = 1364; + _localctx.marshallerType = compQstring(); + State = 1365; + Match(T__27); + State = 1366; + _localctx.cookie = compQstring(); + State = 1367; + Match(T__30); + _localctx.Value = Actions.CreateDeprecatedCustomMarshallerNativeType( + _localctx, _localctx.guid.Value, _localctx.nativeTypeName.Value, _localctx.marshallerType.Value, _localctx.cookie.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1134; - Match(T__41); - State = 1135; - Match(PTR); - State = 1136; - Match(T__42); - State = 1137; - slashedName(); + State = 1370; + _localctx.marshalType = Match(CUSTOM); + State = 1371; + Match(T__29); + State = 1372; + _localctx.marshallerType = compQstring(); + State = 1373; + Match(T__27); + State = 1374; + _localctx.cookie = compQstring(); + State = 1375; + Match(T__30); + _localctx.Value = Actions.CreateCustomMarshallerNativeType(_localctx.marshallerType.Value, _localctx.cookie.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1138; + State = 1378; + Match(FIXED); + State = 1379; + _localctx.marshalType = Match(SYSSTRING); + State = 1380; Match(T__41); - State = 1139; - Match(MODULE); - State = 1140; - dottedName(); - State = 1141; + State = 1381; + _localctx.size = int32(); + State = 1382; Match(T__42); - State = 1142; - slashedName(); + _localctx.Value = Actions.CreateFixedSysStringNativeType((_localctx.size!=null?(_localctx.size.Start):null)); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1144; - slashedName(); + State = 1385; + Match(FIXED); + State = 1386; + _localctx.marshalType = Match(ARRAY); + State = 1387; + Match(T__41); + State = 1388; + _localctx.size = int32(); + State = 1389; + Match(T__42); + State = 1390; + _localctx.element = nativeType(); + _localctx.Value = Actions.CreateFixedArrayNativeType((_localctx.size!=null?(_localctx.size.Start):null), _localctx.element.Value); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1145; - mdtoken(); + State = 1393; + _localctx.marshalType = Match(VARIANT); + _localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, _localctx.marshalType); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 1146; - Match(THIS); + State = 1395; + _localctx.marshalType = Match(CURRENCY); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 1147; - Match(BASE); + State = 1397; + _localctx.marshalType = Match(SYSCHAR); + _localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, _localctx.marshalType); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 1148; - Match(NESTER); + State = 1399; + _localctx.marshalType = Match(VOID); + _localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, _localctx.marshalType); } break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class SlashedNameContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext[] dottedName() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName(int i) { - return GetRuleContext(i); - } - public SlashedNameContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_slashedName; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSlashedName(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public SlashedNameContext slashedName() { - SlashedNameContext _localctx = new SlashedNameContext(Context, State); - EnterRule(_localctx, 140, RULE_slashedName); - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - State = 1156; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,47,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - State = 1151; - dottedName(); - State = 1152; - Match(T__87); - } - } + case 10: + EnterOuterAlt(_localctx, 10); + { + State = 1401; + _localctx.marshalType = Match(BOOL); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } - State = 1158; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,47,Context); - } - State = 1159; - dottedName(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class AssemblyDeclsContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public AssemblyDeclContext[] assemblyDecl() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public AssemblyDeclContext assemblyDecl(int i) { - return GetRuleContext(i); - } - public AssemblyDeclsContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_assemblyDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssemblyDecls(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public AssemblyDeclsContext assemblyDecls() { - AssemblyDeclsContext _localctx = new AssemblyDeclsContext(Context, State); - EnterRule(_localctx, 142, RULE_assemblyDecls); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 1164; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 38654771200L) != 0) || ((((_la - 167)) & ~0x3f) == 0 && ((1L << (_la - 167)) & 4294975503L) != 0) || ((((_la - 243)) & ~0x3f) == 0 && ((1L << (_la - 243)) & 6860954690125825L) != 0)) { + break; + case 11: + EnterOuterAlt(_localctx, 11); { + State = 1403; + _localctx.marshalType = Match(INT8); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 12: + EnterOuterAlt(_localctx, 12); { - State = 1161; - assemblyDecl(); + State = 1405; + _localctx.marshalType = Match(INT16); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } + break; + case 13: + EnterOuterAlt(_localctx, 13); + { + State = 1407; + _localctx.marshalType = Match(INT32_); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } - State = 1166; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class AssemblyDeclContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode HASH() { return GetToken(CILParser.HASH, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public SecDeclContext secDecl() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public AsmOrRefDeclContext asmOrRefDecl() { - return GetRuleContext(0); - } - public AssemblyDeclContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_assemblyDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssemblyDecl(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public AssemblyDeclContext assemblyDecl() { - AssemblyDeclContext _localctx = new AssemblyDeclContext(Context, State); - EnterRule(_localctx, 144, RULE_assemblyDecl); - try { - State = 1172; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case HASH: - EnterOuterAlt(_localctx, 1); + break; + case 14: + EnterOuterAlt(_localctx, 14); { + State = 1409; + _localctx.marshalType = Match(INT64_); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 15: + EnterOuterAlt(_localctx, 15); + { + State = 1411; + _localctx.marshalType = Match(FLOAT32); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 16: + EnterOuterAlt(_localctx, 16); + { + State = 1413; + _localctx.marshalType = Match(FLOAT64_); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 17: + EnterOuterAlt(_localctx, 17); + { + State = 1415; + _localctx.marshalType = Match(ERROR); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 18: + EnterOuterAlt(_localctx, 18); + { + State = 1417; + _localctx.marshalType = Match(UINT8); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 19: + EnterOuterAlt(_localctx, 19); + { + State = 1419; + _localctx.marshalType = Match(UINT16); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 20: + EnterOuterAlt(_localctx, 20); + { + State = 1421; + _localctx.marshalType = Match(UINT32); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 21: + EnterOuterAlt(_localctx, 21); + { + State = 1423; + _localctx.marshalType = Match(UINT64); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 22: + EnterOuterAlt(_localctx, 22); + { + State = 1425; + _localctx.marshalType = Match(DECIMAL); + _localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, _localctx.marshalType); + } + break; + case 23: + EnterOuterAlt(_localctx, 23); + { + State = 1427; + _localctx.marshalType = Match(DATE); + _localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, _localctx.marshalType); + } + break; + case 24: + EnterOuterAlt(_localctx, 24); + { + State = 1429; + _localctx.marshalType = Match(BSTR); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 25: + EnterOuterAlt(_localctx, 25); + { + State = 1431; + _localctx.marshalType = Match(LPSTR); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 26: + EnterOuterAlt(_localctx, 26); + { + State = 1433; + _localctx.marshalType = Match(LPWSTR); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 27: + EnterOuterAlt(_localctx, 27); + { + State = 1435; + _localctx.marshalType = Match(LPTSTR); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 28: + EnterOuterAlt(_localctx, 28); + { + State = 1437; + _localctx.marshalType = Match(OBJECTREF); + _localctx.Value = Actions.CreateDeprecatedNativeType(_localctx, _localctx.marshalType); + } + break; + case 29: + EnterOuterAlt(_localctx, 29); + { + State = 1439; + _localctx.marshalType = Match(IUNKNOWN); + State = 1440; + _localctx.index = iidParamIndex(); + _localctx.Value = Actions.CreateIidNativeType(_localctx.marshalType, _localctx.index.Value); + } + break; + case 30: + EnterOuterAlt(_localctx, 30); + { + State = 1443; + _localctx.marshalType = Match(IDISPATCH); + State = 1444; + _localctx.index = iidParamIndex(); + _localctx.Value = Actions.CreateIidNativeType(_localctx.marshalType, _localctx.index.Value); + } + break; + case 31: + EnterOuterAlt(_localctx, 31); + { + State = 1447; + _localctx.marshalType = Match(STRUCT); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 32: + EnterOuterAlt(_localctx, 32); + { + State = 1449; + _localctx.marshalType = Match(INTERFACE); + State = 1450; + _localctx.index = iidParamIndex(); + _localctx.Value = Actions.CreateIidNativeType(_localctx.marshalType, _localctx.index.Value); + } + break; + case 33: + EnterOuterAlt(_localctx, 33); + { + State = 1453; + _localctx.marshalType = Match(SAFEARRAY); + State = 1454; + _localctx.variant = variantType(); + _localctx.Value = Actions.CreateSafeArrayNativeType(_localctx.variant.Value, null); + } + break; + case 34: + EnterOuterAlt(_localctx, 34); + { + State = 1457; + _localctx.marshalType = Match(SAFEARRAY); + State = 1458; + _localctx.variant = variantType(); + State = 1459; + Match(T__27); + State = 1460; + _localctx.userDefinedType = compQstring(); + _localctx.Value = Actions.CreateSafeArrayNativeType(_localctx.variant.Value, _localctx.userDefinedType.Value); + } + break; + case 35: + EnterOuterAlt(_localctx, 35); + { + State = 1463; + _localctx.marshalType = Match(INT); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 36: + EnterOuterAlt(_localctx, 36); + { + State = 1465; + _localctx.marshalType = Match(UINT); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); + } + break; + case 37: + EnterOuterAlt(_localctx, 37); + { + State = 1467; + Match(T__89); + State = 1468; + _localctx.unsignedMarshalType = Match(INT8); + _localctx.Value = Actions.CreateUnsignedNativeType(_localctx.unsignedMarshalType); + } + break; + case 38: + EnterOuterAlt(_localctx, 38); + { + State = 1470; + Match(T__89); + State = 1471; + _localctx.unsignedMarshalType = Match(INT16); + _localctx.Value = Actions.CreateUnsignedNativeType(_localctx.unsignedMarshalType); + } + break; + case 39: + EnterOuterAlt(_localctx, 39); + { + State = 1473; + Match(T__89); + State = 1474; + _localctx.unsignedMarshalType = Match(INT32_); + _localctx.Value = Actions.CreateUnsignedNativeType(_localctx.unsignedMarshalType); + } + break; + case 40: + EnterOuterAlt(_localctx, 40); + { + State = 1476; + Match(T__89); + State = 1477; + _localctx.unsignedMarshalType = Match(INT64_); + _localctx.Value = Actions.CreateUnsignedNativeType(_localctx.unsignedMarshalType); + } + break; + case 41: + EnterOuterAlt(_localctx, 41); + { + State = 1479; + Match(T__61); + State = 1480; + _localctx.marshalType = Match(STRUCT); + _localctx.Value = Actions.CreateNestedStructNativeType(_localctx); + } + break; + case 42: + EnterOuterAlt(_localctx, 42); { - State = 1167; - Match(HASH); - State = 1168; - Match(T__88); - State = 1169; - int32(); + State = 1482; + _localctx.marshalType = Match(BYVALSTR); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } + break; + case 43: + EnterOuterAlt(_localctx, 43); + { + State = 1484; + Match(ANSI); + State = 1485; + _localctx.marshalType = Match(BSTR); + _localctx.Value = Actions.CreateAnsiBstrNativeType(); } break; - case PERMISSION: - case PERMISSIONSET: - EnterOuterAlt(_localctx, 2); + case 44: + EnterOuterAlt(_localctx, 44); { - State = 1170; - secDecl(); + State = 1487; + _localctx.marshalType = Match(TBSTR); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } break; - case T__15: - case T__31: - case T__34: - case T__166: - case T__167: - case T__168: - case T__169: - case VALUE: - case INSTANCE: - case SQSTRING: - case PP_DEFINE: - case PP_UNDEF: - case PP_IFDEF: - case PP_IFNDEF: - case PP_ELSE: - case PP_ENDIF: - case PP_INCLUDE: - case DOTTEDNAME: - case ID: - EnterOuterAlt(_localctx, 3); + case 45: + EnterOuterAlt(_localctx, 45); { - State = 1171; - asmOrRefDecl(); + State = 1489; + Match(VARIANT); + State = 1490; + _localctx.marshalBool = Match(BOOL); + _localctx.Value = Actions.CreateVariantBoolNativeType(); } break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class TypeSpecContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ClassNameContext className() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MODULE() { return GetToken(CILParser.MODULE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { - return GetRuleContext(0); - } - public TypeSpecContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_typeSpec; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTypeSpec(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public TypeSpecContext typeSpec() { - TypeSpecContext _localctx = new TypeSpecContext(Context, State); - EnterRule(_localctx, 146, RULE_typeSpec); - try { - State = 1185; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,50,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); + case 46: + EnterOuterAlt(_localctx, 46); { - State = 1174; - className(); + State = 1492; + _localctx.marshalType = Match(METHOD); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } break; - case 2: - EnterOuterAlt(_localctx, 2); + case 47: + EnterOuterAlt(_localctx, 47); { - State = 1175; - Match(T__41); - State = 1176; - dottedName(); - State = 1177; - Match(T__42); + State = 1494; + _localctx.marshalType = Match(LPSTRUCT); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } break; - case 3: - EnterOuterAlt(_localctx, 3); + case 48: + EnterOuterAlt(_localctx, 48); { - State = 1179; - Match(T__41); - State = 1180; - Match(MODULE); - State = 1181; - dottedName(); - State = 1182; - Match(T__42); + State = 1496; + Match(T__33); + State = 1497; + _localctx.marshalType = Match(ANY); + _localctx.Value = Actions.CreateSimpleNativeType(_localctx.marshalType); } break; - case 4: - EnterOuterAlt(_localctx, 4); + case 49: + EnterOuterAlt(_localctx, 49); { - State = 1184; - type(); + State = 1499; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateNativeTypeTypedef(_localctx, _localctx.alias.Value); } break; } @@ -5968,66 +6448,54 @@ public TypeSpecContext typeSpec() { return _localctx; } - public partial class NativeTypeContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public NativeTypeElementContext nativeTypeElement() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public NativeTypeArrayPointerInfoContext[] nativeTypeArrayPointerInfo() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public NativeTypeArrayPointerInfoContext nativeTypeArrayPointerInfo(int i) { - return GetRuleContext(i); + public partial class IidParamIndexContext : ParserRuleContext { + public CILParser.IidParamIndexValue Value; + public Int32Context index; + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); } - public NativeTypeContext(ParserRuleContext parent, int invokingState) + public IidParamIndexContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_nativeType; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitNativeType(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_iidParamIndex; } } } [RuleVersion(0)] - public NativeTypeContext nativeType() { - NativeTypeContext _localctx = new NativeTypeContext(Context, State); - EnterRule(_localctx, 148, RULE_nativeType); + public IidParamIndexContext iidParamIndex() { + IidParamIndexContext _localctx = new IidParamIndexContext(Context, State); + EnterRule(_localctx, 134, RULE_iidParamIndex); + _localctx.Value = CILParser.IidParamIndexValue.Empty; try { - int _alt; - State = 1195; + State = 1512; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,52,Context) ) { - case 1: + switch (TokenStream.LA(1)) { + case T__30: + case T__41: + case ARRAY_TYPE_NO_BOUNDS: + case PTR: EnterOuterAlt(_localctx, 1); { } break; - case 2: + case T__29: EnterOuterAlt(_localctx, 2); { - State = 1188; - nativeTypeElement(); - State = 1192; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,51,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - State = 1189; - nativeTypeArrayPointerInfo(); - } - } - } - State = 1194; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,51,Context); - } + State = 1505; + Match(T__29); + State = 1506; + Match(T__90); + State = 1507; + Match(T__35); + State = 1508; + _localctx.index = int32(); + State = 1509; + Match(T__30); + _localctx.Value = Actions.GetIidParamIndex((_localctx.index!=null?(_localctx.index.Start):null)); } break; + default: + throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -6041,144 +6509,80 @@ public NativeTypeContext nativeType() { return _localctx; } - public partial class NativeTypeArrayPointerInfoContext : ParserRuleContext { - public NativeTypeArrayPointerInfoContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_nativeTypeArrayPointerInfo; } } - - public NativeTypeArrayPointerInfoContext() { } - public virtual void CopyFrom(NativeTypeArrayPointerInfoContext context) { - base.CopyFrom(context); - } - } - public partial class PointerArrayTypeSizeContext : NativeTypeArrayPointerInfoContext { - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { - return GetRuleContext(0); - } - public PointerArrayTypeSizeContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPointerArrayTypeSize(this); - else return visitor.VisitChildren(this); - } - } - public partial class PointerArrayTypeParamIndexContext : NativeTypeArrayPointerInfoContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PLUS() { return GetToken(CILParser.PLUS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { - return GetRuleContext(0); - } - public PointerArrayTypeParamIndexContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPointerArrayTypeParamIndex(this); - else return visitor.VisitChildren(this); - } - } - public partial class PointerNativeTypeContext : NativeTypeArrayPointerInfoContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } - public PointerNativeTypeContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPointerNativeType(this); - else return visitor.VisitChildren(this); + public partial class VariantTypeContext : ParserRuleContext { + public CILParser.VariantTypeValue Value; + public CILParser.VariantTypeBuilder Builder; + public VariantTypeElementContext element; + public IToken modifier; + [System.Diagnostics.DebuggerNonUserCode] public VariantTypeElementContext variantTypeElement() { + return GetRuleContext(0); } - } - public partial class PointerArrayTypeSizeParamIndexContext : NativeTypeArrayPointerInfoContext { - [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { - return GetRuleContexts(); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] ARRAY_TYPE_NO_BOUNDS() { return GetTokens(CILParser.ARRAY_TYPE_NO_BOUNDS); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ARRAY_TYPE_NO_BOUNDS(int i) { + return GetToken(CILParser.ARRAY_TYPE_NO_BOUNDS, i); } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32(int i) { - return GetRuleContext(i); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] VECTOR() { return GetTokens(CILParser.VECTOR); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VECTOR(int i) { + return GetToken(CILParser.VECTOR, i); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PLUS() { return GetToken(CILParser.PLUS, 0); } - public PointerArrayTypeSizeParamIndexContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPointerArrayTypeSizeParamIndex(this); - else return visitor.VisitChildren(this); + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] REF() { return GetTokens(CILParser.REF); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode REF(int i) { + return GetToken(CILParser.REF, i); } - } - public partial class PointerArrayTypeNoSizeDataContext : NativeTypeArrayPointerInfoContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ARRAY_TYPE_NO_BOUNDS() { return GetToken(CILParser.ARRAY_TYPE_NO_BOUNDS, 0); } - public PointerArrayTypeNoSizeDataContext(NativeTypeArrayPointerInfoContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPointerArrayTypeNoSizeData(this); - else return visitor.VisitChildren(this); + public VariantTypeContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { } + public override int RuleIndex { get { return RULE_variantType; } } } [RuleVersion(0)] - public NativeTypeArrayPointerInfoContext nativeTypeArrayPointerInfo() { - NativeTypeArrayPointerInfoContext _localctx = new NativeTypeArrayPointerInfoContext(Context, State); - EnterRule(_localctx, 150, RULE_nativeTypeArrayPointerInfo); + public VariantTypeContext variantType() { + VariantTypeContext _localctx = new VariantTypeContext(Context, State); + EnterRule(_localctx, 136, RULE_variantType); + _localctx.Builder = new CILParser.VariantTypeBuilder(); + int _la; try { - State = 1214; + int _alt; + State = 1524; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,53,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,62,Context) ) { case 1: - _localctx = new PointerNativeTypeContext(_localctx); EnterOuterAlt(_localctx, 1); { - State = 1197; - Match(PTR); } break; case 2: - _localctx = new PointerArrayTypeNoSizeDataContext(_localctx); EnterOuterAlt(_localctx, 2); { - State = 1198; - Match(ARRAY_TYPE_NO_BOUNDS); - } - break; - case 3: - _localctx = new PointerArrayTypeSizeContext(_localctx); - EnterOuterAlt(_localctx, 3); - { - State = 1199; - Match(T__41); - State = 1200; - int32(); - State = 1201; - Match(T__42); - } - break; - case 4: - _localctx = new PointerArrayTypeSizeParamIndexContext(_localctx); - EnterOuterAlt(_localctx, 4); - { - State = 1203; - Match(T__41); - State = 1204; - int32(); - State = 1205; - Match(PLUS); - State = 1206; - int32(); - State = 1207; - Match(T__42); + State = 1515; + _localctx.element = variantTypeElement(); + Actions.SetVariantTypeElement(_localctx.Builder, _localctx.element.Value); + State = 1521; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,61,Context); + while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + State = 1517; + _localctx.modifier = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(((((_la - 229)) & ~0x3f) == 0 && ((1L << (_la - 229)) & 6442450945L) != 0)) ) { + _localctx.modifier = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + Actions.AddVariantTypeModifier(_localctx.Builder, _localctx.modifier); + } + } + } + State = 1523; + ErrorHandler.Sync(this); + _alt = Interpreter.AdaptivePredict(TokenStream,61,Context); } - break; - case 5: - _localctx = new PointerArrayTypeParamIndexContext(_localctx); - EnterOuterAlt(_localctx, 5); - { - State = 1209; - Match(T__41); - State = 1210; - Match(PLUS); - State = 1211; - int32(); - State = 1212; - Match(T__42); } break; } @@ -6189,34 +6593,18 @@ public NativeTypeArrayPointerInfoContext nativeTypeArrayPointerInfo() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.CreateVariantType(_localctx.Builder); ExitRule(); } return _localctx; } - public partial class NativeTypeElementContext : ParserRuleContext { - public IToken marshalType; - public IToken unsignedMarshalType; - public IToken marshalBool; - [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext[] compQstring() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext compQstring(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CUSTOM() { return GetToken(CILParser.CUSTOM, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FIXED() { return GetToken(CILParser.FIXED, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SYSSTRING() { return GetToken(CILParser.SYSSTRING, 0); } - [System.Diagnostics.DebuggerNonUserCode] public NativeTypeContext nativeType() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ARRAY() { return GetToken(CILParser.ARRAY, 0); } + public partial class VariantTypeElementContext : ParserRuleContext { + public CILParser.VariantTypeElementValue Value; + public IToken value; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NULL() { return GetToken(CILParser.NULL, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIANT() { return GetToken(CILParser.VARIANT, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CURRENCY() { return GetToken(CILParser.CURRENCY, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SYSCHAR() { return GetToken(CILParser.SYSCHAR, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VOID() { return GetToken(CILParser.VOID, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOL() { return GetToken(CILParser.BOOL, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT8() { return GetToken(CILParser.INT8, 0); } @@ -6225,712 +6613,373 @@ [System.Diagnostics.DebuggerNonUserCode] public NativeTypeContext nativeType() { [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT64_() { return GetToken(CILParser.INT64_, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT32() { return GetToken(CILParser.FLOAT32, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT64_() { return GetToken(CILParser.FLOAT64_, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ERROR() { return GetToken(CILParser.ERROR, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT8() { return GetToken(CILParser.UINT8, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT16() { return GetToken(CILParser.UINT16, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT32() { return GetToken(CILParser.UINT32, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT64() { return GetToken(CILParser.UINT64, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DECIMAL() { return GetToken(CILParser.DECIMAL, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DATE() { return GetToken(CILParser.DATE, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BSTR() { return GetToken(CILParser.BSTR, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPSTR() { return GetToken(CILParser.LPSTR, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPWSTR() { return GetToken(CILParser.LPWSTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPTSTR() { return GetToken(CILParser.LPTSTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OBJECTREF() { return GetToken(CILParser.OBJECTREF, 0); } - [System.Diagnostics.DebuggerNonUserCode] public IidParamIndexContext iidParamIndex() { - return GetRuleContext(0); - } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IUNKNOWN() { return GetToken(CILParser.IUNKNOWN, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IDISPATCH() { return GetToken(CILParser.IDISPATCH, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRUCT() { return GetToken(CILParser.STRUCT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INTERFACE() { return GetToken(CILParser.INTERFACE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public VariantTypeContext variantType() { - return GetRuleContext(0); - } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SAFEARRAY() { return GetToken(CILParser.SAFEARRAY, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(CILParser.INT, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT() { return GetToken(CILParser.UINT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BYVALSTR() { return GetToken(CILParser.BYVALSTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANSI() { return GetToken(CILParser.ANSI, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TBSTR() { return GetToken(CILParser.TBSTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode METHOD() { return GetToken(CILParser.METHOD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPSTRUCT() { return GetToken(CILParser.LPSTRUCT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANY() { return GetToken(CILParser.ANY, 0); } - [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { - return GetRuleContext(0); - } - public NativeTypeElementContext(ParserRuleContext parent, int invokingState) + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ERROR() { return GetToken(CILParser.ERROR, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode HRESULT() { return GetToken(CILParser.HRESULT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CARRAY() { return GetToken(CILParser.CARRAY, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode USERDEFINED() { return GetToken(CILParser.USERDEFINED, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RECORD() { return GetToken(CILParser.RECORD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FILETIME() { return GetToken(CILParser.FILETIME, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOB() { return GetToken(CILParser.BLOB, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STREAM() { return GetToken(CILParser.STREAM, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STORAGE() { return GetToken(CILParser.STORAGE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STREAMED_OBJECT() { return GetToken(CILParser.STREAMED_OBJECT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STORED_OBJECT() { return GetToken(CILParser.STORED_OBJECT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOB_OBJECT() { return GetToken(CILParser.BLOB_OBJECT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CF() { return GetToken(CILParser.CF, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CLSID() { return GetToken(CILParser.CLSID, 0); } + public VariantTypeElementContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_nativeTypeElement; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitNativeTypeElement(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_variantTypeElement; } } } [RuleVersion(0)] - public NativeTypeElementContext nativeTypeElement() { - NativeTypeElementContext _localctx = new NativeTypeElementContext(Context, State); - EnterRule(_localctx, 152, RULE_nativeTypeElement); + public VariantTypeElementContext variantTypeElement() { + VariantTypeElementContext _localctx = new VariantTypeElementContext(Context, State); + EnterRule(_localctx, 138, RULE_variantTypeElement); + _localctx.Value = CILParser.VariantTypeElementValue.Error; try { - State = 1308; + State = 1606; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,54,Context) ) { - case 1: + switch (TokenStream.LA(1)) { + case NULL: EnterOuterAlt(_localctx, 1); { + State = 1526; + _localctx.value = Match(NULL); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 2: + case VARIANT: EnterOuterAlt(_localctx, 2); { - State = 1217; - _localctx.marshalType = Match(CUSTOM); - State = 1218; - Match(T__29); - State = 1219; - compQstring(); - State = 1220; - Match(T__27); - State = 1221; - compQstring(); - State = 1222; - Match(T__27); - State = 1223; - compQstring(); - State = 1224; - Match(T__27); - State = 1225; - compQstring(); - State = 1226; - Match(T__30); + State = 1528; + _localctx.value = Match(VARIANT); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 3: + case CURRENCY: EnterOuterAlt(_localctx, 3); { - State = 1228; - _localctx.marshalType = Match(CUSTOM); - State = 1229; - Match(T__29); - State = 1230; - compQstring(); - State = 1231; - Match(T__27); - State = 1232; - compQstring(); - State = 1233; - Match(T__30); + State = 1530; + _localctx.value = Match(CURRENCY); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 4: + case VOID: EnterOuterAlt(_localctx, 4); { - State = 1235; - Match(FIXED); - State = 1236; - _localctx.marshalType = Match(SYSSTRING); - State = 1237; - Match(T__41); - State = 1238; - int32(); - State = 1239; - Match(T__42); + State = 1532; + _localctx.value = Match(VOID); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 5: + case BOOL: EnterOuterAlt(_localctx, 5); { - State = 1241; - Match(FIXED); - State = 1242; - _localctx.marshalType = Match(ARRAY); - State = 1243; - Match(T__41); - State = 1244; - int32(); - State = 1245; - Match(T__42); - State = 1246; - nativeType(); + State = 1534; + _localctx.value = Match(BOOL); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 6: + case INT8: EnterOuterAlt(_localctx, 6); { - State = 1248; - _localctx.marshalType = Match(VARIANT); + State = 1536; + _localctx.value = Match(INT8); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 7: + case INT16: EnterOuterAlt(_localctx, 7); { - State = 1249; - _localctx.marshalType = Match(CURRENCY); - } - break; - case 8: - EnterOuterAlt(_localctx, 8); - { - State = 1250; - _localctx.marshalType = Match(SYSCHAR); - } - break; - case 9: - EnterOuterAlt(_localctx, 9); - { - State = 1251; - _localctx.marshalType = Match(VOID); - } - break; - case 10: - EnterOuterAlt(_localctx, 10); - { - State = 1252; - _localctx.marshalType = Match(BOOL); - } - break; - case 11: - EnterOuterAlt(_localctx, 11); - { - State = 1253; - _localctx.marshalType = Match(INT8); - } - break; - case 12: - EnterOuterAlt(_localctx, 12); - { - State = 1254; - _localctx.marshalType = Match(INT16); - } - break; - case 13: - EnterOuterAlt(_localctx, 13); - { - State = 1255; - _localctx.marshalType = Match(INT32_); - } - break; - case 14: - EnterOuterAlt(_localctx, 14); - { - State = 1256; - _localctx.marshalType = Match(INT64_); - } - break; - case 15: - EnterOuterAlt(_localctx, 15); - { - State = 1257; - _localctx.marshalType = Match(FLOAT32); - } - break; - case 16: - EnterOuterAlt(_localctx, 16); - { - State = 1258; - _localctx.marshalType = Match(FLOAT64_); - } - break; - case 17: - EnterOuterAlt(_localctx, 17); - { - State = 1259; - _localctx.marshalType = Match(ERROR); - } - break; - case 18: - EnterOuterAlt(_localctx, 18); - { - State = 1260; - _localctx.marshalType = Match(UINT8); - } - break; - case 19: - EnterOuterAlt(_localctx, 19); - { - State = 1261; - _localctx.marshalType = Match(UINT16); - } - break; - case 20: - EnterOuterAlt(_localctx, 20); - { - State = 1262; - _localctx.marshalType = Match(UINT32); - } - break; - case 21: - EnterOuterAlt(_localctx, 21); - { - State = 1263; - _localctx.marshalType = Match(UINT64); - } - break; - case 22: - EnterOuterAlt(_localctx, 22); - { - State = 1264; - _localctx.marshalType = Match(DECIMAL); - } - break; - case 23: - EnterOuterAlt(_localctx, 23); - { - State = 1265; - _localctx.marshalType = Match(DATE); - } - break; - case 24: - EnterOuterAlt(_localctx, 24); - { - State = 1266; - _localctx.marshalType = Match(BSTR); + State = 1538; + _localctx.value = Match(INT16); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 25: - EnterOuterAlt(_localctx, 25); + case INT32_: + EnterOuterAlt(_localctx, 8); { - State = 1267; - _localctx.marshalType = Match(LPSTR); + State = 1540; + _localctx.value = Match(INT32_); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 26: - EnterOuterAlt(_localctx, 26); + case INT64_: + EnterOuterAlt(_localctx, 9); { - State = 1268; - _localctx.marshalType = Match(LPWSTR); + State = 1542; + _localctx.value = Match(INT64_); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 27: - EnterOuterAlt(_localctx, 27); + case FLOAT32: + EnterOuterAlt(_localctx, 10); { - State = 1269; - _localctx.marshalType = Match(LPTSTR); + State = 1544; + _localctx.value = Match(FLOAT32); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 28: - EnterOuterAlt(_localctx, 28); + case FLOAT64_: + EnterOuterAlt(_localctx, 11); { - State = 1270; - _localctx.marshalType = Match(OBJECTREF); + State = 1546; + _localctx.value = Match(FLOAT64_); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 29: - EnterOuterAlt(_localctx, 29); + case UINT8: + EnterOuterAlt(_localctx, 12); { - State = 1271; - _localctx.marshalType = Match(IUNKNOWN); - State = 1272; - iidParamIndex(); + State = 1548; + _localctx.value = Match(UINT8); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 30: - EnterOuterAlt(_localctx, 30); + case UINT16: + EnterOuterAlt(_localctx, 13); { - State = 1273; - _localctx.marshalType = Match(IDISPATCH); - State = 1274; - iidParamIndex(); + State = 1550; + _localctx.value = Match(UINT16); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 31: - EnterOuterAlt(_localctx, 31); + case UINT32: + EnterOuterAlt(_localctx, 14); { - State = 1275; - _localctx.marshalType = Match(STRUCT); + State = 1552; + _localctx.value = Match(UINT32); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 32: - EnterOuterAlt(_localctx, 32); + case UINT64: + EnterOuterAlt(_localctx, 15); { - State = 1276; - _localctx.marshalType = Match(INTERFACE); - State = 1277; - iidParamIndex(); + State = 1554; + _localctx.value = Match(UINT64); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 33: - EnterOuterAlt(_localctx, 33); + case PTR: + EnterOuterAlt(_localctx, 16); { - State = 1278; - _localctx.marshalType = Match(SAFEARRAY); - State = 1279; - variantType(); + State = 1556; + _localctx.value = Match(PTR); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 34: - EnterOuterAlt(_localctx, 34); + case DECIMAL: + EnterOuterAlt(_localctx, 17); { - State = 1280; - _localctx.marshalType = Match(SAFEARRAY); - State = 1281; - variantType(); - State = 1282; - Match(T__27); - State = 1283; - compQstring(); + State = 1558; + _localctx.value = Match(DECIMAL); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 35: - EnterOuterAlt(_localctx, 35); + case DATE: + EnterOuterAlt(_localctx, 18); { - State = 1285; - _localctx.marshalType = Match(INT); + State = 1560; + _localctx.value = Match(DATE); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 36: - EnterOuterAlt(_localctx, 36); + case BSTR: + EnterOuterAlt(_localctx, 19); { - State = 1286; - _localctx.marshalType = Match(UINT); + State = 1562; + _localctx.value = Match(BSTR); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 37: - EnterOuterAlt(_localctx, 37); + case LPSTR: + EnterOuterAlt(_localctx, 20); { - State = 1287; - Match(T__89); - State = 1288; - _localctx.unsignedMarshalType = Match(INT8); + State = 1564; + _localctx.value = Match(LPSTR); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 38: - EnterOuterAlt(_localctx, 38); + case LPWSTR: + EnterOuterAlt(_localctx, 21); { - State = 1289; - Match(T__89); - State = 1290; - _localctx.unsignedMarshalType = Match(INT16); + State = 1566; + _localctx.value = Match(LPWSTR); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 39: - EnterOuterAlt(_localctx, 39); + case IUNKNOWN: + EnterOuterAlt(_localctx, 22); { - State = 1291; - Match(T__89); - State = 1292; - _localctx.unsignedMarshalType = Match(INT32_); + State = 1568; + _localctx.value = Match(IUNKNOWN); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 40: - EnterOuterAlt(_localctx, 40); + case IDISPATCH: + EnterOuterAlt(_localctx, 23); { - State = 1293; - Match(T__89); - State = 1294; - _localctx.unsignedMarshalType = Match(INT64_); + State = 1570; + _localctx.value = Match(IDISPATCH); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 41: - EnterOuterAlt(_localctx, 41); + case SAFEARRAY: + EnterOuterAlt(_localctx, 24); { - State = 1295; - Match(T__61); - State = 1296; - _localctx.marshalType = Match(STRUCT); + State = 1572; + _localctx.value = Match(SAFEARRAY); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 42: - EnterOuterAlt(_localctx, 42); + case INT: + EnterOuterAlt(_localctx, 25); { - State = 1297; - _localctx.marshalType = Match(BYVALSTR); + State = 1574; + _localctx.value = Match(INT); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 43: - EnterOuterAlt(_localctx, 43); + case UINT: + EnterOuterAlt(_localctx, 26); { - State = 1298; - Match(ANSI); - State = 1299; - _localctx.marshalType = Match(BSTR); + State = 1576; + _localctx.value = Match(UINT); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 44: - EnterOuterAlt(_localctx, 44); + case ERROR: + EnterOuterAlt(_localctx, 27); { - State = 1300; - _localctx.marshalType = Match(TBSTR); + State = 1578; + _localctx.value = Match(ERROR); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 45: - EnterOuterAlt(_localctx, 45); + case HRESULT: + EnterOuterAlt(_localctx, 28); { - State = 1301; - Match(VARIANT); - State = 1302; - _localctx.marshalBool = Match(BOOL); + State = 1580; + _localctx.value = Match(HRESULT); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 46: - EnterOuterAlt(_localctx, 46); + case CARRAY: + EnterOuterAlt(_localctx, 29); { - State = 1303; - _localctx.marshalType = Match(METHOD); + State = 1582; + _localctx.value = Match(CARRAY); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 47: - EnterOuterAlt(_localctx, 47); + case USERDEFINED: + EnterOuterAlt(_localctx, 30); { - State = 1304; - _localctx.marshalType = Match(LPSTRUCT); + State = 1584; + _localctx.value = Match(USERDEFINED); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 48: - EnterOuterAlt(_localctx, 48); + case RECORD: + EnterOuterAlt(_localctx, 31); { - State = 1305; - Match(T__33); - State = 1306; - _localctx.marshalType = Match(ANY); + State = 1586; + _localctx.value = Match(RECORD); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 49: - EnterOuterAlt(_localctx, 49); + case FILETIME: + EnterOuterAlt(_localctx, 32); { - State = 1307; - dottedName(); + State = 1588; + _localctx.value = Match(FILETIME); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class IidParamIndexContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { - return GetRuleContext(0); - } - public IidParamIndexContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_iidParamIndex; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitIidParamIndex(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public IidParamIndexContext iidParamIndex() { - IidParamIndexContext _localctx = new IidParamIndexContext(Context, State); - EnterRule(_localctx, 154, RULE_iidParamIndex); - try { - State = 1317; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case T__30: - case T__41: - case ARRAY_TYPE_NO_BOUNDS: - case PTR: - EnterOuterAlt(_localctx, 1); + case BLOB: + EnterOuterAlt(_localctx, 33); { + State = 1590; + _localctx.value = Match(BLOB); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case T__29: - EnterOuterAlt(_localctx, 2); + case STREAM: + EnterOuterAlt(_localctx, 34); { - State = 1311; - Match(T__29); - State = 1312; - Match(T__90); - State = 1313; - Match(T__35); - State = 1314; - int32(); - State = 1315; - Match(T__30); + State = 1592; + _localctx.value = Match(STREAM); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class VariantTypeContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public VariantTypeElementContext variantTypeElement() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] ARRAY_TYPE_NO_BOUNDS() { return GetTokens(CILParser.ARRAY_TYPE_NO_BOUNDS); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ARRAY_TYPE_NO_BOUNDS(int i) { - return GetToken(CILParser.ARRAY_TYPE_NO_BOUNDS, i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] VECTOR() { return GetTokens(CILParser.VECTOR); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VECTOR(int i) { - return GetToken(CILParser.VECTOR, i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] REF() { return GetTokens(CILParser.REF); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode REF(int i) { - return GetToken(CILParser.REF, i); - } - public VariantTypeContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_variantType; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitVariantType(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public VariantTypeContext variantType() { - VariantTypeContext _localctx = new VariantTypeContext(Context, State); - EnterRule(_localctx, 156, RULE_variantType); - int _la; - try { - int _alt; - State = 1327; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,57,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); + case STORAGE: + EnterOuterAlt(_localctx, 35); { + State = 1594; + _localctx.value = Match(STORAGE); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - case 2: - EnterOuterAlt(_localctx, 2); + case STREAMED_OBJECT: + EnterOuterAlt(_localctx, 36); { - State = 1320; - variantTypeElement(); - State = 1324; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,56,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - { - { - State = 1321; - _la = TokenStream.LA(1); - if ( !(((((_la - 229)) & ~0x3f) == 0 && ((1L << (_la - 229)) & 6442450945L) != 0)) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - } - } - } - State = 1326; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,56,Context); + State = 1596; + _localctx.value = Match(STREAMED_OBJECT); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } + break; + case STORED_OBJECT: + EnterOuterAlt(_localctx, 37); + { + State = 1598; + _localctx.value = Match(STORED_OBJECT); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); } break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class VariantTypeElementContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NULL() { return GetToken(CILParser.NULL, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIANT() { return GetToken(CILParser.VARIANT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CURRENCY() { return GetToken(CILParser.CURRENCY, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VOID() { return GetToken(CILParser.VOID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOL() { return GetToken(CILParser.BOOL, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT8() { return GetToken(CILParser.INT8, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT16() { return GetToken(CILParser.INT16, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT32_() { return GetToken(CILParser.INT32_, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT64_() { return GetToken(CILParser.INT64_, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT32() { return GetToken(CILParser.FLOAT32, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT64_() { return GetToken(CILParser.FLOAT64_, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT8() { return GetToken(CILParser.UINT8, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT16() { return GetToken(CILParser.UINT16, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT32() { return GetToken(CILParser.UINT32, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT64() { return GetToken(CILParser.UINT64, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DECIMAL() { return GetToken(CILParser.DECIMAL, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DATE() { return GetToken(CILParser.DATE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BSTR() { return GetToken(CILParser.BSTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPSTR() { return GetToken(CILParser.LPSTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LPWSTR() { return GetToken(CILParser.LPWSTR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IUNKNOWN() { return GetToken(CILParser.IUNKNOWN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IDISPATCH() { return GetToken(CILParser.IDISPATCH, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SAFEARRAY() { return GetToken(CILParser.SAFEARRAY, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(CILParser.INT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT() { return GetToken(CILParser.UINT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ERROR() { return GetToken(CILParser.ERROR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode HRESULT() { return GetToken(CILParser.HRESULT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CARRAY() { return GetToken(CILParser.CARRAY, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode USERDEFINED() { return GetToken(CILParser.USERDEFINED, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RECORD() { return GetToken(CILParser.RECORD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FILETIME() { return GetToken(CILParser.FILETIME, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOB() { return GetToken(CILParser.BLOB, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STREAM() { return GetToken(CILParser.STREAM, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STORAGE() { return GetToken(CILParser.STORAGE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STREAMED_OBJECT() { return GetToken(CILParser.STREAMED_OBJECT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STORED_OBJECT() { return GetToken(CILParser.STORED_OBJECT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BLOB_OBJECT() { return GetToken(CILParser.BLOB_OBJECT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CF() { return GetToken(CILParser.CF, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CLSID() { return GetToken(CILParser.CLSID, 0); } - public VariantTypeElementContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_variantTypeElement; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitVariantTypeElement(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public VariantTypeElementContext variantTypeElement() { - VariantTypeElementContext _localctx = new VariantTypeElementContext(Context, State); - EnterRule(_localctx, 158, RULE_variantTypeElement); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 1329; - _la = TokenStream.LA(1); - if ( !(((((_la - 178)) & ~0x3f) == 0 && ((1L << (_la - 178)) & -4482436704239647L) != 0) || _la==CLSID || _la==PTR) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } + case BLOB_OBJECT: + EnterOuterAlt(_localctx, 38); + { + State = 1600; + _localctx.value = Match(BLOB_OBJECT); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); + } + break; + case CF: + EnterOuterAlt(_localctx, 39); + { + State = 1602; + _localctx.value = Match(CF); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); + } + break; + case CLSID: + EnterOuterAlt(_localctx, 40); + { + State = 1604; + _localctx.value = Match(CLSID); + _localctx.Value = Actions.GetVariantTypeElement(_localctx.value); + } + break; + default: + throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -6945,6 +6994,11 @@ public VariantTypeElementContext variantTypeElement() { } public partial class TypeContext : ParserRuleContext { + public CILParser.TypeValue Value; + public CILParser.ElementTypeValue ElementType; + public System.Collections.Immutable.ImmutableArray.Builder Modifiers; + public ElementTypeContext element; + public TypeModifiersContext modifier; [System.Diagnostics.DebuggerNonUserCode] public ElementTypeContext elementType() { return GetRuleContext(0); } @@ -6959,39 +7013,39 @@ public TypeContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_type; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitType(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TypeContext type() { TypeContext _localctx = new TypeContext(Context, State); - EnterRule(_localctx, 160, RULE_type); + EnterRule(_localctx, 140, RULE_type); + + _localctx.ElementType = CILParser.ElementTypeValue.Error; + _localctx.Modifiers = System.Collections.Immutable.ImmutableArray.CreateBuilder(); + try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 1331; - elementType(); - State = 1335; + State = 1608; + _localctx.element = elementType(); + _localctx.ElementType = _localctx.element.Value; + State = 1615; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,58,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,64,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1332; - typeModifiers(); + State = 1610; + _localctx.modifier = typeModifiers(); + _localctx.Modifiers.Add(_localctx.modifier.Value); } } } - State = 1337; + State = 1617; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,58,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,64,Context); } } } @@ -7001,12 +7055,14 @@ public TypeContext type() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = new CILParser.TypeValue(_localctx.ElementType, _localctx.Modifiers.ToImmutable()); ExitRule(); } return _localctx; } public partial class TypeModifiersContext : ParserRuleContext { + public CILParser.TypeModifierValue Value; public TypeModifiersContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { @@ -7016,188 +7072,155 @@ public TypeModifiersContext(ParserRuleContext parent, int invokingState) public TypeModifiersContext() { } public virtual void CopyFrom(TypeModifiersContext context) { base.CopyFrom(context); + this.Value = context.Value; } } public partial class OptionalModifierContext : TypeModifiersContext { + public TypeSpecContext modifierType; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } public OptionalModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitOptionalModifier(this); - else return visitor.VisitChildren(this); - } } public partial class SZArrayModifierContext : TypeModifiersContext { [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ARRAY_TYPE_NO_BOUNDS() { return GetToken(CILParser.ARRAY_TYPE_NO_BOUNDS, 0); } public SZArrayModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSZArrayModifier(this); - else return visitor.VisitChildren(this); - } } public partial class RequiredModifierContext : TypeModifiersContext { + public TypeSpecContext modifierType; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } public RequiredModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitRequiredModifier(this); - else return visitor.VisitChildren(this); - } } public partial class PtrModifierContext : TypeModifiersContext { [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } public PtrModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPtrModifier(this); - else return visitor.VisitChildren(this); - } } public partial class PinnedModifierContext : TypeModifiersContext { public PinnedModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPinnedModifier(this); - else return visitor.VisitChildren(this); - } } public partial class GenericArgumentsModifierContext : TypeModifiersContext { + public TypeArgsContext arguments; [System.Diagnostics.DebuggerNonUserCode] public TypeArgsContext typeArgs() { return GetRuleContext(0); } public GenericArgumentsModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitGenericArgumentsModifier(this); - else return visitor.VisitChildren(this); - } } public partial class ByRefModifierContext : TypeModifiersContext { [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode REF() { return GetToken(CILParser.REF, 0); } public ByRefModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitByRefModifier(this); - else return visitor.VisitChildren(this); - } } public partial class ArrayModifierContext : TypeModifiersContext { + public BoundsContext arrayBounds; [System.Diagnostics.DebuggerNonUserCode] public BoundsContext bounds() { return GetRuleContext(0); } public ArrayModifierContext(TypeModifiersContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitArrayModifier(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TypeModifiersContext typeModifiers() { TypeModifiersContext _localctx = new TypeModifiersContext(Context, State); - EnterRule(_localctx, 162, RULE_typeModifiers); + EnterRule(_localctx, 142, RULE_typeModifiers); + _localctx.Value = CILParser.TypeModifierValue.Error; try { - State = 1356; + State = 1647; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,59,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,65,Context) ) { case 1: _localctx = new SZArrayModifierContext(_localctx); EnterOuterAlt(_localctx, 1); { - State = 1338; + State = 1618; Match(ARRAY_TYPE_NO_BOUNDS); + _localctx.Value = Actions.CreateSzArrayTypeModifier(); } break; case 2: _localctx = new SZArrayModifierContext(_localctx); EnterOuterAlt(_localctx, 2); { - State = 1339; + State = 1620; Match(T__41); - State = 1340; + State = 1621; Match(T__42); + _localctx.Value = Actions.CreateSzArrayTypeModifier(); } break; case 3: _localctx = new ArrayModifierContext(_localctx); EnterOuterAlt(_localctx, 3); { - State = 1341; - bounds(); + State = 1623; + ((ArrayModifierContext)_localctx).arrayBounds = bounds(); + _localctx.Value = Actions.CreateArrayTypeModifier(((ArrayModifierContext)_localctx).arrayBounds.Value); } break; case 4: _localctx = new ByRefModifierContext(_localctx); EnterOuterAlt(_localctx, 4); { - State = 1342; + State = 1626; Match(REF); + _localctx.Value = Actions.CreateByReferenceTypeModifier(); } break; case 5: _localctx = new PtrModifierContext(_localctx); EnterOuterAlt(_localctx, 5); { - State = 1343; + State = 1628; Match(PTR); + _localctx.Value = Actions.CreatePointerTypeModifier(); } break; case 6: _localctx = new PinnedModifierContext(_localctx); EnterOuterAlt(_localctx, 6); { - State = 1344; + State = 1630; Match(T__91); + _localctx.Value = Actions.CreatePinnedTypeModifier(); } break; case 7: _localctx = new RequiredModifierContext(_localctx); EnterOuterAlt(_localctx, 7); { - State = 1345; + State = 1632; Match(T__92); - State = 1346; + State = 1633; Match(T__29); - State = 1347; - typeSpec(); - State = 1348; + State = 1634; + ((RequiredModifierContext)_localctx).modifierType = typeSpec(); + State = 1635; Match(T__30); + _localctx.Value = Actions.CreateCustomTypeModifier(((RequiredModifierContext)_localctx).modifierType.Value, true); } break; case 8: _localctx = new OptionalModifierContext(_localctx); EnterOuterAlt(_localctx, 8); { - State = 1350; + State = 1638; Match(T__93); - State = 1351; + State = 1639; Match(T__29); - State = 1352; - typeSpec(); - State = 1353; + State = 1640; + ((OptionalModifierContext)_localctx).modifierType = typeSpec(); + State = 1641; Match(T__30); + _localctx.Value = Actions.CreateCustomTypeModifier(((OptionalModifierContext)_localctx).modifierType.Value, false); } break; case 9: _localctx = new GenericArgumentsModifierContext(_localctx); EnterOuterAlt(_localctx, 9); { - State = 1355; - typeArgs(); + State = 1644; + ((GenericArgumentsModifierContext)_localctx).arguments = typeArgs(); + _localctx.Value = Actions.CreateGenericArgumentsModifier(((GenericArgumentsModifierContext)_localctx).arguments.Value); } break; } @@ -7214,6 +7237,20 @@ public TypeModifiersContext typeModifiers() { } public partial class ElementTypeContext : ParserRuleContext { + public CILParser.ElementTypeValue Value; + public ClassNameContext classType; + public ClassNameContext valueClassType; + public ClassNameContext valueType; + public CallConvContext convention; + public TypeContext returnType; + public SigArgsContext arguments; + public Int32Context parameterIndex; + public DottedNameContext parameterName; + public NativeIntContext signedNative; + public NativeUintContext unsignedNative; + public SimpleTypeContext primitive; + public DottedNameContext alias; + public TypeContext sentinelType; [System.Diagnostics.DebuggerNonUserCode] public ClassNameContext className() { return GetRuleContext(0); } @@ -7221,13 +7258,13 @@ [System.Diagnostics.DebuggerNonUserCode] public ClassNameContext className() { [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VALUE() { return GetToken(CILParser.VALUE, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VALUETYPE() { return GetToken(CILParser.VALUETYPE, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode METHOD() { return GetToken(CILParser.METHOD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } [System.Diagnostics.DebuggerNonUserCode] public SigArgsContext sigArgs() { return GetRuleContext(0); } @@ -7256,158 +7293,169 @@ public ElementTypeContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_elementType; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitElementType(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ElementTypeContext elementType() { ElementTypeContext _localctx = new ElementTypeContext(Context, State); - EnterRule(_localctx, 164, RULE_elementType); + EnterRule(_localctx, 144, RULE_elementType); + _localctx.Value = CILParser.ElementTypeValue.Error; try { - State = 1388; + State = 1707; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,60,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,66,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1358; + State = 1649; Match(T__38); - State = 1359; - className(); + State = 1650; + _localctx.classType = className(); + _localctx.Value = Actions.CreateClassElementType(_localctx.classType.Value, false); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1360; + State = 1653; Match(OBJECT); + _localctx.Value = Actions.CreateObjectElementType(); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1361; + State = 1655; Match(VALUE); - State = 1362; + State = 1656; Match(T__38); - State = 1363; - className(); + State = 1657; + _localctx.valueClassType = className(); + _localctx.Value = Actions.CreateClassElementType(_localctx.valueClassType.Value, true); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1364; + State = 1660; Match(VALUETYPE); - State = 1365; - className(); + State = 1661; + _localctx.valueType = className(); + _localctx.Value = Actions.CreateClassElementType(_localctx.valueType.Value, true); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1366; + State = 1664; Match(METHOD); - State = 1367; - callConv(); - State = 1368; - type(); - State = 1369; + State = 1665; + _localctx.convention = callConv(); + State = 1666; + _localctx.returnType = type(); + State = 1667; Match(PTR); - State = 1370; - sigArgs(); + State = 1668; + _localctx.arguments = sigArgs(); + _localctx.Value = Actions.CreateFunctionPointerElementType(_localctx.convention.Value, _localctx.returnType.Value, _localctx.arguments.Value); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1372; + State = 1671; Match(METHOD_TYPE_PARAMETER); - State = 1373; - int32(); + State = 1672; + _localctx.parameterIndex = int32(); + _localctx.Value = Actions.CreateIndexedGenericParameterElementType(true, (_localctx.parameterIndex!=null?(_localctx.parameterIndex.Start):null)); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 1374; + State = 1675; Match(TYPE_PARAMETER); - State = 1375; - int32(); + State = 1676; + _localctx.parameterIndex = int32(); + _localctx.Value = Actions.CreateIndexedGenericParameterElementType(false, (_localctx.parameterIndex!=null?(_localctx.parameterIndex.Start):null)); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 1376; + State = 1679; Match(METHOD_TYPE_PARAMETER); - State = 1377; - dottedName(); + State = 1680; + _localctx.parameterName = dottedName(); + _localctx.Value = Actions.CreateNamedGenericParameterElementType(_localctx.Start, true, _localctx.parameterName.Value); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 1378; + State = 1683; Match(TYPE_PARAMETER); - State = 1379; - dottedName(); + State = 1684; + _localctx.parameterName = dottedName(); + _localctx.Value = Actions.CreateNamedGenericParameterElementType(_localctx.Start, false, _localctx.parameterName.Value); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 1380; + State = 1687; Match(TYPEDREF); + _localctx.Value = Actions.CreateTypedReferenceElementType(); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 1381; + State = 1689; Match(VOID); + _localctx.Value = Actions.CreateVoidElementType(); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 1382; - nativeInt(); + State = 1691; + _localctx.signedNative = nativeInt(); + _localctx.Value = Actions.CreatePrimitiveElementType(_localctx.signedNative.Value); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 1383; - nativeUint(); + State = 1694; + _localctx.unsignedNative = nativeUint(); + _localctx.Value = Actions.CreatePrimitiveElementType(_localctx.unsignedNative.Value); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 1384; - simpleType(); + State = 1697; + _localctx.primitive = simpleType(); + _localctx.Value = Actions.CreatePrimitiveElementType(_localctx.primitive.Value); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 1385; - dottedName(); + State = 1700; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateTypedefElementType(_localctx.Start, _localctx.alias.Value); } break; case 16: EnterOuterAlt(_localctx, 16); { - State = 1386; + State = 1703; Match(ELLIPSIS); - State = 1387; - type(); + State = 1704; + _localctx.sentinelType = type(); + _localctx.Value = Actions.CreateSentinelElementType(_localctx.sentinelType.Value); } break; } @@ -7424,6 +7472,8 @@ public ElementTypeContext elementType() { } public partial class SimpleTypeContext : ParserRuleContext { + public byte Value; + public IToken value; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CHAR() { return GetToken(CILParser.CHAR, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(CILParser.STRING, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BOOL() { return GetToken(CILParser.BOOL, 0); } @@ -7442,147 +7492,158 @@ public SimpleTypeContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_simpleType; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSimpleType(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SimpleTypeContext simpleType() { SimpleTypeContext _localctx = new SimpleTypeContext(Context, State); - EnterRule(_localctx, 166, RULE_simpleType); + EnterRule(_localctx, 146, RULE_simpleType); try { - State = 1411; + State = 1747; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,61,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,67,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1390; - Match(CHAR); + State = 1709; + _localctx.value = Match(CHAR); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1391; - Match(STRING); + State = 1711; + _localctx.value = Match(STRING); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1392; - Match(BOOL); + State = 1713; + _localctx.value = Match(BOOL); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1393; - Match(INT8); + State = 1715; + _localctx.value = Match(INT8); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1394; - Match(INT16); + State = 1717; + _localctx.value = Match(INT16); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1395; - Match(INT32_); + State = 1719; + _localctx.value = Match(INT32_); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 1396; - Match(INT64_); + State = 1721; + _localctx.value = Match(INT64_); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 1397; - Match(FLOAT32); + State = 1723; + _localctx.value = Match(FLOAT32); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 1398; - Match(FLOAT64_); + State = 1725; + _localctx.value = Match(FLOAT64_); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 1399; - Match(UINT8); + State = 1727; + _localctx.value = Match(UINT8); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 1400; - Match(UINT16); + State = 1729; + _localctx.value = Match(UINT16); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 1401; - Match(UINT32); + State = 1731; + _localctx.value = Match(UINT32); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 1402; - Match(UINT64); + State = 1733; + _localctx.value = Match(UINT64); + _localctx.Value = Actions.GetSimpleType(_localctx.value, false); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 1403; + State = 1735; Match(T__89); - State = 1404; - Match(INT8); + State = 1736; + _localctx.value = Match(INT8); + _localctx.Value = Actions.GetSimpleType(_localctx.value, true); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 1405; + State = 1738; Match(T__89); - State = 1406; - Match(INT16); + State = 1739; + _localctx.value = Match(INT16); + _localctx.Value = Actions.GetSimpleType(_localctx.value, true); } break; case 16: EnterOuterAlt(_localctx, 16); { - State = 1407; + State = 1741; Match(T__89); - State = 1408; - Match(INT32_); + State = 1742; + _localctx.value = Match(INT32_); + _localctx.Value = Actions.GetSimpleType(_localctx.value, true); } break; case 17: EnterOuterAlt(_localctx, 17); { - State = 1409; + State = 1744; Match(T__89); - State = 1410; - Match(INT64_); + State = 1745; + _localctx.value = Match(INT64_); + _localctx.Value = Actions.GetSimpleType(_localctx.value, true); } break; } @@ -7599,6 +7660,13 @@ public SimpleTypeContext simpleType() { } public partial class BoundContext : ParserRuleContext { + public int Lower; + public int Upper; + public bool HasLower; + public bool HasUpper; + public Int32Context size; + public Int32Context lower; + public Int32Context upper; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELLIPSIS() { return GetToken(CILParser.ELLIPSIS, 0); } [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { return GetRuleContexts(); @@ -7611,22 +7679,17 @@ public BoundContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_bound; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitBound(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public BoundContext bound() { BoundContext _localctx = new BoundContext(Context, State); - EnterRule(_localctx, 168, RULE_bound); + EnterRule(_localctx, 148, RULE_bound); + Actions.InitializeBound(_localctx); try { - State = 1423; + State = 1763; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,62,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,68,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { @@ -7635,35 +7698,38 @@ public BoundContext bound() { case 2: EnterOuterAlt(_localctx, 2); { - State = 1414; + State = 1750; Match(ELLIPSIS); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1415; - int32(); + State = 1751; + _localctx.size = int32(); + Actions.SetBoundSize(_localctx, (_localctx.size!=null?(_localctx.size.Start):null)); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1416; - int32(); - State = 1417; + State = 1754; + _localctx.lower = int32(); + State = 1755; Match(ELLIPSIS); - State = 1418; - int32(); + State = 1756; + _localctx.upper = int32(); + Actions.SetBoundRange(_localctx, (_localctx.lower!=null?(_localctx.lower.Start):null), (_localctx.upper!=null?(_localctx.upper.Start):null)); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1420; - int32(); - State = 1421; + State = 1759; + _localctx.lower = int32(); + State = 1760; Match(ELLIPSIS); + Actions.SetBoundLower(_localctx, (_localctx.lower!=null?(_localctx.lower.Start):null)); } break; } @@ -7680,31 +7746,27 @@ public BoundContext bound() { } public partial class NativeIntContext : ParserRuleContext { + public byte Value; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(CILParser.INT, 0); } public NativeIntContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_nativeInt; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitNativeInt(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public NativeIntContext nativeInt() { NativeIntContext _localctx = new NativeIntContext(Context, State); - EnterRule(_localctx, 170, RULE_nativeInt); + EnterRule(_localctx, 150, RULE_nativeInt); try { EnterOuterAlt(_localctx, 1); { - State = 1425; + State = 1765; Match(T__0); - State = 1426; + State = 1766; Match(INT); + _localctx.Value = Actions.GetNativeIntType(); } } catch (RecognitionException re) { @@ -7719,6 +7781,7 @@ public NativeIntContext nativeInt() { } public partial class NativeUintContext : ParserRuleContext { + public byte Value; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(CILParser.INT, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UINT() { return GetToken(CILParser.UINT, 0); } public NativeUintContext(ParserRuleContext parent, int invokingState) @@ -7726,43 +7789,38 @@ public NativeUintContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_nativeUint; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitNativeUint(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public NativeUintContext nativeUint() { NativeUintContext _localctx = new NativeUintContext(Context, State); - EnterRule(_localctx, 172, RULE_nativeUint); + EnterRule(_localctx, 152, RULE_nativeUint); try { EnterOuterAlt(_localctx, 1); { - State = 1428; + State = 1769; Match(T__0); - State = 1432; + State = 1773; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__89: { - State = 1429; + State = 1770; Match(T__89); - State = 1430; + State = 1771; Match(INT); } break; case UINT: { - State = 1431; + State = 1772; Match(UINT); } break; default: throw new NoViableAltException(this); } + _localctx.Value = Actions.GetNativeUIntType(); } } catch (RecognitionException re) { @@ -7777,6 +7835,16 @@ public NativeUintContext nativeUint() { } public partial class SecDeclContext : ParserRuleContext { + public CILParser.SecurityDeclarationValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public SecActionContext action; + public TypeSpecContext permissionType; + public NameValPairsContext pairs; + public CustomBlobDescrContext structuredValue; + public BytesContext rawValue; + public CompQstringContext textValue; + public SecAttrSetBlobContext attributes; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PERMISSION() { return GetToken(CILParser.PERMISSION, 0); } [System.Diagnostics.DebuggerNonUserCode] public SecActionContext secAction() { return GetRuleContext(0); @@ -7805,140 +7873,148 @@ public SecDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_secDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSecDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SecDeclContext secDecl() { SecDeclContext _localctx = new SecDeclContext(Context, State); - EnterRule(_localctx, 174, RULE_secDecl); + EnterRule(_localctx, 154, RULE_secDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; int _la; try { - State = 1481; + State = 1831; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,65,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,71,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1434; + State = 1777; Match(PERMISSION); - State = 1435; - secAction(); - State = 1436; - typeSpec(); - State = 1437; + State = 1778; + _localctx.action = secAction(); + State = 1779; + _localctx.permissionType = typeSpec(); + State = 1780; Match(T__29); - State = 1438; - nameValPairs(); - State = 1439; + State = 1781; + _localctx.pairs = nameValPairs(); + State = 1782; Match(T__30); + _localctx.Value = Actions.CreateNamedPermissionDeclaration( + _localctx.action.Value, + _localctx.permissionType.Value, + _localctx.pairs.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1441; + State = 1785; Match(PERMISSION); - State = 1442; - secAction(); - State = 1443; - typeSpec(); - State = 1444; + State = 1786; + _localctx.action = secAction(); + State = 1787; + _localctx.permissionType = typeSpec(); + State = 1788; Match(T__35); - State = 1445; + State = 1789; Match(T__16); - State = 1446; - customBlobDescr(); - State = 1447; + State = 1790; + _localctx.structuredValue = customBlobDescr(); + State = 1791; Match(T__17); + _localctx.Value = Actions.CreateStructuredPermissionDeclaration( + _localctx.action.Value, + _localctx.permissionType.Value, + _localctx.structuredValue.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1449; + State = 1794; Match(PERMISSION); - State = 1450; - secAction(); - State = 1451; - typeSpec(); + State = 1795; + _localctx.action = secAction(); + State = 1796; + _localctx.permissionType = typeSpec(); + _localctx.Value = Actions.CreateEmptyPermissionDeclaration(_localctx.action.Value, _localctx.permissionType.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1453; + State = 1799; Match(PERMISSIONSET); - State = 1454; - secAction(); - State = 1455; + State = 1800; + _localctx.action = secAction(); + State = 1801; Match(T__35); - State = 1457; + State = 1803; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==T__83) { { - State = 1456; + State = 1802; Match(T__83); } } - State = 1459; + State = 1805; Match(T__29); - State = 1460; - bytes(); - State = 1461; + State = 1806; + _localctx.rawValue = bytes(); + State = 1807; Match(T__30); + _localctx.Value = Actions.CreateRawPermissionSetDeclaration(_localctx.action.Value, _localctx.rawValue.Value); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1463; + State = 1810; Match(PERMISSIONSET); - State = 1464; - secAction(); - State = 1465; + State = 1811; + _localctx.action = secAction(); + State = 1812; Match(T__83); - State = 1466; + State = 1813; Match(T__29); - State = 1467; - bytes(); - State = 1468; + State = 1814; + _localctx.rawValue = bytes(); + State = 1815; Match(T__30); + _localctx.Value = Actions.CreateRawPermissionSetDeclaration(_localctx.action.Value, _localctx.rawValue.Value); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1470; + State = 1818; Match(PERMISSIONSET); - State = 1471; - secAction(); - State = 1472; - compQstring(); + State = 1819; + _localctx.action = secAction(); + State = 1820; + _localctx.textValue = compQstring(); + _localctx.Value = Actions.CreateStringPermissionSetDeclaration(_localctx.action.Value, _localctx.textValue.Value); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 1474; + State = 1823; Match(PERMISSIONSET); - State = 1475; - secAction(); - State = 1476; + State = 1824; + _localctx.action = secAction(); + State = 1825; Match(T__35); - State = 1477; + State = 1826; Match(T__16); - State = 1478; - secAttrSetBlob(); - State = 1479; + State = 1827; + _localctx.attributes = secAttrSetBlob(); + State = 1828; Match(T__17); + _localctx.Value = Actions.CreateAttributePermissionSetDeclaration(_localctx.action.Value, _localctx.attributes.Value); } break; } @@ -7949,12 +8025,17 @@ public SecDeclContext secDecl() { ErrorHandler.Recover(this, re); } finally { + Actions.EndSecurityDeclaration(_localctx, _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; } public partial class SecAttrSetBlobContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public SecAttrBlobContext attribute; + public SecAttrBlobContext tail; [System.Diagnostics.DebuggerNonUserCode] public SecAttrBlobContext[] secAttrBlob() { return GetRuleContexts(); } @@ -7966,21 +8047,16 @@ public SecAttrSetBlobContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_secAttrSetBlob; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSecAttrSetBlob(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SecAttrSetBlobContext secAttrSetBlob() { SecAttrSetBlobContext _localctx = new SecAttrSetBlobContext(Context, State); - EnterRule(_localctx, 176, RULE_secAttrSetBlob); + EnterRule(_localctx, 156, RULE_secAttrSetBlob); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { int _alt; - State = 1493; + State = 1846; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__17: @@ -8025,26 +8101,28 @@ public SecAttrSetBlobContext secAttrSetBlob() { case ID: EnterOuterAlt(_localctx, 2); { - State = 1489; + State = 1840; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,66,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,72,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1484; - secAttrBlob(); - State = 1485; + State = 1834; + _localctx.attribute = secAttrBlob(); + _localctx.Builder.Add(_localctx.attribute.Value); + State = 1836; Match(T__27); } } } - State = 1491; + State = 1842; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,66,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,72,Context); } - State = 1492; - secAttrBlob(); + State = 1843; + _localctx.tail = secAttrBlob(); + _localctx.Builder.Add(_localctx.tail.Value); } break; default: @@ -8057,12 +8135,17 @@ public SecAttrSetBlobContext secAttrSetBlob() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class SecAttrBlobContext : ParserRuleContext { + public CILParser.SecurityAttributeValue Value; + public IToken name; + public CustomBlobNVPairsContext arguments; + public TypeSpecContext securityType; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SQSTRING() { return GetToken(CILParser.SQSTRING, 0); } [System.Diagnostics.DebuggerNonUserCode] public CustomBlobNVPairsContext customBlobNVPairs() { return GetRuleContext(0); @@ -8075,52 +8158,49 @@ public SecAttrBlobContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_secAttrBlob; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSecAttrBlob(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SecAttrBlobContext secAttrBlob() { SecAttrBlobContext _localctx = new SecAttrBlobContext(Context, State); - EnterRule(_localctx, 178, RULE_secAttrBlob); + EnterRule(_localctx, 158, RULE_secAttrBlob); + _localctx.Value = CILParser.SecurityAttributeValue.Error; try { - State = 1508; + State = 1863; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,68,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,74,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1495; + State = 1848; Match(T__38); - State = 1496; - Match(SQSTRING); - State = 1497; + State = 1849; + _localctx.name = Match(SQSTRING); + State = 1850; Match(T__35); - State = 1498; + State = 1851; Match(T__16); - State = 1499; - customBlobNVPairs(); - State = 1500; + State = 1852; + _localctx.arguments = customBlobNVPairs(); + State = 1853; Match(T__17); + _localctx.Value = Actions.CreateNamedSecurityAttribute(_localctx.name, _localctx.arguments.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1502; - typeSpec(); - State = 1503; + State = 1856; + _localctx.securityType = typeSpec(); + State = 1857; Match(T__35); - State = 1504; + State = 1858; Match(T__16); - State = 1505; - customBlobNVPairs(); - State = 1506; + State = 1859; + _localctx.arguments = customBlobNVPairs(); + State = 1860; Match(T__17); + _localctx.Value = Actions.CreateTypedSecurityAttribute(_localctx.securityType.Value, _localctx.arguments.Value); } break; } @@ -8137,6 +8217,10 @@ public SecAttrBlobContext secAttrBlob() { } public partial class NameValPairsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public NameValPairContext pair; + public NameValPairContext tail; [System.Diagnostics.DebuggerNonUserCode] public NameValPairContext[] nameValPair() { return GetRuleContexts(); } @@ -8148,42 +8232,39 @@ public NameValPairsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_nameValPairs; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitNameValPairs(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public NameValPairsContext nameValPairs() { NameValPairsContext _localctx = new NameValPairsContext(Context, State); - EnterRule(_localctx, 180, RULE_nameValPairs); + EnterRule(_localctx, 160, RULE_nameValPairs); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 1515; + State = 1871; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,69,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,75,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1510; - nameValPair(); - State = 1511; + State = 1865; + _localctx.pair = nameValPair(); + _localctx.Builder.Add(_localctx.pair.Value); + State = 1867; Match(T__27); } } } - State = 1517; + State = 1873; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,69,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,75,Context); } - State = 1518; - nameValPair(); + State = 1874; + _localctx.tail = nameValPair(); + _localctx.Builder.Add(_localctx.tail.Value); } } catch (RecognitionException re) { @@ -8192,12 +8273,16 @@ public NameValPairsContext nameValPairs() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class NameValPairContext : ParserRuleContext { + public CILParser.SecurityNameValuePairValue Value; + public CompQstringContext name; + public CaValueContext value; [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext compQstring() { return GetRuleContext(0); } @@ -8209,27 +8294,23 @@ public NameValPairContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_nameValPair; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitNameValPair(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public NameValPairContext nameValPair() { NameValPairContext _localctx = new NameValPairContext(Context, State); - EnterRule(_localctx, 182, RULE_nameValPair); + EnterRule(_localctx, 162, RULE_nameValPair); + _localctx.Value = CILParser.SecurityNameValuePairValue.Error; try { EnterOuterAlt(_localctx, 1); { - State = 1520; - compQstring(); - State = 1521; + State = 1877; + _localctx.name = compQstring(); + State = 1878; Match(T__35); - State = 1522; - caValue(); + State = 1879; + _localctx.value = caValue(); + _localctx.Value = Actions.CreateSecurityNameValuePair(_localctx.name.Value, _localctx.value.Value); } } catch (RecognitionException re) { @@ -8244,28 +8325,23 @@ public NameValPairContext nameValPair() { } public partial class TruefalseContext : ParserRuleContext { + public bool Value; public TruefalseContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_truefalse; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTruefalse(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TruefalseContext truefalse() { TruefalseContext _localctx = new TruefalseContext(Context, State); - EnterRule(_localctx, 184, RULE_truefalse); + EnterRule(_localctx, 164, RULE_truefalse); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1524; + State = 1882; _la = TokenStream.LA(1); if ( !(_la==T__94 || _la==T__95) ) { ErrorHandler.RecoverInline(this); @@ -8275,6 +8351,8 @@ public TruefalseContext truefalse() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = Actions.ParseBoolean(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -8288,6 +8366,13 @@ public TruefalseContext truefalse() { } public partial class CaValueContext : ParserRuleContext { + public CILParser.SecurityCaValue Value; + public TruefalseContext booleanValue; + public Int32Context integerValue; + public CompQstringContext textValue; + public ClassNameContext enumType; + public IToken kind; + public Int32Context enumValue; [System.Diagnostics.DebuggerNonUserCode] public TruefalseContext truefalse() { return GetRuleContext(0); } @@ -8308,118 +8393,121 @@ public CaValueContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_caValue; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCaValue(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CaValueContext caValue() { CaValueContext _localctx = new CaValueContext(Context, State); - EnterRule(_localctx, 186, RULE_caValue); + EnterRule(_localctx, 166, RULE_caValue); + _localctx.Value = CILParser.SecurityCaValue.Error; try { - State = 1560; + State = 1929; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,70,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,76,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1526; - truefalse(); + State = 1884; + _localctx.booleanValue = truefalse(); + _localctx.Value = Actions.CreateSecurityBooleanValue(_localctx.booleanValue.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1527; - int32(); + State = 1887; + _localctx.integerValue = int32(); + _localctx.Value = Actions.CreateSecurityInt32Value((_localctx.integerValue!=null?(_localctx.integerValue.Start):null)); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1528; + State = 1890; Match(INT32_); - State = 1529; + State = 1891; Match(T__29); - State = 1530; - int32(); - State = 1531; + State = 1892; + _localctx.integerValue = int32(); + State = 1893; Match(T__30); + _localctx.Value = Actions.CreateSecurityInt32Value((_localctx.integerValue!=null?(_localctx.integerValue.Start):null)); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1533; - compQstring(); + State = 1896; + _localctx.textValue = compQstring(); + _localctx.Value = Actions.CreateSecurityStringValue(_localctx.textValue.Value); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1534; - className(); - State = 1535; + State = 1899; + _localctx.enumType = className(); + State = 1900; Match(T__29); - State = 1536; - Match(INT8); - State = 1537; + State = 1901; + _localctx.kind = Match(INT8); + State = 1902; Match(T__74); - State = 1538; - int32(); - State = 1539; + State = 1903; + _localctx.enumValue = int32(); + State = 1904; Match(T__30); + _localctx.Value = Actions.CreateSecurityEnumValue(_localctx.enumType.Value, _localctx.kind, (_localctx.enumValue!=null?(_localctx.enumValue.Start):null)); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1541; - className(); - State = 1542; + State = 1907; + _localctx.enumType = className(); + State = 1908; Match(T__29); - State = 1543; - Match(INT16); - State = 1544; + State = 1909; + _localctx.kind = Match(INT16); + State = 1910; Match(T__74); - State = 1545; - int32(); - State = 1546; + State = 1911; + _localctx.enumValue = int32(); + State = 1912; Match(T__30); + _localctx.Value = Actions.CreateSecurityEnumValue(_localctx.enumType.Value, _localctx.kind, (_localctx.enumValue!=null?(_localctx.enumValue.Start):null)); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 1548; - className(); - State = 1549; + State = 1915; + _localctx.enumType = className(); + State = 1916; Match(T__29); - State = 1550; - Match(INT32_); - State = 1551; + State = 1917; + _localctx.kind = Match(INT32_); + State = 1918; Match(T__74); - State = 1552; - int32(); - State = 1553; + State = 1919; + _localctx.enumValue = int32(); + State = 1920; Match(T__30); + _localctx.Value = Actions.CreateSecurityEnumValue(_localctx.enumType.Value, _localctx.kind, (_localctx.enumValue!=null?(_localctx.enumValue.Start):null)); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 1555; - className(); - State = 1556; + State = 1923; + _localctx.enumType = className(); + State = 1924; Match(T__29); - State = 1557; - int32(); - State = 1558; + State = 1925; + _localctx.enumValue = int32(); + State = 1926; Match(T__30); + _localctx.Value = Actions.CreateSecurityEnumValue(_localctx.enumType.Value, (_localctx.enumValue!=null?(_localctx.enumValue.Start):null)); } break; } @@ -8436,28 +8524,23 @@ public CaValueContext caValue() { } public partial class SecActionContext : ParserRuleContext { + public System.Reflection.DeclarativeSecurityAction Value; public SecActionContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_secAction; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSecAction(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SecActionContext secAction() { SecActionContext _localctx = new SecActionContext(Context, State); - EnterRule(_localctx, 188, RULE_secAction); + EnterRule(_localctx, 168, RULE_secAction); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1562; + State = 1931; _la = TokenStream.LA(1); if ( !(((((_la - 97)) & ~0x3f) == 0 && ((1L << (_la - 97)) & 32767L) != 0)) ) { ErrorHandler.RecoverInline(this); @@ -8467,6 +8550,8 @@ public SecActionContext secAction() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = Actions.ParseSecurityAction(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -8480,6 +8565,19 @@ public SecActionContext secAction() { } public partial class MethodRefContext : ParserRuleContext { + public CILParser.MethodReferenceValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public CallConvContext convention; + public TypeContext returnType; + public TypeSpecContext owner; + public MethodNameContext name; + public TypeArgsContext genericArguments; + public SigArgsContext arguments; + public GenArityNotEmptyContext genericArity; + public MdtokenContext token; + public DottedNameContext alias; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON() { return GetToken(CILParser.DCOLON, 0); } [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { return GetRuleContext(0); } @@ -8489,7 +8587,6 @@ [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON() { return GetToken(CILParser.DCOLON, 0); } [System.Diagnostics.DebuggerNonUserCode] public MethodNameContext methodName() { return GetRuleContext(0); } @@ -8513,119 +8610,123 @@ public MethodRefContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_methodRef; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethodRef(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MethodRefContext methodRef() { MethodRefContext _localctx = new MethodRefContext(Context, State); - EnterRule(_localctx, 190, RULE_methodRef); + EnterRule(_localctx, 170, RULE_methodRef); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.MethodReferenceValue.Error; + int _la; try { - State = 1598; + State = 1975; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,73,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,79,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1564; - callConv(); - State = 1565; - type(); - State = 1566; - typeSpec(); - State = 1567; + State = 1933; + _localctx.convention = callConv(); + State = 1934; + _localctx.returnType = type(); + State = 1935; + _localctx.owner = typeSpec(); + State = 1936; Match(DCOLON); - State = 1568; - methodName(); - State = 1570; + State = 1937; + _localctx.name = methodName(); + State = 1939; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==T__85) { { - State = 1569; - typeArgs(); + State = 1938; + _localctx.genericArguments = typeArgs(); } } - State = 1572; - sigArgs(); + State = 1941; + _localctx.arguments = sigArgs(); + _localctx.Value = Actions.CreateMethodReference(_localctx.Start, _localctx.convention.Value, _localctx.returnType.Value, _localctx.owner.Value, _localctx.name.Value, _localctx.genericArguments is null ? null : _localctx.genericArguments.Value, null, _localctx.arguments.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1574; - callConv(); - State = 1575; - type(); - State = 1576; - typeSpec(); - State = 1577; + State = 1944; + _localctx.convention = callConv(); + State = 1945; + _localctx.returnType = type(); + State = 1946; + _localctx.owner = typeSpec(); + State = 1947; Match(DCOLON); - State = 1578; - methodName(); - State = 1579; - genArityNotEmpty(); - State = 1580; - sigArgs(); + State = 1948; + _localctx.name = methodName(); + State = 1949; + _localctx.genericArity = genArityNotEmpty(); + State = 1950; + _localctx.arguments = sigArgs(); + _localctx.Value = Actions.CreateMethodReference(_localctx.Start, _localctx.convention.Value, _localctx.returnType.Value, _localctx.owner.Value, _localctx.name.Value, null, _localctx.genericArity.Value, _localctx.arguments.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1582; - callConv(); - State = 1583; - type(); - State = 1584; - methodName(); - State = 1586; + State = 1953; + _localctx.convention = callConv(); + State = 1954; + _localctx.returnType = type(); + State = 1955; + _localctx.name = methodName(); + State = 1957; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==T__85) { { - State = 1585; - typeArgs(); + State = 1956; + _localctx.genericArguments = typeArgs(); } } - State = 1588; - sigArgs(); + State = 1959; + _localctx.arguments = sigArgs(); + _localctx.Value = Actions.CreateMethodReference(_localctx.Start, _localctx.convention.Value, _localctx.returnType.Value, null, _localctx.name.Value, _localctx.genericArguments is null ? null : _localctx.genericArguments.Value, null, _localctx.arguments.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1590; - callConv(); - State = 1591; - type(); - State = 1592; - methodName(); - State = 1593; - genArityNotEmpty(); - State = 1594; - sigArgs(); + State = 1962; + _localctx.convention = callConv(); + State = 1963; + _localctx.returnType = type(); + State = 1964; + _localctx.name = methodName(); + State = 1965; + _localctx.genericArity = genArityNotEmpty(); + State = 1966; + _localctx.arguments = sigArgs(); + _localctx.Value = Actions.CreateMethodReference(_localctx.Start, _localctx.convention.Value, _localctx.returnType.Value, null, _localctx.name.Value, null, _localctx.genericArity.Value, _localctx.arguments.Value); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1596; - mdtoken(); + State = 1969; + _localctx.token = mdtoken(); + _localctx.Value = Actions.CreateTokenMethodReference(_localctx.token.Value); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1597; - dottedName(); + State = 1972; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateTypedefMethodReference(_localctx.Start, _localctx.alias.Value); } break; } @@ -8636,12 +8737,21 @@ public MethodRefContext methodRef() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class CallConvContext : ParserRuleContext { + public byte Value; + public CallConvContext inner; + public CallKindContext kind; + public Int32Context raw; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INSTANCE() { return GetToken(CILParser.INSTANCE, 0); } [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { return GetRuleContext(0); @@ -8658,58 +8768,56 @@ public CallConvContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_callConv; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCallConv(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CallConvContext callConv() { CallConvContext _localctx = new CallConvContext(Context, State); - EnterRule(_localctx, 192, RULE_callConv); + EnterRule(_localctx, 172, RULE_callConv); try { - State = 1610; + State = 1994; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,74,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,80,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1600; + State = 1977; Match(INSTANCE); - State = 1601; - callConv(); + State = 1978; + _localctx.inner = callConv(); + _localctx.Value = Actions.AddInstanceCallingConvention(_localctx.inner.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1602; + State = 1981; Match(EXPLICIT); - State = 1603; - callConv(); + State = 1982; + _localctx.inner = callConv(); + _localctx.Value = Actions.AddExplicitCallingConvention(_localctx.inner.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1604; - callKind(); + State = 1985; + _localctx.kind = callKind(); + _localctx.Value = _localctx.kind.Value; } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1605; + State = 1988; Match(T__111); - State = 1606; + State = 1989; Match(T__29); - State = 1607; - int32(); - State = 1608; + State = 1990; + _localctx.raw = int32(); + State = 1991; Match(T__30); + _localctx.Value = Actions.GetRawCallingConvention((_localctx.raw!=null?(_localctx.raw.Start):null)); } break; } @@ -8726,6 +8834,8 @@ public CallConvContext callConv() { } public partial class CallKindContext : ParserRuleContext { + public byte Value; + public IToken kind; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DEFAULT() { return GetToken(CILParser.DEFAULT, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARARG() { return GetToken(CILParser.VARARG, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UNMANAGED() { return GetToken(CILParser.UNMANAGED, 0); } @@ -8738,22 +8848,17 @@ public CallKindContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_callKind; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCallKind(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CallKindContext callKind() { CallKindContext _localctx = new CallKindContext(Context, State); - EnterRule(_localctx, 194, RULE_callKind); + EnterRule(_localctx, 174, RULE_callKind); + _localctx.Value = Actions.GetDefaultCallingConvention(); try { - State = 1624; + State = 2015; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,75,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,81,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { @@ -8762,58 +8867,65 @@ public CallKindContext callKind() { case 2: EnterOuterAlt(_localctx, 2); { - State = 1613; - Match(DEFAULT); + State = 1997; + _localctx.kind = Match(DEFAULT); + _localctx.Value = Actions.GetCallingConvention(_localctx.kind); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1614; - Match(VARARG); + State = 1999; + _localctx.kind = Match(VARARG); + _localctx.Value = Actions.GetCallingConvention(_localctx.kind); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1615; + State = 2001; Match(UNMANAGED); - State = 1616; - Match(CDECL); + State = 2002; + _localctx.kind = Match(CDECL); + _localctx.Value = Actions.GetCallingConvention(_localctx.kind); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1617; + State = 2004; Match(UNMANAGED); - State = 1618; - Match(STDCALL); + State = 2005; + _localctx.kind = Match(STDCALL); + _localctx.Value = Actions.GetCallingConvention(_localctx.kind); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1619; + State = 2007; Match(UNMANAGED); - State = 1620; - Match(THISCALL); + State = 2008; + _localctx.kind = Match(THISCALL); + _localctx.Value = Actions.GetCallingConvention(_localctx.kind); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 1621; + State = 2010; Match(UNMANAGED); - State = 1622; - Match(FASTCALL); + State = 2011; + _localctx.kind = Match(FASTCALL); + _localctx.Value = Actions.GetCallingConvention(_localctx.kind); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 1623; - Match(UNMANAGED); + State = 2013; + _localctx.kind = Match(UNMANAGED); + _localctx.Value = Actions.GetCallingConvention(_localctx.kind); } break; } @@ -8830,6 +8942,10 @@ public CallKindContext callKind() { } public partial class MdtokenContext : ParserRuleContext { + public int Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public Int32Context token; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -8838,29 +8954,25 @@ public MdtokenContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_mdtoken; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMdtoken(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MdtokenContext mdtoken() { MdtokenContext _localctx = new MdtokenContext(Context, State); - EnterRule(_localctx, 196, RULE_mdtoken); + EnterRule(_localctx, 176, RULE_mdtoken); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; try { EnterOuterAlt(_localctx, 1); { - State = 1626; + State = 2017; Match(T__112); - State = 1627; + State = 2018; Match(T__29); - State = 1628; - int32(); - State = 1629; + State = 2019; + _localctx.token = int32(); + State = 2020; Match(T__30); + _localctx.Value = Actions.ParseInt32((_localctx.token!=null?(_localctx.token.Start):null)); } } catch (RecognitionException re) { @@ -8869,12 +8981,21 @@ public MdtokenContext mdtoken() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class MemberRefContext : ParserRuleContext { + public CILParser.MemberReferenceValue Value; + public MethodRefContext method; + public FieldRefContext field; + public MdtokenContext token; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode METHOD() { return GetToken(CILParser.METHOD, 0); } [System.Diagnostics.DebuggerNonUserCode] public MethodRefContext methodRef() { return GetRuleContext(0); @@ -8890,45 +9011,43 @@ public MemberRefContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_memberRef; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMemberRef(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MemberRefContext memberRef() { MemberRefContext _localctx = new MemberRefContext(Context, State); - EnterRule(_localctx, 198, RULE_memberRef); + EnterRule(_localctx, 178, RULE_memberRef); + _localctx.Value = CILParser.MemberReferenceValue.Error; try { - State = 1636; + State = 2034; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case METHOD: EnterOuterAlt(_localctx, 1); { - State = 1631; + State = 2023; Match(METHOD); - State = 1632; - methodRef(); + State = 2024; + _localctx.method = methodRef(); + _localctx.Value = Actions.CreateMethodMemberReference(_localctx.method.Value); } break; case T__36: EnterOuterAlt(_localctx, 2); { - State = 1633; + State = 2027; Match(T__36); - State = 1634; - fieldRef(); + State = 2028; + _localctx.field = fieldRef(); + _localctx.Value = Actions.CreateFieldMemberReference(_localctx.field.Value); } break; case T__112: EnterOuterAlt(_localctx, 3); { - State = 1635; - mdtoken(); + State = 2031; + _localctx.token = mdtoken(); + _localctx.Value = Actions.CreateTokenMemberReference(_localctx.token.Value); } break; default: @@ -8947,13 +9066,20 @@ public MemberRefContext memberRef() { } public partial class FieldRefContext : ParserRuleContext { + public CILParser.FieldReferenceValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public TypeContext fieldType; + public TypeSpecContext owner; + public DottedNameContext name; + public DottedNameContext alias; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON() { return GetToken(CILParser.DCOLON, 0); } [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON() { return GetToken(CILParser.DCOLON, 0); } [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } @@ -8962,49 +9088,50 @@ public FieldRefContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_fieldRef; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFieldRef(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FieldRefContext fieldRef() { FieldRefContext _localctx = new FieldRefContext(Context, State); - EnterRule(_localctx, 200, RULE_fieldRef); + EnterRule(_localctx, 180, RULE_fieldRef); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.FieldReferenceValue.Error; + try { - State = 1647; + State = 2049; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,77,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,83,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1638; - type(); - State = 1639; - typeSpec(); - State = 1640; + State = 2036; + _localctx.fieldType = type(); + State = 2037; + _localctx.owner = typeSpec(); + State = 2038; Match(DCOLON); - State = 1641; - dottedName(); + State = 2039; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateFieldReference(_localctx.fieldType.Value, _localctx.owner.Value, _localctx.name.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1643; - type(); - State = 1644; - dottedName(); + State = 2042; + _localctx.fieldType = type(); + State = 2043; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateFieldReference(_localctx.fieldType.Value, null, _localctx.name.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1646; - dottedName(); + State = 2046; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateTypedefFieldReference(_localctx.Start, _localctx.alias.Value); } break; } @@ -9015,12 +9142,21 @@ public FieldRefContext fieldRef() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class TypeListContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public TypeSpecContext item; + public TypeSpecContext tail; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext[] typeSpec() { return GetRuleContexts(); } @@ -9032,42 +9168,39 @@ public TypeListContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typeList; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTypeList(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TypeListContext typeList() { TypeListContext _localctx = new TypeListContext(Context, State); - EnterRule(_localctx, 202, RULE_typeList); + EnterRule(_localctx, 182, RULE_typeList); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 1654; + State = 2057; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,78,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,84,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1649; - typeSpec(); - State = 1650; + State = 2051; + _localctx.item = typeSpec(); + _localctx.Builder.Add(_localctx.item.Value); + State = 2053; Match(T__27); } } } - State = 1656; + State = 2059; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,78,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,84,Context); } - State = 1657; - typeSpec(); + State = 2060; + _localctx.tail = typeSpec(); + _localctx.Builder.Add(_localctx.tail.Value); } } catch (RecognitionException re) { @@ -9076,12 +9209,15 @@ public TypeListContext typeList() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class TyparsClauseContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public TyparsContext parameters; [System.Diagnostics.DebuggerNonUserCode] public TyparsContext typars() { return GetRuleContext(0); } @@ -9090,20 +9226,15 @@ public TyparsClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typarsClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTyparsClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TyparsClauseContext typarsClause() { TyparsClauseContext _localctx = new TyparsClauseContext(Context, State); - EnterRule(_localctx, 204, RULE_typarsClause); + EnterRule(_localctx, 184, RULE_typarsClause); + _localctx.Value = System.Collections.Immutable.ImmutableArray.Empty; try { - State = 1664; + State = 2069; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__16: @@ -9118,12 +9249,13 @@ public TyparsClauseContext typarsClause() { case T__85: EnterOuterAlt(_localctx, 2); { - State = 1660; + State = 2064; Match(T__85); - State = 1661; - typars(); - State = 1662; + State = 2065; + _localctx.parameters = typars(); + State = 2066; Match(T__86); + _localctx.Value = _localctx.parameters.Value; } break; default: @@ -9142,6 +9274,7 @@ public TyparsClauseContext typarsClause() { } public partial class TyparAttribContext : ParserRuleContext { + public CILParser.AttributeValue Value; public IToken covariant; public IToken contravariant; public IToken @class; @@ -9159,75 +9292,77 @@ public TyparAttribContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typarAttrib; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTyparAttrib(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TyparAttribContext typarAttrib() { TyparAttribContext _localctx = new TyparAttribContext(Context, State); - EnterRule(_localctx, 206, RULE_typarAttrib); + EnterRule(_localctx, 186, RULE_typarAttrib); + _localctx.Value = CILParser.AttributeValue.Empty; try { - State = 1677; + State = 2089; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case PLUS: EnterOuterAlt(_localctx, 1); { - State = 1666; + State = 2071; _localctx.covariant = Match(PLUS); + _localctx.Value = Actions.CreateGenericParameterAttribute(_localctx.covariant); } break; case T__113: EnterOuterAlt(_localctx, 2); { - State = 1667; + State = 2073; _localctx.contravariant = Match(T__113); + _localctx.Value = Actions.CreateGenericParameterAttribute(_localctx.contravariant); } break; case T__38: EnterOuterAlt(_localctx, 3); { - State = 1668; + State = 2075; _localctx.@class = Match(T__38); + _localctx.Value = Actions.CreateGenericParameterAttribute(_localctx.@class); } break; case VALUETYPE: EnterOuterAlt(_localctx, 4); { - State = 1669; + State = 2077; _localctx.valuetype = Match(VALUETYPE); + _localctx.Value = Actions.CreateGenericParameterAttribute(_localctx.valuetype); } break; case T__114: EnterOuterAlt(_localctx, 5); { - State = 1670; + State = 2079; _localctx.byrefLike = Match(T__114); + _localctx.Value = Actions.CreateGenericParameterAttribute(_localctx.byrefLike); } break; case T__115: EnterOuterAlt(_localctx, 6); { - State = 1671; + State = 2081; _localctx.ctor = Match(T__115); + _localctx.Value = Actions.CreateGenericParameterAttribute(_localctx.ctor); } break; case T__69: EnterOuterAlt(_localctx, 7); { - State = 1672; + State = 2083; Match(T__69); - State = 1673; + State = 2084; Match(T__29); - State = 1674; + State = 2085; _localctx.flags = int32(); - State = 1675; + State = 2086; Match(T__30); + _localctx.Value = Actions.CreateRawGenericParameterAttribute((_localctx.flags!=null?(_localctx.flags.Start):null)); } break; default: @@ -9246,6 +9381,8 @@ public TyparAttribContext typarAttrib() { } public partial class TyparAttribsContext : ParserRuleContext { + public System.Reflection.GenericParameterAttributes Value; + public TyparAttribContext attribute; [System.Diagnostics.DebuggerNonUserCode] public TyparAttribContext[] typarAttrib() { return GetRuleContexts(); } @@ -9257,33 +9394,29 @@ public TyparAttribsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typarAttribs; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTyparAttribs(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TyparAttribsContext typarAttribs() { TyparAttribsContext _localctx = new TyparAttribsContext(Context, State); - EnterRule(_localctx, 208, RULE_typarAttribs); + EnterRule(_localctx, 188, RULE_typarAttribs); + _localctx.Value = 0; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1682; + State = 2096; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__38 || ((((_la - 70)) & ~0x3f) == 0 && ((1L << (_la - 70)) & 123145302310913L) != 0) || _la==VALUETYPE || _la==PLUS) { { { - State = 1679; - typarAttrib(); + State = 2091; + _localctx.attribute = typarAttrib(); + _localctx.Value = Actions.AddGenericParameterAttribute(_localctx.Value, _localctx.attribute.Value); } } - State = 1684; + State = 2098; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -9301,6 +9434,10 @@ public TyparAttribsContext typarAttribs() { } public partial class TyparContext : ParserRuleContext { + public CILParser.GenericParameterDeclarationValue Value; + public TyparAttribsContext attributes; + public TyBoundContext constraints; + public DottedNameContext name; [System.Diagnostics.DebuggerNonUserCode] public TyparAttribsContext typarAttribs() { return GetRuleContext(0); } @@ -9315,36 +9452,32 @@ public TyparContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typar; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTypar(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TyparContext typar() { TyparContext _localctx = new TyparContext(Context, State); - EnterRule(_localctx, 210, RULE_typar); + EnterRule(_localctx, 190, RULE_typar); + _localctx.Value = CILParser.GenericParameterDeclarationValue.Error; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1685; - typarAttribs(); - State = 1687; + State = 2099; + _localctx.attributes = typarAttribs(); + State = 2101; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==T__29) { { - State = 1686; - tyBound(); + State = 2100; + _localctx.constraints = tyBound(); } } - State = 1689; - dottedName(); + State = 2103; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateGenericParameterDeclaration(_localctx.attributes.Value, _localctx.constraints, _localctx.name.Value); } } catch (RecognitionException re) { @@ -9359,6 +9492,10 @@ public TyparContext typar() { } public partial class TyparsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public TyparContext parameter; + public TyparContext tail; [System.Diagnostics.DebuggerNonUserCode] public TyparContext[] typar() { return GetRuleContexts(); } @@ -9370,42 +9507,39 @@ public TyparsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_typars; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTypars(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TyparsContext typars() { TyparsContext _localctx = new TyparsContext(Context, State); - EnterRule(_localctx, 212, RULE_typars); + EnterRule(_localctx, 192, RULE_typars); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 1696; + State = 2112; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,83,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,89,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1691; - typar(); - State = 1692; + State = 2106; + _localctx.parameter = typar(); + _localctx.Builder.Add(_localctx.parameter.Value); + State = 2108; Match(T__27); } } } - State = 1698; + State = 2114; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,83,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,89,Context); } - State = 1699; - typar(); + State = 2115; + _localctx.tail = typar(); + _localctx.Builder.Add(_localctx.tail.Value); } } catch (RecognitionException re) { @@ -9414,12 +9548,15 @@ public TyparsContext typars() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class TyBoundContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public TypeListContext constraints; [System.Diagnostics.DebuggerNonUserCode] public TypeListContext typeList() { return GetRuleContext(0); } @@ -9428,27 +9565,23 @@ public TyBoundContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_tyBound; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTyBound(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TyBoundContext tyBound() { TyBoundContext _localctx = new TyBoundContext(Context, State); - EnterRule(_localctx, 214, RULE_tyBound); + EnterRule(_localctx, 194, RULE_tyBound); + _localctx.Value = System.Collections.Immutable.ImmutableArray.Empty; try { EnterOuterAlt(_localctx, 1); { - State = 1701; + State = 2118; Match(T__29); - State = 1702; - typeList(); - State = 1703; + State = 2119; + _localctx.constraints = typeList(); + State = 2120; Match(T__30); + _localctx.Value = _localctx.constraints.Value; } } catch (RecognitionException re) { @@ -9463,6 +9596,8 @@ public TyBoundContext tyBound() { } public partial class GenArityContext : ParserRuleContext { + public int Value; + public GenArityNotEmptyContext value; [System.Diagnostics.DebuggerNonUserCode] public GenArityNotEmptyContext genArityNotEmpty() { return GetRuleContext(0); } @@ -9471,37 +9606,27 @@ public GenArityContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_genArity; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitGenArity(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public GenArityContext genArity() { GenArityContext _localctx = new GenArityContext(Context, State); - EnterRule(_localctx, 216, RULE_genArity); + EnterRule(_localctx, 196, RULE_genArity); + int _la; try { - State = 1707; + EnterOuterAlt(_localctx, 1); + { + State = 2124; ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case T__29: - case T__84: - EnterOuterAlt(_localctx, 1); - { - } - break; - case T__85: - EnterOuterAlt(_localctx, 2); + _la = TokenStream.LA(1); + if (_la==T__85) { { - State = 1706; - genArityNotEmpty(); + State = 2123; + _localctx.value = genArityNotEmpty(); } - break; - default: - throw new NoViableAltException(this); + } + + _localctx.Value = Actions.GetGenericArity(_localctx.value); } } catch (RecognitionException re) { @@ -9516,6 +9641,8 @@ public GenArityContext genArity() { } public partial class GenArityNotEmptyContext : ParserRuleContext { + public int Value; + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -9524,31 +9651,26 @@ public GenArityNotEmptyContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_genArityNotEmpty; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitGenArityNotEmpty(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public GenArityNotEmptyContext genArityNotEmpty() { GenArityNotEmptyContext _localctx = new GenArityNotEmptyContext(Context, State); - EnterRule(_localctx, 218, RULE_genArityNotEmpty); + EnterRule(_localctx, 198, RULE_genArityNotEmpty); try { EnterOuterAlt(_localctx, 1); { - State = 1709; + State = 2128; Match(T__85); - State = 1710; + State = 2129; Match(T__41); - State = 1711; - int32(); - State = 1712; + State = 2130; + _localctx.value = int32(); + State = 2131; Match(T__42); - State = 1713; + State = 2132; Match(T__86); + _localctx.Value = Actions.ParseInt32((_localctx.value!=null?(_localctx.value.Start):null)); } } catch (RecognitionException re) { @@ -9563,6 +9685,37 @@ public GenArityNotEmptyContext genArityNotEmpty() { } public partial class ClassDeclContext : ParserRuleContext { + public CILParser.PropertyBodyValue PropertyBody; + public CILParser.EventBodyValue EventBody; + public CILParser.CustomAttributeOwnerValue AttributeOwner; + public EventHeadContext eventHeader; + public PropHeadContext property; + public DataDeclContext data; + public SecDeclContext security; + public ExtSourceSpecContext source; + public CustomAttrDeclContext attribute; + public Int32Context size; + public Int32Context packing; + public ExportHeadContext export; + public ExptypeDeclsContext exportDeclarations; + public TypeSpecContext declarationOwner; + public MethodNameContext declarationName; + public CallConvContext bodyConvention; + public TypeContext bodyReturnType; + public TypeSpecContext bodyOwner; + public MethodNameContext bodyName; + public SigArgsContext bodyArguments; + public CallConvContext declarationConvention; + public TypeContext declarationReturnType; + public GenArityContext declarationArity; + public SigArgsContext declarationArguments; + public GenArityContext bodyArity; + public LanguageDeclContext language; + public Int32Context parameterIndex; + public DottedNameContext parameterName; + public TypeSpecContext constraintType; + public TypeSpecContext interfaceType; + public CustomDescrContext interfaceAttribute; [System.Diagnostics.DebuggerNonUserCode] public MethodHeadContext methodHead() { return GetRuleContext(0); } @@ -9575,18 +9728,18 @@ [System.Diagnostics.DebuggerNonUserCode] public ClassHeadContext classHead() { [System.Diagnostics.DebuggerNonUserCode] public ClassDeclsContext classDecls() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public EventHeadContext eventHead() { - return GetRuleContext(0); - } [System.Diagnostics.DebuggerNonUserCode] public EventDeclsContext eventDecls() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public PropHeadContext propHead() { - return GetRuleContext(0); + [System.Diagnostics.DebuggerNonUserCode] public EventHeadContext eventHead() { + return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public PropDeclsContext propDecls() { return GetRuleContext(0); } + [System.Diagnostics.DebuggerNonUserCode] public PropHeadContext propHead() { + return GetRuleContext(0); + } [System.Diagnostics.DebuggerNonUserCode] public FieldDeclContext fieldDecl() { return GetRuleContext(0); } @@ -9615,16 +9768,16 @@ [System.Diagnostics.DebuggerNonUserCode] public ExptypeDeclsContext exptypeDecls return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OVERRIDE() { return GetToken(CILParser.OVERRIDE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] DCOLON() { return GetTokens(CILParser.DCOLON); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON(int i) { + return GetToken(CILParser.DCOLON, i); + } [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext[] typeSpec() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec(int i) { return GetRuleContext(i); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] DCOLON() { return GetTokens(CILParser.DCOLON); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON(int i) { - return GetToken(CILParser.DCOLON, i); - } [System.Diagnostics.DebuggerNonUserCode] public MethodNameContext[] methodName() { return GetRuleContexts(); } @@ -9679,358 +9832,395 @@ public ClassDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_classDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitClassDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ClassDeclContext classDecl() { ClassDeclContext _localctx = new ClassDeclContext(Context, State); - EnterRule(_localctx, 220, RULE_classDecl); + EnterRule(_localctx, 200, RULE_classDecl); try { int _alt; - State = 1831; + State = 2285; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,89,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,95,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1715; + State = 2135; methodHead(); - State = 1716; + State = 2136; Match(T__16); - State = 1717; + State = 2137; methodDecls(); - State = 1718; + State = 2138; Match(T__17); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1720; + State = 2140; classHead(); - State = 1721; + State = 2141; Match(T__16); - State = 1722; + State = 2142; classDecls(); - State = 1723; + State = 2143; Match(T__17); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1725; - eventHead(); - State = 1726; + State = 2145; + _localctx.eventHeader = eventHead(); + _localctx.EventBody = Actions.BeginEvent(_localctx.eventHeader.Value); + State = 2147; Match(T__16); - State = 1727; - eventDecls(); - State = 1728; + State = 2148; + eventDecls(_localctx.EventBody); + State = 2149; Match(T__17); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 1730; - propHead(); - State = 1731; + State = 2151; + _localctx.property = propHead(); + _localctx.PropertyBody = Actions.BeginProperty(_localctx.property.Value); + State = 2153; Match(T__16); - State = 1732; - propDecls(); - State = 1733; + State = 2154; + propDecls(_localctx.PropertyBody); + State = 2155; Match(T__17); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 1735; + State = 2157; fieldDecl(); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 1736; - dataDecl(); + State = 2158; + _localctx.data = dataDecl(); + Actions.ProcessClassDataDeclaration(_localctx.data); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 1737; - secDecl(); + State = 2161; + _localctx.security = secDecl(); + Actions.ProcessClassSecurityDeclaration(_localctx.security); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 1738; - extSourceSpec(); + State = 2164; + _localctx.source = extSourceSpec(); + Actions.ProcessClassSourceDirective(_localctx.source); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 1739; - customAttrDecl(); + State = 2167; + _localctx.attribute = customAttrDecl(); + Actions.ProcessClassCustomAttribute(_localctx.attribute); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 1740; + State = 2170; Match(T__116); - State = 1741; - int32(); + State = 2171; + _localctx.size = int32(); + Actions.SetClassSize((_localctx.size!=null?(_localctx.size.Start):null)); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 1742; + State = 2174; Match(T__117); - State = 1743; - int32(); + State = 2175; + _localctx.packing = int32(); + Actions.SetClassPackingSize((_localctx.packing!=null?(_localctx.packing.Start):null)); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 1744; - exportHead(); - State = 1745; + State = 2178; + _localctx.export = exportHead(); + State = 2179; Match(T__16); - State = 1746; - exptypeDecls(); - State = 1747; + State = 2180; + _localctx.exportDeclarations = exptypeDecls(); + State = 2181; Match(T__17); + Actions.ProcessClassExport(_localctx.export, _localctx.exportDeclarations); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 1749; + State = 2184; Match(OVERRIDE); - State = 1750; - typeSpec(); - State = 1751; + State = 2185; + _localctx.declarationOwner = typeSpec(); + State = 2186; Match(DCOLON); - State = 1752; - methodName(); - State = 1753; + State = 2187; + _localctx.declarationName = methodName(); + State = 2188; Match(T__118); - State = 1754; - callConv(); - State = 1755; - type(); - State = 1756; - typeSpec(); - State = 1757; + State = 2189; + _localctx.bodyConvention = callConv(); + State = 2190; + _localctx.bodyReturnType = type(); + State = 2191; + _localctx.bodyOwner = typeSpec(); + State = 2192; Match(DCOLON); - State = 1758; - methodName(); - State = 1759; - sigArgs(); + State = 2193; + _localctx.bodyName = methodName(); + State = 2194; + _localctx.bodyArguments = sigArgs(); + Actions.AddClassMethodOverride( + _localctx, + _localctx.declarationOwner.Value, + _localctx.declarationName.Value, + _localctx.bodyConvention.Value, + _localctx.bodyReturnType.Value, + _localctx.bodyOwner.Value, + _localctx.bodyName.Value, + _localctx.bodyArguments.Value); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 1761; + State = 2197; Match(OVERRIDE); - State = 1762; + State = 2198; Match(METHOD); - State = 1763; - callConv(); - State = 1764; - type(); - State = 1765; - typeSpec(); - State = 1766; + State = 2199; + _localctx.declarationConvention = callConv(); + State = 2200; + _localctx.declarationReturnType = type(); + State = 2201; + _localctx.declarationOwner = typeSpec(); + State = 2202; Match(DCOLON); - State = 1767; - methodName(); - State = 1768; - genArity(); - State = 1769; - sigArgs(); - State = 1770; + State = 2203; + _localctx.declarationName = methodName(); + State = 2204; + _localctx.declarationArity = genArity(); + State = 2205; + _localctx.declarationArguments = sigArgs(); + State = 2206; Match(T__118); - State = 1771; + State = 2207; Match(METHOD); - State = 1772; - callConv(); - State = 1773; - type(); - State = 1774; - typeSpec(); - State = 1775; + State = 2208; + _localctx.bodyConvention = callConv(); + State = 2209; + _localctx.bodyReturnType = type(); + State = 2210; + _localctx.bodyOwner = typeSpec(); + State = 2211; Match(DCOLON); - State = 1776; - methodName(); - State = 1777; - genArity(); - State = 1778; - sigArgs(); + State = 2212; + _localctx.bodyName = methodName(); + State = 2213; + _localctx.bodyArity = genArity(); + State = 2214; + _localctx.bodyArguments = sigArgs(); + Actions.AddClassMethodOverride( + _localctx, + _localctx.declarationConvention.Value, + _localctx.declarationReturnType.Value, + _localctx.declarationOwner.Value, + _localctx.declarationName.Value, + _localctx.declarationArity.Value, + _localctx.declarationArguments.Value, + _localctx.bodyConvention.Value, + _localctx.bodyReturnType.Value, + _localctx.bodyOwner.Value, + _localctx.bodyName.Value, + _localctx.bodyArity.Value, + _localctx.bodyArguments.Value); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 1780; - languageDecl(); + State = 2217; + _localctx.language = languageDecl(); + Actions.ProcessClassLanguageDirective(_localctx.language); } break; case 16: EnterOuterAlt(_localctx, 16); { - State = 1781; + State = 2220; compControl(); + Actions.ProcessClassCompilerControl(); } break; case 17: EnterOuterAlt(_localctx, 17); { - State = 1782; + State = 2223; Match(PARAM); - State = 1783; + State = 2224; Match(TYPE); - State = 1784; + State = 2225; Match(T__41); - State = 1785; - int32(); - State = 1786; + State = 2226; + _localctx.parameterIndex = int32(); + State = 2227; Match(T__42); - State = 1790; + _localctx.AttributeOwner = Actions.BeginClassGenericParameterDirective(_localctx, (_localctx.parameterIndex!=null?(_localctx.parameterIndex.Start):null)); + State = 2234; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,85,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,91,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1787; - customAttrDecl(); + State = 2229; + _localctx.attribute = customAttrDecl(); + Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, _localctx.attribute); } } } - State = 1792; + State = 2236; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,85,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,91,Context); } } break; case 18: EnterOuterAlt(_localctx, 18); { - State = 1793; + State = 2237; Match(PARAM); - State = 1794; + State = 2238; Match(TYPE); - State = 1795; - dottedName(); - State = 1799; + State = 2239; + _localctx.parameterName = dottedName(); + _localctx.AttributeOwner = Actions.BeginClassGenericParameterDirective(_localctx.parameterName.Value); + State = 2246; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,86,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,92,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1796; - customAttrDecl(); + State = 2241; + _localctx.attribute = customAttrDecl(); + Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, _localctx.attribute); } } } - State = 1801; + State = 2248; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,86,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,92,Context); } } break; case 19: EnterOuterAlt(_localctx, 19); { - State = 1802; + State = 2249; Match(PARAM); - State = 1803; + State = 2250; Match(CONSTRAINT); - State = 1804; + State = 2251; Match(T__41); - State = 1805; - int32(); - State = 1806; + State = 2252; + _localctx.parameterIndex = int32(); + State = 2253; Match(T__42); - State = 1807; + State = 2254; Match(T__27); - State = 1808; - typeSpec(); - State = 1812; + State = 2255; + _localctx.constraintType = typeSpec(); + _localctx.AttributeOwner = Actions.BeginClassGenericConstraintDirective(_localctx, (_localctx.parameterIndex!=null?(_localctx.parameterIndex.Start):null), _localctx.constraintType.Value); + State = 2262; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,87,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,93,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1809; - customAttrDecl(); + State = 2257; + _localctx.attribute = customAttrDecl(); + Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, _localctx.attribute); } } } - State = 1814; + State = 2264; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,87,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,93,Context); } } break; case 20: EnterOuterAlt(_localctx, 20); { - State = 1815; + State = 2265; Match(PARAM); - State = 1816; + State = 2266; Match(CONSTRAINT); - State = 1817; - dottedName(); - State = 1818; + State = 2267; + _localctx.parameterName = dottedName(); + State = 2268; Match(T__27); - State = 1819; - typeSpec(); - State = 1823; + State = 2269; + _localctx.constraintType = typeSpec(); + _localctx.AttributeOwner = Actions.BeginClassGenericConstraintDirective(_localctx.parameterName.Value, _localctx.constraintType.Value); + State = 2276; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,88,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,94,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 1820; - customAttrDecl(); + State = 2271; + _localctx.attribute = customAttrDecl(); + Actions.AddClassGenericDirectiveAttribute(_localctx.AttributeOwner, _localctx.attribute); } } } - State = 1825; + State = 2278; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,88,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,94,Context); } } break; case 21: EnterOuterAlt(_localctx, 21); { - State = 1826; + State = 2279; Match(T__119); - State = 1827; + State = 2280; Match(TYPE); - State = 1828; - typeSpec(); - State = 1829; - customDescr(); + State = 2281; + _localctx.interfaceType = typeSpec(); + State = 2282; + _localctx.interfaceAttribute = customDescr(); + Actions.AddInterfaceImplementationAttribute(_localctx, _localctx.interfaceType.Value, _localctx.interfaceAttribute); } break; } @@ -10041,12 +10231,23 @@ public ClassDeclContext classDecl() { ErrorHandler.Recover(this, re); } finally { + Actions.EndClassDeclaration(_localctx); ExitRule(); } return _localctx; } public partial class FieldDeclContext : ParserRuleContext { + public CILParser.FieldDeclarationValue Value; + public int InitialSyntaxErrorCount; + public CILParser.FieldDeclarationBuilder Builder; + public RepeatOptContext offset; + public FieldAttrContext attribute; + public MarshalBlobContext marshalling; + public TypeContext fieldType; + public DottedNameContext name; + public AtOptContext data; + public InitOptContext initializer; [System.Diagnostics.DebuggerNonUserCode] public RepeatOptContext repeatOpt() { return GetRuleContext(0); } @@ -10079,33 +10280,32 @@ public FieldDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_fieldDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFieldDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FieldDeclContext fieldDecl() { FieldDeclContext _localctx = new FieldDeclContext(Context, State); - EnterRule(_localctx, 222, RULE_fieldDecl); + EnterRule(_localctx, 202, RULE_fieldDecl); + + _localctx.Builder = Actions.PrepareFieldDeclaration(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.FieldDeclarationValue.Error; + try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 1833; + State = 2287; Match(T__120); - State = 1834; - repeatOpt(); - State = 1843; + State = 2288; + _localctx.offset = repeatOpt(); + State = 2300; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,91,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,97,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { - State = 1841; + State = 2298; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__15: @@ -10124,20 +10324,22 @@ public FieldDeclContext fieldDecl() { case T__125: case T__126: { - State = 1835; - fieldAttr(); + State = 2289; + _localctx.attribute = fieldAttr(); + Actions.AddFieldAttribute(_localctx.Builder, _localctx.attribute.Value); } break; case T__121: { - State = 1836; + State = 2292; Match(T__121); - State = 1837; + State = 2293; Match(T__29); - State = 1838; - marshalBlob(); - State = 1839; + State = 2294; + _localctx.marshalling = marshalBlob(); + State = 2295; Match(T__30); + Actions.SetFieldMarshalling(_localctx.Builder, _localctx.marshalling.Value); } break; default: @@ -10145,19 +10347,30 @@ public FieldDeclContext fieldDecl() { } } } - State = 1845; + State = 2302; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,91,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,97,Context); } - State = 1846; - type(); - State = 1847; - dottedName(); - State = 1848; - atOpt(); - State = 1849; - initOpt(); + State = 2303; + _localctx.fieldType = type(); + State = 2304; + _localctx.name = dottedName(); + State = 2305; + _localctx.data = atOpt(); + State = 2306; + _localctx.initializer = initOpt(); + _localctx.Value = Actions.CreateFieldDeclaration( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + _localctx.offset, + _localctx.fieldType.Value, + _localctx.name.Value, + _localctx.data.Value, + _localctx.initializer.Value); } + Context.Stop = TokenStream.LT(-1); + Actions.DefineField(_localctx, _localctx.Value); } catch (RecognitionException re) { _localctx.exception = re; @@ -10171,6 +10384,9 @@ public FieldDeclContext fieldDecl() { } public partial class FieldAttrContext : ParserRuleContext { + public CILParser.AttributeValue Value; + public IToken attribute; + public Int32Context flags; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -10179,131 +10395,141 @@ public FieldAttrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_fieldAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFieldAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FieldAttrContext fieldAttr() { FieldAttrContext _localctx = new FieldAttrContext(Context, State); - EnterRule(_localctx, 224, RULE_fieldAttr); + EnterRule(_localctx, 204, RULE_fieldAttr); + _localctx.Value = CILParser.AttributeValue.Empty; try { - State = 1870; + State = 2343; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__122: EnterOuterAlt(_localctx, 1); { - State = 1851; - Match(T__122); + State = 2309; + _localctx.attribute = Match(T__122); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__50: EnterOuterAlt(_localctx, 2); { - State = 1852; - Match(T__50); + State = 2311; + _localctx.attribute = Match(T__50); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__51: EnterOuterAlt(_localctx, 3); { - State = 1853; - Match(T__51); + State = 2313; + _localctx.attribute = Match(T__51); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__62: EnterOuterAlt(_localctx, 4); { - State = 1854; - Match(T__62); + State = 2315; + _localctx.attribute = Match(T__62); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__123: EnterOuterAlt(_localctx, 5); { - State = 1855; - Match(T__123); + State = 2317; + _localctx.attribute = Match(T__123); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__68: EnterOuterAlt(_localctx, 6); { - State = 1856; - Match(T__68); + State = 2319; + _localctx.attribute = Match(T__68); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__67: EnterOuterAlt(_localctx, 7); { - State = 1857; - Match(T__67); + State = 2321; + _localctx.attribute = Match(T__67); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__63: EnterOuterAlt(_localctx, 8); { - State = 1858; - Match(T__63); + State = 2323; + _localctx.attribute = Match(T__63); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__64: EnterOuterAlt(_localctx, 9); { - State = 1859; - Match(T__64); + State = 2325; + _localctx.attribute = Match(T__64); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__65: EnterOuterAlt(_localctx, 10); { - State = 1860; - Match(T__65); + State = 2327; + _localctx.attribute = Match(T__65); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__124: EnterOuterAlt(_localctx, 11); { - State = 1861; - Match(T__124); + State = 2329; + _localctx.attribute = Match(T__124); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__125: EnterOuterAlt(_localctx, 12); { - State = 1862; - Match(T__125); + State = 2331; + _localctx.attribute = Match(T__125); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__126: EnterOuterAlt(_localctx, 13); { - State = 1863; - Match(T__126); + State = 2333; + _localctx.attribute = Match(T__126); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__15: EnterOuterAlt(_localctx, 14); { - State = 1864; - Match(T__15); + State = 2335; + _localctx.attribute = Match(T__15); + _localctx.Value = Actions.CreateFieldAttribute(_localctx.attribute); } break; case T__69: EnterOuterAlt(_localctx, 15); { - State = 1865; + State = 2337; Match(T__69); - State = 1866; + State = 2338; Match(T__29); - State = 1867; - int32(); - State = 1868; + State = 2339; + _localctx.flags = int32(); + State = 2340; Match(T__30); + _localctx.Value = Actions.CreateRawFieldAttribute((_localctx.flags!=null?(_localctx.flags.Start):null)); } break; default: @@ -10322,6 +10548,9 @@ public FieldAttrContext fieldAttr() { } public partial class AtOptContext : ParserRuleContext { + public string? Value; + public IdContext name; + public Int32Context offset; [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { return GetRuleContext(0); } @@ -10333,22 +10562,17 @@ public AtOptContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_atOpt; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAtOpt(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AtOptContext atOpt() { AtOptContext _localctx = new AtOptContext(Context, State); - EnterRule(_localctx, 226, RULE_atOpt); + EnterRule(_localctx, 206, RULE_atOpt); + _localctx.Value = null; try { - State = 1877; + State = 2354; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,93,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,99,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { @@ -10357,19 +10581,21 @@ public AtOptContext atOpt() { case 2: EnterOuterAlt(_localctx, 2); { - State = 1873; + State = 2346; Match(T__43); - State = 1874; - id(); + State = 2347; + _localctx.name = id(); + _localctx.Value = Actions.GetFieldDataName((_localctx.name!=null?(_localctx.name.Start):null)); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1875; + State = 2350; Match(T__43); - State = 1876; - int32(); + State = 2351; + _localctx.offset = int32(); + _localctx.Value = Actions.GetFieldDataOffset((_localctx.offset!=null?(_localctx.offset.Start):null)); } break; } @@ -10386,6 +10612,10 @@ public AtOptContext atOpt() { } public partial class InitOptContext : ParserRuleContext { + public CILParser.FieldInitializerValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public FieldInitContext initializer; [System.Diagnostics.DebuggerNonUserCode] public FieldInitContext fieldInit() { return GetRuleContext(0); } @@ -10394,20 +10624,18 @@ public InitOptContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_initOpt; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitInitOpt(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public InitOptContext initOpt() { InitOptContext _localctx = new InitOptContext(Context, State); - EnterRule(_localctx, 228, RULE_initOpt); + EnterRule(_localctx, 208, RULE_initOpt); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.FieldInitializerValue.Empty; + try { - State = 1882; + State = 2361; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__0: @@ -10501,10 +10729,11 @@ public InitOptContext initOpt() { case T__35: EnterOuterAlt(_localctx, 2); { - State = 1880; + State = 2357; Match(T__35); - State = 1881; - fieldInit(); + State = 2358; + _localctx.initializer = fieldInit(); + _localctx.Value = _localctx.initializer.Value; } break; default: @@ -10517,12 +10746,20 @@ public InitOptContext initOpt() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class RepeatOptContext : ParserRuleContext { + public int Value; + public bool HasValue; + public Int32Context offset; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -10531,20 +10768,14 @@ public RepeatOptContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_repeatOpt; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitRepeatOpt(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public RepeatOptContext repeatOpt() { RepeatOptContext _localctx = new RepeatOptContext(Context, State); - EnterRule(_localctx, 230, RULE_repeatOpt); + EnterRule(_localctx, 210, RULE_repeatOpt); try { - State = 1889; + State = 2369; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__0: @@ -10599,12 +10830,13 @@ public RepeatOptContext repeatOpt() { case T__41: EnterOuterAlt(_localctx, 2); { - State = 1885; + State = 2364; Match(T__41); - State = 1886; - int32(); - State = 1887; + State = 2365; + _localctx.offset = int32(); + State = 2366; Match(T__42); + Actions.SetFieldOffset(_localctx, (_localctx.offset!=null?(_localctx.offset.Start):null)); } break; default: @@ -10623,6 +10855,12 @@ public RepeatOptContext repeatOpt() { } public partial class EventHeadContext : ParserRuleContext { + public CILParser.EventHeaderValue Value; + public int InitialSyntaxErrorCount; + public CILParser.EventHeaderBuilder Builder; + public EventAttrContext attribute; + public TypeSpecContext eventType; + public DottedNameContext name; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } @@ -10640,69 +10878,82 @@ public EventHeadContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_eventHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitEventHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public EventHeadContext eventHead() { EventHeadContext _localctx = new EventHeadContext(Context, State); - EnterRule(_localctx, 232, RULE_eventHead); + EnterRule(_localctx, 212, RULE_eventHead); + + _localctx.Builder = new CILParser.EventHeaderBuilder(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.EventHeaderValue.Error; + int _la; try { - State = 1909; + State = 2396; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,98,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,104,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1891; + State = 2371; Match(T__127); - State = 1895; + State = 2377; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__67 || _la==T__68) { { { - State = 1892; - eventAttr(); + State = 2372; + _localctx.attribute = eventAttr(); + Actions.AddEventAttribute(_localctx.Builder, _localctx.attribute.Value); } } - State = 1897; + State = 2379; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 1898; - typeSpec(); - State = 1899; - dottedName(); + State = 2380; + _localctx.eventType = typeSpec(); + State = 2381; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateEventHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + _localctx.eventType.Value, + _localctx.name.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1901; + State = 2384; Match(T__127); - State = 1905; + State = 2390; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__67 || _la==T__68) { { { - State = 1902; - eventAttr(); + State = 2385; + _localctx.attribute = eventAttr(); + Actions.AddEventAttribute(_localctx.Builder, _localctx.attribute.Value); } } - State = 1907; + State = 2392; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 1908; - dottedName(); + State = 2393; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateEventHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + null, + _localctx.name.Value); } break; } @@ -10719,36 +10970,42 @@ public EventHeadContext eventHead() { } public partial class EventAttrContext : ParserRuleContext { + public CILParser.AttributeValue Value; + public IToken attribute; public EventAttrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_eventAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitEventAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public EventAttrContext eventAttr() { EventAttrContext _localctx = new EventAttrContext(Context, State); - EnterRule(_localctx, 234, RULE_eventAttr); - int _la; + EnterRule(_localctx, 214, RULE_eventAttr); + _localctx.Value = CILParser.AttributeValue.Empty; try { - EnterOuterAlt(_localctx, 1); - { - State = 1911; - _la = TokenStream.LA(1); - if ( !(_la==T__67 || _la==T__68) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } + State = 2402; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case T__68: + EnterOuterAlt(_localctx, 1); + { + State = 2398; + _localctx.attribute = Match(T__68); + _localctx.Value = Actions.CreateEventAttribute(_localctx.attribute); + } + break; + case T__67: + EnterOuterAlt(_localctx, 2); + { + State = 2400; + _localctx.attribute = Match(T__67); + _localctx.Value = Actions.CreateEventAttribute(_localctx.attribute); + } + break; + default: + throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -10763,44 +11020,41 @@ public EventAttrContext eventAttr() { } public partial class EventDeclsContext : ParserRuleContext { + public CILParser.EventBodyValue Body; [System.Diagnostics.DebuggerNonUserCode] public EventDeclContext[] eventDecl() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public EventDeclContext eventDecl(int i) { return GetRuleContext(i); } - public EventDeclsContext(ParserRuleContext parent, int invokingState) + public EventDeclsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public EventDeclsContext(ParserRuleContext parent, int invokingState, CILParser.EventBodyValue Body) : base(parent, invokingState) { + this.Body = Body; } public override int RuleIndex { get { return RULE_eventDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitEventDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public EventDeclsContext eventDecls() { - EventDeclsContext _localctx = new EventDeclsContext(Context, State); - EnterRule(_localctx, 236, RULE_eventDecls); + public EventDeclsContext eventDecls(CILParser.EventBodyValue Body) { + EventDeclsContext _localctx = new EventDeclsContext(Context, State, Body); + EnterRule(_localctx, 216, RULE_eventDecls); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1916; + State = 2407; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 38788988928L) != 0) || ((((_la - 73)) & ~0x3f) == 0 && ((1L << (_la - 73)) & 1080863910568919043L) != 0) || _la==VALUE || _la==INSTANCE || ((((_la - 264)) & ~0x3f) == 0 && ((1L << (_la - 264)) & 50332665L) != 0)) { { { - State = 1913; - eventDecl(); + State = 2404; + eventDecl(_localctx.Body); } } - State = 1918; + State = 2409; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -10818,6 +11072,11 @@ public EventDeclsContext eventDecls() { } public partial class EventDeclContext : ParserRuleContext { + public CILParser.EventBodyValue Body; + public MethodRefContext accessor; + public ExtSourceSpecContext source; + public CustomAttrDeclContext attribute; + public LanguageDeclContext language; [System.Diagnostics.DebuggerNonUserCode] public MethodRefContext methodRef() { return GetRuleContext(0); } @@ -10833,69 +11092,70 @@ [System.Diagnostics.DebuggerNonUserCode] public LanguageDeclContext languageDecl [System.Diagnostics.DebuggerNonUserCode] public CompControlContext compControl() { return GetRuleContext(0); } - public EventDeclContext(ParserRuleContext parent, int invokingState) + public EventDeclContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public EventDeclContext(ParserRuleContext parent, int invokingState, CILParser.EventBodyValue Body) : base(parent, invokingState) { + this.Body = Body; } public override int RuleIndex { get { return RULE_eventDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitEventDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public EventDeclContext eventDecl() { - EventDeclContext _localctx = new EventDeclContext(Context, State); - EnterRule(_localctx, 238, RULE_eventDecl); + public EventDeclContext eventDecl(CILParser.EventBodyValue Body) { + EventDeclContext _localctx = new EventDeclContext(Context, State, Body); + EnterRule(_localctx, 218, RULE_eventDecl); try { - State = 1931; + State = 2436; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__128: EnterOuterAlt(_localctx, 1); { - State = 1919; + State = 2410; Match(T__128); - State = 1920; - methodRef(); + State = 2411; + _localctx.accessor = methodRef(); + Actions.AddEventAdder(_localctx.Body, _localctx.accessor.Value); } break; case T__129: EnterOuterAlt(_localctx, 2); { - State = 1921; + State = 2414; Match(T__129); - State = 1922; - methodRef(); + State = 2415; + _localctx.accessor = methodRef(); + Actions.AddEventRemover(_localctx.Body, _localctx.accessor.Value); } break; case T__130: EnterOuterAlt(_localctx, 3); { - State = 1923; + State = 2418; Match(T__130); - State = 1924; - methodRef(); + State = 2419; + _localctx.accessor = methodRef(); + Actions.AddEventRaiser(_localctx.Body, _localctx.accessor.Value); } break; case T__131: EnterOuterAlt(_localctx, 4); { - State = 1925; + State = 2422; Match(T__131); - State = 1926; - methodRef(); + State = 2423; + _localctx.accessor = methodRef(); + Actions.AddEventOther(_localctx.Body, _localctx.accessor.Value); } break; case T__72: case T__73: EnterOuterAlt(_localctx, 5); { - State = 1927; - extSourceSpec(); + State = 2426; + _localctx.source = extSourceSpec(); + Actions.ProcessEventSourceDirective(_localctx.Body, _localctx.source); } break; case T__15: @@ -10907,15 +11167,17 @@ public EventDeclContext eventDecl() { case ID: EnterOuterAlt(_localctx, 6); { - State = 1928; - customAttrDecl(); + State = 2429; + _localctx.attribute = customAttrDecl(); + Actions.AddEventCustomAttribute(_localctx.Body, _localctx.attribute); } break; case T__26: EnterOuterAlt(_localctx, 7); { - State = 1929; - languageDecl(); + State = 2432; + _localctx.language = languageDecl(); + Actions.ProcessEventLanguageDirective(_localctx.Body, _localctx.language); } break; case T__31: @@ -10928,7 +11190,7 @@ public EventDeclContext eventDecl() { case PP_INCLUDE: EnterOuterAlt(_localctx, 8); { - State = 1930; + State = 2435; compControl(); } break; @@ -10948,6 +11210,15 @@ public EventDeclContext eventDecl() { } public partial class PropHeadContext : ParserRuleContext { + public CILParser.PropertyHeaderValue Value; + public int InitialSyntaxErrorCount; + public CILParser.PropertyHeaderBuilder Builder; + public PropAttrContext attribute; + public CallConvContext convention; + public TypeContext propertyType; + public DottedNameContext name; + public SigArgsContext arguments; + public InitOptContext initializer; [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { return GetRuleContext(0); } @@ -10974,48 +11245,57 @@ public PropHeadContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_propHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPropHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public PropHeadContext propHead() { PropHeadContext _localctx = new PropHeadContext(Context, State); - EnterRule(_localctx, 240, RULE_propHead); + EnterRule(_localctx, 220, RULE_propHead); + + _localctx.Builder = new CILParser.PropertyHeaderBuilder(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.PropertyHeaderValue.Error; + int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1933; + State = 2438; Match(T__132); - State = 1937; + State = 2444; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__67 || _la==T__68) { { { - State = 1934; - propAttr(); + State = 2439; + _localctx.attribute = propAttr(); + Actions.AddPropertyAttribute(_localctx.Builder, _localctx.attribute.Value); } } - State = 1939; + State = 2446; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 1940; - callConv(); - State = 1941; - type(); - State = 1942; - dottedName(); - State = 1943; - sigArgs(); - State = 1944; - initOpt(); + State = 2447; + _localctx.convention = callConv(); + State = 2448; + _localctx.propertyType = type(); + State = 2449; + _localctx.name = dottedName(); + State = 2450; + _localctx.arguments = sigArgs(); + State = 2451; + _localctx.initializer = initOpt(); + _localctx.Value = Actions.CreatePropertyHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + _localctx.convention.Value, + _localctx.propertyType.Value, + _localctx.name.Value, + _localctx.arguments.Value, + _localctx.initializer.Value); } } catch (RecognitionException re) { @@ -11030,36 +11310,42 @@ public PropHeadContext propHead() { } public partial class PropAttrContext : ParserRuleContext { + public CILParser.AttributeValue Value; + public IToken attribute; public PropAttrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_propAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPropAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public PropAttrContext propAttr() { PropAttrContext _localctx = new PropAttrContext(Context, State); - EnterRule(_localctx, 242, RULE_propAttr); - int _la; + EnterRule(_localctx, 222, RULE_propAttr); + _localctx.Value = CILParser.AttributeValue.Empty; try { - EnterOuterAlt(_localctx, 1); - { - State = 1946; - _la = TokenStream.LA(1); - if ( !(_la==T__67 || _la==T__68) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } + State = 2458; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case T__68: + EnterOuterAlt(_localctx, 1); + { + State = 2454; + _localctx.attribute = Match(T__68); + _localctx.Value = Actions.CreatePropertyAttribute(_localctx.attribute); + } + break; + case T__67: + EnterOuterAlt(_localctx, 2); + { + State = 2456; + _localctx.attribute = Match(T__67); + _localctx.Value = Actions.CreatePropertyAttribute(_localctx.attribute); + } + break; + default: + throw new NoViableAltException(this); } } catch (RecognitionException re) { @@ -11074,44 +11360,41 @@ public PropAttrContext propAttr() { } public partial class PropDeclsContext : ParserRuleContext { + public CILParser.PropertyBodyValue Body; [System.Diagnostics.DebuggerNonUserCode] public PropDeclContext[] propDecl() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public PropDeclContext propDecl(int i) { return GetRuleContext(i); } - public PropDeclsContext(ParserRuleContext parent, int invokingState) + public PropDeclsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public PropDeclsContext(ParserRuleContext parent, int invokingState, CILParser.PropertyBodyValue Body) : base(parent, invokingState) { + this.Body = Body; } public override int RuleIndex { get { return RULE_propDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPropDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public PropDeclsContext propDecls() { - PropDeclsContext _localctx = new PropDeclsContext(Context, State); - EnterRule(_localctx, 244, RULE_propDecls); + public PropDeclsContext propDecls(CILParser.PropertyBodyValue Body) { + PropDeclsContext _localctx = new PropDeclsContext(Context, State, Body); + EnterRule(_localctx, 224, RULE_propDecls); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1951; + State = 2463; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 38788988928L) != 0) || ((((_la - 73)) & ~0x3f) == 0 && ((1L << (_la - 73)) & 7493989779944505347L) != 0) || _la==VALUE || _la==INSTANCE || ((((_la - 264)) & ~0x3f) == 0 && ((1L << (_la - 264)) & 50332665L) != 0)) { { { - State = 1948; - propDecl(); + State = 2460; + propDecl(_localctx.Body); } } - State = 1953; + State = 2465; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -11129,6 +11412,11 @@ public PropDeclsContext propDecls() { } public partial class PropDeclContext : ParserRuleContext { + public CILParser.PropertyBodyValue Body; + public MethodRefContext accessor; + public CustomAttrDeclContext attribute; + public ExtSourceSpecContext source; + public LanguageDeclContext language; [System.Diagnostics.DebuggerNonUserCode] public MethodRefContext methodRef() { return GetRuleContext(0); } @@ -11144,52 +11432,51 @@ [System.Diagnostics.DebuggerNonUserCode] public LanguageDeclContext languageDecl [System.Diagnostics.DebuggerNonUserCode] public CompControlContext compControl() { return GetRuleContext(0); } - public PropDeclContext(ParserRuleContext parent, int invokingState) + public PropDeclContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public PropDeclContext(ParserRuleContext parent, int invokingState, CILParser.PropertyBodyValue Body) : base(parent, invokingState) { + this.Body = Body; } public override int RuleIndex { get { return RULE_propDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPropDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public PropDeclContext propDecl() { - PropDeclContext _localctx = new PropDeclContext(Context, State); - EnterRule(_localctx, 246, RULE_propDecl); + public PropDeclContext propDecl(CILParser.PropertyBodyValue Body) { + PropDeclContext _localctx = new PropDeclContext(Context, State, Body); + EnterRule(_localctx, 226, RULE_propDecl); try { - State = 1964; + State = 2488; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__133: EnterOuterAlt(_localctx, 1); { - State = 1954; + State = 2466; Match(T__133); - State = 1955; - methodRef(); + State = 2467; + _localctx.accessor = methodRef(); + Actions.AddPropertySetter(_localctx.Body, _localctx.accessor.Value); } break; case T__134: EnterOuterAlt(_localctx, 2); { - State = 1956; + State = 2470; Match(T__134); - State = 1957; - methodRef(); + State = 2471; + _localctx.accessor = methodRef(); + Actions.AddPropertyGetter(_localctx.Body, _localctx.accessor.Value); } break; case T__131: EnterOuterAlt(_localctx, 3); { - State = 1958; + State = 2474; Match(T__131); - State = 1959; - methodRef(); + State = 2475; + _localctx.accessor = methodRef(); + Actions.AddPropertyOther(_localctx.Body, _localctx.accessor.Value); } break; case T__15: @@ -11201,23 +11488,26 @@ public PropDeclContext propDecl() { case ID: EnterOuterAlt(_localctx, 4); { - State = 1960; - customAttrDecl(); + State = 2478; + _localctx.attribute = customAttrDecl(); + Actions.AddPropertyCustomAttribute(_localctx.Body, _localctx.attribute); } break; case T__72: case T__73: EnterOuterAlt(_localctx, 5); { - State = 1961; - extSourceSpec(); + State = 2481; + _localctx.source = extSourceSpec(); + Actions.ProcessPropertySourceDirective(_localctx.Body, _localctx.source); } break; case T__26: EnterOuterAlt(_localctx, 6); { - State = 1962; - languageDecl(); + State = 2484; + _localctx.language = languageDecl(); + Actions.ProcessPropertyLanguageDirective(_localctx.Body, _localctx.language); } break; case T__31: @@ -11230,7 +11520,7 @@ public PropDeclContext propDecl() { case PP_INCLUDE: EnterOuterAlt(_localctx, 7); { - State = 1963; + State = 2487; compControl(); } break; @@ -11250,6 +11540,8 @@ public PropDeclContext propDecl() { } public partial class MarshalClauseContext : ParserRuleContext { + public CILParser.MarshallingDescriptorValue Value; + public MarshalBlobContext value; [System.Diagnostics.DebuggerNonUserCode] public MarshalBlobContext marshalBlob() { return GetRuleContext(0); } @@ -11258,20 +11550,15 @@ public MarshalClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_marshalClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMarshalClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MarshalClauseContext marshalClause() { MarshalClauseContext _localctx = new MarshalClauseContext(Context, State); - EnterRule(_localctx, 248, RULE_marshalClause); + EnterRule(_localctx, 228, RULE_marshalClause); + _localctx.Value = CILParser.MarshallingDescriptorValue.Empty; try { - State = 1972; + State = 2497; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__0: @@ -11302,19 +11589,21 @@ public MarshalClauseContext marshalClause() { case ID: EnterOuterAlt(_localctx, 1); { + _localctx.Value = Actions.CreateEmptyMarshallingDescriptor(); } break; case T__121: EnterOuterAlt(_localctx, 2); { - State = 1967; + State = 2491; Match(T__121); - State = 1968; + State = 2492; Match(T__29); - State = 1969; - marshalBlob(); - State = 1970; + State = 2493; + _localctx.value = marshalBlob(); + State = 2494; Match(T__30); + _localctx.Value = Actions.CompleteMarshalClause(_localctx.value.Value); } break; default: @@ -11333,6 +11622,10 @@ public MarshalClauseContext marshalClause() { } public partial class MarshalBlobContext : ParserRuleContext { + public CILParser.MarshallingDescriptorValue Value; + public CILParser.MarshalBlobBuilder Builder; + public NativeTypeContext nativeValue; + public HexbyteContext rawByte; [System.Diagnostics.DebuggerNonUserCode] public NativeTypeContext nativeType() { return GetRuleContext(0); } @@ -11347,21 +11640,16 @@ public MarshalBlobContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_marshalBlob; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMarshalBlob(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MarshalBlobContext marshalBlob() { MarshalBlobContext _localctx = new MarshalBlobContext(Context, State); - EnterRule(_localctx, 250, RULE_marshalBlob); + EnterRule(_localctx, 230, RULE_marshalBlob); + _localctx.Builder = new CILParser.MarshalBlobBuilder(); int _la; try { - State = 1983; + State = 2512; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__15: @@ -11416,30 +11704,32 @@ public MarshalBlobContext marshalBlob() { case ID: EnterOuterAlt(_localctx, 1); { - State = 1974; - nativeType(); + State = 2499; + _localctx.nativeValue = nativeType(); + Actions.SetMarshalBlobNativeType(_localctx.Builder, _localctx.nativeValue.Value); } break; case T__16: EnterOuterAlt(_localctx, 2); { - State = 1975; + State = 2502; Match(T__16); - State = 1977; + State = 2506; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { - State = 1976; - hexbyte(); + State = 2503; + _localctx.rawByte = hexbyte(); + Actions.AddMarshalBlobByte(_localctx.Builder, _localctx.rawByte.Value); } } - State = 1979; + State = 2508; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ( _la==INT32 || _la==ID || _la==HEXBYTE ); - State = 1981; + State = 2510; Match(T__17); } break; @@ -11453,12 +11743,15 @@ public MarshalBlobContext marshalBlob() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.CreateMarshallingDescriptor(_localctx.Builder); ExitRule(); } return _localctx; } public partial class ParamAttrContext : ParserRuleContext { + public int Value; + public ParamAttrElementContext element; [System.Diagnostics.DebuggerNonUserCode] public ParamAttrElementContext[] paramAttrElement() { return GetRuleContexts(); } @@ -11470,33 +11763,32 @@ public ParamAttrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_paramAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitParamAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ParamAttrContext paramAttr() { ParamAttrContext _localctx = new ParamAttrContext(Context, State); - EnterRule(_localctx, 252, RULE_paramAttr); + EnterRule(_localctx, 232, RULE_paramAttr); + _localctx.Value = 0; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 1988; + State = 2519; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__41) { { { - State = 1985; - paramAttrElement(); + State = 2514; + _localctx.element = paramAttrElement(); + _localctx.Value = Actions.AddParameterAttribute( + _localctx.Value, + _localctx.element.Value, + _localctx.element.ShouldAppend); } } - State = 1990; + State = 2521; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -11514,9 +11806,10 @@ public ParamAttrContext paramAttr() { } public partial class ParamAttrElementContext : ParserRuleContext { - public IToken @in; - public IToken @out; - public IToken opt; + public int Value; + public bool ShouldAppend; + public IToken attribute; + public Int32Context raw; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -11525,64 +11818,62 @@ public ParamAttrElementContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_paramAttrElement; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitParamAttrElement(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ParamAttrElementContext paramAttrElement() { ParamAttrElementContext _localctx = new ParamAttrElementContext(Context, State); - EnterRule(_localctx, 254, RULE_paramAttrElement); + EnterRule(_localctx, 234, RULE_paramAttrElement); try { - State = 2004; + State = 2539; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,108,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,116,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 1991; + State = 2522; Match(T__41); - State = 1992; - _localctx.@in = Match(T__135); - State = 1993; + State = 2523; + _localctx.attribute = Match(T__135); + State = 2524; Match(T__42); + Actions.SetParameterAttributeElement(_localctx, _localctx.attribute); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 1994; + State = 2526; Match(T__41); - State = 1995; - _localctx.@out = Match(T__136); - State = 1996; + State = 2527; + _localctx.attribute = Match(T__136); + State = 2528; Match(T__42); + Actions.SetParameterAttributeElement(_localctx, _localctx.attribute); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 1997; + State = 2530; Match(T__41); - State = 1998; - _localctx.opt = Match(T__137); - State = 1999; + State = 2531; + _localctx.attribute = Match(T__137); + State = 2532; Match(T__42); + Actions.SetParameterAttributeElement(_localctx, _localctx.attribute); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 2000; + State = 2534; Match(T__41); - State = 2001; - int32(); - State = 2002; + State = 2535; + _localctx.raw = int32(); + State = 2536; Match(T__42); + Actions.SetRawParameterAttributeElement(_localctx, (_localctx.raw!=null?(_localctx.raw.Start):null)); } break; } @@ -11599,6 +11890,19 @@ public ParamAttrElementContext paramAttrElement() { } public partial class MethodHeadContext : ParserRuleContext { + public CILParser.MethodHeaderValue Value; + public int InitialSyntaxErrorCount; + public CILParser.MethodHeaderBuilder Builder; + public MethAttrContext attribute; + public PinvImplContext pInvoke; + public CallConvContext convention; + public ParamAttrContext returnAttributes; + public TypeContext returnType; + public MarshalClauseContext returnMarshalling; + public MethodNameContext name; + public TyparsClauseContext genericParameters; + public SigArgsContext arguments; + public ImplAttrContext implementation; [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { return GetRuleContext(0); } @@ -11643,30 +11947,29 @@ public MethodHeadContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_methodHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethodHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MethodHeadContext methodHead() { MethodHeadContext _localctx = new MethodHeadContext(Context, State); - EnterRule(_localctx, 256, RULE_methodHead); + EnterRule(_localctx, 236, RULE_methodHead); + + _localctx.Builder = Actions.PrepareMethodHeader(); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.MethodHeaderValue.Error; + int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2006; + State = 2541; Match(T__138); - State = 2011; + State = 2550; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (((((_la - 51)) & ~0x3f) == 0 && ((1L << (_la - 51)) & 978955L) != 0) || ((((_la - 123)) & ~0x3f) == 0 && ((1L << (_la - 123)) & 33423365L) != 0)) { { - State = 2009; + State = 2548; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__50: @@ -11689,53 +11992,69 @@ public MethodHeadContext methodHead() { case T__144: case T__145: { - State = 2007; - methAttr(); + State = 2542; + _localctx.attribute = methAttr(); + Actions.AddMethodAttribute(_localctx.Builder, _localctx.attribute.Value); } break; case T__146: { - State = 2008; - pinvImpl(); + State = 2545; + _localctx.pInvoke = pinvImpl(); + Actions.AddPInvoke(_localctx.Builder, _localctx.pInvoke.Value); } break; default: throw new NoViableAltException(this); } } - State = 2013; + State = 2552; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 2014; - callConv(); - State = 2015; - paramAttr(); - State = 2016; - type(); - State = 2017; - marshalClause(); - State = 2018; - methodName(); - State = 2019; - typarsClause(); - State = 2020; - sigArgs(); - State = 2024; + State = 2553; + _localctx.convention = callConv(); + State = 2554; + _localctx.returnAttributes = paramAttr(); + State = 2555; + _localctx.returnType = type(); + State = 2556; + _localctx.returnMarshalling = marshalClause(); + State = 2557; + _localctx.name = methodName(); + State = 2558; + _localctx.genericParameters = typarsClause(); + State = 2559; + _localctx.arguments = sigArgs(); + State = 2565; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 32766L) != 0) || _la==T__69 || _la==T__155 || _la==UNMANAGED) { { { - State = 2021; - implAttr(); + State = 2560; + _localctx.implementation = implAttr(); + Actions.AddMethodImplementationAttribute(_localctx.Builder, _localctx.implementation.Value); } } - State = 2026; + State = 2567; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } + _localctx.Value = Actions.CreateMethodHeader( + _localctx, + _localctx.Builder, + _localctx.InitialSyntaxErrorCount, + _localctx.convention.Value, + _localctx.returnAttributes.Value, + _localctx.returnType.Value, + _localctx.returnMarshalling.Value, + _localctx.name.Value, + _localctx.genericParameters.Value, + _localctx.arguments.Value); } + Context.Stop = TokenStream.LT(-1); + Actions.BeginMethod(_localctx, _localctx.Value); } catch (RecognitionException re) { _localctx.exception = re; @@ -11749,6 +12068,9 @@ public MethodHeadContext methodHead() { } public partial class MethAttrContext : ParserRuleContext { + public CILParser.AttributeValue Value; + public IToken attribute; + public Int32Context flags; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -11757,159 +12079,173 @@ public MethAttrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_methAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MethAttrContext methAttr() { MethAttrContext _localctx = new MethAttrContext(Context, State); - EnterRule(_localctx, 258, RULE_methAttr); + EnterRule(_localctx, 238, RULE_methAttr); + _localctx.Value = CILParser.AttributeValue.Empty; try { - State = 2050; + State = 2612; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__122: EnterOuterAlt(_localctx, 1); { - State = 2027; - Match(T__122); + State = 2570; + _localctx.attribute = Match(T__122); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__50: EnterOuterAlt(_localctx, 2); { - State = 2028; - Match(T__50); + State = 2572; + _localctx.attribute = Match(T__50); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__51: EnterOuterAlt(_localctx, 3); { - State = 2029; - Match(T__51); + State = 2574; + _localctx.attribute = Match(T__51); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__62: EnterOuterAlt(_localctx, 4); { - State = 2030; - Match(T__62); + State = 2576; + _localctx.attribute = Match(T__62); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__139: EnterOuterAlt(_localctx, 5); { - State = 2031; - Match(T__139); + State = 2578; + _localctx.attribute = Match(T__139); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__67: EnterOuterAlt(_localctx, 6); { - State = 2032; - Match(T__67); + State = 2580; + _localctx.attribute = Match(T__67); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__140: EnterOuterAlt(_localctx, 7); { - State = 2033; - Match(T__140); + State = 2582; + _localctx.attribute = Match(T__140); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__141: EnterOuterAlt(_localctx, 8); { - State = 2034; - Match(T__141); + State = 2584; + _localctx.attribute = Match(T__141); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__53: EnterOuterAlt(_localctx, 9); { - State = 2035; - Match(T__53); + State = 2586; + _localctx.attribute = Match(T__53); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__63: EnterOuterAlt(_localctx, 10); { - State = 2036; - Match(T__63); + State = 2588; + _localctx.attribute = Match(T__63); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__64: EnterOuterAlt(_localctx, 11); { - State = 2037; - Match(T__64); + State = 2590; + _localctx.attribute = Match(T__64); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__65: EnterOuterAlt(_localctx, 12); { - State = 2038; - Match(T__65); + State = 2592; + _localctx.attribute = Match(T__65); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__124: EnterOuterAlt(_localctx, 13); { - State = 2039; - Match(T__124); + State = 2594; + _localctx.attribute = Match(T__124); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__142: EnterOuterAlt(_localctx, 14); { - State = 2040; - Match(T__142); + State = 2596; + _localctx.attribute = Match(T__142); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__143: EnterOuterAlt(_localctx, 15); { - State = 2041; - Match(T__143); + State = 2598; + _localctx.attribute = Match(T__143); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__68: EnterOuterAlt(_localctx, 16); { - State = 2042; - Match(T__68); + State = 2600; + _localctx.attribute = Match(T__68); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__144: EnterOuterAlt(_localctx, 17); { - State = 2043; - Match(T__144); + State = 2602; + _localctx.attribute = Match(T__144); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__145: EnterOuterAlt(_localctx, 18); { - State = 2044; - Match(T__145); + State = 2604; + _localctx.attribute = Match(T__145); + _localctx.Value = Actions.CreateMethodAttribute(_localctx.attribute); } break; case T__69: EnterOuterAlt(_localctx, 19); { - State = 2045; + State = 2606; Match(T__69); - State = 2046; + State = 2607; Match(T__29); - State = 2047; - int32(); - State = 2048; + State = 2608; + _localctx.flags = int32(); + State = 2609; Match(T__30); + _localctx.Value = Actions.CreateRawMethodAttribute((_localctx.flags!=null?(_localctx.flags.Start):null)); } break; default: @@ -11928,6 +12264,11 @@ public MethAttrContext methAttr() { } public partial class PinvImplContext : ParserRuleContext { + public CILParser.PInvokeValue Value; + public CILParser.PInvokeBuilder Builder; + public CompQstringContext module; + public CompQstringContext entryPoint; + public PinvAttrContext attribute; [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext[] compQstring() { return GetRuleContexts(); } @@ -11945,76 +12286,74 @@ public PinvImplContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_pinvImpl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPinvImpl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public PinvImplContext pinvImpl() { PinvImplContext _localctx = new PinvImplContext(Context, State); - EnterRule(_localctx, 260, RULE_pinvImpl); + EnterRule(_localctx, 240, RULE_pinvImpl); + _localctx.Builder = new CILParser.PInvokeBuilder(); int _la; try { - State = 2070; + State = 2637; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,116,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,124,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2052; + State = 2614; Match(T__146); - State = 2053; + State = 2615; Match(T__29); - State = 2059; + State = 2624; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==QSTRING) { { - State = 2054; - compQstring(); - State = 2057; + State = 2616; + _localctx.module = compQstring(); + Actions.SetPInvokeModule(_localctx.Builder, _localctx.module.Value); + State = 2622; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la==T__33) { { - State = 2055; + State = 2618; Match(T__33); - State = 2056; - compQstring(); + State = 2619; + _localctx.entryPoint = compQstring(); + Actions.SetPInvokeEntryPoint(_localctx.Builder, _localctx.entryPoint.Value); } } } } - State = 2064; + State = 2631; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (((((_la - 57)) & ~0x3f) == 0 && ((1L << (_la - 57)) & 8195L) != 0) || ((((_la - 148)) & ~0x3f) == 0 && ((1L << (_la - 148)) & 79L) != 0) || ((((_la - 224)) & ~0x3f) == 0 && ((1L << (_la - 224)) & 251658241L) != 0)) { { { - State = 2061; - pinvAttr(); + State = 2626; + _localctx.attribute = pinvAttr(); + Actions.AddPInvokeAttribute(_localctx.Builder, _localctx.attribute.Value); } } - State = 2066; + State = 2633; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 2067; + State = 2634; Match(T__30); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2068; + State = 2635; Match(T__146); - State = 2069; + State = 2636; Match(T__84); } break; @@ -12026,12 +12365,17 @@ public PinvImplContext pinvImpl() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.CreatePInvoke(_localctx.Builder); ExitRule(); } return _localctx; } public partial class PinvAttrContext : ParserRuleContext { + public CILParser.AttributeValue Value; + public IToken attribute; + public IToken setting; + public Int32Context flags; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ANSI() { return GetToken(CILParser.ANSI, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CDECL() { return GetToken(CILParser.CDECL, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STDCALL() { return GetToken(CILParser.STDCALL, 0); } @@ -12045,147 +12389,157 @@ public PinvAttrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_pinvAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitPinvAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public PinvAttrContext pinvAttr() { PinvAttrContext _localctx = new PinvAttrContext(Context, State); - EnterRule(_localctx, 262, RULE_pinvAttr); + EnterRule(_localctx, 242, RULE_pinvAttr); + _localctx.Value = CILParser.AttributeValue.Empty; try { - State = 2099; + State = 2681; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,117,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,125,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2072; - Match(T__147); + State = 2639; + _localctx.attribute = Match(T__147); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2073; - Match(ANSI); + State = 2641; + _localctx.attribute = Match(ANSI); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2074; - Match(T__56); + State = 2643; + _localctx.attribute = Match(T__56); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 2075; - Match(T__57); + State = 2645; + _localctx.attribute = Match(T__57); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 2076; - Match(T__148); + State = 2647; + _localctx.attribute = Match(T__148); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 2077; - Match(T__149); + State = 2649; + _localctx.attribute = Match(T__149); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 2078; - Match(CDECL); + State = 2651; + _localctx.attribute = Match(CDECL); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 2079; - Match(STDCALL); + State = 2653; + _localctx.attribute = Match(STDCALL); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 2080; - Match(THISCALL); + State = 2655; + _localctx.attribute = Match(THISCALL); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 2081; - Match(FASTCALL); + State = 2657; + _localctx.attribute = Match(FASTCALL); + _localctx.Value = Actions.CreatePInvokeAttribute(_localctx.attribute); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 2082; + State = 2659; Match(T__150); - State = 2083; + State = 2660; Match(T__74); - State = 2084; - Match(T__151); + State = 2661; + _localctx.setting = Match(T__151); + _localctx.Value = Actions.CreateBestFitPInvokeAttribute(_localctx.setting); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 2085; + State = 2663; Match(T__150); - State = 2086; + State = 2664; Match(T__74); - State = 2087; - Match(T__152); + State = 2665; + _localctx.setting = Match(T__152); + _localctx.Value = Actions.CreateBestFitPInvokeAttribute(_localctx.setting); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 2088; + State = 2667; Match(T__153); - State = 2089; + State = 2668; Match(T__74); - State = 2090; - Match(T__151); + State = 2669; + _localctx.setting = Match(T__151); + _localctx.Value = Actions.CreateCharMapErrorPInvokeAttribute(_localctx.setting); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 2091; + State = 2671; Match(T__153); - State = 2092; + State = 2672; Match(T__74); - State = 2093; - Match(T__152); + State = 2673; + _localctx.setting = Match(T__152); + _localctx.Value = Actions.CreateCharMapErrorPInvokeAttribute(_localctx.setting); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 2094; + State = 2675; Match(T__69); - State = 2095; + State = 2676; Match(T__29); - State = 2096; - int32(); - State = 2097; + State = 2677; + _localctx.flags = int32(); + State = 2678; Match(T__30); + _localctx.Value = Actions.CreateRawPInvokeAttribute((_localctx.flags!=null?(_localctx.flags.Start):null)); } break; } @@ -12202,6 +12556,10 @@ public PinvAttrContext pinvAttr() { } public partial class MethodNameContext : ParserRuleContext { + public string Value; + public IToken ctorName; + public IToken cctorName; + public DottedNameContext dotted; [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } @@ -12210,34 +12568,31 @@ public MethodNameContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_methodName; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethodName(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MethodNameContext methodName() { MethodNameContext _localctx = new MethodNameContext(Context, State); - EnterRule(_localctx, 264, RULE_methodName); + EnterRule(_localctx, 244, RULE_methodName); + _localctx.Value = string.Empty; try { - State = 2104; + State = 2690; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__115: EnterOuterAlt(_localctx, 1); { - State = 2101; - Match(T__115); + State = 2683; + _localctx.ctorName = Match(T__115); + _localctx.Value = Actions.GetMethodName(_localctx.ctorName); } break; case T__154: EnterOuterAlt(_localctx, 2); { - State = 2102; - Match(T__154); + State = 2685; + _localctx.cctorName = Match(T__154); + _localctx.Value = Actions.GetMethodName(_localctx.cctorName); } break; case T__15: @@ -12248,8 +12603,9 @@ public MethodNameContext methodName() { case ID: EnterOuterAlt(_localctx, 3); { - State = 2103; - dottedName(); + State = 2687; + _localctx.dotted = dottedName(); + _localctx.Value = _localctx.dotted.Value; } break; default: @@ -12268,6 +12624,9 @@ public MethodNameContext methodName() { } public partial class ImplAttrContext : ParserRuleContext { + public CILParser.AttributeValue Value; + public IToken attribute; + public Int32Context flags; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode UNMANAGED() { return GetToken(CILParser.UNMANAGED, 0); } [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); @@ -12277,145 +12636,157 @@ public ImplAttrContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_implAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitImplAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ImplAttrContext implAttr() { ImplAttrContext _localctx = new ImplAttrContext(Context, State); - EnterRule(_localctx, 266, RULE_implAttr); + EnterRule(_localctx, 246, RULE_implAttr); + _localctx.Value = CILParser.AttributeValue.Empty; try { - State = 2127; + State = 2730; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__0: EnterOuterAlt(_localctx, 1); { - State = 2106; - Match(T__0); + State = 2692; + _localctx.attribute = Match(T__0); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__1: EnterOuterAlt(_localctx, 2); { - State = 2107; - Match(T__1); + State = 2694; + _localctx.attribute = Match(T__1); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__155: EnterOuterAlt(_localctx, 3); { - State = 2108; - Match(T__155); + State = 2696; + _localctx.attribute = Match(T__155); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__2: EnterOuterAlt(_localctx, 4); { - State = 2109; - Match(T__2); + State = 2698; + _localctx.attribute = Match(T__2); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__3: EnterOuterAlt(_localctx, 5); { - State = 2110; - Match(T__3); + State = 2700; + _localctx.attribute = Match(T__3); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case UNMANAGED: EnterOuterAlt(_localctx, 6); { - State = 2111; - Match(UNMANAGED); + State = 2702; + _localctx.attribute = Match(UNMANAGED); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__4: EnterOuterAlt(_localctx, 7); { - State = 2112; - Match(T__4); + State = 2704; + _localctx.attribute = Match(T__4); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__5: EnterOuterAlt(_localctx, 8); { - State = 2113; - Match(T__5); + State = 2706; + _localctx.attribute = Match(T__5); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__6: EnterOuterAlt(_localctx, 9); { - State = 2114; - Match(T__6); + State = 2708; + _localctx.attribute = Match(T__6); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__7: EnterOuterAlt(_localctx, 10); { - State = 2115; - Match(T__7); + State = 2710; + _localctx.attribute = Match(T__7); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__8: EnterOuterAlt(_localctx, 11); { - State = 2116; - Match(T__8); + State = 2712; + _localctx.attribute = Match(T__8); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__9: EnterOuterAlt(_localctx, 12); { - State = 2117; - Match(T__9); + State = 2714; + _localctx.attribute = Match(T__9); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__10: EnterOuterAlt(_localctx, 13); { - State = 2118; - Match(T__10); + State = 2716; + _localctx.attribute = Match(T__10); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__11: EnterOuterAlt(_localctx, 14); { - State = 2119; - Match(T__11); + State = 2718; + _localctx.attribute = Match(T__11); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__12: EnterOuterAlt(_localctx, 15); { - State = 2120; - Match(T__12); + State = 2720; + _localctx.attribute = Match(T__12); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__13: EnterOuterAlt(_localctx, 16); { - State = 2121; - Match(T__13); + State = 2722; + _localctx.attribute = Match(T__13); + _localctx.Value = Actions.CreateMethodImplementationAttribute(_localctx.attribute); } break; case T__69: EnterOuterAlt(_localctx, 17); { - State = 2122; + State = 2724; Match(T__69); - State = 2123; + State = 2725; Match(T__29); - State = 2124; - int32(); - State = 2125; + State = 2726; + _localctx.flags = int32(); + State = 2727; Match(T__30); + _localctx.Value = Actions.CreateRawMethodImplementationAttribute((_localctx.flags!=null?(_localctx.flags.Start):null)); } break; default: @@ -12445,33 +12816,27 @@ public MethodDeclsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_methodDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethodDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MethodDeclsContext methodDecls() { MethodDeclsContext _localctx = new MethodDeclsContext(Context, State); - EnterRule(_localctx, 268, RULE_methodDecls); + EnterRule(_localctx, 248, RULE_methodDecls); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2132; + State = 2735; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 38789119998L) != 0) || _la==T__72 || _la==T__73 || ((((_la - 158)) & ~0x3f) == 0 && ((1L << (_la - 158)) & 2199023255681L) != 0) || ((((_la - 243)) & ~0x3f) == 0 && ((1L << (_la - 243)) & 2303696760354115601L) != 0)) { { { - State = 2129; + State = 2732; methodDecl(); } } - State = 2134; + State = 2737; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -12489,32 +12854,37 @@ public MethodDeclsContext methodDecls() { } public partial class MethodDeclContext : ParserRuleContext { + public Int32Context value; + public DataDeclContext declaration; + public SecDeclContext security; + public ExtSourceSpecContext source; + public LanguageDeclContext language; + public CustomDescrInMethodBodyContext attribute; [System.Diagnostics.DebuggerNonUserCode] public InstrContext instr() { return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EMITBYTE() { return GetToken(CILParser.EMITBYTE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32(int i) { - return GetRuleContext(i); + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public SehBlockContext sehBlock() { return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MAXSTACK() { return GetToken(CILParser.MAXSTACK, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LOCALS() { return GetToken(CILParser.LOCALS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public SigArgsContext sigArgs() { - return GetRuleContext(0); - } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ENTRYPOINT() { return GetToken(CILParser.ENTRYPOINT, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ZEROINIT() { return GetToken(CILParser.ZEROINIT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public DataDeclContext dataDecl() { - return GetRuleContext(0); - } [System.Diagnostics.DebuggerNonUserCode] public LabelDeclContext labelDecl() { return GetRuleContext(0); } + [System.Diagnostics.DebuggerNonUserCode] public ScopeBlockContext scopeBlock() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public LocalsDeclContext localsDecl() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public DataDeclContext dataDecl() { + return GetRuleContext(0); + } [System.Diagnostics.DebuggerNonUserCode] public SecDeclContext secDecl() { return GetRuleContext(0); } @@ -12530,422 +12900,699 @@ [System.Diagnostics.DebuggerNonUserCode] public CustomDescrInMethodBodyContext c [System.Diagnostics.DebuggerNonUserCode] public CompControlContext compControl() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EXPORT() { return GetToken(CILParser.EXPORT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VTENTRY() { return GetToken(CILParser.VTENTRY, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OVERRIDE() { return GetToken(CILParser.OVERRIDE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON() { return GetToken(CILParser.DCOLON, 0); } - [System.Diagnostics.DebuggerNonUserCode] public MethodNameContext methodName() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode METHOD() { return GetToken(CILParser.METHOD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public GenArityContext genArity() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ScopeBlockContext scopeBlock() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAM() { return GetToken(CILParser.PARAM, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TYPE() { return GetToken(CILParser.TYPE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public CustomAttrDeclContext[] customAttrDecl() { - return GetRuleContexts(); + [System.Diagnostics.DebuggerNonUserCode] public ExportDeclContext exportDecl() { + return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public CustomAttrDeclContext customAttrDecl(int i) { - return GetRuleContext(i); + [System.Diagnostics.DebuggerNonUserCode] public VtentryDeclContext vtentryDecl() { + return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { - return GetRuleContext(0); + [System.Diagnostics.DebuggerNonUserCode] public OverrideDeclContext overrideDecl() { + return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CONSTRAINT() { return GetToken(CILParser.CONSTRAINT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public InitOptContext initOpt() { - return GetRuleContext(0); + [System.Diagnostics.DebuggerNonUserCode] public ParameterDeclContext parameterDecl() { + return GetRuleContext(0); } public MethodDeclContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_methodDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethodDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public MethodDeclContext methodDecl() { MethodDeclContext _localctx = new MethodDeclContext(Context, State); - EnterRule(_localctx, 270, RULE_methodDecl); + EnterRule(_localctx, 250, RULE_methodDecl); try { - int _alt; - State = 2243; + State = 2775; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,126,Context) ) { - case 1: + switch (TokenStream.LA(1)) { + case INSTR_NONE: + case INSTR_VAR: + case INSTR_I: + case INSTR_I8: + case INSTR_R: + case INSTR_METHOD: + case INSTR_SIG: + case INSTR_BRTARGET: + case INSTR_SWITCH: + case INSTR_TYPE: + case INSTR_STRING: + case INSTR_FIELD: + case INSTR_TOK: EnterOuterAlt(_localctx, 1); { - State = 2135; + State = 2738; instr(); } break; - case 2: + case EMITBYTE: EnterOuterAlt(_localctx, 2); { - State = 2136; + State = 2739; Match(EMITBYTE); - State = 2137; - int32(); + State = 2740; + _localctx.value = int32(); + Actions.EmitByte((_localctx.value!=null?(_localctx.value.Start):null)); } break; - case 3: + case T__157: EnterOuterAlt(_localctx, 3); { - State = 2138; + State = 2743; sehBlock(); } break; - case 4: + case MAXSTACK: EnterOuterAlt(_localctx, 4); { - State = 2139; + State = 2744; Match(MAXSTACK); - State = 2140; - int32(); + State = 2745; + _localctx.value = int32(); + Actions.SetMaxStack((_localctx.value!=null?(_localctx.value.Start):null)); } break; - case 5: + case ENTRYPOINT: EnterOuterAlt(_localctx, 5); { - State = 2141; - Match(LOCALS); - State = 2142; - sigArgs(); + State = 2748; + Match(ENTRYPOINT); + Actions.SetEntryPoint(); } break; - case 6: + case ZEROINIT: EnterOuterAlt(_localctx, 6); { - State = 2143; - Match(LOCALS); - State = 2144; - Match(T__156); - State = 2145; - sigArgs(); + State = 2750; + Match(ZEROINIT); + Actions.SetZeroInit(); } break; - case 7: + case T__0: + case T__1: + case T__2: + case T__3: + case T__4: + case T__5: + case T__6: + case T__7: + case T__8: + case T__9: + case T__10: + case T__11: + case T__12: + case T__13: + case T__14: + case VALUE: + case INSTANCE: + case UNMANAGED: + case SQSTRING: + case ID: EnterOuterAlt(_localctx, 7); { - State = 2146; - Match(ENTRYPOINT); + State = 2752; + labelDecl(); } break; - case 8: + case T__16: EnterOuterAlt(_localctx, 8); { - State = 2147; - Match(ZEROINIT); + State = 2753; + scopeBlock(); } break; - case 9: + case LOCALS: EnterOuterAlt(_localctx, 9); { - State = 2148; - dataDecl(); + State = 2754; + localsDecl(); } break; - case 10: + case T__164: EnterOuterAlt(_localctx, 10); { - State = 2149; - labelDecl(); + State = 2755; + _localctx.declaration = dataDecl(); + Actions.ProcessMethodDataDeclaration(_localctx.declaration); } break; - case 11: + case PERMISSION: + case PERMISSIONSET: EnterOuterAlt(_localctx, 11); { - State = 2150; - secDecl(); + State = 2758; + _localctx.security = secDecl(); + Actions.ProcessMethodSecurityDeclaration(_localctx.security); } break; - case 12: + case T__72: + case T__73: EnterOuterAlt(_localctx, 12); { - State = 2151; - extSourceSpec(); + State = 2761; + _localctx.source = extSourceSpec(); + Actions.ProcessMethodSourceDirective(_localctx.source); } break; - case 13: + case T__26: EnterOuterAlt(_localctx, 13); { - State = 2152; - languageDecl(); + State = 2764; + _localctx.language = languageDecl(); + Actions.ProcessMethodLanguageDirective(_localctx.language); } break; - case 14: + case T__34: EnterOuterAlt(_localctx, 14); { - State = 2153; - customDescrInMethodBody(); + State = 2767; + _localctx.attribute = customDescrInMethodBody(); + Actions.ProcessMethodCustomAttribute(_localctx.attribute); } break; - case 15: + case T__31: + case PP_DEFINE: + case PP_UNDEF: + case PP_IFDEF: + case PP_IFNDEF: + case PP_ELSE: + case PP_ENDIF: + case PP_INCLUDE: EnterOuterAlt(_localctx, 15); { - State = 2154; + State = 2770; compControl(); } break; - case 16: + case EXPORT: EnterOuterAlt(_localctx, 16); { - State = 2155; - Match(EXPORT); - State = 2156; - Match(T__41); - State = 2157; - int32(); - State = 2158; - Match(T__42); + State = 2771; + exportDecl(); } break; - case 17: + case VTENTRY: EnterOuterAlt(_localctx, 17); { - State = 2160; - Match(EXPORT); - State = 2161; - Match(T__41); - State = 2162; - int32(); - State = 2163; - Match(T__42); - State = 2164; - Match(T__33); - State = 2165; - id(); + State = 2772; + vtentryDecl(); } break; - case 18: + case OVERRIDE: EnterOuterAlt(_localctx, 18); { - State = 2167; - Match(VTENTRY); - State = 2168; - int32(); - State = 2169; - Match(T__74); - State = 2170; - int32(); + State = 2773; + overrideDecl(); } break; - case 19: + case PARAM: EnterOuterAlt(_localctx, 19); { - State = 2172; + State = 2774; + parameterDecl(); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class LocalsDeclContext : ParserRuleContext { + public int InitialSyntaxErrorCount; + public IToken initialize; + public SigArgsContext arguments; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LOCALS() { return GetToken(CILParser.LOCALS, 0); } + [System.Diagnostics.DebuggerNonUserCode] public SigArgsContext sigArgs() { + return GetRuleContext(0); + } + public LocalsDeclContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_localsDecl; } } + } + + [RuleVersion(0)] + public LocalsDeclContext localsDecl() { + LocalsDeclContext _localctx = new LocalsDeclContext(Context, State); + EnterRule(_localctx, 252, RULE_localsDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 2777; + Match(LOCALS); + State = 2779; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==T__156) { + { + State = 2778; + _localctx.initialize = Match(T__156); + } + } + + State = 2781; + _localctx.arguments = sigArgs(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + Actions.EndLocalsDirective(_localctx, _localctx.InitialSyntaxErrorCount); + ExitRule(); + } + return _localctx; + } + + public partial class ExportDeclContext : ParserRuleContext { + public int InitialSyntaxErrorCount; + public Int32Context ordinal; + public IdContext alias; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EXPORT() { return GetToken(CILParser.EXPORT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { + return GetRuleContext(0); + } + public ExportDeclContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_exportDecl; } } + } + + [RuleVersion(0)] + public ExportDeclContext exportDecl() { + ExportDeclContext _localctx = new ExportDeclContext(Context, State); + EnterRule(_localctx, 254, RULE_exportDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 2783; + Match(EXPORT); + State = 2784; + Match(T__41); + State = 2785; + _localctx.ordinal = int32(); + State = 2786; + Match(T__42); + State = 2789; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + if (_la==T__33) { + { + State = 2787; + Match(T__33); + State = 2788; + _localctx.alias = id(); + } + } + + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + Actions.EndExportDirective(_localctx, _localctx.InitialSyntaxErrorCount); + ExitRule(); + } + return _localctx; + } + + public partial class VtentryDeclContext : ParserRuleContext { + public int InitialSyntaxErrorCount; + public Int32Context table; + public Int32Context slot; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VTENTRY() { return GetToken(CILParser.VTENTRY, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32(int i) { + return GetRuleContext(i); + } + public VtentryDeclContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_vtentryDecl; } } + } + + [RuleVersion(0)] + public VtentryDeclContext vtentryDecl() { + VtentryDeclContext _localctx = new VtentryDeclContext(Context, State); + EnterRule(_localctx, 256, RULE_vtentryDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + try { + EnterOuterAlt(_localctx, 1); + { + State = 2791; + Match(VTENTRY); + State = 2792; + _localctx.table = int32(); + State = 2793; + Match(T__74); + State = 2794; + _localctx.slot = int32(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + Actions.EndVTableEntryDirective(_localctx, _localctx.InitialSyntaxErrorCount); + ExitRule(); + } + return _localctx; + } + + public partial class OverrideDeclContext : ParserRuleContext { + public int InitialSyntaxErrorCount; + public TypeSpecContext owner; + public MethodNameContext name; + public CallConvContext convention; + public TypeContext returnType; + public GenArityContext arity; + public SigArgsContext arguments; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OVERRIDE() { return GetToken(CILParser.OVERRIDE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DCOLON() { return GetToken(CILParser.DCOLON, 0); } + [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public MethodNameContext methodName() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode METHOD() { return GetToken(CILParser.METHOD, 0); } + [System.Diagnostics.DebuggerNonUserCode] public CallConvContext callConv() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public GenArityContext genArity() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public SigArgsContext sigArgs() { + return GetRuleContext(0); + } + public OverrideDeclContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_overrideDecl; } } + } + + [RuleVersion(0)] + public OverrideDeclContext overrideDecl() { + OverrideDeclContext _localctx = new OverrideDeclContext(Context, State); + EnterRule(_localctx, 258, RULE_overrideDecl); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + try { + State = 2811; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,132,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); + { + State = 2796; Match(OVERRIDE); - State = 2173; - typeSpec(); - State = 2174; + State = 2797; + _localctx.owner = typeSpec(); + State = 2798; Match(DCOLON); - State = 2175; - methodName(); + State = 2799; + _localctx.name = methodName(); } break; - case 20: - EnterOuterAlt(_localctx, 20); + case 2: + EnterOuterAlt(_localctx, 2); { - State = 2177; + State = 2801; Match(OVERRIDE); - State = 2178; + State = 2802; Match(METHOD); - State = 2179; - callConv(); - State = 2180; - type(); - State = 2181; - typeSpec(); - State = 2182; + State = 2803; + _localctx.convention = callConv(); + State = 2804; + _localctx.returnType = type(); + State = 2805; + _localctx.owner = typeSpec(); + State = 2806; Match(DCOLON); - State = 2183; - methodName(); - State = 2184; - genArity(); - State = 2185; - sigArgs(); - } - break; - case 21: - EnterOuterAlt(_localctx, 21); - { - State = 2187; - scopeBlock(); + State = 2807; + _localctx.name = methodName(); + State = 2808; + _localctx.arity = genArity(); + State = 2809; + _localctx.arguments = sigArgs(); } break; - case 22: - EnterOuterAlt(_localctx, 22); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + Actions.EndOverrideDirective(_localctx, _localctx.InitialSyntaxErrorCount); + ExitRule(); + } + return _localctx; + } + + public partial class ParameterDeclContext : ParserRuleContext { + public int InitialSyntaxErrorCount; + public System.Collections.Immutable.ImmutableArray.Builder Attributes; + public Int32Context genericIndex; + public CustomAttrDeclContext attribute; + public DottedNameContext genericName; + public Int32Context constraintIndex; + public TypeSpecContext constraintType; + public DottedNameContext constraintName; + public Int32Context parameterIndex; + public InitOptContext initializer; + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAM() { return GetToken(CILParser.PARAM, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode TYPE() { return GetToken(CILParser.TYPE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public CustomAttrDeclContext[] customAttrDecl() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public CustomAttrDeclContext customAttrDecl(int i) { + return GetRuleContext(i); + } + [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CONSTRAINT() { return GetToken(CILParser.CONSTRAINT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public InitOptContext initOpt() { + return GetRuleContext(0); + } + public ParameterDeclContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_parameterDecl; } } + } + + [RuleVersion(0)] + public ParameterDeclContext parameterDecl() { + ParameterDeclContext _localctx = new ParameterDeclContext(Context, State); + EnterRule(_localctx, 260, RULE_parameterDecl); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Attributes = System.Collections.Immutable.ImmutableArray.CreateBuilder(); + + try { + int _alt; + State = 2878; + ErrorHandler.Sync(this); + switch ( Interpreter.AdaptivePredict(TokenStream,138,Context) ) { + case 1: + EnterOuterAlt(_localctx, 1); { - State = 2188; + State = 2813; Match(PARAM); - State = 2189; + State = 2814; Match(TYPE); - State = 2190; + State = 2815; Match(T__41); - State = 2191; - int32(); - State = 2192; + State = 2816; + _localctx.genericIndex = int32(); + State = 2817; Match(T__42); - State = 2196; + State = 2823; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,121,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,133,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 2193; - customAttrDecl(); + State = 2818; + _localctx.attribute = customAttrDecl(); + Actions.AddCustomAttributeApplication(_localctx.Attributes, _localctx.attribute); } } } - State = 2198; + State = 2825; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,121,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,133,Context); } } break; - case 23: - EnterOuterAlt(_localctx, 23); + case 2: + EnterOuterAlt(_localctx, 2); { - State = 2199; + State = 2826; Match(PARAM); - State = 2200; + State = 2827; Match(TYPE); - State = 2201; - dottedName(); - State = 2205; + State = 2828; + _localctx.genericName = dottedName(); + State = 2834; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,122,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,134,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 2202; - customAttrDecl(); + State = 2829; + _localctx.attribute = customAttrDecl(); + Actions.AddCustomAttributeApplication(_localctx.Attributes, _localctx.attribute); } } } - State = 2207; + State = 2836; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,122,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,134,Context); } } break; - case 24: - EnterOuterAlt(_localctx, 24); + case 3: + EnterOuterAlt(_localctx, 3); { - State = 2208; + State = 2837; Match(PARAM); - State = 2209; + State = 2838; Match(CONSTRAINT); - State = 2210; + State = 2839; Match(T__41); - State = 2211; - int32(); - State = 2212; + State = 2840; + _localctx.constraintIndex = int32(); + State = 2841; Match(T__42); - State = 2213; + State = 2842; Match(T__27); - State = 2214; - typeSpec(); - State = 2218; + State = 2843; + _localctx.constraintType = typeSpec(); + State = 2849; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,123,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,135,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 2215; - customAttrDecl(); + State = 2844; + _localctx.attribute = customAttrDecl(); + Actions.AddCustomAttributeApplication(_localctx.Attributes, _localctx.attribute); } } } - State = 2220; + State = 2851; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,123,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,135,Context); } } break; - case 25: - EnterOuterAlt(_localctx, 25); + case 4: + EnterOuterAlt(_localctx, 4); { - State = 2221; + State = 2852; Match(PARAM); - State = 2222; + State = 2853; Match(CONSTRAINT); - State = 2223; - dottedName(); - State = 2224; + State = 2854; + _localctx.constraintName = dottedName(); + State = 2855; Match(T__27); - State = 2225; - typeSpec(); - State = 2229; + State = 2856; + _localctx.constraintType = typeSpec(); + State = 2862; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,124,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,136,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 2226; - customAttrDecl(); + State = 2857; + _localctx.attribute = customAttrDecl(); + Actions.AddCustomAttributeApplication(_localctx.Attributes, _localctx.attribute); } } } - State = 2231; + State = 2864; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,124,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,136,Context); } } break; - case 26: - EnterOuterAlt(_localctx, 26); + case 5: + EnterOuterAlt(_localctx, 5); { - State = 2232; + State = 2865; Match(PARAM); - State = 2233; + State = 2866; Match(T__41); - State = 2234; - int32(); - State = 2235; + State = 2867; + _localctx.parameterIndex = int32(); + State = 2868; Match(T__42); - State = 2236; - initOpt(); - State = 2240; + State = 2869; + _localctx.initializer = initOpt(); + State = 2875; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,125,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,137,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 2237; - customAttrDecl(); + State = 2870; + _localctx.attribute = customAttrDecl(); + Actions.AddCustomAttributeApplication(_localctx.Attributes, _localctx.attribute); } } } - State = 2242; + State = 2877; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,125,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,137,Context); } } break; @@ -12957,12 +13604,17 @@ public MethodDeclContext methodDecl() { ErrorHandler.Recover(this, re); } finally { + Actions.EndParameterDirective( + _localctx, + _localctx.Attributes.ToImmutable(), + _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; } public partial class LabelDeclContext : ParserRuleContext { + public IdContext name; [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { return GetRuleContext(0); } @@ -12971,25 +13623,20 @@ public LabelDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_labelDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitLabelDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public LabelDeclContext labelDecl() { LabelDeclContext _localctx = new LabelDeclContext(Context, State); - EnterRule(_localctx, 272, RULE_labelDecl); + EnterRule(_localctx, 262, RULE_labelDecl); try { EnterOuterAlt(_localctx, 1); { - State = 2245; - id(); - State = 2246; + State = 2880; + _localctx.name = id(); + State = 2881; Match(T__74); + Actions.DefineLabel((_localctx.name!=null?(_localctx.name.Start):null)); } } catch (RecognitionException re) { @@ -13004,6 +13651,11 @@ public LabelDeclContext labelDecl() { } public partial class CustomDescrInMethodBodyContext : ParserRuleContext { + public CILParser.CustomAttributeDeclarationValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public CustomDescrContext directAttribute; + public CustomDescrWithOwnerContext ownedAttribute; [System.Diagnostics.DebuggerNonUserCode] public CustomDescrContext customDescr() { return GetRuleContext(0); } @@ -13015,34 +13667,34 @@ public CustomDescrInMethodBodyContext(ParserRuleContext parent, int invokingStat { } public override int RuleIndex { get { return RULE_customDescrInMethodBody; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomDescrInMethodBody(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomDescrInMethodBodyContext customDescrInMethodBody() { CustomDescrInMethodBodyContext _localctx = new CustomDescrInMethodBodyContext(Context, State); - EnterRule(_localctx, 274, RULE_customDescrInMethodBody); + EnterRule(_localctx, 264, RULE_customDescrInMethodBody); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDeclarationValue.Error; + try { - State = 2250; + State = 2890; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,127,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,139,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2248; - customDescr(); + State = 2884; + _localctx.directAttribute = customDescr(); + _localctx.Value = Actions.CreateCustomAttributeDeclaration(_localctx.directAttribute.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2249; - customDescrWithOwner(); + State = 2887; + _localctx.ownedAttribute = customDescrWithOwner(); + _localctx.Value = Actions.CreateCustomAttributeDeclaration(_localctx.ownedAttribute.Value); } break; } @@ -13053,6 +13705,11 @@ public CustomDescrInMethodBodyContext customDescrInMethodBody() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; @@ -13067,26 +13724,21 @@ public ScopeBlockContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_scopeBlock; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitScopeBlock(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ScopeBlockContext scopeBlock() { ScopeBlockContext _localctx = new ScopeBlockContext(Context, State); - EnterRule(_localctx, 276, RULE_scopeBlock); + EnterRule(_localctx, 266, RULE_scopeBlock); + Actions.BeginScope(_localctx); try { EnterOuterAlt(_localctx, 1); { - State = 2252; + State = 2892; Match(T__16); - State = 2253; + State = 2893; methodDecls(); - State = 2254; + State = 2894; Match(T__17); } } @@ -13096,12 +13748,16 @@ public ScopeBlockContext scopeBlock() { ErrorHandler.Recover(this, re); } finally { + Actions.EndScope(_localctx); ExitRule(); } return _localctx; } public partial class SehBlockContext : ParserRuleContext { + public int InitialSyntaxErrorCount; + public TryBlockContext tryRange; + public SehClausesContext clauses; [System.Diagnostics.DebuggerNonUserCode] public TryBlockContext tryBlock() { return GetRuleContext(0); } @@ -13113,25 +13769,20 @@ public SehBlockContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_sehBlock; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSehBlock(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SehBlockContext sehBlock() { SehBlockContext _localctx = new SehBlockContext(Context, State); - EnterRule(_localctx, 278, RULE_sehBlock); + EnterRule(_localctx, 268, RULE_sehBlock); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; try { EnterOuterAlt(_localctx, 1); { - State = 2256; - tryBlock(); - State = 2257; - sehClauses(); + State = 2896; + _localctx.tryRange = tryBlock(); + State = 2897; + _localctx.clauses = sehClauses(); } } catch (RecognitionException re) { @@ -13140,12 +13791,16 @@ public SehBlockContext sehBlock() { ErrorHandler.Recover(this, re); } finally { + Actions.EndExceptionBlock(_localctx, _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; } public partial class SehClausesContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public SehClauseContext clause; [System.Diagnostics.DebuggerNonUserCode] public SehClauseContext[] sehClause() { return GetRuleContexts(); } @@ -13157,33 +13812,29 @@ public SehClausesContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_sehClauses; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSehClauses(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SehClausesContext sehClauses() { SehClausesContext _localctx = new SehClausesContext(Context, State); - EnterRule(_localctx, 280, RULE_sehClauses); + EnterRule(_localctx, 270, RULE_sehClauses); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2260; + State = 2902; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { - State = 2259; - sehClause(); + State = 2899; + _localctx.clause = sehClause(); + _localctx.Builder.Add(_localctx.clause.Value); } } - State = 2262; + State = 2904; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ( ((((_la - 160)) & ~0x3f) == 0 && ((1L << (_la - 160)) & 15L) != 0) ); @@ -13195,12 +13846,19 @@ public SehClausesContext sehClauses() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class TryBlockContext : ParserRuleContext { + public CILParser.ExceptionRangeValue Value; + public ScopeBlockContext body; + public IdContext startLabel; + public IdContext endLabel; + public Int32Context startOffset; + public Int32Context endOffset; [System.Diagnostics.DebuggerNonUserCode] public ScopeBlockContext scopeBlock() { return GetRuleContext(0); } @@ -13221,55 +13879,53 @@ public TryBlockContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_tryBlock; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTryBlock(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TryBlockContext tryBlock() { TryBlockContext _localctx = new TryBlockContext(Context, State); - EnterRule(_localctx, 282, RULE_tryBlock); + EnterRule(_localctx, 272, RULE_tryBlock); + _localctx.Value = CILParser.ExceptionRangeValue.Invalid; try { - State = 2276; + State = 2922; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,129,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,141,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2264; + State = 2906; Match(T__157); - State = 2265; - scopeBlock(); + State = 2907; + _localctx.body = scopeBlock(); + _localctx.Value = Actions.CreateScopeExceptionRange(_localctx.body); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2266; + State = 2910; Match(T__157); - State = 2267; - id(); - State = 2268; + State = 2911; + _localctx.startLabel = id(); + State = 2912; Match(T__158); - State = 2269; - id(); + State = 2913; + _localctx.endLabel = id(); + _localctx.Value = Actions.CreateLabelExceptionRange((_localctx.startLabel!=null?(_localctx.startLabel.Start):null), (_localctx.endLabel!=null?(_localctx.endLabel.Start):null)); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2271; + State = 2916; Match(T__157); - State = 2272; - int32(); - State = 2273; + State = 2917; + _localctx.startOffset = int32(); + State = 2918; Match(T__158); - State = 2274; - int32(); + State = 2919; + _localctx.endOffset = int32(); + _localctx.Value = Actions.CreateOffsetExceptionRange((_localctx.startOffset!=null?(_localctx.startOffset.Start):null), (_localctx.endOffset!=null?(_localctx.endOffset.Start):null)); } break; } @@ -13286,6 +13942,10 @@ public TryBlockContext tryBlock() { } public partial class SehClauseContext : ParserRuleContext { + public CILParser.ExceptionClauseValue Value; + public CatchClauseContext caught; + public HandlerBlockContext handler; + public FilterClauseContext filtered; [System.Diagnostics.DebuggerNonUserCode] public CatchClauseContext catchClause() { return GetRuleContext(0); } @@ -13306,56 +13966,55 @@ public SehClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_sehClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSehClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SehClauseContext sehClause() { SehClauseContext _localctx = new SehClauseContext(Context, State); - EnterRule(_localctx, 284, RULE_sehClause); + EnterRule(_localctx, 274, RULE_sehClause); + _localctx.Value = CILParser.ExceptionClauseValue.Invalid; try { - State = 2290; + State = 2940; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__160: EnterOuterAlt(_localctx, 1); { - State = 2278; - catchClause(); - State = 2279; - handlerBlock(); + State = 2924; + _localctx.caught = catchClause(); + State = 2925; + _localctx.handler = handlerBlock(); + _localctx.Value = Actions.CreateCatchExceptionClause(_localctx.caught.Value, _localctx.handler.Value); } break; case T__159: EnterOuterAlt(_localctx, 2); { - State = 2281; - filterClause(); - State = 2282; - handlerBlock(); + State = 2928; + _localctx.filtered = filterClause(); + State = 2929; + _localctx.handler = handlerBlock(); + _localctx.Value = Actions.CreateFilterExceptionClause(_localctx.filtered.Value, _localctx.handler.Value); } break; case T__161: EnterOuterAlt(_localctx, 3); { - State = 2284; + State = 2932; finallyClause(); - State = 2285; - handlerBlock(); + State = 2933; + _localctx.handler = handlerBlock(); + _localctx.Value = Actions.CreateFinallyExceptionClause(_localctx.handler.Value); } break; case T__162: EnterOuterAlt(_localctx, 4); { - State = 2287; + State = 2936; faultClause(); - State = 2288; - handlerBlock(); + State = 2937; + _localctx.handler = handlerBlock(); + _localctx.Value = Actions.CreateFaultExceptionClause(_localctx.handler.Value); } break; default: @@ -13374,6 +14033,10 @@ public SehClauseContext sehClause() { } public partial class FilterClauseContext : ParserRuleContext { + public CILParser.ExceptionFilterValue Value; + public ScopeBlockContext body; + public IdContext label; + public Int32Context offset; [System.Diagnostics.DebuggerNonUserCode] public ScopeBlockContext scopeBlock() { return GetRuleContext(0); } @@ -13388,47 +14051,45 @@ public FilterClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_filterClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFilterClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FilterClauseContext filterClause() { FilterClauseContext _localctx = new FilterClauseContext(Context, State); - EnterRule(_localctx, 286, RULE_filterClause); + EnterRule(_localctx, 276, RULE_filterClause); + _localctx.Value = CILParser.ExceptionFilterValue.Invalid; try { - State = 2298; + State = 2954; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,131,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,143,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2292; + State = 2942; Match(T__159); - State = 2293; - scopeBlock(); + State = 2943; + _localctx.body = scopeBlock(); + _localctx.Value = Actions.CreateScopeFilter(_localctx.body); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2294; + State = 2946; Match(T__159); - State = 2295; - id(); + State = 2947; + _localctx.label = id(); + _localctx.Value = Actions.CreateLabelFilter((_localctx.label!=null?(_localctx.label.Start):null)); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2296; + State = 2950; Match(T__159); - State = 2297; - int32(); + State = 2951; + _localctx.offset = int32(); + _localctx.Value = Actions.CreateOffsetFilter((_localctx.offset!=null?(_localctx.offset.Start):null)); } break; } @@ -13445,6 +14106,9 @@ public FilterClauseContext filterClause() { } public partial class CatchClauseContext : ParserRuleContext { + public CILParser.CatchTypeValue Value; + public int InitialSyntaxErrorCount; + public TypeSpecContext catchType; [System.Diagnostics.DebuggerNonUserCode] public TypeSpecContext typeSpec() { return GetRuleContext(0); } @@ -13453,25 +14117,23 @@ public CatchClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_catchClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCatchClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CatchClauseContext catchClause() { CatchClauseContext _localctx = new CatchClauseContext(Context, State); - EnterRule(_localctx, 288, RULE_catchClause); + EnterRule(_localctx, 278, RULE_catchClause); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CatchTypeValue.Invalid; + try { EnterOuterAlt(_localctx, 1); { - State = 2300; + State = 2956; Match(T__160); - State = 2301; - typeSpec(); + State = 2957; + _localctx.catchType = typeSpec(); } } catch (RecognitionException re) { @@ -13480,6 +14142,7 @@ public CatchClauseContext catchClause() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.EndCatchClause(_localctx, _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; @@ -13491,22 +14154,16 @@ public FinallyClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_finallyClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFinallyClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FinallyClauseContext finallyClause() { FinallyClauseContext _localctx = new FinallyClauseContext(Context, State); - EnterRule(_localctx, 290, RULE_finallyClause); + EnterRule(_localctx, 280, RULE_finallyClause); try { EnterOuterAlt(_localctx, 1); { - State = 2303; + State = 2959; Match(T__161); } } @@ -13527,22 +14184,16 @@ public FaultClauseContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_faultClause; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFaultClause(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FaultClauseContext faultClause() { FaultClauseContext _localctx = new FaultClauseContext(Context, State); - EnterRule(_localctx, 292, RULE_faultClause); + EnterRule(_localctx, 282, RULE_faultClause); try { EnterOuterAlt(_localctx, 1); { - State = 2305; + State = 2961; Match(T__162); } } @@ -13558,6 +14209,12 @@ public FaultClauseContext faultClause() { } public partial class HandlerBlockContext : ParserRuleContext { + public CILParser.ExceptionRangeValue Value; + public ScopeBlockContext body; + public IdContext startLabel; + public IdContext endLabel; + public Int32Context startOffset; + public Int32Context endOffset; [System.Diagnostics.DebuggerNonUserCode] public ScopeBlockContext scopeBlock() { return GetRuleContext(0); } @@ -13578,53 +14235,51 @@ public HandlerBlockContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_handlerBlock; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitHandlerBlock(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public HandlerBlockContext handlerBlock() { HandlerBlockContext _localctx = new HandlerBlockContext(Context, State); - EnterRule(_localctx, 294, RULE_handlerBlock); + EnterRule(_localctx, 284, RULE_handlerBlock); + _localctx.Value = CILParser.ExceptionRangeValue.Invalid; try { - State = 2318; + State = 2978; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,132,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,144,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2307; - scopeBlock(); + State = 2963; + _localctx.body = scopeBlock(); + _localctx.Value = Actions.CreateScopeExceptionRange(_localctx.body); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2308; + State = 2966; Match(T__163); - State = 2309; - id(); - State = 2310; + State = 2967; + _localctx.startLabel = id(); + State = 2968; Match(T__158); - State = 2311; - id(); + State = 2969; + _localctx.endLabel = id(); + _localctx.Value = Actions.CreateLabelExceptionRange((_localctx.startLabel!=null?(_localctx.startLabel.Start):null), (_localctx.endLabel!=null?(_localctx.endLabel.Start):null)); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2313; + State = 2972; Match(T__163); - State = 2314; - int32(); - State = 2315; + State = 2973; + _localctx.startOffset = int32(); + State = 2974; Match(T__158); - State = 2316; - int32(); + State = 2975; + _localctx.endOffset = int32(); + _localctx.Value = Actions.CreateOffsetExceptionRange((_localctx.startOffset!=null?(_localctx.startOffset.Start):null), (_localctx.endOffset!=null?(_localctx.endOffset.Start):null)); } break; } @@ -13641,6 +14296,9 @@ public HandlerBlockContext handlerBlock() { } public partial class DataDeclContext : ParserRuleContext { + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public CILParser.DataDeclarationBuilder Builder; [System.Diagnostics.DebuggerNonUserCode] public DdHeadContext ddHead() { return GetRuleContext(0); } @@ -13652,25 +14310,23 @@ public DataDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_dataDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDataDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public DataDeclContext dataDecl() { DataDeclContext _localctx = new DataDeclContext(Context, State); - EnterRule(_localctx, 296, RULE_dataDecl); + EnterRule(_localctx, 286, RULE_dataDecl); + + _localctx.Builder = Actions.CreateDataDeclaration(_localctx); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + try { EnterOuterAlt(_localctx, 1); { - State = 2320; - ddHead(); - State = 2321; - ddBody(); + State = 2980; + ddHead(_localctx.Builder); + State = 2981; + ddBody(_localctx.Builder); } } catch (RecognitionException re) { @@ -13679,59 +14335,61 @@ public DataDeclContext dataDecl() { ErrorHandler.Recover(this, re); } finally { + Actions.EndDataDeclaration(_localctx, _localctx.Builder, _localctx.InitialSyntaxErrorCount); ExitRule(); } return _localctx; } public partial class DdHeadContext : ParserRuleContext { + public CILParser.DataDeclarationBuilder Builder; + public TlsContext section; + public IdContext name; [System.Diagnostics.DebuggerNonUserCode] public TlsContext tls() { return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { return GetRuleContext(0); } - public DdHeadContext(ParserRuleContext parent, int invokingState) + public DdHeadContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public DdHeadContext(ParserRuleContext parent, int invokingState, CILParser.DataDeclarationBuilder Builder) : base(parent, invokingState) { + this.Builder = Builder; } public override int RuleIndex { get { return RULE_ddHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDdHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public DdHeadContext ddHead() { - DdHeadContext _localctx = new DdHeadContext(Context, State); - EnterRule(_localctx, 298, RULE_ddHead); + public DdHeadContext ddHead(CILParser.DataDeclarationBuilder Builder) { + DdHeadContext _localctx = new DdHeadContext(Context, State, Builder); + EnterRule(_localctx, 288, RULE_ddHead); try { - State = 2330; + State = 2993; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,133,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,145,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2323; + State = 2983; Match(T__164); - State = 2324; - tls(); - State = 2325; - id(); - State = 2326; + State = 2984; + _localctx.section = tls(); + State = 2985; + _localctx.name = id(); + State = 2986; Match(T__35); + Actions.SetDataDeclarationHeader(_localctx.Builder, _localctx.section.Value, (_localctx.name!=null?(_localctx.name.Start):null)); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2328; + State = 2989; Match(T__164); - State = 2329; - tls(); + State = 2990; + _localctx.section = tls(); + Actions.SetAnonymousDataDeclarationHeader(_localctx.Builder, _localctx.section.Value); } break; } @@ -13748,27 +14406,23 @@ public DdHeadContext ddHead() { } public partial class TlsContext : ParserRuleContext { + public byte Value; public TlsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_tls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitTls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public TlsContext tls() { TlsContext _localctx = new TlsContext(Context, State); - EnterRule(_localctx, 300, RULE_tls); + EnterRule(_localctx, 290, RULE_tls); + _localctx.Value = Actions.GetMappedDataSection(); try { - State = 2335; + State = 3000; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,134,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,146,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { @@ -13777,15 +14431,17 @@ public TlsContext tls() { case 2: EnterOuterAlt(_localctx, 2); { - State = 2333; + State = 2996; Match(T__165); + _localctx.Value = Actions.GetTlsDataSection(); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2334; + State = 2998; Match(T__1); + _localctx.Value = Actions.GetCilDataSection(); } break; } @@ -13802,6 +14458,7 @@ public TlsContext tls() { } public partial class DdBodyContext : ParserRuleContext { + public CILParser.DataDeclarationBuilder Builder; [System.Diagnostics.DebuggerNonUserCode] public DdItemListContext ddItemList() { return GetRuleContext(0); } @@ -13811,36 +14468,32 @@ [System.Diagnostics.DebuggerNonUserCode] public DdItemContext[] ddItem() { [System.Diagnostics.DebuggerNonUserCode] public DdItemContext ddItem(int i) { return GetRuleContext(i); } - public DdBodyContext(ParserRuleContext parent, int invokingState) + public DdBodyContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public DdBodyContext(ParserRuleContext parent, int invokingState, CILParser.DataDeclarationBuilder Builder) : base(parent, invokingState) { + this.Builder = Builder; } public override int RuleIndex { get { return RULE_ddBody; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDdBody(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public DdBodyContext ddBody() { - DdBodyContext _localctx = new DdBodyContext(Context, State); - EnterRule(_localctx, 302, RULE_ddBody); + public DdBodyContext ddBody(CILParser.DataDeclarationBuilder Builder) { + DdBodyContext _localctx = new DdBodyContext(Context, State, Builder); + EnterRule(_localctx, 292, RULE_ddBody); int _la; try { - State = 2346; + State = 3011; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__16: EnterOuterAlt(_localctx, 1); { - State = 2337; + State = 3002; Match(T__16); - State = 2338; - ddItemList(); - State = 2339; + State = 3003; + ddItemList(_localctx.Builder); + State = 3004; Match(T__17); } break; @@ -13855,17 +14508,17 @@ public DdBodyContext ddBody() { case REF: EnterOuterAlt(_localctx, 2); { - State = 2342; + State = 3007; ErrorHandler.Sync(this); _la = TokenStream.LA(1); do { { { - State = 2341; - ddItem(); + State = 3006; + ddItem(_localctx.Builder); } } - State = 2344; + State = 3009; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } while ( _la==T__83 || ((((_la - 181)) & ~0x3f) == 0 && ((1L << (_la - 181)) & 505L) != 0) || _la==REF ); @@ -13887,53 +14540,50 @@ public DdBodyContext ddBody() { } public partial class DdItemListContext : ParserRuleContext { + public CILParser.DataDeclarationBuilder Builder; [System.Diagnostics.DebuggerNonUserCode] public DdItemContext[] ddItem() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public DdItemContext ddItem(int i) { return GetRuleContext(i); } - public DdItemListContext(ParserRuleContext parent, int invokingState) + public DdItemListContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public DdItemListContext(ParserRuleContext parent, int invokingState, CILParser.DataDeclarationBuilder Builder) : base(parent, invokingState) { + this.Builder = Builder; } public override int RuleIndex { get { return RULE_ddItemList; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDdItemList(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public DdItemListContext ddItemList() { - DdItemListContext _localctx = new DdItemListContext(Context, State); - EnterRule(_localctx, 304, RULE_ddItemList); + public DdItemListContext ddItemList(CILParser.DataDeclarationBuilder Builder) { + DdItemListContext _localctx = new DdItemListContext(Context, State, Builder); + EnterRule(_localctx, 294, RULE_ddItemList); try { int _alt; EnterOuterAlt(_localctx, 1); { - State = 2353; + State = 3018; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,137,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,149,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { - State = 2348; - ddItem(); - State = 2349; + State = 3013; + ddItem(_localctx.Builder); + State = 3014; Match(T__27); } } } - State = 2355; + State = 3020; ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,137,Context); + _alt = Interpreter.AdaptivePredict(TokenStream,149,Context); } - State = 2356; - ddItem(); + State = 3021; + ddItem(_localctx.Builder); } } catch (RecognitionException re) { @@ -13948,6 +14598,8 @@ public DdItemListContext ddItemList() { } public partial class DdItemCountContext : ParserRuleContext { + public int Value; + public Int32Context count; [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } @@ -13956,20 +14608,15 @@ public DdItemCountContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_ddItemCount; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDdItemCount(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public DdItemCountContext ddItemCount() { DdItemCountContext _localctx = new DdItemCountContext(Context, State); - EnterRule(_localctx, 306, RULE_ddItemCount); + EnterRule(_localctx, 296, RULE_ddItemCount); + _localctx.Value = 1; try { - State = 2363; + State = 3029; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__0: @@ -14073,12 +14720,13 @@ public DdItemCountContext ddItemCount() { case T__41: EnterOuterAlt(_localctx, 2); { - State = 2359; + State = 3024; Match(T__41); - State = 2360; - int32(); - State = 2361; + State = 3025; + _localctx.count = int32(); + State = 3026; Match(T__42); + _localctx.Value = Actions.ParseDataItemCount((_localctx.count!=null?(_localctx.count.Start):null)); } break; default: @@ -14097,6 +14745,15 @@ public DdItemCountContext ddItemCount() { } public partial class DdItemContext : ParserRuleContext { + public CILParser.DataDeclarationBuilder Builder; + public CompQstringContext stringValue; + public IdContext target; + public BytesContext byteValue; + public IToken kind; + public Float64Context floatingValue; + public DdItemCountContext count; + public Int64Context int64Value; + public Int32Context integerValue; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CHAR() { return GetToken(CILParser.CHAR, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PTR() { return GetToken(CILParser.PTR, 0); } [System.Diagnostics.DebuggerNonUserCode] public CompQstringContext compQstring() { @@ -14109,237 +14766,176 @@ [System.Diagnostics.DebuggerNonUserCode] public IdContext id() { [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT32() { return GetToken(CILParser.FLOAT32, 0); } [System.Diagnostics.DebuggerNonUserCode] public Float64Context float64() { return GetRuleContext(0); } [System.Diagnostics.DebuggerNonUserCode] public DdItemCountContext ddItemCount() { return GetRuleContext(0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT32() { return GetToken(CILParser.FLOAT32, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT64_() { return GetToken(CILParser.FLOAT64_, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT64_() { return GetToken(CILParser.INT64_, 0); } [System.Diagnostics.DebuggerNonUserCode] public Int64Context int64() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT32_() { return GetToken(CILParser.INT32_, 0); } [System.Diagnostics.DebuggerNonUserCode] public Int32Context int32() { return GetRuleContext(0); } + [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT32_() { return GetToken(CILParser.INT32_, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT16() { return GetToken(CILParser.INT16, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT8() { return GetToken(CILParser.INT8, 0); } - public DdItemContext(ParserRuleContext parent, int invokingState) + public DdItemContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } + public DdItemContext(ParserRuleContext parent, int invokingState, CILParser.DataDeclarationBuilder Builder) : base(parent, invokingState) { + this.Builder = Builder; } public override int RuleIndex { get { return RULE_ddItem; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitDdItem(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] - public DdItemContext ddItem() { - DdItemContext _localctx = new DdItemContext(Context, State); - EnterRule(_localctx, 308, RULE_ddItem); + public DdItemContext ddItem(CILParser.DataDeclarationBuilder Builder) { + DdItemContext _localctx = new DdItemContext(Context, State, Builder); + EnterRule(_localctx, 298, RULE_ddItem); + int _la; try { - State = 2431; + State = 3079; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,139,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,151,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2365; + State = 3031; Match(CHAR); - State = 2366; + State = 3032; Match(PTR); - State = 2367; + State = 3033; Match(T__29); - State = 2368; - compQstring(); - State = 2369; + State = 3034; + _localctx.stringValue = compQstring(); + State = 3035; Match(T__30); + Actions.AddDataString(_localctx.Builder, _localctx.stringValue.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2371; - Match(REF); - State = 2372; - Match(T__29); - State = 2373; - id(); - State = 2374; - Match(T__30); - } - break; - case 3: - EnterOuterAlt(_localctx, 3); - { - State = 2376; + State = 3038; Match(REF); - State = 2377; - id(); - } - break; - case 4: - EnterOuterAlt(_localctx, 4); - { - State = 2378; - Match(T__83); - State = 2379; - Match(T__29); - State = 2380; - bytes(); - State = 2381; - Match(T__30); - } - break; - case 5: - EnterOuterAlt(_localctx, 5); - { - State = 2383; - Match(FLOAT32); - State = 2384; - Match(T__29); - State = 2385; - float64(); - State = 2386; - Match(T__30); - State = 2387; - ddItemCount(); - } - break; - case 6: - EnterOuterAlt(_localctx, 6); - { - State = 2389; - Match(FLOAT64_); - State = 2390; - Match(T__29); - State = 2391; - float64(); - State = 2392; - Match(T__30); - State = 2393; - ddItemCount(); - } - break; - case 7: - EnterOuterAlt(_localctx, 7); - { - State = 2395; - Match(INT64_); - State = 2396; + State = 3039; Match(T__29); - State = 2397; - int64(); - State = 2398; + State = 3040; + _localctx.target = id(); + State = 3041; Match(T__30); - State = 2399; - ddItemCount(); + Actions.AddDataReference(_localctx.Builder, (_localctx.target!=null?(_localctx.target.Start):null)); } break; - case 8: - EnterOuterAlt(_localctx, 8); + case 3: + EnterOuterAlt(_localctx, 3); { - State = 2401; - Match(INT32_); - State = 2402; - Match(T__29); - State = 2403; - int32(); - State = 2404; - Match(T__30); - State = 2405; - ddItemCount(); + State = 3044; + Match(REF); + State = 3045; + _localctx.target = id(); + Actions.AddDataReference(_localctx.Builder, (_localctx.target!=null?(_localctx.target.Start):null)); } break; - case 9: - EnterOuterAlt(_localctx, 9); + case 4: + EnterOuterAlt(_localctx, 4); { - State = 2407; - Match(INT16); - State = 2408; + State = 3048; + Match(T__83); + State = 3049; Match(T__29); - State = 2409; - int32(); - State = 2410; + State = 3050; + _localctx.byteValue = bytes(); + State = 3051; Match(T__30); - State = 2411; - ddItemCount(); + Actions.AddDataBytes(_localctx.Builder, _localctx.byteValue.Value); } break; - case 10: - EnterOuterAlt(_localctx, 10); + case 5: + EnterOuterAlt(_localctx, 5); { - State = 2413; - Match(INT8); - State = 2414; + State = 3054; + _localctx.kind = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(_la==FLOAT32 || _la==FLOAT64_) ) { + _localctx.kind = ErrorHandler.RecoverInline(this); + } + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 3055; Match(T__29); - State = 2415; - int32(); - State = 2416; + State = 3056; + _localctx.floatingValue = float64(); + State = 3057; Match(T__30); - State = 2417; - ddItemCount(); + State = 3058; + _localctx.count = ddItemCount(); + Actions.AddFloatingPointData(_localctx.Builder, _localctx.kind, _localctx.floatingValue.Value, _localctx.count.Value); } break; - case 11: - EnterOuterAlt(_localctx, 11); + case 6: + EnterOuterAlt(_localctx, 6); { - State = 2419; - Match(FLOAT32); - State = 2420; - ddItemCount(); + State = 3061; + _localctx.kind = Match(INT64_); + State = 3062; + Match(T__29); + State = 3063; + _localctx.int64Value = int64(); + State = 3064; + Match(T__30); + State = 3065; + _localctx.count = ddItemCount(); + Actions.AddInt64Data(_localctx.Builder, _localctx.kind, (_localctx.int64Value!=null?(_localctx.int64Value.Start):null), _localctx.count.Value); } break; - case 12: - EnterOuterAlt(_localctx, 12); + case 7: + EnterOuterAlt(_localctx, 7); { - State = 2421; - Match(FLOAT64_); - State = 2422; - ddItemCount(); + State = 3068; + _localctx.kind = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(((((_la - 184)) & ~0x3f) == 0 && ((1L << (_la - 184)) & 7L) != 0)) ) { + _localctx.kind = ErrorHandler.RecoverInline(this); } - break; - case 13: - EnterOuterAlt(_localctx, 13); - { - State = 2423; - Match(INT64_); - State = 2424; - ddItemCount(); + else { + ErrorHandler.ReportMatch(this); + Consume(); } - break; - case 14: - EnterOuterAlt(_localctx, 14); - { - State = 2425; - Match(INT32_); - State = 2426; - ddItemCount(); + State = 3069; + Match(T__29); + State = 3070; + _localctx.integerValue = int32(); + State = 3071; + Match(T__30); + State = 3072; + _localctx.count = ddItemCount(); + Actions.AddIntegerData(_localctx.Builder, _localctx.kind, (_localctx.integerValue!=null?(_localctx.integerValue.Start):null), _localctx.count.Value); } break; - case 15: - EnterOuterAlt(_localctx, 15); + case 8: + EnterOuterAlt(_localctx, 8); { - State = 2427; - Match(INT16); - State = 2428; - ddItemCount(); + State = 3075; + _localctx.kind = TokenStream.LT(1); + _la = TokenStream.LA(1); + if ( !(((((_la - 184)) & ~0x3f) == 0 && ((1L << (_la - 184)) & 63L) != 0)) ) { + _localctx.kind = ErrorHandler.RecoverInline(this); } - break; - case 16: - EnterOuterAlt(_localctx, 16); - { - State = 2429; - Match(INT8); - State = 2430; - ddItemCount(); + else { + ErrorHandler.ReportMatch(this); + Consume(); + } + State = 3076; + _localctx.count = ddItemCount(); + Actions.AddZeroData(_localctx.Builder, _localctx.kind, _localctx.count.Value); } break; } @@ -14356,6 +14952,32 @@ public DdItemContext ddItem() { } public partial class FieldSerInitContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public Float64Context float32Value; + public Float64Context float64Value; + public Int32Context float32Bits; + public Int64Context float64Bits; + public IToken int64Type; + public Int64Context int64Value; + public IToken int32Type; + public Int32Context int32Value; + public IToken int16Type; + public Int32Context int16Value; + public IToken int8Type; + public Int32Context int8Value; + public IToken uint64Type; + public Int64Context uint64Value; + public IToken uint32Type; + public Int32Context uint32Value; + public IToken uint16Type; + public Int32Context uint16Value; + public IToken uint8Type; + public Int32Context uint8Value; + public IToken charType; + public Int32Context charValue; + public IToken boolType; + public TruefalseContext boolValue; + public BytesContext byteArrayValue; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT32() { return GetToken(CILParser.FLOAT32, 0); } [System.Diagnostics.DebuggerNonUserCode] public Float64Context float64() { return GetRuleContext(0); @@ -14388,215 +15010,224 @@ public FieldSerInitContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_fieldSerInit; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFieldSerInit(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FieldSerInitContext fieldSerInit() { FieldSerInitContext _localctx = new FieldSerInitContext(Context, State); - EnterRule(_localctx, 310, RULE_fieldSerInit); + EnterRule(_localctx, 300, RULE_fieldSerInit); try { - State = 2508; + State = 3171; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,140,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,152,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2433; + State = 3081; Match(FLOAT32); - State = 2434; + State = 3082; Match(T__29); - State = 2435; - float64(); - State = 2436; + State = 3083; + _localctx.float32Value = float64(); + State = 3084; Match(T__30); + _localctx.Value = Actions.CreateFloat32SerializedInitializer(_localctx.float32Value, _localctx.float32Value.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2438; + State = 3087; Match(FLOAT64_); - State = 2439; + State = 3088; Match(T__29); - State = 2440; - float64(); - State = 2441; + State = 3089; + _localctx.float64Value = float64(); + State = 3090; Match(T__30); + _localctx.Value = Actions.CreateFloat64SerializedInitializer(_localctx.float64Value, _localctx.float64Value.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2443; + State = 3093; Match(FLOAT32); - State = 2444; + State = 3094; Match(T__29); - State = 2445; - int32(); - State = 2446; + State = 3095; + _localctx.float32Bits = int32(); + State = 3096; Match(T__30); + _localctx.Value = Actions.CreateFloat32BitsSerializedInitializer((_localctx.float32Bits!=null?(_localctx.float32Bits.Start):null)); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 2448; + State = 3099; Match(FLOAT64_); - State = 2449; + State = 3100; Match(T__29); - State = 2450; - int64(); - State = 2451; + State = 3101; + _localctx.float64Bits = int64(); + State = 3102; Match(T__30); + _localctx.Value = Actions.CreateFloat64BitsSerializedInitializer((_localctx.float64Bits!=null?(_localctx.float64Bits.Start):null)); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 2453; - Match(INT64_); - State = 2454; + State = 3105; + _localctx.int64Type = Match(INT64_); + State = 3106; Match(T__29); - State = 2455; - int64(); - State = 2456; + State = 3107; + _localctx.int64Value = int64(); + State = 3108; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.int64Type, (_localctx.int64Value!=null?(_localctx.int64Value.Start):null)); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 2458; - Match(INT32_); - State = 2459; + State = 3111; + _localctx.int32Type = Match(INT32_); + State = 3112; Match(T__29); - State = 2460; - int32(); - State = 2461; + State = 3113; + _localctx.int32Value = int32(); + State = 3114; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.int32Type, (_localctx.int32Value!=null?(_localctx.int32Value.Start):null)); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 2463; - Match(INT16); - State = 2464; + State = 3117; + _localctx.int16Type = Match(INT16); + State = 3118; Match(T__29); - State = 2465; - int32(); - State = 2466; + State = 3119; + _localctx.int16Value = int32(); + State = 3120; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.int16Type, (_localctx.int16Value!=null?(_localctx.int16Value.Start):null)); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 2468; - Match(INT8); - State = 2469; + State = 3123; + _localctx.int8Type = Match(INT8); + State = 3124; Match(T__29); - State = 2470; - int32(); - State = 2471; + State = 3125; + _localctx.int8Value = int32(); + State = 3126; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.int8Type, (_localctx.int8Value!=null?(_localctx.int8Value.Start):null)); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 2473; - Match(UINT64); - State = 2474; + State = 3129; + _localctx.uint64Type = Match(UINT64); + State = 3130; Match(T__29); - State = 2475; - int64(); - State = 2476; + State = 3131; + _localctx.uint64Value = int64(); + State = 3132; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.uint64Type, (_localctx.uint64Value!=null?(_localctx.uint64Value.Start):null)); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 2478; - Match(UINT32); - State = 2479; + State = 3135; + _localctx.uint32Type = Match(UINT32); + State = 3136; Match(T__29); - State = 2480; - int32(); - State = 2481; + State = 3137; + _localctx.uint32Value = int32(); + State = 3138; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.uint32Type, (_localctx.uint32Value!=null?(_localctx.uint32Value.Start):null)); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 2483; - Match(UINT16); - State = 2484; + State = 3141; + _localctx.uint16Type = Match(UINT16); + State = 3142; Match(T__29); - State = 2485; - int32(); - State = 2486; + State = 3143; + _localctx.uint16Value = int32(); + State = 3144; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.uint16Type, (_localctx.uint16Value!=null?(_localctx.uint16Value.Start):null)); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 2488; - Match(UINT8); - State = 2489; + State = 3147; + _localctx.uint8Type = Match(UINT8); + State = 3148; Match(T__29); - State = 2490; - int32(); - State = 2491; + State = 3149; + _localctx.uint8Value = int32(); + State = 3150; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.uint8Type, (_localctx.uint8Value!=null?(_localctx.uint8Value.Start):null)); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 2493; - Match(CHAR); - State = 2494; + State = 3153; + _localctx.charType = Match(CHAR); + State = 3154; Match(T__29); - State = 2495; - int32(); - State = 2496; + State = 3155; + _localctx.charValue = int32(); + State = 3156; Match(T__30); + _localctx.Value = Actions.CreateIntegerSerializedInitializer(_localctx.charType, (_localctx.charValue!=null?(_localctx.charValue.Start):null)); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 2498; - Match(BOOL); - State = 2499; + State = 3159; + _localctx.boolType = Match(BOOL); + State = 3160; Match(T__29); - State = 2500; - truefalse(); - State = 2501; + State = 3161; + _localctx.boolValue = truefalse(); + State = 3162; Match(T__30); + _localctx.Value = Actions.CreateBooleanSerializedInitializer(_localctx.boolType, _localctx.boolValue.Value); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 2503; + State = 3165; Match(T__83); - State = 2504; + State = 3166; Match(T__29); - State = 2505; - bytes(); - State = 2506; + State = 3167; + _localctx.byteArrayValue = bytes(); + State = 3168; Match(T__30); + _localctx.Value = Actions.CreateByteArraySerializedInitializer(_localctx.byteArrayValue.Value); } break; } @@ -14607,12 +15238,16 @@ public FieldSerInitContext fieldSerInit() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value ??= new System.Reflection.Metadata.BlobBuilder(); ExitRule(); } return _localctx; } public partial class BytesContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public HexbyteContext b; [System.Diagnostics.DebuggerNonUserCode] public HexbyteContext[] hexbyte() { return GetRuleContexts(); } @@ -14624,33 +15259,29 @@ public BytesContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_bytes; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitBytes(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public BytesContext bytes() { BytesContext _localctx = new BytesContext(Context, State); - EnterRule(_localctx, 312, RULE_bytes); + EnterRule(_localctx, 302, RULE_bytes); + _localctx.Builder = Actions.CreateByteAccumulator(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2513; + State = 3178; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==INT32 || _la==ID || _la==HEXBYTE) { { { - State = 2510; - hexbyte(); + State = 3173; + _localctx.b = hexbyte(); + Actions.AddByte(_localctx.Builder, _localctx.b.Value); } } - State = 2515; + State = 3180; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -14662,12 +15293,14 @@ public BytesContext bytes() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = Actions.EndBytes(_localctx.Builder); ExitRule(); } return _localctx; } public partial class HexbyteContext : ParserRuleContext { + public byte Value; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT32() { return GetToken(CILParser.INT32, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(CILParser.ID, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode HEXBYTE() { return GetToken(CILParser.HEXBYTE, 0); } @@ -14676,23 +15309,17 @@ public HexbyteContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_hexbyte; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitHexbyte(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public HexbyteContext hexbyte() { HexbyteContext _localctx = new HexbyteContext(Context, State); - EnterRule(_localctx, 314, RULE_hexbyte); + EnterRule(_localctx, 304, RULE_hexbyte); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2516; + State = 3181; _la = TokenStream.LA(1); if ( !(_la==INT32 || _la==ID || _la==HEXBYTE) ) { ErrorHandler.RecoverInline(this); @@ -14702,6 +15329,8 @@ public HexbyteContext hexbyte() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = GrammarActions.ParseHexbyte(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -14715,6 +15344,9 @@ public HexbyteContext hexbyte() { } public partial class FieldInitContext : ParserRuleContext { + public CILParser.FieldInitializerValue Value; + public FieldSerInitContext serializedValue; + public CompQstringContext stringValue; [System.Diagnostics.DebuggerNonUserCode] public FieldSerInitContext fieldSerInit() { return GetRuleContext(0); } @@ -14727,20 +15359,15 @@ public FieldInitContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_fieldInit; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitFieldInit(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public FieldInitContext fieldInit() { FieldInitContext _localctx = new FieldInitContext(Context, State); - EnterRule(_localctx, 316, RULE_fieldInit); + EnterRule(_localctx, 306, RULE_fieldInit); + _localctx.Value = CILParser.FieldInitializerValue.Empty; try { - State = 2521; + State = 3191; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__83: @@ -14758,22 +15385,25 @@ public FieldInitContext fieldInit() { case UINT64: EnterOuterAlt(_localctx, 1); { - State = 2518; - fieldSerInit(); + State = 3183; + _localctx.serializedValue = fieldSerInit(); + _localctx.Value = Actions.CreateFieldInitializer(_localctx.serializedValue.Value); } break; case QSTRING: EnterOuterAlt(_localctx, 2); { - State = 2519; - compQstring(); + State = 3186; + _localctx.stringValue = compQstring(); + _localctx.Value = Actions.CreateFieldInitializer(_localctx.stringValue.Value); } break; case NULLREF: EnterOuterAlt(_localctx, 3); { - State = 2520; + State = 3189; Match(NULLREF); + _localctx.Value = Actions.CreateNullFieldInitializer(); } break; default: @@ -14792,6 +15422,57 @@ public FieldInitContext fieldInit() { } public partial class SerInitContext : ParserRuleContext { + public CILParser.SerializedInitializerValue Value; + public FieldSerInitContext scalarValue; + public IToken stringToken; + public IToken typeToken; + public ClassNameContext typeName; + public SerInitContext objectValue; + public IToken f32ElementToken; + public Int32Context f32Length; + public F32seqContext f32Values; + public IToken f64ElementToken; + public Int32Context f64Length; + public F64seqContext f64Values; + public IToken i64ElementToken; + public Int32Context i64Length; + public I64seqContext i64Values; + public IToken i32ElementToken; + public Int32Context i32Length; + public I32seqContext i32Values; + public IToken i16ElementToken; + public Int32Context i16Length; + public I16seqContext i16Values; + public IToken i8ElementToken; + public Int32Context i8Length; + public I8seqContext i8Values; + public IToken u64ElementToken; + public Int32Context u64Length; + public I64seqContext u64Values; + public IToken u32ElementToken; + public Int32Context u32Length; + public I32seqContext u32Values; + public IToken u16ElementToken; + public Int32Context u16Length; + public I16seqContext u16Values; + public IToken u8ElementToken; + public Int32Context u8Length; + public I8seqContext u8Values; + public IToken charElementToken; + public Int32Context charLength; + public I16seqContext charValues; + public IToken boolElementToken; + public Int32Context boolLength; + public BoolSeqContext boolValues; + public IToken stringElementToken; + public Int32Context stringLength; + public SqstringSeqContext stringValues; + public IToken typeElementToken; + public Int32Context typeLength; + public ClassSeqContext typeValues; + public IToken objectElementToken; + public Int32Context objectLength; + public ObjSeqContext objectValues; [System.Diagnostics.DebuggerNonUserCode] public FieldSerInitContext fieldSerInit() { return GetRuleContext(0); } @@ -14856,392 +15537,409 @@ public SerInitContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_serInit; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSerInit(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SerInitContext serInit() { SerInitContext _localctx = new SerInitContext(Context, State); - EnterRule(_localctx, 318, RULE_serInit); + EnterRule(_localctx, 308, RULE_serInit); + _localctx.Value = CILParser.SerializedInitializerValue.Error; try { - State = 2671; + State = 3364; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,143,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,155,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2523; - fieldSerInit(); + State = 3193; + _localctx.scalarValue = fieldSerInit(); + _localctx.Value = Actions.CreateScalarSerializedValue(_localctx, _localctx.scalarValue, _localctx.scalarValue.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2524; + State = 3196; Match(STRING); - State = 2525; + State = 3197; Match(T__29); - State = 2526; + State = 3198; Match(NULLREF); - State = 2527; + State = 3199; Match(T__30); + _localctx.Value = Actions.CreateStringSerializedValue(); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2528; + State = 3201; Match(STRING); - State = 2529; + State = 3202; Match(T__29); - State = 2530; - Match(SQSTRING); - State = 2531; + State = 3203; + _localctx.stringToken = Match(SQSTRING); + State = 3204; Match(T__30); + _localctx.Value = Actions.CreateStringSerializedValue(_localctx.stringToken); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 2532; + State = 3206; Match(TYPE); - State = 2533; + State = 3207; Match(T__29); - State = 2534; + State = 3208; Match(T__38); - State = 2535; - Match(SQSTRING); - State = 2536; + State = 3209; + _localctx.typeToken = Match(SQSTRING); + State = 3210; Match(T__30); + _localctx.Value = Actions.CreateTypeSerializedValue(_localctx.typeToken); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 2537; + State = 3212; Match(TYPE); - State = 2538; + State = 3213; Match(T__29); - State = 2539; - className(); - State = 2540; + State = 3214; + _localctx.typeName = className(); + State = 3215; Match(T__30); + _localctx.Value = Actions.CreateTypeSerializedValue(_localctx.typeName.Value); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 2542; + State = 3218; Match(TYPE); - State = 2543; + State = 3219; Match(T__29); - State = 2544; + State = 3220; Match(NULLREF); - State = 2545; + State = 3221; Match(T__30); + _localctx.Value = Actions.CreateNullTypeSerializedValue(); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 2546; + State = 3223; Match(OBJECT); - State = 2547; + State = 3224; Match(T__29); - State = 2548; - serInit(); - State = 2549; + State = 3225; + _localctx.objectValue = serInit(); + State = 3226; Match(T__30); + _localctx.Value = Actions.CreateObjectSerializedValue(_localctx.objectValue.Value); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 2551; - Match(FLOAT32); - State = 2552; + State = 3229; + _localctx.f32ElementToken = Match(FLOAT32); + State = 3230; Match(T__41); - State = 2553; - int32(); - State = 2554; + State = 3231; + _localctx.f32Length = int32(); + State = 3232; Match(T__42); - State = 2555; + State = 3233; Match(T__29); - State = 2556; - f32seq(); - State = 2557; + State = 3234; + _localctx.f32Values = f32seq(); + State = 3235; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.f32ElementToken, (_localctx.f32Length!=null?(_localctx.f32Length.Start):null), _localctx.f32Values.Value); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 2559; - Match(FLOAT64_); - State = 2560; + State = 3238; + _localctx.f64ElementToken = Match(FLOAT64_); + State = 3239; Match(T__41); - State = 2561; - int32(); - State = 2562; + State = 3240; + _localctx.f64Length = int32(); + State = 3241; Match(T__42); - State = 2563; + State = 3242; Match(T__29); - State = 2564; - f64seq(); - State = 2565; + State = 3243; + _localctx.f64Values = f64seq(); + State = 3244; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.f64ElementToken, (_localctx.f64Length!=null?(_localctx.f64Length.Start):null), _localctx.f64Values.Value); } break; case 10: EnterOuterAlt(_localctx, 10); { - State = 2567; - Match(INT64_); - State = 2568; + State = 3247; + _localctx.i64ElementToken = Match(INT64_); + State = 3248; Match(T__41); - State = 2569; - int32(); - State = 2570; + State = 3249; + _localctx.i64Length = int32(); + State = 3250; Match(T__42); - State = 2571; + State = 3251; Match(T__29); - State = 2572; - i64seq(); - State = 2573; + State = 3252; + _localctx.i64Values = i64seq(); + State = 3253; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.i64ElementToken, (_localctx.i64Length!=null?(_localctx.i64Length.Start):null), _localctx.i64Values.Value); } break; case 11: EnterOuterAlt(_localctx, 11); { - State = 2575; - Match(INT32_); - State = 2576; + State = 3256; + _localctx.i32ElementToken = Match(INT32_); + State = 3257; Match(T__41); - State = 2577; - int32(); - State = 2578; + State = 3258; + _localctx.i32Length = int32(); + State = 3259; Match(T__42); - State = 2579; + State = 3260; Match(T__29); - State = 2580; - i32seq(); - State = 2581; + State = 3261; + _localctx.i32Values = i32seq(); + State = 3262; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.i32ElementToken, (_localctx.i32Length!=null?(_localctx.i32Length.Start):null), _localctx.i32Values.Value); } break; case 12: EnterOuterAlt(_localctx, 12); { - State = 2583; - Match(INT16); - State = 2584; + State = 3265; + _localctx.i16ElementToken = Match(INT16); + State = 3266; Match(T__41); - State = 2585; - int32(); - State = 2586; + State = 3267; + _localctx.i16Length = int32(); + State = 3268; Match(T__42); - State = 2587; + State = 3269; Match(T__29); - State = 2588; - i16seq(); - State = 2589; + State = 3270; + _localctx.i16Values = i16seq(); + State = 3271; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.i16ElementToken, (_localctx.i16Length!=null?(_localctx.i16Length.Start):null), _localctx.i16Values.Value); } break; case 13: EnterOuterAlt(_localctx, 13); { - State = 2591; - Match(INT8); - State = 2592; + State = 3274; + _localctx.i8ElementToken = Match(INT8); + State = 3275; Match(T__41); - State = 2593; - int32(); - State = 2594; + State = 3276; + _localctx.i8Length = int32(); + State = 3277; Match(T__42); - State = 2595; + State = 3278; Match(T__29); - State = 2596; - i8seq(); - State = 2597; + State = 3279; + _localctx.i8Values = i8seq(); + State = 3280; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.i8ElementToken, (_localctx.i8Length!=null?(_localctx.i8Length.Start):null), _localctx.i8Values.Value); } break; case 14: EnterOuterAlt(_localctx, 14); { - State = 2599; - Match(UINT64); - State = 2600; + State = 3283; + _localctx.u64ElementToken = Match(UINT64); + State = 3284; Match(T__41); - State = 2601; - int32(); - State = 2602; + State = 3285; + _localctx.u64Length = int32(); + State = 3286; Match(T__42); - State = 2603; + State = 3287; Match(T__29); - State = 2604; - i64seq(); - State = 2605; + State = 3288; + _localctx.u64Values = i64seq(); + State = 3289; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.u64ElementToken, (_localctx.u64Length!=null?(_localctx.u64Length.Start):null), _localctx.u64Values.Value); } break; case 15: EnterOuterAlt(_localctx, 15); { - State = 2607; - Match(UINT32); - State = 2608; + State = 3292; + _localctx.u32ElementToken = Match(UINT32); + State = 3293; Match(T__41); - State = 2609; - int32(); - State = 2610; + State = 3294; + _localctx.u32Length = int32(); + State = 3295; Match(T__42); - State = 2611; + State = 3296; Match(T__29); - State = 2612; - i32seq(); - State = 2613; + State = 3297; + _localctx.u32Values = i32seq(); + State = 3298; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.u32ElementToken, (_localctx.u32Length!=null?(_localctx.u32Length.Start):null), _localctx.u32Values.Value); } break; case 16: EnterOuterAlt(_localctx, 16); { - State = 2615; - Match(UINT16); - State = 2616; + State = 3301; + _localctx.u16ElementToken = Match(UINT16); + State = 3302; Match(T__41); - State = 2617; - int32(); - State = 2618; + State = 3303; + _localctx.u16Length = int32(); + State = 3304; Match(T__42); - State = 2619; + State = 3305; Match(T__29); - State = 2620; - i16seq(); - State = 2621; + State = 3306; + _localctx.u16Values = i16seq(); + State = 3307; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.u16ElementToken, (_localctx.u16Length!=null?(_localctx.u16Length.Start):null), _localctx.u16Values.Value); } break; case 17: EnterOuterAlt(_localctx, 17); { - State = 2623; - Match(UINT8); - State = 2624; + State = 3310; + _localctx.u8ElementToken = Match(UINT8); + State = 3311; Match(T__41); - State = 2625; - int32(); - State = 2626; + State = 3312; + _localctx.u8Length = int32(); + State = 3313; Match(T__42); - State = 2627; + State = 3314; Match(T__29); - State = 2628; - i8seq(); - State = 2629; + State = 3315; + _localctx.u8Values = i8seq(); + State = 3316; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.u8ElementToken, (_localctx.u8Length!=null?(_localctx.u8Length.Start):null), _localctx.u8Values.Value); } break; case 18: EnterOuterAlt(_localctx, 18); { - State = 2631; - Match(CHAR); - State = 2632; + State = 3319; + _localctx.charElementToken = Match(CHAR); + State = 3320; Match(T__41); - State = 2633; - int32(); - State = 2634; + State = 3321; + _localctx.charLength = int32(); + State = 3322; Match(T__42); - State = 2635; + State = 3323; Match(T__29); - State = 2636; - i16seq(); - State = 2637; + State = 3324; + _localctx.charValues = i16seq(); + State = 3325; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.charElementToken, (_localctx.charLength!=null?(_localctx.charLength.Start):null), _localctx.charValues.Value); } break; case 19: EnterOuterAlt(_localctx, 19); { - State = 2639; - Match(BOOL); - State = 2640; + State = 3328; + _localctx.boolElementToken = Match(BOOL); + State = 3329; Match(T__41); - State = 2641; - int32(); - State = 2642; + State = 3330; + _localctx.boolLength = int32(); + State = 3331; Match(T__42); - State = 2643; + State = 3332; Match(T__29); - State = 2644; - boolSeq(); - State = 2645; + State = 3333; + _localctx.boolValues = boolSeq(); + State = 3334; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.boolElementToken, (_localctx.boolLength!=null?(_localctx.boolLength.Start):null), _localctx.boolValues.Value); } break; case 20: EnterOuterAlt(_localctx, 20); { - State = 2647; - Match(STRING); - State = 2648; + State = 3337; + _localctx.stringElementToken = Match(STRING); + State = 3338; Match(T__41); - State = 2649; - int32(); - State = 2650; + State = 3339; + _localctx.stringLength = int32(); + State = 3340; Match(T__42); - State = 2651; + State = 3341; Match(T__29); - State = 2652; - sqstringSeq(); - State = 2653; + State = 3342; + _localctx.stringValues = sqstringSeq(); + State = 3343; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.stringElementToken, (_localctx.stringLength!=null?(_localctx.stringLength.Start):null), _localctx.stringValues.Value); } break; case 21: EnterOuterAlt(_localctx, 21); { - State = 2655; - Match(TYPE); - State = 2656; + State = 3346; + _localctx.typeElementToken = Match(TYPE); + State = 3347; Match(T__41); - State = 2657; - int32(); - State = 2658; + State = 3348; + _localctx.typeLength = int32(); + State = 3349; Match(T__42); - State = 2659; + State = 3350; Match(T__29); - State = 2660; - classSeq(); - State = 2661; + State = 3351; + _localctx.typeValues = classSeq(); + State = 3352; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.typeElementToken, (_localctx.typeLength!=null?(_localctx.typeLength.Start):null), _localctx.typeValues.Value); } break; case 22: EnterOuterAlt(_localctx, 22); { - State = 2663; - Match(OBJECT); - State = 2664; + State = 3355; + _localctx.objectElementToken = Match(OBJECT); + State = 3356; Match(T__41); - State = 2665; - int32(); - State = 2666; + State = 3357; + _localctx.objectLength = int32(); + State = 3358; Match(T__42); - State = 2667; + State = 3359; Match(T__29); - State = 2668; - objSeq(); - State = 2669; + State = 3360; + _localctx.objectValues = objSeq(); + State = 3361; Match(T__30); + _localctx.Value = Actions.CreateArraySerializedValue(_localctx.objectElementToken, (_localctx.objectLength!=null?(_localctx.objectLength.Start):null), _localctx.objectValues.Value); } break; } @@ -15258,6 +15956,10 @@ public SerInitContext serInit() { } public partial class F32seqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public Float64Context floatingValue; + public Int32Context integerValue; [System.Diagnostics.DebuggerNonUserCode] public Float64Context[] float64() { return GetRuleContexts(); } @@ -15275,45 +15977,42 @@ public F32seqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_f32seq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitF32seq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public F32seqContext f32seq() { F32seqContext _localctx = new F32seqContext(Context, State); - EnterRule(_localctx, 320, RULE_f32seq); + EnterRule(_localctx, 310, RULE_f32seq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2677; + State = 3374; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (((((_la - 173)) & ~0x3f) == 0 && ((1L << (_la - 173)) & 98309L) != 0)) { { - State = 2675; + State = 3372; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,144,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,156,Context) ) { case 1: { - State = 2673; - float64(); + State = 3366; + _localctx.floatingValue = float64(); + Actions.AddFloat32SequenceValue(_localctx.Builder, _localctx.floatingValue.Value); } break; case 2: { - State = 2674; - int32(); + State = 3369; + _localctx.integerValue = int32(); + Actions.AddFloat32SequenceValue(_localctx.Builder, (_localctx.integerValue!=null?(_localctx.integerValue.Start):null)); } break; } } - State = 2679; + State = 3376; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15325,12 +16024,17 @@ public F32seqContext f32seq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class F64seqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public Float64Context floatingValue; + public Int64Context integerValue; [System.Diagnostics.DebuggerNonUserCode] public Float64Context[] float64() { return GetRuleContexts(); } @@ -15348,45 +16052,42 @@ public F64seqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_f64seq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitF64seq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public F64seqContext f64seq() { F64seqContext _localctx = new F64seqContext(Context, State); - EnterRule(_localctx, 322, RULE_f64seq); + EnterRule(_localctx, 312, RULE_f64seq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2684; + State = 3385; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (((((_la - 173)) & ~0x3f) == 0 && ((1L << (_la - 173)) & 98311L) != 0)) { { - State = 2682; + State = 3383; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,146,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,158,Context) ) { case 1: { - State = 2680; - float64(); + State = 3377; + _localctx.floatingValue = float64(); + Actions.AddFloat64SequenceValue(_localctx.Builder, _localctx.floatingValue.Value); } break; case 2: { - State = 2681; - int64(); + State = 3380; + _localctx.integerValue = int64(); + Actions.AddFloat64SequenceValue(_localctx.Builder, (_localctx.integerValue!=null?(_localctx.integerValue.Start):null)); } break; } } - State = 2686; + State = 3387; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15398,12 +16099,16 @@ public F64seqContext f64seq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class I64seqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public Int64Context value; [System.Diagnostics.DebuggerNonUserCode] public Int64Context[] int64() { return GetRuleContexts(); } @@ -15415,33 +16120,29 @@ public I64seqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_i64seq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitI64seq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public I64seqContext i64seq() { I64seqContext _localctx = new I64seqContext(Context, State); - EnterRule(_localctx, 324, RULE_i64seq); + EnterRule(_localctx, 314, RULE_i64seq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2690; + State = 3393; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==INT32 || _la==INT64) { { { - State = 2687; - int64(); + State = 3388; + _localctx.value = int64(); + Actions.AddInt64SequenceValue(_localctx.Builder, (_localctx.value!=null?(_localctx.value.Start):null)); } } - State = 2692; + State = 3395; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15453,12 +16154,16 @@ public I64seqContext i64seq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class I32seqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { return GetRuleContexts(); } @@ -15470,33 +16175,29 @@ public I32seqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_i32seq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitI32seq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public I32seqContext i32seq() { I32seqContext _localctx = new I32seqContext(Context, State); - EnterRule(_localctx, 326, RULE_i32seq); + EnterRule(_localctx, 316, RULE_i32seq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2696; + State = 3401; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==INT32) { { { - State = 2693; - int32(); + State = 3396; + _localctx.value = int32(); + Actions.AddInt32SequenceValue(_localctx.Builder, (_localctx.value!=null?(_localctx.value.Start):null)); } } - State = 2698; + State = 3403; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15508,12 +16209,16 @@ public I32seqContext i32seq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class I16seqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { return GetRuleContexts(); } @@ -15525,33 +16230,29 @@ public I16seqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_i16seq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitI16seq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public I16seqContext i16seq() { I16seqContext _localctx = new I16seqContext(Context, State); - EnterRule(_localctx, 328, RULE_i16seq); + EnterRule(_localctx, 318, RULE_i16seq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2702; + State = 3409; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==INT32) { { { - State = 2699; - int32(); + State = 3404; + _localctx.value = int32(); + Actions.AddInt16SequenceValue(_localctx.Builder, (_localctx.value!=null?(_localctx.value.Start):null)); } } - State = 2704; + State = 3411; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15563,12 +16264,16 @@ public I16seqContext i16seq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class I8seqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public Int32Context value; [System.Diagnostics.DebuggerNonUserCode] public Int32Context[] int32() { return GetRuleContexts(); } @@ -15580,33 +16285,29 @@ public I8seqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_i8seq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitI8seq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public I8seqContext i8seq() { I8seqContext _localctx = new I8seqContext(Context, State); - EnterRule(_localctx, 330, RULE_i8seq); + EnterRule(_localctx, 320, RULE_i8seq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2708; + State = 3417; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==INT32) { { { - State = 2705; - int32(); + State = 3412; + _localctx.value = int32(); + Actions.AddInt8SequenceValue(_localctx.Builder, (_localctx.value!=null?(_localctx.value.Start):null)); } } - State = 2710; + State = 3419; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15618,12 +16319,16 @@ public I8seqContext i8seq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class BoolSeqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public TruefalseContext value; [System.Diagnostics.DebuggerNonUserCode] public TruefalseContext[] truefalse() { return GetRuleContexts(); } @@ -15635,33 +16340,29 @@ public BoolSeqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_boolSeq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitBoolSeq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public BoolSeqContext boolSeq() { BoolSeqContext _localctx = new BoolSeqContext(Context, State); - EnterRule(_localctx, 332, RULE_boolSeq); + EnterRule(_localctx, 322, RULE_boolSeq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2714; + State = 3425; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__94 || _la==T__95) { { { - State = 2711; - truefalse(); + State = 3420; + _localctx.value = truefalse(); + Actions.AddBooleanSequenceValue(_localctx.Builder, _localctx.value.Value); } } - State = 2716; + State = 3427; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15673,12 +16374,17 @@ public BoolSeqContext boolSeq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class SqstringSeqContext : ParserRuleContext { + public System.Reflection.Metadata.BlobBuilder Value; + public System.Reflection.Metadata.BlobBuilder Builder; + public IToken nullValue; + public IToken stringValue; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] NULLREF() { return GetTokens(CILParser.NULLREF); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NULLREF(int i) { return GetToken(CILParser.NULLREF, i); @@ -15692,40 +16398,44 @@ public SqstringSeqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_sqstringSeq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitSqstringSeq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public SqstringSeqContext sqstringSeq() { SqstringSeqContext _localctx = new SqstringSeqContext(Context, State); - EnterRule(_localctx, 334, RULE_sqstringSeq); + EnterRule(_localctx, 324, RULE_sqstringSeq); + _localctx.Builder = new System.Reflection.Metadata.BlobBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2720; + State = 3434; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==NULLREF || _la==SQSTRING) { { - { - State = 2717; - _la = TokenStream.LA(1); - if ( !(_la==NULLREF || _la==SQSTRING) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } + State = 3432; + ErrorHandler.Sync(this); + switch (TokenStream.LA(1)) { + case NULLREF: + { + State = 3428; + _localctx.nullValue = Match(NULLREF); + Actions.AddStringSequenceValue(_localctx.Builder, _localctx.nullValue); + } + break; + case SQSTRING: + { + State = 3430; + _localctx.stringValue = Match(SQSTRING); + Actions.AddStringSequenceValue(_localctx.Builder, _localctx.stringValue); + } + break; + default: + throw new NoViableAltException(this); } } - State = 2722; + State = 3436; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15737,12 +16447,16 @@ public SqstringSeqContext sqstringSeq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder; ExitRule(); } return _localctx; } public partial class ClassSeqContext : ParserRuleContext { + public CILParser.SerializedSequenceValue Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public ClassSeqElementContext value; [System.Diagnostics.DebuggerNonUserCode] public ClassSeqElementContext[] classSeqElement() { return GetRuleContexts(); } @@ -15754,33 +16468,29 @@ public ClassSeqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_classSeq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitClassSeq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ClassSeqContext classSeq() { ClassSeqContext _localctx = new ClassSeqContext(Context, State); - EnterRule(_localctx, 336, RULE_classSeq); + EnterRule(_localctx, 326, RULE_classSeq); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2726; + State = 3442; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 4947802390528L) != 0) || _la==T__112 || _la==NULLREF || _la==VALUE || ((((_la - 243)) & ~0x3f) == 0 && ((1L << (_la - 243)) & 105553118478337L) != 0)) { { { - State = 2723; - classSeqElement(); + State = 3437; + _localctx.value = classSeqElement(); + _localctx.Builder.Add(_localctx.value.Value); } } - State = 2728; + State = 3444; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15792,12 +16502,16 @@ public ClassSeqContext classSeq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = new CILParser.ClassSerializedSequenceValue(_localctx.Builder.ToImmutable()); ExitRule(); } return _localctx; } public partial class ClassSeqElementContext : ParserRuleContext { + public CILParser.ClassSequenceElementValue Value; + public IToken quotedValue; + public ClassNameContext typeValue; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NULLREF() { return GetToken(CILParser.NULLREF, 0); } [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SQSTRING() { return GetToken(CILParser.SQSTRING, 0); } [System.Diagnostics.DebuggerNonUserCode] public ClassNameContext className() { @@ -15808,36 +16522,33 @@ public ClassSeqElementContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_classSeqElement; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitClassSeqElement(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ClassSeqElementContext classSeqElement() { ClassSeqElementContext _localctx = new ClassSeqElementContext(Context, State); - EnterRule(_localctx, 338, RULE_classSeqElement); + EnterRule(_localctx, 328, RULE_classSeqElement); + _localctx.Value = CILParser.ClassSequenceElementValue.Error; try { - State = 2733; + State = 3453; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case NULLREF: EnterOuterAlt(_localctx, 1); { - State = 2729; + State = 3445; Match(NULLREF); + _localctx.Value = Actions.CreateNullClassSequenceValue(); } break; case T__38: EnterOuterAlt(_localctx, 2); { - State = 2730; + State = 3447; Match(T__38); - State = 2731; - Match(SQSTRING); + State = 3448; + _localctx.quotedValue = Match(SQSTRING); + _localctx.Value = Actions.CreateQuotedClassSequenceValue(_localctx.quotedValue); } break; case T__15: @@ -15853,8 +16564,9 @@ public ClassSeqElementContext classSeqElement() { case ID: EnterOuterAlt(_localctx, 3); { - State = 2732; - className(); + State = 3450; + _localctx.typeValue = className(); + _localctx.Value = Actions.CreateClassSequenceValue(_localctx.typeValue.Value); } break; default: @@ -15873,6 +16585,9 @@ public ClassSeqElementContext classSeqElement() { } public partial class ObjSeqContext : ParserRuleContext { + public CILParser.SerializedSequenceValue Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public SerInitContext value; [System.Diagnostics.DebuggerNonUserCode] public SerInitContext[] serInit() { return GetRuleContexts(); } @@ -15884,33 +16599,29 @@ public ObjSeqContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_objSeq; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitObjSeq(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ObjSeqContext objSeq() { ObjSeqContext _localctx = new ObjSeqContext(Context, State); - EnterRule(_localctx, 340, RULE_objSeq); + EnterRule(_localctx, 330, RULE_objSeq); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2738; + State = 3460; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while (_la==T__83 || ((((_la - 181)) & ~0x3f) == 0 && ((1L << (_la - 181)) & 106495L) != 0)) { { { - State = 2735; - serInit(); + State = 3455; + _localctx.value = serInit(); + _localctx.Builder.Add(_localctx.value.Value); } } - State = 2740; + State = 3462; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -15922,12 +16633,19 @@ public ObjSeqContext objSeq() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = new CILParser.ObjectSerializedSequenceValue(_localctx.Builder.ToImmutable()); ExitRule(); } return _localctx; } public partial class CustomAttrDeclContext : ParserRuleContext { + public CILParser.CustomAttributeDeclarationValue Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public CustomDescrContext directAttribute; + public CustomDescrWithOwnerContext ownedAttribute; + public DottedNameContext alias; [System.Diagnostics.DebuggerNonUserCode] public CustomDescrContext customDescr() { return GetRuleContext(0); } @@ -15942,41 +16660,42 @@ public CustomAttrDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_customAttrDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitCustomAttrDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public CustomAttrDeclContext customAttrDecl() { CustomAttrDeclContext _localctx = new CustomAttrDeclContext(Context, State); - EnterRule(_localctx, 342, RULE_customAttrDecl); + EnterRule(_localctx, 332, RULE_customAttrDecl); + + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + _localctx.Value = CILParser.CustomAttributeDeclarationValue.Error; + try { - State = 2744; + State = 3472; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,157,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,170,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2741; - customDescr(); + State = 3463; + _localctx.directAttribute = customDescr(); + _localctx.Value = Actions.CreateCustomAttributeDeclaration(_localctx.directAttribute.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2742; - customDescrWithOwner(); + State = 3466; + _localctx.ownedAttribute = customDescrWithOwner(); + _localctx.Value = Actions.CreateCustomAttributeDeclaration(_localctx.ownedAttribute.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2743; - dottedName(); + State = 3469; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateCustomAttributeTypedef(_localctx.alias.Value); } break; } @@ -15987,12 +16706,26 @@ public CustomAttrDeclContext customAttrDecl() { ErrorHandler.Recover(this, re); } finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + ExitRule(); } return _localctx; } public partial class AsmOrRefDeclContext : ParserRuleContext { + public CILParser.AssemblyDeclarationValue? Value; + public BytesContext key; + public IntOrWildcardContext major; + public IntOrWildcardContext minor; + public IntOrWildcardContext build; + public IntOrWildcardContext revision; + public CompQstringContext locale; + public BytesContext localeBytes; + public CustomAttrDeclContext attribute; [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { return GetRuleContext(0); } @@ -16016,27 +16749,21 @@ public AsmOrRefDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_asmOrRefDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAsmOrRefDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AsmOrRefDeclContext asmOrRefDecl() { AsmOrRefDeclContext _localctx = new AsmOrRefDeclContext(Context, State); - EnterRule(_localctx, 344, RULE_asmOrRefDecl); + EnterRule(_localctx, 334, RULE_asmOrRefDecl); int _la; try { - State = 2771; + State = 3506; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,158,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,171,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2746; + State = 3474; _la = TokenStream.LA(1); if ( !(_la==T__166 || _la==T__167) ) { ErrorHandler.RecoverInline(this); @@ -16045,72 +16772,83 @@ public AsmOrRefDeclContext asmOrRefDecl() { ErrorHandler.ReportMatch(this); Consume(); } - State = 2747; + State = 3475; Match(T__35); - State = 2748; + State = 3476; Match(T__29); - State = 2749; - bytes(); - State = 2750; + State = 3477; + _localctx.key = bytes(); + State = 3478; Match(T__30); + _localctx.Value = Actions.CreateAssemblyPublicKeyDeclaration(_localctx.key.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2752; + State = 3481; Match(T__168); - State = 2753; - intOrWildcard(); - State = 2754; + State = 3482; + _localctx.major = intOrWildcard(); + State = 3483; Match(T__74); - State = 2755; - intOrWildcard(); - State = 2756; + State = 3484; + _localctx.minor = intOrWildcard(); + State = 3485; Match(T__74); - State = 2757; - intOrWildcard(); - State = 2758; + State = 3486; + _localctx.build = intOrWildcard(); + State = 3487; Match(T__74); - State = 2759; - intOrWildcard(); + State = 3488; + _localctx.revision = intOrWildcard(); + _localctx.Value = Actions.CreateAssemblyVersionDeclaration( + _localctx.major.Value, + _localctx.minor.Value, + _localctx.build.Value, + _localctx.revision.Value); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2761; + State = 3491; Match(T__169); - State = 2762; - compQstring(); + State = 3492; + _localctx.locale = compQstring(); + _localctx.Value = Actions.CreateAssemblyLocaleDeclaration(_localctx.locale.Value); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 2763; + State = 3495; Match(T__169); - State = 2764; + State = 3496; Match(T__35); - State = 2765; + State = 3497; Match(T__29); - State = 2766; - bytes(); - State = 2767; + State = 3498; + _localctx.localeBytes = bytes(); + State = 3499; Match(T__30); + _localctx.Value = Actions.CreateAssemblyLocaleDeclaration(_localctx.localeBytes.Value); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 2769; - customAttrDecl(); + State = 3502; + _localctx.attribute = customAttrDecl(); + _localctx.Value = Actions.CreateAssemblyCustomAttributeDeclaration( + _localctx.attribute.Value, + (_localctx.attribute!=null?(_localctx.attribute.Start):null)); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 2770; + State = 3505; compControl(); } break; @@ -16127,7 +16865,71 @@ public AsmOrRefDeclContext asmOrRefDecl() { return _localctx; } + public partial class AssemblyRefBlockContext : ParserRuleContext { + public CILParser.AssemblyReferenceValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public AssemblyRefHeadContext header; + public AssemblyRefDeclsContext declarations; + [System.Diagnostics.DebuggerNonUserCode] public AssemblyRefHeadContext assemblyRefHead() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public AssemblyRefDeclsContext assemblyRefDecls() { + return GetRuleContext(0); + } + public AssemblyRefBlockContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_assemblyRefBlock; } } + } + + [RuleVersion(0)] + public AssemblyRefBlockContext assemblyRefBlock() { + AssemblyRefBlockContext _localctx = new AssemblyRefBlockContext(Context, State); + EnterRule(_localctx, 336, RULE_assemblyRefBlock); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + try { + EnterOuterAlt(_localctx, 1); + { + State = 3508; + _localctx.header = assemblyRefHead(); + State = 3509; + Match(T__16); + State = 3510; + _localctx.declarations = assemblyRefDecls(); + State = 3511; + Match(T__17); + _localctx.Value = Actions.CreateAssemblyReference( + _localctx.header.Value, + _localctx.declarations.Value); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } + + ExitRule(); + } + return _localctx; + } + public partial class AssemblyRefHeadContext : ParserRuleContext { + public CILParser.AssemblyReferenceHeaderValue Value; + public AsmAttrContext attributes; + public DottedNameContext name; + public DottedNameContext alias; [System.Diagnostics.DebuggerNonUserCode] public AsmAttrContext asmAttr() { return GetRuleContext(0); } @@ -16142,50 +16944,53 @@ public AssemblyRefHeadContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_assemblyRefHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssemblyRefHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AssemblyRefHeadContext assemblyRefHead() { AssemblyRefHeadContext _localctx = new AssemblyRefHeadContext(Context, State); - EnterRule(_localctx, 346, RULE_assemblyRefHead); + EnterRule(_localctx, 338, RULE_assemblyRefHead); + _localctx.Value = CILParser.AssemblyReferenceHeaderValue.Error; try { - State = 2785; + State = 3528; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,159,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,172,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2773; + State = 3514; Match(T__24); - State = 2774; + State = 3515; Match(T__39); - State = 2775; - asmAttr(); - State = 2776; - dottedName(); + State = 3516; + _localctx.attributes = asmAttr(); + State = 3517; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateAssemblyReferenceHeader( + _localctx.attributes.Value, + _localctx.name.Value, + _localctx.name.Value); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2778; + State = 3520; Match(T__24); - State = 2779; + State = 3521; Match(T__39); - State = 2780; - asmAttr(); - State = 2781; - dottedName(); - State = 2782; + State = 3522; + _localctx.attributes = asmAttr(); + State = 3523; + _localctx.name = dottedName(); + State = 3524; Match(T__33); - State = 2783; - dottedName(); + State = 3525; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateAssemblyReferenceHeader( + _localctx.attributes.Value, + _localctx.name.Value, + _localctx.alias.Value); } break; } @@ -16202,6 +17007,9 @@ public AssemblyRefHeadContext assemblyRefHead() { } public partial class AssemblyRefDeclsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public AssemblyRefDeclContext declaration; [System.Diagnostics.DebuggerNonUserCode] public AssemblyRefDeclContext[] assemblyRefDecl() { return GetRuleContexts(); } @@ -16213,33 +17021,29 @@ public AssemblyRefDeclsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_assemblyRefDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssemblyRefDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AssemblyRefDeclsContext assemblyRefDecls() { AssemblyRefDeclsContext _localctx = new AssemblyRefDeclsContext(Context, State); - EnterRule(_localctx, 348, RULE_assemblyRefDecls); + EnterRule(_localctx, 340, RULE_assemblyRefDecls); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2790; + State = 3535; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 36028835673735168L) != 0) || ((((_la - 167)) & ~0x3f) == 0 && ((1L << (_la - 167)) & 4294975519L) != 0) || ((((_la - 243)) & ~0x3f) == 0 && ((1L << (_la - 243)) & 105555249070081L) != 0)) { { { - State = 2787; - assemblyRefDecl(); + State = 3530; + _localctx.declaration = assemblyRefDecl(); + if (_localctx.declaration.Value is not null) _localctx.Builder.Add(_localctx.declaration.Value); } } - State = 2792; + State = 3537; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -16251,12 +17055,17 @@ public AssemblyRefDeclsContext assemblyRefDecls() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class AssemblyRefDeclContext : ParserRuleContext { + public CILParser.AssemblyDeclarationValue? Value; + public BytesContext hash; + public AsmOrRefDeclContext shared; + public BytesContext token; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode HASH() { return GetToken(CILParser.HASH, 0); } [System.Diagnostics.DebuggerNonUserCode] public BytesContext bytes() { return GetRuleContext(0); @@ -16269,35 +17078,30 @@ public AssemblyRefDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_assemblyRefDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssemblyRefDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public AssemblyRefDeclContext assemblyRefDecl() { AssemblyRefDeclContext _localctx = new AssemblyRefDeclContext(Context, State); - EnterRule(_localctx, 350, RULE_assemblyRefDecl); + EnterRule(_localctx, 342, RULE_assemblyRefDecl); try { - State = 2807; + State = 3557; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case HASH: EnterOuterAlt(_localctx, 1); { - State = 2793; + State = 3538; Match(HASH); - State = 2794; + State = 3539; Match(T__35); - State = 2795; + State = 3540; Match(T__29); - State = 2796; - bytes(); - State = 2797; + State = 3541; + _localctx.hash = bytes(); + State = 3542; Match(T__30); + _localctx.Value = Actions.CreateAssemblyReferenceHashDeclaration(_localctx.hash.Value); } break; case T__15: @@ -16321,30 +17125,33 @@ public AssemblyRefDeclContext assemblyRefDecl() { case ID: EnterOuterAlt(_localctx, 2); { - State = 2799; - asmOrRefDecl(); + State = 3545; + _localctx.shared = asmOrRefDecl(); + _localctx.Value = _localctx.shared.Value; } break; case T__170: EnterOuterAlt(_localctx, 3); { - State = 2800; + State = 3548; Match(T__170); - State = 2801; + State = 3549; Match(T__35); - State = 2802; + State = 3550; Match(T__29); - State = 2803; - bytes(); - State = 2804; + State = 3551; + _localctx.token = bytes(); + State = 3552; Match(T__30); + _localctx.Value = Actions.CreateAssemblyReferencePublicKeyTokenDeclaration(_localctx.token.Value); } break; case T__54: EnterOuterAlt(_localctx, 4); { - State = 2806; + State = 3555; Match(T__54); + _localctx.Value = Actions.CreateAssemblyReferenceAutoDeclaration(); } break; default: @@ -16362,57 +17169,104 @@ public AssemblyRefDeclContext assemblyRefDecl() { return _localctx; } + public partial class ExptypeBlockContext : ParserRuleContext { + public CILParser.ExportedTypeValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public ExptypeHeadContext header; + public ExptypeDeclsContext declarations; + [System.Diagnostics.DebuggerNonUserCode] public ExptypeHeadContext exptypeHead() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ExptypeDeclsContext exptypeDecls() { + return GetRuleContext(0); + } + public ExptypeBlockContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_exptypeBlock; } } + } + + [RuleVersion(0)] + public ExptypeBlockContext exptypeBlock() { + ExptypeBlockContext _localctx = new ExptypeBlockContext(Context, State); + EnterRule(_localctx, 344, RULE_exptypeBlock); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + try { + EnterOuterAlt(_localctx, 1); + { + State = 3559; + _localctx.header = exptypeHead(); + State = 3560; + Match(T__16); + State = 3561; + _localctx.declarations = exptypeDecls(); + State = 3562; + Match(T__17); + _localctx.Value = Actions.CreateExportedType( + _localctx.header.Value, + _localctx.declarations.Value); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } + + ExitRule(); + } + return _localctx; + } + public partial class ExptypeHeadContext : ParserRuleContext { + public CILParser.ExportedTypeHeaderValue Value; + public IToken head; + public ExptAttrsContext attributes; + public DottedNameContext name; + [System.Diagnostics.DebuggerNonUserCode] public ExptAttrsContext exptAttrs() { + return GetRuleContext(0); + } [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } - [System.Diagnostics.DebuggerNonUserCode] public ExptAttrContext[] exptAttr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExptAttrContext exptAttr(int i) { - return GetRuleContext(i); - } public ExptypeHeadContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_exptypeHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitExptypeHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ExptypeHeadContext exptypeHead() { ExptypeHeadContext _localctx = new ExptypeHeadContext(Context, State); - EnterRule(_localctx, 352, RULE_exptypeHead); - int _la; + EnterRule(_localctx, 346, RULE_exptypeHead); + _localctx.Value = CILParser.ExportedTypeHeaderValue.Error; try { EnterOuterAlt(_localctx, 1); { - State = 2809; - Match(T__49); - State = 2810; + State = 3565; + _localctx.head = Match(T__49); + State = 3566; Match(T__39); - State = 2814; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 4618441417868443648L) != 0) || _la==T__171) { - { - { - State = 2811; - exptAttr(); - } - } - State = 2816; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 2817; - dottedName(); + State = 3567; + _localctx.attributes = exptAttrs(); + State = 3568; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateExportedTypeHeader( + _localctx.attributes.Value, + _localctx.name.Value, + _localctx.head); } } catch (RecognitionException re) { @@ -16427,55 +17281,98 @@ public ExptypeHeadContext exptypeHead() { } public partial class ExportHeadContext : ParserRuleContext { + public CILParser.ExportedTypeHeaderValue Value; + public IToken head; + public ExptAttrsContext attributes; + public DottedNameContext name; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EXPORT() { return GetToken(CILParser.EXPORT, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ExptAttrsContext exptAttrs() { + return GetRuleContext(0); + } [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } + public ExportHeadContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_exportHead; } } + } + + [RuleVersion(0)] + public ExportHeadContext exportHead() { + ExportHeadContext _localctx = new ExportHeadContext(Context, State); + EnterRule(_localctx, 348, RULE_exportHead); + _localctx.Value = CILParser.ExportedTypeHeaderValue.Error; + try { + EnterOuterAlt(_localctx, 1); + { + State = 3571; + _localctx.head = Match(EXPORT); + State = 3572; + _localctx.attributes = exptAttrs(); + State = 3573; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateExportedTypeHeader( + _localctx.attributes.Value, + _localctx.name.Value, + _localctx.head); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + + public partial class ExptAttrsContext : ParserRuleContext { + public System.Reflection.TypeAttributes Value; + public ExptAttrContext attribute; [System.Diagnostics.DebuggerNonUserCode] public ExptAttrContext[] exptAttr() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public ExptAttrContext exptAttr(int i) { return GetRuleContext(i); } - public ExportHeadContext(ParserRuleContext parent, int invokingState) + public ExptAttrsContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } - public override int RuleIndex { get { return RULE_exportHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitExportHead(this); - else return visitor.VisitChildren(this); - } + public override int RuleIndex { get { return RULE_exptAttrs; } } } [RuleVersion(0)] - public ExportHeadContext exportHead() { - ExportHeadContext _localctx = new ExportHeadContext(Context, State); - EnterRule(_localctx, 354, RULE_exportHead); + public ExptAttrsContext exptAttrs() { + ExptAttrsContext _localctx = new ExptAttrsContext(Context, State); + EnterRule(_localctx, 350, RULE_exptAttrs); + _localctx.Value = 0; int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2819; - Match(EXPORT); - State = 2823; + State = 3581; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 4618441417868443648L) != 0) || _la==T__171) { { { - State = 2820; - exptAttr(); + State = 3576; + _localctx.attribute = exptAttr(); + _localctx.Value = Actions.AddExportedTypeAttribute( + _localctx.Value, + _localctx.attribute.Value, + _localctx.attribute.Mask); } } - State = 2825; + State = 3583; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } - State = 2826; - dottedName(); } } catch (RecognitionException re) { @@ -16490,103 +17387,101 @@ public ExportHeadContext exportHead() { } public partial class ExptAttrContext : ParserRuleContext { + public System.Reflection.TypeAttributes Value; + public System.Reflection.TypeAttributes Mask; public ExptAttrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_exptAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitExptAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ExptAttrContext exptAttr() { ExptAttrContext _localctx = new ExptAttrContext(Context, State); - EnterRule(_localctx, 356, RULE_exptAttr); + EnterRule(_localctx, 352, RULE_exptAttr); try { - State = 2843; + State = 3599; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,164,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,176,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2828; + State = 3584; Match(T__51); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2829; + State = 3585; Match(T__50); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2830; + State = 3586; Match(T__171); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 2831; + State = 3587; Match(T__61); - State = 2832; + State = 3588; Match(T__50); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 2833; + State = 3589; Match(T__61); - State = 2834; + State = 3590; Match(T__51); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 2835; + State = 3591; Match(T__61); - State = 2836; + State = 3592; Match(T__62); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 2837; + State = 3593; Match(T__61); - State = 2838; + State = 3594; Match(T__63); } break; case 8: EnterOuterAlt(_localctx, 8); { - State = 2839; + State = 3595; Match(T__61); - State = 2840; + State = 3596; Match(T__64); } break; case 9: EnterOuterAlt(_localctx, 9); { - State = 2841; + State = 3597; Match(T__61); - State = 2842; + State = 3598; Match(T__65); } break; } + Context.Stop = TokenStream.LT(-1); + Actions.SetExportedTypeAttribute(_localctx); } catch (RecognitionException re) { _localctx.exception = re; @@ -16600,6 +17495,9 @@ public ExptAttrContext exptAttr() { } public partial class ExptypeDeclsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public ExptypeDeclContext declaration; [System.Diagnostics.DebuggerNonUserCode] public ExptypeDeclContext[] exptypeDecl() { return GetRuleContexts(); } @@ -16611,33 +17509,29 @@ public ExptypeDeclsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_exptypeDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitExptypeDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ExptypeDeclsContext exptypeDecls() { ExptypeDeclsContext _localctx = new ExptypeDeclsContext(Context, State); - EnterRule(_localctx, 358, RULE_exptypeDecls); + EnterRule(_localctx, 354, RULE_exptypeDecls); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2848; + State = 3606; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 1125938597265408L) != 0) || _la==T__112 || _la==VALUE || _la==INSTANCE || ((((_la - 264)) & ~0x3f) == 0 && ((1L << (_la - 264)) & 50332665L) != 0)) { { { - State = 2845; - exptypeDecl(); + State = 3601; + _localctx.declaration = exptypeDecl(); + if (_localctx.declaration.Value is not null) _localctx.Builder.Add(_localctx.declaration.Value); } } - State = 2850; + State = 3608; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -16649,12 +17543,21 @@ public ExptypeDeclsContext exptypeDecls() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class ExptypeDeclContext : ParserRuleContext { + public CILParser.ExportedTypeDeclarationValue? Value; + public IToken location; + public DottedNameContext name; + public SlashedNameContext nestedName; + public DottedNameContext assemblyName; + public MdtokenContext token; + public Int32Context typeDefinitionId; + public CustomAttrDeclContext attribute; [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } @@ -16678,80 +17581,91 @@ public ExptypeDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_exptypeDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitExptypeDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ExptypeDeclContext exptypeDecl() { ExptypeDeclContext _localctx = new ExptypeDeclContext(Context, State); - EnterRule(_localctx, 360, RULE_exptypeDecl); + EnterRule(_localctx, 356, RULE_exptypeDecl); try { - State = 2864; + State = 3634; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,166,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,178,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2851; - Match(T__20); - State = 2852; - dottedName(); + State = 3609; + _localctx.location = Match(T__20); + State = 3610; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateExportedTypeFileDeclaration( + _localctx.name.Value, + _localctx.location); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2853; - Match(T__49); - State = 2854; + State = 3613; + _localctx.location = Match(T__49); + State = 3614; Match(T__39); - State = 2855; - slashedName(); + State = 3615; + _localctx.nestedName = slashedName(); + _localctx.Value = Actions.CreateNestedExportedTypeDeclaration( + _localctx.nestedName.Value, + _localctx.location); } break; case 3: EnterOuterAlt(_localctx, 3); { - State = 2856; - Match(T__24); - State = 2857; + State = 3618; + _localctx.location = Match(T__24); + State = 3619; Match(T__39); - State = 2858; - dottedName(); + State = 3620; + _localctx.assemblyName = dottedName(); + _localctx.Value = Actions.CreateExportedTypeAssemblyDeclaration( + _localctx.assemblyName.Value, + _localctx.location); } break; case 4: EnterOuterAlt(_localctx, 4); { - State = 2859; - mdtoken(); + State = 3623; + _localctx.token = mdtoken(); + _localctx.Value = Actions.CreateExportedTypeMetadataTokenDeclaration( + _localctx.token.Value, + (_localctx.token!=null?(_localctx.token.Start):null)); } break; case 5: EnterOuterAlt(_localctx, 5); { - State = 2860; + State = 3626; Match(T__49); - State = 2861; - int32(); + State = 3627; + _localctx.typeDefinitionId = int32(); + _localctx.Value = Actions.CreateExportedTypeDefinitionIdDeclaration( + (_localctx.typeDefinitionId!=null?(_localctx.typeDefinitionId.Start):null)); } break; case 6: EnterOuterAlt(_localctx, 6); { - State = 2862; - customAttrDecl(); + State = 3630; + _localctx.attribute = customAttrDecl(); + _localctx.Value = Actions.CreateExportedTypeCustomAttributeDeclaration( + _localctx.attribute.Value, + (_localctx.attribute!=null?(_localctx.attribute.Start):null)); } break; case 7: EnterOuterAlt(_localctx, 7); { - State = 2863; + State = 3633; compControl(); } break; @@ -16768,90 +17682,132 @@ public ExptypeDeclContext exptypeDecl() { return _localctx; } + public partial class ManifestResBlockContext : ParserRuleContext { + public CILParser.ManifestResourceValue? Value; + public bool HasSyntaxError; + public int InitialSyntaxErrorCount; + public ManifestResHeadContext header; + public ManifestResDeclsContext declarations; + [System.Diagnostics.DebuggerNonUserCode] public ManifestResHeadContext manifestResHead() { + return GetRuleContext(0); + } + [System.Diagnostics.DebuggerNonUserCode] public ManifestResDeclsContext manifestResDecls() { + return GetRuleContext(0); + } + public ManifestResBlockContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_manifestResBlock; } } + } + + [RuleVersion(0)] + public ManifestResBlockContext manifestResBlock() { + ManifestResBlockContext _localctx = new ManifestResBlockContext(Context, State); + EnterRule(_localctx, 358, RULE_manifestResBlock); + _localctx.InitialSyntaxErrorCount = Actions.SyntaxErrorCount; + try { + EnterOuterAlt(_localctx, 1); + { + State = 3636; + _localctx.header = manifestResHead(); + State = 3637; + Match(T__16); + State = 3638; + _localctx.declarations = manifestResDecls(); + State = 3639; + Match(T__17); + _localctx.Value = Actions.CreateManifestResource( + _localctx.header.Value, + _localctx.declarations.Value); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + + _localctx.HasSyntaxError = + Actions.HasSyntaxErrorsSince(_localctx.InitialSyntaxErrorCount) || + _localctx.exception is not null; + if (_localctx.HasSyntaxError) + { + _localctx.Value = null; + } + + ExitRule(); + } + return _localctx; + } + public partial class ManifestResHeadContext : ParserRuleContext { + public CILParser.ManifestResourceHeaderValue Value; + public IToken head; + public ManresAttrsContext attributes; + public DottedNameContext name; + public DottedNameContext alias; [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MRESOURCE() { return GetToken(CILParser.MRESOURCE, 0); } + [System.Diagnostics.DebuggerNonUserCode] public ManresAttrsContext manresAttrs() { + return GetRuleContext(0); + } [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext[] dottedName() { return GetRuleContexts(); } [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName(int i) { return GetRuleContext(i); } - [System.Diagnostics.DebuggerNonUserCode] public ManresAttrContext[] manresAttr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ManresAttrContext manresAttr(int i) { - return GetRuleContext(i); - } public ManifestResHeadContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_manifestResHead; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitManifestResHead(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ManifestResHeadContext manifestResHead() { ManifestResHeadContext _localctx = new ManifestResHeadContext(Context, State); - EnterRule(_localctx, 362, RULE_manifestResHead); - int _la; + EnterRule(_localctx, 360, RULE_manifestResHead); + _localctx.Value = CILParser.ManifestResourceHeaderValue.Error; try { - State = 2885; + State = 3654; ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,169,Context) ) { + switch ( Interpreter.AdaptivePredict(TokenStream,179,Context) ) { case 1: EnterOuterAlt(_localctx, 1); { - State = 2866; - Match(MRESOURCE); - State = 2870; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==T__50 || _la==T__51) { - { - { - State = 2867; - manresAttr(); - } - } - State = 2872; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 2873; - dottedName(); + State = 3642; + _localctx.head = Match(MRESOURCE); + State = 3643; + _localctx.attributes = manresAttrs(); + State = 3644; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateManifestResourceHeader( + _localctx.attributes.Value, + _localctx.name.Value, + _localctx.name.Value, + _localctx.head); } break; case 2: EnterOuterAlt(_localctx, 2); { - State = 2874; - Match(MRESOURCE); - State = 2878; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==T__50 || _la==T__51) { - { - { - State = 2875; - manresAttr(); - } - } - State = 2880; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 2881; - dottedName(); - State = 2882; + State = 3647; + _localctx.head = Match(MRESOURCE); + State = 3648; + _localctx.attributes = manresAttrs(); + State = 3649; + _localctx.name = dottedName(); + State = 3650; Match(T__33); - State = 2883; - dottedName(); + State = 3651; + _localctx.alias = dottedName(); + _localctx.Value = Actions.CreateManifestResourceHeader( + _localctx.attributes.Value, + _localctx.name.Value, + _localctx.alias.Value, + _localctx.head); } break; } @@ -16867,18 +17823,68 @@ public ManifestResHeadContext manifestResHead() { return _localctx; } + public partial class ManresAttrsContext : ParserRuleContext { + public System.Reflection.ManifestResourceAttributes Value; + public ManresAttrContext attribute; + [System.Diagnostics.DebuggerNonUserCode] public ManresAttrContext[] manresAttr() { + return GetRuleContexts(); + } + [System.Diagnostics.DebuggerNonUserCode] public ManresAttrContext manresAttr(int i) { + return GetRuleContext(i); + } + public ManresAttrsContext(ParserRuleContext parent, int invokingState) + : base(parent, invokingState) + { + } + public override int RuleIndex { get { return RULE_manresAttrs; } } + } + + [RuleVersion(0)] + public ManresAttrsContext manresAttrs() { + ManresAttrsContext _localctx = new ManresAttrsContext(Context, State); + EnterRule(_localctx, 362, RULE_manresAttrs); + _localctx.Value = 0; + int _la; + try { + EnterOuterAlt(_localctx, 1); + { + State = 3661; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + while (_la==T__50 || _la==T__51) { + { + { + State = 3656; + _localctx.attribute = manresAttr(); + _localctx.Value = Actions.AddManifestResourceAttribute( + _localctx.Value, + _localctx.attribute.Value); + } + } + State = 3663; + ErrorHandler.Sync(this); + _la = TokenStream.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + ErrorHandler.ReportError(this, re); + ErrorHandler.Recover(this, re); + } + finally { + ExitRule(); + } + return _localctx; + } + public partial class ManresAttrContext : ParserRuleContext { + public System.Reflection.ManifestResourceAttributes Value; public ManresAttrContext(ParserRuleContext parent, int invokingState) : base(parent, invokingState) { } public override int RuleIndex { get { return RULE_manresAttr; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitManresAttr(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -16889,7 +17895,7 @@ public ManresAttrContext manresAttr() { try { EnterOuterAlt(_localctx, 1); { - State = 2887; + State = 3664; _la = TokenStream.LA(1); if ( !(_la==T__50 || _la==T__51) ) { ErrorHandler.RecoverInline(this); @@ -16899,6 +17905,8 @@ public ManresAttrContext manresAttr() { Consume(); } } + Context.Stop = TokenStream.LT(-1); + _localctx.Value = Actions.ParseManifestResourceAttribute(_localctx.Start); } catch (RecognitionException re) { _localctx.exception = re; @@ -16912,6 +17920,9 @@ public ManresAttrContext manresAttr() { } public partial class ManifestResDeclsContext : ParserRuleContext { + public System.Collections.Immutable.ImmutableArray Value; + public System.Collections.Immutable.ImmutableArray.Builder Builder; + public ManifestResDeclContext declaration; [System.Diagnostics.DebuggerNonUserCode] public ManifestResDeclContext[] manifestResDecl() { return GetRuleContexts(); } @@ -16923,33 +17934,29 @@ public ManifestResDeclsContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_manifestResDecls; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitManifestResDecls(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] public ManifestResDeclsContext manifestResDecls() { ManifestResDeclsContext _localctx = new ManifestResDeclsContext(Context, State); EnterRule(_localctx, 366, RULE_manifestResDecls); + _localctx.Builder = System.Collections.Immutable.ImmutableArray.CreateBuilder(); int _la; try { EnterOuterAlt(_localctx, 1); { - State = 2892; + State = 3671; ErrorHandler.Sync(this); _la = TokenStream.LA(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 38690422784L) != 0) || _la==VALUE || _la==INSTANCE || ((((_la - 264)) & ~0x3f) == 0 && ((1L << (_la - 264)) & 50332665L) != 0)) { { { - State = 2889; - manifestResDecl(); + State = 3666; + _localctx.declaration = manifestResDecl(); + if (_localctx.declaration.Value is not null) _localctx.Builder.Add(_localctx.declaration.Value); } } - State = 2894; + State = 3673; ErrorHandler.Sync(this); _la = TokenStream.LA(1); } @@ -16961,12 +17968,18 @@ public ManifestResDeclsContext manifestResDecls() { ErrorHandler.Recover(this, re); } finally { + _localctx.Value = _localctx.Builder.ToImmutable(); ExitRule(); } return _localctx; } public partial class ManifestResDeclContext : ParserRuleContext { + public CILParser.ManifestResourceDeclarationValue? Value; + public IToken location; + public DottedNameContext name; + public Int32Context offset; + public CustomAttrDeclContext attribute; [System.Diagnostics.DebuggerNonUserCode] public DottedNameContext dottedName() { return GetRuleContext(0); } @@ -16984,12 +17997,6 @@ public ManifestResDeclContext(ParserRuleContext parent, int invokingState) { } public override int RuleIndex { get { return RULE_manifestResDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - ICILVisitor typedVisitor = visitor as ICILVisitor; - if (typedVisitor != null) return typedVisitor.VisitManifestResDecl(this); - else return visitor.VisitChildren(this); - } } [RuleVersion(0)] @@ -16997,31 +18004,36 @@ public ManifestResDeclContext manifestResDecl() { ManifestResDeclContext _localctx = new ManifestResDeclContext(Context, State); EnterRule(_localctx, 368, RULE_manifestResDecl); try { - State = 2905; + State = 3689; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case T__20: EnterOuterAlt(_localctx, 1); { - State = 2895; - Match(T__20); - State = 2896; - dottedName(); - State = 2897; + State = 3674; + _localctx.location = Match(T__20); + State = 3675; + _localctx.name = dottedName(); + State = 3676; Match(T__43); - State = 2898; - int32(); + State = 3677; + _localctx.offset = int32(); + _localctx.Value = Actions.CreateManifestResourceFileDeclaration( + _localctx.name.Value, + (_localctx.offset!=null?(_localctx.offset.Start):null), + _localctx.location); } break; case T__24: EnterOuterAlt(_localctx, 2); { - State = 2900; + State = 3680; Match(T__24); - State = 2901; + State = 3681; Match(T__39); - State = 2902; - dottedName(); + State = 3682; + _localctx.name = dottedName(); + _localctx.Value = Actions.CreateManifestResourceAssemblyDeclaration(_localctx.name.Value); } break; case T__15: @@ -17033,8 +18045,11 @@ public ManifestResDeclContext manifestResDecl() { case ID: EnterOuterAlt(_localctx, 3); { - State = 2903; - customAttrDecl(); + State = 3685; + _localctx.attribute = customAttrDecl(); + _localctx.Value = Actions.CreateManifestResourceCustomAttributeDeclaration( + _localctx.attribute.Value, + (_localctx.attribute!=null?(_localctx.attribute.Start):null)); } break; case T__31: @@ -17047,7 +18062,7 @@ public ManifestResDeclContext manifestResDecl() { case PP_INCLUDE: EnterOuterAlt(_localctx, 4); { - State = 2904; + State = 3688; compControl(); } break; @@ -17066,25 +18081,8 @@ public ManifestResDeclContext manifestResDecl() { return _localctx; } - public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) { - switch (ruleIndex) { - case 34: return vtfixupAttr_sempred((VtfixupAttrContext)_localctx, predIndex); - } - return true; - } - private bool vtfixupAttr_sempred(VtfixupAttrContext _localctx, int predIndex) { - switch (predIndex) { - case 0: return Precpred(Context, 5); - case 1: return Precpred(Context, 4); - case 2: return Precpred(Context, 3); - case 3: return Precpred(Context, 2); - case 4: return Precpred(Context, 1); - } - return true; - } - private static int[] _serializedATN = { - 4,1,305,2908,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2, + 4,1,305,3692,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2, 7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14, 2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,7,21, 2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,7,28, @@ -17112,1102 +18110,1386 @@ private bool vtfixupAttr_sempred(VtfixupAttrContext _localctx, int predIndex) { 2,165,7,165,2,166,7,166,2,167,7,167,2,168,7,168,2,169,7,169,2,170,7,170, 2,171,7,171,2,172,7,172,2,173,7,173,2,174,7,174,2,175,7,175,2,176,7,176, 2,177,7,177,2,178,7,178,2,179,7,179,2,180,7,180,2,181,7,181,2,182,7,182, - 2,183,7,183,2,184,7,184,1,0,1,0,1,1,1,1,1,1,1,1,5,1,377,8,1,10,1,12,1, - 380,9,1,1,1,1,1,3,1,384,8,1,1,2,1,2,1,3,1,3,5,3,390,8,3,10,3,12,3,393, - 9,3,1,3,1,3,1,4,5,4,398,8,4,10,4,12,4,401,9,4,1,5,1,5,1,5,1,5,1,5,1,5, + 2,183,7,183,2,184,7,184,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,5,1,379,8,1,10, + 1,12,1,382,9,1,1,1,1,1,1,1,1,1,1,1,3,1,389,8,1,1,2,1,2,1,3,1,3,1,3,5,3, + 396,8,3,10,3,12,3,399,9,3,1,3,1,3,1,3,1,4,5,4,405,8,4,10,4,12,4,408,9, + 4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5, 1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1, 5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5, - 1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,453,8,5,1,6,1,6,1,6,1,7,1,7,1, - 7,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11, - 1,11,1,11,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13, - 1,13,1,13,1,13,1,13,3,13,494,8,13,1,14,1,14,1,15,1,15,1,15,5,15,501,8, - 15,10,15,12,15,504,9,15,1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,18,1, - 18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,527,8,18, - 1,19,1,19,3,19,531,8,19,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1, - 20,1,20,1,20,1,20,1,20,1,20,1,20,3,20,549,8,20,1,21,1,21,1,21,1,21,1,21, + 1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1, + 5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5, + 496,8,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1, + 9,1,9,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,12, + 1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13,1,13, + 1,13,1,13,1,13,1,13,1,13,3,13,547,8,13,1,14,1,14,1,15,1,15,1,15,1,15,1, + 15,5,15,556,8,15,10,15,12,15,559,9,15,1,15,1,15,1,16,1,16,1,17,1,17,1, + 18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1,18,1, + 18,1,18,1,18,1,18,1,18,1,18,1,18,3,18,588,8,18,1,19,1,19,1,19,1,19,1,19, + 3,19,595,8,19,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1,20,1, + 20,1,20,1,20,1,20,1,20,3,20,613,8,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21, 1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21, - 1,21,1,21,1,21,1,21,1,21,1,21,3,21,576,8,21,1,22,1,22,1,22,1,22,1,22,1, + 1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21,3,21,645,8,21,1,22,1,22,1, 22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1, - 22,1,22,3,22,599,8,22,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23, + 22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,1,22,3,22,673,8,22,1,23,1,23, 1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23, - 1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,635,8,23,1,24,1, - 24,1,25,1,25,3,25,641,8,25,1,26,1,26,1,26,1,27,1,27,5,27,648,8,27,10,27, - 12,27,651,9,27,1,28,1,28,1,28,1,28,1,28,1,28,1,28,5,28,660,8,28,10,28, - 12,28,663,9,28,1,29,1,29,1,30,1,30,3,30,669,8,30,1,31,1,31,1,31,1,31,1, - 31,1,31,1,31,1,31,1,31,3,31,680,8,31,1,32,1,32,1,32,1,32,1,32,1,32,3,32, - 688,8,32,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,1,34,1, - 34,1,34,1,34,1,34,1,34,1,34,1,34,5,34,709,8,34,10,34,12,34,712,9,34,1, - 35,1,35,1,35,1,35,1,35,1,35,1,36,1,36,1,36,1,37,1,37,5,37,725,8,37,10, - 37,12,37,728,9,37,1,37,1,37,1,37,1,37,1,37,1,38,1,38,1,38,1,38,1,38,1, - 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, - 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, - 38,1,38,1,38,1,38,3,38,772,8,38,1,39,1,39,1,39,3,39,777,8,39,1,40,1,40, - 1,40,3,40,782,8,40,1,41,5,41,785,8,41,10,41,12,41,788,9,41,1,42,1,42,1, - 42,5,42,793,8,42,10,42,12,42,796,9,42,1,42,1,42,1,43,1,43,1,44,1,44,1, - 44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1, - 44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1, - 44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1, - 44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1, - 44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1, - 44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1, - 44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1,44,1, - 44,1,44,1,44,3,44,905,8,44,1,45,1,45,5,45,909,8,45,10,45,12,45,912,9,45, - 1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,5,45,925,8,45,10, - 45,12,45,928,9,45,1,45,1,45,1,45,3,45,933,8,45,1,46,1,46,1,47,1,47,3,47, - 939,8,47,1,48,1,48,1,49,5,49,944,8,49,10,49,12,49,947,9,49,1,50,1,50,1, - 51,1,51,1,52,1,52,1,53,1,53,1,54,1,54,1,55,1,55,1,56,1,56,1,57,1,57,1, - 58,1,58,1,59,1,59,1,60,1,60,1,61,1,61,1,62,1,62,1,63,1,63,1,63,1,63,1, - 63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1, - 63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1, - 63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1, - 63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1, - 63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1, - 63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,3,63,1057,8,63,1,64,1,64,1,64,3, - 64,1062,8,64,1,64,1,64,5,64,1066,8,64,10,64,12,64,1069,9,64,1,64,1,64, - 3,64,1073,8,64,3,64,1075,8,64,1,65,1,65,1,65,1,65,5,65,1081,8,65,10,65, - 12,65,1084,9,65,1,65,1,65,1,65,1,66,1,66,1,66,1,66,5,66,1093,8,66,10,66, - 12,66,1096,9,66,1,66,1,66,1,66,1,67,1,67,1,67,1,67,5,67,1105,8,67,10,67, - 12,67,1108,9,67,1,67,1,67,1,67,1,67,3,67,1114,8,67,1,68,1,68,1,68,1,68, - 1,68,3,68,1121,8,68,3,68,1123,8,68,1,69,1,69,1,69,1,69,1,69,1,69,1,69, + 1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23, + 1,23,1,23,1,23,1,23,1,23,1,23,1,23,1,23,3,23,713,8,23,1,24,1,24,1,24,1, + 25,1,25,1,25,1,25,1,25,1,25,3,25,724,8,25,1,26,1,26,1,26,1,26,1,27,1,27, + 1,27,1,27,5,27,734,8,27,10,27,12,27,737,9,27,1,28,1,28,1,28,1,28,1,28, + 1,28,1,28,1,28,5,28,747,8,28,10,28,12,28,750,9,28,1,29,1,29,1,29,1,30, + 1,30,3,30,757,8,30,1,30,1,30,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1, + 31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,1,31,3,31,779,8,31,1,32,1,32, + 1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,3,32,792,8,32,1,33,1,33,1, + 33,1,33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,34,5,34,806,8,34,10,34,12, + 34,809,9,34,1,34,1,34,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36,1,37, + 1,37,1,37,1,37,1,38,1,38,1,38,1,38,5,38,830,8,38,10,38,12,38,833,9,38, + 1,38,1,38,1,38,1,38,1,38,1,38,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, + 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, + 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, + 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, + 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, + 3,39,905,8,39,1,40,1,40,1,40,1,40,1,40,3,40,912,8,40,1,41,1,41,1,41,1, + 41,1,41,3,41,919,8,41,1,42,5,42,922,8,42,10,42,12,42,925,9,42,1,43,1,43, + 1,43,1,43,5,43,931,8,43,10,43,12,43,934,9,43,1,43,1,43,1,43,1,44,1,44, + 1,45,1,45,1,45,3,45,944,8,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,3,45,953, + 8,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,3,45,964,8,45,1,45,1, + 45,1,45,1,45,1,45,1,45,1,45,1,45,1,45,3,45,975,8,45,1,45,1,45,1,45,1,45, + 1,45,1,45,1,45,1,45,1,45,1,45,1,45,3,45,988,8,45,1,45,1,45,3,45,992,8, + 45,1,46,1,46,1,46,1,46,5,46,998,8,46,10,46,12,46,1001,9,46,1,46,1,46,1, + 46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,1,46,3,46,1016,8,46,1, + 47,1,47,1,48,1,48,1,48,3,48,1023,8,48,1,49,1,49,1,50,1,50,1,50,5,50,1030, + 8,50,10,50,12,50,1033,9,50,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51, + 1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51,1,51, + 1,51,1,51,3,51,1060,8,51,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52, + 1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52, + 1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52, + 1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52, + 1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52, + 1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,1,52,3,52,1138,8,52, + 3,52,1140,8,52,1,53,1,53,1,53,1,53,1,53,1,54,1,54,1,54,1,54,1,54,1,54, + 1,54,3,54,1154,8,54,1,54,1,54,5,54,1158,8,54,10,54,12,54,1161,9,54,1,54, + 1,54,1,54,1,54,1,54,1,54,3,54,1169,8,54,3,54,1171,8,54,1,55,1,55,1,55, + 1,55,1,55,5,55,1178,8,55,10,55,12,55,1181,9,55,1,55,1,55,1,55,1,55,1,56, + 1,56,1,56,1,56,1,56,5,56,1192,8,56,10,56,12,56,1195,9,56,1,56,1,56,1,56, + 1,56,1,57,1,57,1,57,1,57,1,57,5,57,1206,8,57,10,57,12,57,1209,9,57,1,57, + 1,57,1,57,1,57,1,57,3,57,1216,8,57,1,58,1,58,1,58,1,58,1,58,1,58,3,58, + 1224,8,58,1,58,1,58,3,58,1228,8,58,1,59,1,59,1,59,1,59,1,59,1,59,1,59, + 1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59, + 1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59,1,59, + 1,59,1,59,3,59,1267,8,59,1,60,1,60,1,60,1,60,5,60,1273,8,60,10,60,12,60, + 1276,9,60,1,60,1,60,1,60,1,61,1,61,1,61,5,61,1284,8,61,10,61,12,61,1287, + 9,61,1,62,1,62,1,62,1,62,1,62,1,62,1,62,1,62,1,62,1,62,1,62,3,62,1300, + 8,62,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63,1,63, + 1,63,1,63,1,63,1,63,3,63,1319,8,63,1,64,1,64,1,64,1,64,1,64,1,64,5,64, + 1327,8,64,10,64,12,64,1330,9,64,3,64,1332,8,64,1,65,1,65,1,65,1,65,1,65, + 1,65,1,65,1,65,1,65,1,65,1,65,1,65,1,65,1,65,1,65,1,65,1,65,1,65,1,65, + 1,65,1,65,1,65,3,65,1356,8,65,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66, + 1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,1,66,3,66,1503,8,66, + 1,67,1,67,1,67,1,67,1,67,1,67,1,67,1,67,3,67,1513,8,67,1,68,1,68,1,68, + 1,68,1,68,5,68,1520,8,68,10,68,12,68,1523,9,68,3,68,1525,8,68,1,69,1,69, + 1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69, 1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69, - 1,69,1,69,1,69,1,69,3,69,1150,8,69,1,70,1,70,1,70,5,70,1155,8,70,10,70, - 12,70,1158,9,70,1,70,1,70,1,71,5,71,1163,8,71,10,71,12,71,1166,9,71,1, - 72,1,72,1,72,1,72,1,72,3,72,1173,8,72,1,73,1,73,1,73,1,73,1,73,1,73,1, - 73,1,73,1,73,1,73,1,73,3,73,1186,8,73,1,74,1,74,1,74,5,74,1191,8,74,10, - 74,12,74,1194,9,74,3,74,1196,8,74,1,75,1,75,1,75,1,75,1,75,1,75,1,75,1, - 75,1,75,1,75,1,75,1,75,1,75,1,75,1,75,1,75,1,75,3,75,1215,8,75,1,76,1, - 76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1, - 76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1, - 76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1, - 76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1, - 76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1, - 76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1, - 76,1,76,1,76,1,76,1,76,1,76,1,76,3,76,1309,8,76,1,77,1,77,1,77,1,77,1, - 77,1,77,1,77,3,77,1318,8,77,1,78,1,78,1,78,5,78,1323,8,78,10,78,12,78, - 1326,9,78,3,78,1328,8,78,1,79,1,79,1,80,1,80,5,80,1334,8,80,10,80,12,80, - 1337,9,80,1,81,1,81,1,81,1,81,1,81,1,81,1,81,1,81,1,81,1,81,1,81,1,81, - 1,81,1,81,1,81,1,81,1,81,1,81,3,81,1357,8,81,1,82,1,82,1,82,1,82,1,82, - 1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82, - 1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,1,82,3,82,1389,8,82, + 1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69, + 1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69, + 1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69, + 1,69,1,69,1,69,1,69,1,69,1,69,1,69,1,69,3,69,1607,8,69,1,70,1,70,1,70, + 1,70,1,70,5,70,1614,8,70,10,70,12,70,1617,9,70,1,71,1,71,1,71,1,71,1,71, + 1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71, + 1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,1,71,3,71,1648,8,71,1,72, + 1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72, + 1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72, + 1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72, + 1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72,1,72, + 1,72,3,72,1708,8,72,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73, + 1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73, + 1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73,1,73, + 3,73,1748,8,73,1,74,1,74,1,74,1,74,1,74,1,74,1,74,1,74,1,74,1,74,1,74, + 1,74,1,74,1,74,3,74,1764,8,74,1,75,1,75,1,75,1,75,1,76,1,76,1,76,1,76, + 3,76,1774,8,76,1,76,1,76,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77, + 1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77, + 1,77,1,77,1,77,3,77,1804,8,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77, + 1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77,1,77, + 1,77,1,77,1,77,1,77,3,77,1832,8,77,1,78,1,78,1,78,1,78,1,78,5,78,1839, + 8,78,10,78,12,78,1842,9,78,1,78,1,78,1,78,3,78,1847,8,78,1,79,1,79,1,79, + 1,79,1,79,1,79,1,79,1,79,1,79,1,79,1,79,1,79,1,79,1,79,1,79,3,79,1864, + 8,79,1,80,1,80,1,80,1,80,5,80,1870,8,80,10,80,12,80,1873,9,80,1,80,1,80, + 1,80,1,81,1,81,1,81,1,81,1,81,1,82,1,82,1,83,1,83,1,83,1,83,1,83,1,83, + 1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83, 1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83, - 1,83,1,83,1,83,1,83,1,83,1,83,1,83,3,83,1412,8,83,1,84,1,84,1,84,1,84, - 1,84,1,84,1,84,1,84,1,84,1,84,3,84,1424,8,84,1,85,1,85,1,85,1,86,1,86, - 1,86,1,86,3,86,1433,8,86,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87, + 1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,1,83,3,83,1930,8,83, + 1,84,1,84,1,85,1,85,1,85,1,85,1,85,1,85,3,85,1940,8,85,1,85,1,85,1,85, + 1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,3,85, + 1958,8,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85,1,85, + 1,85,1,85,1,85,1,85,3,85,1976,8,85,1,86,1,86,1,86,1,86,1,86,1,86,1,86, + 1,86,1,86,1,86,1,86,1,86,1,86,1,86,1,86,1,86,1,86,3,86,1995,8,86,1,87, 1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87, - 3,87,1458,8,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87, - 1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,1,87,3,87,1482,8,87, - 1,88,1,88,1,88,1,88,5,88,1488,8,88,10,88,12,88,1491,9,88,1,88,3,88,1494, - 8,88,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89, - 3,89,1509,8,89,1,90,1,90,1,90,5,90,1514,8,90,10,90,12,90,1517,9,90,1,90, - 1,90,1,91,1,91,1,91,1,91,1,92,1,92,1,93,1,93,1,93,1,93,1,93,1,93,1,93, + 1,87,1,87,1,87,1,87,3,87,2016,8,87,1,88,1,88,1,88,1,88,1,88,1,88,1,89, + 1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,1,89,3,89,2035,8,89,1,90, + 1,90,1,90,1,90,1,90,1,90,1,90,1,90,1,90,1,90,1,90,1,90,1,90,3,90,2050, + 8,90,1,91,1,91,1,91,1,91,5,91,2056,8,91,10,91,12,91,2059,9,91,1,91,1,91, + 1,91,1,92,1,92,1,92,1,92,1,92,1,92,3,92,2070,8,92,1,93,1,93,1,93,1,93, 1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93, - 1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,1,93,3,93, - 1561,8,93,1,94,1,94,1,95,1,95,1,95,1,95,1,95,1,95,3,95,1571,8,95,1,95, - 1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,3,95, - 1587,8,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,1,95,3,95,1599, - 8,95,1,96,1,96,1,96,1,96,1,96,1,96,1,96,1,96,1,96,1,96,3,96,1611,8,96, - 1,97,1,97,1,97,1,97,1,97,1,97,1,97,1,97,1,97,1,97,1,97,1,97,3,97,1625, - 8,97,1,98,1,98,1,98,1,98,1,98,1,99,1,99,1,99,1,99,1,99,3,99,1637,8,99, - 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,3,100,1648,8,100, - 1,101,1,101,1,101,5,101,1653,8,101,10,101,12,101,1656,9,101,1,101,1,101, - 1,102,1,102,1,102,1,102,1,102,3,102,1665,8,102,1,103,1,103,1,103,1,103, - 1,103,1,103,1,103,1,103,1,103,1,103,1,103,3,103,1678,8,103,1,104,5,104, - 1681,8,104,10,104,12,104,1684,9,104,1,105,1,105,3,105,1688,8,105,1,105, - 1,105,1,106,1,106,1,106,5,106,1695,8,106,10,106,12,106,1698,9,106,1,106, - 1,106,1,107,1,107,1,107,1,107,1,108,1,108,3,108,1708,8,108,1,109,1,109, - 1,109,1,109,1,109,1,109,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110, - 1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110, - 1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110, - 1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110, - 1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110, - 1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110,1,110, - 1,110,1,110,1,110,1,110,1,110,5,110,1789,8,110,10,110,12,110,1792,9,110, - 1,110,1,110,1,110,1,110,5,110,1798,8,110,10,110,12,110,1801,9,110,1,110, - 1,110,1,110,1,110,1,110,1,110,1,110,1,110,5,110,1811,8,110,10,110,12,110, - 1814,9,110,1,110,1,110,1,110,1,110,1,110,1,110,5,110,1822,8,110,10,110, - 12,110,1825,9,110,1,110,1,110,1,110,1,110,1,110,3,110,1832,8,110,1,111, - 1,111,1,111,1,111,1,111,1,111,1,111,1,111,5,111,1842,8,111,10,111,12,111, - 1845,9,111,1,111,1,111,1,111,1,111,1,111,1,112,1,112,1,112,1,112,1,112, - 1,112,1,112,1,112,1,112,1,112,1,112,1,112,1,112,1,112,1,112,1,112,1,112, - 1,112,1,112,3,112,1871,8,112,1,113,1,113,1,113,1,113,1,113,3,113,1878, - 8,113,1,114,1,114,1,114,3,114,1883,8,114,1,115,1,115,1,115,1,115,1,115, - 3,115,1890,8,115,1,116,1,116,5,116,1894,8,116,10,116,12,116,1897,9,116, - 1,116,1,116,1,116,1,116,1,116,5,116,1904,8,116,10,116,12,116,1907,9,116, - 1,116,3,116,1910,8,116,1,117,1,117,1,118,5,118,1915,8,118,10,118,12,118, - 1918,9,118,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119, - 1,119,1,119,3,119,1932,8,119,1,120,1,120,5,120,1936,8,120,10,120,12,120, - 1939,9,120,1,120,1,120,1,120,1,120,1,120,1,120,1,121,1,121,1,122,5,122, - 1950,8,122,10,122,12,122,1953,9,122,1,123,1,123,1,123,1,123,1,123,1,123, - 1,123,1,123,1,123,1,123,3,123,1965,8,123,1,124,1,124,1,124,1,124,1,124, - 1,124,3,124,1973,8,124,1,125,1,125,1,125,4,125,1978,8,125,11,125,12,125, - 1979,1,125,1,125,3,125,1984,8,125,1,126,5,126,1987,8,126,10,126,12,126, - 1990,9,126,1,127,1,127,1,127,1,127,1,127,1,127,1,127,1,127,1,127,1,127, - 1,127,1,127,1,127,3,127,2005,8,127,1,128,1,128,1,128,5,128,2010,8,128, - 10,128,12,128,2013,9,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128,1,128, - 5,128,2023,8,128,10,128,12,128,2026,9,128,1,129,1,129,1,129,1,129,1,129, - 1,129,1,129,1,129,1,129,1,129,1,129,1,129,1,129,1,129,1,129,1,129,1,129, - 1,129,1,129,1,129,1,129,1,129,1,129,3,129,2051,8,129,1,130,1,130,1,130, - 1,130,1,130,3,130,2058,8,130,3,130,2060,8,130,1,130,5,130,2063,8,130,10, - 130,12,130,2066,9,130,1,130,1,130,1,130,3,130,2071,8,130,1,131,1,131,1, - 131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131, - 1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131,1,131, - 1,131,3,131,2100,8,131,1,132,1,132,1,132,3,132,2105,8,132,1,133,1,133, - 1,133,1,133,1,133,1,133,1,133,1,133,1,133,1,133,1,133,1,133,1,133,1,133, - 1,133,1,133,1,133,1,133,1,133,1,133,1,133,3,133,2128,8,133,1,134,5,134, - 2131,8,134,10,134,12,134,2134,9,134,1,135,1,135,1,135,1,135,1,135,1,135, - 1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135, - 1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135, - 1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135, - 1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135,1,135, - 1,135,1,135,1,135,1,135,1,135,5,135,2195,8,135,10,135,12,135,2198,9,135, - 1,135,1,135,1,135,1,135,5,135,2204,8,135,10,135,12,135,2207,9,135,1,135, - 1,135,1,135,1,135,1,135,1,135,1,135,1,135,5,135,2217,8,135,10,135,12,135, - 2220,9,135,1,135,1,135,1,135,1,135,1,135,1,135,5,135,2228,8,135,10,135, - 12,135,2231,9,135,1,135,1,135,1,135,1,135,1,135,1,135,5,135,2239,8,135, - 10,135,12,135,2242,9,135,3,135,2244,8,135,1,136,1,136,1,136,1,137,1,137, - 3,137,2251,8,137,1,138,1,138,1,138,1,138,1,139,1,139,1,139,1,140,4,140, - 2261,8,140,11,140,12,140,2262,1,141,1,141,1,141,1,141,1,141,1,141,1,141, - 1,141,1,141,1,141,1,141,1,141,3,141,2277,8,141,1,142,1,142,1,142,1,142, - 1,142,1,142,1,142,1,142,1,142,1,142,1,142,1,142,3,142,2291,8,142,1,143, - 1,143,1,143,1,143,1,143,1,143,3,143,2299,8,143,1,144,1,144,1,144,1,145, - 1,145,1,146,1,146,1,147,1,147,1,147,1,147,1,147,1,147,1,147,1,147,1,147, - 1,147,1,147,3,147,2319,8,147,1,148,1,148,1,148,1,149,1,149,1,149,1,149, - 1,149,1,149,1,149,3,149,2331,8,149,1,150,1,150,1,150,3,150,2336,8,150, - 1,151,1,151,1,151,1,151,1,151,4,151,2343,8,151,11,151,12,151,2344,3,151, - 2347,8,151,1,152,1,152,1,152,5,152,2352,8,152,10,152,12,152,2355,9,152, - 1,152,1,152,1,153,1,153,1,153,1,153,1,153,3,153,2364,8,153,1,154,1,154, + 3,93,2090,8,93,1,94,1,94,1,94,5,94,2095,8,94,10,94,12,94,2098,9,94,1,95, + 1,95,3,95,2102,8,95,1,95,1,95,1,95,1,96,1,96,1,96,1,96,5,96,2111,8,96, + 10,96,12,96,2114,9,96,1,96,1,96,1,96,1,97,1,97,1,97,1,97,1,97,1,98,3,98, + 2125,8,98,1,98,1,98,1,99,1,99,1,99,1,99,1,99,1,99,1,99,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,5,100,2233, + 8,100,10,100,12,100,2236,9,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100, + 5,100,2245,8,100,10,100,12,100,2248,9,100,1,100,1,100,1,100,1,100,1,100, + 1,100,1,100,1,100,1,100,1,100,1,100,5,100,2261,8,100,10,100,12,100,2264, + 9,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,1,100,5,100,2275, + 8,100,10,100,12,100,2278,9,100,1,100,1,100,1,100,1,100,1,100,1,100,3,100, + 2286,8,100,1,101,1,101,1,101,1,101,1,101,1,101,1,101,1,101,1,101,1,101, + 1,101,5,101,2299,8,101,10,101,12,101,2302,9,101,1,101,1,101,1,101,1,101, + 1,101,1,101,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102, + 1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102, + 1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102,1,102, + 3,102,2344,8,102,1,103,1,103,1,103,1,103,1,103,1,103,1,103,1,103,1,103, + 3,103,2355,8,103,1,104,1,104,1,104,1,104,1,104,3,104,2362,8,104,1,105, + 1,105,1,105,1,105,1,105,1,105,3,105,2370,8,105,1,106,1,106,1,106,1,106, + 5,106,2376,8,106,10,106,12,106,2379,9,106,1,106,1,106,1,106,1,106,1,106, + 1,106,1,106,1,106,5,106,2389,8,106,10,106,12,106,2392,9,106,1,106,1,106, + 1,106,3,106,2397,8,106,1,107,1,107,1,107,1,107,3,107,2403,8,107,1,108, + 5,108,2406,8,108,10,108,12,108,2409,9,108,1,109,1,109,1,109,1,109,1,109, + 1,109,1,109,1,109,1,109,1,109,1,109,1,109,1,109,1,109,1,109,1,109,1,109, + 1,109,1,109,1,109,1,109,1,109,1,109,1,109,1,109,1,109,3,109,2437,8,109, + 1,110,1,110,1,110,1,110,5,110,2443,8,110,10,110,12,110,2446,9,110,1,110, + 1,110,1,110,1,110,1,110,1,110,1,110,1,111,1,111,1,111,1,111,3,111,2459, + 8,111,1,112,5,112,2462,8,112,10,112,12,112,2465,9,112,1,113,1,113,1,113, + 1,113,1,113,1,113,1,113,1,113,1,113,1,113,1,113,1,113,1,113,1,113,1,113, + 1,113,1,113,1,113,1,113,1,113,1,113,1,113,3,113,2489,8,113,1,114,1,114, + 1,114,1,114,1,114,1,114,1,114,3,114,2498,8,114,1,115,1,115,1,115,1,115, + 1,115,1,115,1,115,4,115,2507,8,115,11,115,12,115,2508,1,115,1,115,3,115, + 2513,8,115,1,116,1,116,1,116,5,116,2518,8,116,10,116,12,116,2521,9,116, + 1,117,1,117,1,117,1,117,1,117,1,117,1,117,1,117,1,117,1,117,1,117,1,117, + 1,117,1,117,1,117,1,117,1,117,3,117,2540,8,117,1,118,1,118,1,118,1,118, + 1,118,1,118,1,118,5,118,2549,8,118,10,118,12,118,2552,9,118,1,118,1,118, + 1,118,1,118,1,118,1,118,1,118,1,118,1,118,1,118,5,118,2564,8,118,10,118, + 12,118,2567,9,118,1,118,1,118,1,119,1,119,1,119,1,119,1,119,1,119,1,119, + 1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119, + 1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119, + 1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,1,119,3,119, + 2613,8,119,1,120,1,120,1,120,1,120,1,120,1,120,1,120,1,120,3,120,2623, + 8,120,3,120,2625,8,120,1,120,1,120,1,120,5,120,2630,8,120,10,120,12,120, + 2633,9,120,1,120,1,120,1,120,3,120,2638,8,120,1,121,1,121,1,121,1,121, + 1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121, + 1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121, + 1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121,1,121, + 1,121,1,121,3,121,2682,8,121,1,122,1,122,1,122,1,122,1,122,1,122,1,122, + 3,122,2691,8,122,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123, + 1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123, + 1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123,1,123, + 1,123,1,123,1,123,1,123,1,123,3,123,2731,8,123,1,124,5,124,2734,8,124, + 10,124,12,124,2737,9,124,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125, + 1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125, + 1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125,1,125, + 1,125,1,125,1,125,1,125,1,125,3,125,2776,8,125,1,126,1,126,3,126,2780, + 8,126,1,126,1,126,1,127,1,127,1,127,1,127,1,127,1,127,3,127,2790,8,127, + 1,128,1,128,1,128,1,128,1,128,1,129,1,129,1,129,1,129,1,129,1,129,1,129, + 1,129,1,129,1,129,1,129,1,129,1,129,1,129,1,129,3,129,2812,8,129,1,130, + 1,130,1,130,1,130,1,130,1,130,1,130,1,130,5,130,2822,8,130,10,130,12,130, + 2825,9,130,1,130,1,130,1,130,1,130,1,130,1,130,5,130,2833,8,130,10,130, + 12,130,2836,9,130,1,130,1,130,1,130,1,130,1,130,1,130,1,130,1,130,1,130, + 1,130,5,130,2848,8,130,10,130,12,130,2851,9,130,1,130,1,130,1,130,1,130, + 1,130,1,130,1,130,1,130,5,130,2861,8,130,10,130,12,130,2864,9,130,1,130, + 1,130,1,130,1,130,1,130,1,130,1,130,1,130,5,130,2874,8,130,10,130,12,130, + 2877,9,130,3,130,2879,8,130,1,131,1,131,1,131,1,131,1,132,1,132,1,132, + 1,132,1,132,1,132,3,132,2891,8,132,1,133,1,133,1,133,1,133,1,134,1,134, + 1,134,1,135,1,135,1,135,4,135,2903,8,135,11,135,12,135,2904,1,136,1,136, + 1,136,1,136,1,136,1,136,1,136,1,136,1,136,1,136,1,136,1,136,1,136,1,136, + 1,136,1,136,3,136,2923,8,136,1,137,1,137,1,137,1,137,1,137,1,137,1,137, + 1,137,1,137,1,137,1,137,1,137,1,137,1,137,1,137,1,137,3,137,2941,8,137, + 1,138,1,138,1,138,1,138,1,138,1,138,1,138,1,138,1,138,1,138,1,138,1,138, + 3,138,2955,8,138,1,139,1,139,1,139,1,140,1,140,1,141,1,141,1,142,1,142, + 1,142,1,142,1,142,1,142,1,142,1,142,1,142,1,142,1,142,1,142,1,142,1,142, + 1,142,3,142,2979,8,142,1,143,1,143,1,143,1,144,1,144,1,144,1,144,1,144, + 1,144,1,144,1,144,1,144,1,144,3,144,2994,8,144,1,145,1,145,1,145,1,145, + 1,145,3,145,3001,8,145,1,146,1,146,1,146,1,146,1,146,4,146,3008,8,146, + 11,146,12,146,3009,3,146,3012,8,146,1,147,1,147,1,147,5,147,3017,8,147, + 10,147,12,147,3020,9,147,1,147,1,147,1,148,1,148,1,148,1,148,1,148,1,148, + 3,148,3030,8,148,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149, + 1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149, + 1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149, + 1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149,1,149, + 1,149,1,149,1,149,3,149,3080,8,149,1,150,1,150,1,150,1,150,1,150,1,150, + 1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150, + 1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150, + 1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150, + 1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150, + 1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150, + 1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150, + 1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150,1,150, + 3,150,3172,8,150,1,151,1,151,1,151,5,151,3177,8,151,10,151,12,151,3180, + 9,151,1,152,1,152,1,153,1,153,1,153,1,153,1,153,1,153,1,153,1,153,3,153, + 3192,8,153,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, + 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, 1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154,1,154, - 1,154,1,154,1,154,1,154,3,154,2432,8,154,1,155,1,155,1,155,1,155,1,155, - 1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155, - 1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155, - 1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155, - 1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155, - 1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155, - 1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,1,155,3,155,2509, - 8,155,1,156,5,156,2512,8,156,10,156,12,156,2515,9,156,1,157,1,157,1,158, - 1,158,1,158,3,158,2522,8,158,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159, - 1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,1,159,3,159,2672,8,159, - 1,160,1,160,5,160,2676,8,160,10,160,12,160,2679,9,160,1,161,1,161,5,161, - 2683,8,161,10,161,12,161,2686,9,161,1,162,5,162,2689,8,162,10,162,12,162, - 2692,9,162,1,163,5,163,2695,8,163,10,163,12,163,2698,9,163,1,164,5,164, - 2701,8,164,10,164,12,164,2704,9,164,1,165,5,165,2707,8,165,10,165,12,165, - 2710,9,165,1,166,5,166,2713,8,166,10,166,12,166,2716,9,166,1,167,5,167, - 2719,8,167,10,167,12,167,2722,9,167,1,168,5,168,2725,8,168,10,168,12,168, - 2728,9,168,1,169,1,169,1,169,1,169,3,169,2734,8,169,1,170,5,170,2737,8, - 170,10,170,12,170,2740,9,170,1,171,1,171,1,171,3,171,2745,8,171,1,172, - 1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172, - 1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172,1,172, - 3,172,2772,8,172,1,173,1,173,1,173,1,173,1,173,1,173,1,173,1,173,1,173, - 1,173,1,173,1,173,3,173,2786,8,173,1,174,5,174,2789,8,174,10,174,12,174, - 2792,9,174,1,175,1,175,1,175,1,175,1,175,1,175,1,175,1,175,1,175,1,175, - 1,175,1,175,1,175,1,175,3,175,2808,8,175,1,176,1,176,1,176,5,176,2813, - 8,176,10,176,12,176,2816,9,176,1,176,1,176,1,177,1,177,5,177,2822,8,177, - 10,177,12,177,2825,9,177,1,177,1,177,1,178,1,178,1,178,1,178,1,178,1,178, - 1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,3,178,2844,8,178, - 1,179,5,179,2847,8,179,10,179,12,179,2850,9,179,1,180,1,180,1,180,1,180, - 1,180,1,180,1,180,1,180,1,180,1,180,1,180,1,180,1,180,3,180,2865,8,180, - 1,181,1,181,5,181,2869,8,181,10,181,12,181,2872,9,181,1,181,1,181,1,181, - 5,181,2877,8,181,10,181,12,181,2880,9,181,1,181,1,181,1,181,1,181,3,181, - 2886,8,181,1,182,1,182,1,183,5,183,2891,8,183,10,183,12,183,2894,9,183, - 1,184,1,184,1,184,1,184,1,184,1,184,1,184,1,184,1,184,1,184,3,184,2906, - 8,184,1,184,0,1,68,185,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34, - 36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82, - 84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122, - 124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158, - 160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194, - 196,198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230, - 232,234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266, - 268,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302, - 304,306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338, - 340,342,344,346,348,350,352,354,356,358,360,362,364,366,368,0,16,6,0,1, - 15,199,199,243,243,247,247,264,264,289,289,5,0,16,16,199,199,243,243,264, - 264,288,289,1,0,263,264,1,0,173,174,1,0,37,38,1,0,73,74,3,0,2,2,61,61, - 77,83,2,0,229,229,260,261,9,0,178,178,183,195,201,201,207,208,210,215, - 218,219,222,222,230,242,262,262,1,0,95,96,1,0,97,111,1,0,68,69,2,0,173, - 173,289,290,2,0,179,179,264,264,1,0,167,168,1,0,51,52,3325,0,370,1,0,0, - 0,2,383,1,0,0,0,4,385,1,0,0,0,6,391,1,0,0,0,8,399,1,0,0,0,10,452,1,0,0, - 0,12,454,1,0,0,0,14,457,1,0,0,0,16,460,1,0,0,0,18,464,1,0,0,0,20,467,1, - 0,0,0,22,470,1,0,0,0,24,477,1,0,0,0,26,493,1,0,0,0,28,495,1,0,0,0,30,497, - 1,0,0,0,32,507,1,0,0,0,34,509,1,0,0,0,36,526,1,0,0,0,38,530,1,0,0,0,40, - 548,1,0,0,0,42,575,1,0,0,0,44,598,1,0,0,0,46,634,1,0,0,0,48,636,1,0,0, - 0,50,640,1,0,0,0,52,642,1,0,0,0,54,649,1,0,0,0,56,661,1,0,0,0,58,664,1, - 0,0,0,60,666,1,0,0,0,62,679,1,0,0,0,64,687,1,0,0,0,66,689,1,0,0,0,68,697, - 1,0,0,0,70,713,1,0,0,0,72,719,1,0,0,0,74,722,1,0,0,0,76,771,1,0,0,0,78, - 776,1,0,0,0,80,781,1,0,0,0,82,786,1,0,0,0,84,794,1,0,0,0,86,799,1,0,0, - 0,88,904,1,0,0,0,90,932,1,0,0,0,92,934,1,0,0,0,94,938,1,0,0,0,96,940,1, - 0,0,0,98,945,1,0,0,0,100,948,1,0,0,0,102,950,1,0,0,0,104,952,1,0,0,0,106, - 954,1,0,0,0,108,956,1,0,0,0,110,958,1,0,0,0,112,960,1,0,0,0,114,962,1, - 0,0,0,116,964,1,0,0,0,118,966,1,0,0,0,120,968,1,0,0,0,122,970,1,0,0,0, - 124,972,1,0,0,0,126,1056,1,0,0,0,128,1074,1,0,0,0,130,1076,1,0,0,0,132, - 1088,1,0,0,0,134,1113,1,0,0,0,136,1122,1,0,0,0,138,1149,1,0,0,0,140,1156, - 1,0,0,0,142,1164,1,0,0,0,144,1172,1,0,0,0,146,1185,1,0,0,0,148,1195,1, - 0,0,0,150,1214,1,0,0,0,152,1308,1,0,0,0,154,1317,1,0,0,0,156,1327,1,0, - 0,0,158,1329,1,0,0,0,160,1331,1,0,0,0,162,1356,1,0,0,0,164,1388,1,0,0, - 0,166,1411,1,0,0,0,168,1423,1,0,0,0,170,1425,1,0,0,0,172,1428,1,0,0,0, - 174,1481,1,0,0,0,176,1493,1,0,0,0,178,1508,1,0,0,0,180,1515,1,0,0,0,182, - 1520,1,0,0,0,184,1524,1,0,0,0,186,1560,1,0,0,0,188,1562,1,0,0,0,190,1598, - 1,0,0,0,192,1610,1,0,0,0,194,1624,1,0,0,0,196,1626,1,0,0,0,198,1636,1, - 0,0,0,200,1647,1,0,0,0,202,1654,1,0,0,0,204,1664,1,0,0,0,206,1677,1,0, - 0,0,208,1682,1,0,0,0,210,1685,1,0,0,0,212,1696,1,0,0,0,214,1701,1,0,0, - 0,216,1707,1,0,0,0,218,1709,1,0,0,0,220,1831,1,0,0,0,222,1833,1,0,0,0, - 224,1870,1,0,0,0,226,1877,1,0,0,0,228,1882,1,0,0,0,230,1889,1,0,0,0,232, - 1909,1,0,0,0,234,1911,1,0,0,0,236,1916,1,0,0,0,238,1931,1,0,0,0,240,1933, - 1,0,0,0,242,1946,1,0,0,0,244,1951,1,0,0,0,246,1964,1,0,0,0,248,1972,1, - 0,0,0,250,1983,1,0,0,0,252,1988,1,0,0,0,254,2004,1,0,0,0,256,2006,1,0, - 0,0,258,2050,1,0,0,0,260,2070,1,0,0,0,262,2099,1,0,0,0,264,2104,1,0,0, - 0,266,2127,1,0,0,0,268,2132,1,0,0,0,270,2243,1,0,0,0,272,2245,1,0,0,0, - 274,2250,1,0,0,0,276,2252,1,0,0,0,278,2256,1,0,0,0,280,2260,1,0,0,0,282, - 2276,1,0,0,0,284,2290,1,0,0,0,286,2298,1,0,0,0,288,2300,1,0,0,0,290,2303, - 1,0,0,0,292,2305,1,0,0,0,294,2318,1,0,0,0,296,2320,1,0,0,0,298,2330,1, - 0,0,0,300,2335,1,0,0,0,302,2346,1,0,0,0,304,2353,1,0,0,0,306,2363,1,0, - 0,0,308,2431,1,0,0,0,310,2508,1,0,0,0,312,2513,1,0,0,0,314,2516,1,0,0, - 0,316,2521,1,0,0,0,318,2671,1,0,0,0,320,2677,1,0,0,0,322,2684,1,0,0,0, - 324,2690,1,0,0,0,326,2696,1,0,0,0,328,2702,1,0,0,0,330,2708,1,0,0,0,332, - 2714,1,0,0,0,334,2720,1,0,0,0,336,2726,1,0,0,0,338,2733,1,0,0,0,340,2738, - 1,0,0,0,342,2744,1,0,0,0,344,2771,1,0,0,0,346,2785,1,0,0,0,348,2790,1, - 0,0,0,350,2807,1,0,0,0,352,2809,1,0,0,0,354,2819,1,0,0,0,356,2843,1,0, - 0,0,358,2848,1,0,0,0,360,2864,1,0,0,0,362,2885,1,0,0,0,364,2887,1,0,0, - 0,366,2892,1,0,0,0,368,2905,1,0,0,0,370,371,7,0,0,0,371,1,1,0,0,0,372, - 384,5,288,0,0,373,374,3,4,2,0,374,375,5,265,0,0,375,377,1,0,0,0,376,373, - 1,0,0,0,377,380,1,0,0,0,378,376,1,0,0,0,378,379,1,0,0,0,379,381,1,0,0, - 0,380,378,1,0,0,0,381,384,3,4,2,0,382,384,5,264,0,0,383,372,1,0,0,0,383, - 378,1,0,0,0,383,382,1,0,0,0,384,3,1,0,0,0,385,386,7,1,0,0,386,5,1,0,0, - 0,387,388,5,263,0,0,388,390,5,266,0,0,389,387,1,0,0,0,390,393,1,0,0,0, - 391,389,1,0,0,0,391,392,1,0,0,0,392,394,1,0,0,0,393,391,1,0,0,0,394,395, - 5,263,0,0,395,7,1,0,0,0,396,398,3,10,5,0,397,396,1,0,0,0,398,401,1,0,0, - 0,399,397,1,0,0,0,399,400,1,0,0,0,400,9,1,0,0,0,401,399,1,0,0,0,402,403, - 3,74,37,0,403,404,5,17,0,0,404,405,3,82,41,0,405,406,5,18,0,0,406,453, - 1,0,0,0,407,408,3,72,36,0,408,409,5,17,0,0,409,410,3,8,4,0,410,411,5,18, - 0,0,411,453,1,0,0,0,412,413,3,256,128,0,413,414,5,17,0,0,414,415,3,268, - 134,0,415,416,5,18,0,0,416,453,1,0,0,0,417,453,3,222,111,0,418,453,3,296, - 148,0,419,453,3,70,35,0,420,453,3,66,33,0,421,453,3,88,44,0,422,453,3, - 90,45,0,423,453,3,22,11,0,424,425,3,346,173,0,425,426,5,17,0,0,426,427, - 3,348,174,0,427,428,5,18,0,0,428,453,1,0,0,0,429,430,3,352,176,0,430,431, - 5,17,0,0,431,432,3,358,179,0,432,433,5,18,0,0,433,453,1,0,0,0,434,435, - 3,362,181,0,435,436,5,17,0,0,436,437,3,366,183,0,437,438,5,18,0,0,438, - 453,1,0,0,0,439,453,3,64,32,0,440,453,3,174,87,0,441,453,3,342,171,0,442, - 453,3,12,6,0,443,453,3,14,7,0,444,453,3,16,8,0,445,453,3,18,9,0,446,453, - 3,20,10,0,447,453,3,26,13,0,448,453,3,42,21,0,449,453,3,40,20,0,450,453, - 3,30,15,0,451,453,3,24,12,0,452,402,1,0,0,0,452,407,1,0,0,0,452,412,1, - 0,0,0,452,417,1,0,0,0,452,418,1,0,0,0,452,419,1,0,0,0,452,420,1,0,0,0, - 452,421,1,0,0,0,452,422,1,0,0,0,452,423,1,0,0,0,452,424,1,0,0,0,452,429, - 1,0,0,0,452,434,1,0,0,0,452,439,1,0,0,0,452,440,1,0,0,0,452,441,1,0,0, - 0,452,442,1,0,0,0,452,443,1,0,0,0,452,444,1,0,0,0,452,445,1,0,0,0,452, - 446,1,0,0,0,452,447,1,0,0,0,452,448,1,0,0,0,452,449,1,0,0,0,452,450,1, - 0,0,0,452,451,1,0,0,0,453,11,1,0,0,0,454,455,5,19,0,0,455,456,3,32,16, - 0,456,13,1,0,0,0,457,458,5,20,0,0,458,459,3,32,16,0,459,15,1,0,0,0,460, - 461,5,21,0,0,461,462,5,22,0,0,462,463,3,32,16,0,463,17,1,0,0,0,464,465, - 5,23,0,0,465,466,3,34,17,0,466,19,1,0,0,0,467,468,5,24,0,0,468,469,3,34, - 17,0,469,21,1,0,0,0,470,471,5,25,0,0,471,472,3,98,49,0,472,473,3,2,1,0, - 473,474,5,17,0,0,474,475,3,142,71,0,475,476,5,18,0,0,476,23,1,0,0,0,477, - 478,5,26,0,0,478,25,1,0,0,0,479,480,5,27,0,0,480,494,3,28,14,0,481,482, - 5,27,0,0,482,483,3,28,14,0,483,484,5,28,0,0,484,485,3,28,14,0,485,494, - 1,0,0,0,486,487,5,27,0,0,487,488,3,28,14,0,488,489,5,28,0,0,489,490,3, - 28,14,0,490,491,5,28,0,0,491,492,3,28,14,0,492,494,1,0,0,0,493,479,1,0, - 0,0,493,481,1,0,0,0,493,486,1,0,0,0,494,27,1,0,0,0,495,496,7,2,0,0,496, - 29,1,0,0,0,497,498,5,29,0,0,498,502,5,17,0,0,499,501,3,138,69,0,500,499, - 1,0,0,0,501,504,1,0,0,0,502,500,1,0,0,0,502,503,1,0,0,0,503,505,1,0,0, - 0,504,502,1,0,0,0,505,506,5,18,0,0,506,31,1,0,0,0,507,508,5,173,0,0,508, - 33,1,0,0,0,509,510,7,3,0,0,510,35,1,0,0,0,511,527,5,175,0,0,512,513,3, - 32,16,0,513,514,5,265,0,0,514,527,1,0,0,0,515,527,3,32,16,0,516,517,5, - 188,0,0,517,518,5,30,0,0,518,519,3,32,16,0,519,520,5,31,0,0,520,527,1, - 0,0,0,521,522,5,189,0,0,522,523,5,30,0,0,523,524,3,34,17,0,524,525,5,31, - 0,0,525,527,1,0,0,0,526,511,1,0,0,0,526,512,1,0,0,0,526,515,1,0,0,0,526, - 516,1,0,0,0,526,521,1,0,0,0,527,37,1,0,0,0,528,531,3,32,16,0,529,531,5, - 262,0,0,530,528,1,0,0,0,530,529,1,0,0,0,531,39,1,0,0,0,532,533,5,267,0, - 0,533,549,5,289,0,0,534,535,5,267,0,0,535,536,5,289,0,0,536,549,5,263, - 0,0,537,538,5,268,0,0,538,549,5,289,0,0,539,540,5,269,0,0,540,549,5,289, - 0,0,541,542,5,270,0,0,542,549,5,289,0,0,543,549,5,271,0,0,544,549,5,272, - 0,0,545,546,5,273,0,0,546,549,5,263,0,0,547,549,5,32,0,0,548,532,1,0,0, - 0,548,534,1,0,0,0,548,537,1,0,0,0,548,539,1,0,0,0,548,541,1,0,0,0,548, - 543,1,0,0,0,548,544,1,0,0,0,548,545,1,0,0,0,548,547,1,0,0,0,549,41,1,0, - 0,0,550,551,5,33,0,0,551,552,3,160,80,0,552,553,5,34,0,0,553,554,3,2,1, - 0,554,576,1,0,0,0,555,556,5,33,0,0,556,557,3,138,69,0,557,558,5,34,0,0, - 558,559,3,2,1,0,559,576,1,0,0,0,560,561,5,33,0,0,561,562,3,198,99,0,562, - 563,5,34,0,0,563,564,3,2,1,0,564,576,1,0,0,0,565,566,5,33,0,0,566,567, - 3,44,22,0,567,568,5,34,0,0,568,569,3,2,1,0,569,576,1,0,0,0,570,571,5,33, - 0,0,571,572,3,46,23,0,572,573,5,34,0,0,573,574,3,2,1,0,574,576,1,0,0,0, - 575,550,1,0,0,0,575,555,1,0,0,0,575,560,1,0,0,0,575,565,1,0,0,0,575,570, - 1,0,0,0,576,43,1,0,0,0,577,578,5,35,0,0,578,599,3,48,24,0,579,580,5,35, - 0,0,580,581,3,48,24,0,581,582,5,36,0,0,582,583,3,6,3,0,583,599,1,0,0,0, - 584,585,5,35,0,0,585,586,3,48,24,0,586,587,5,36,0,0,587,588,5,17,0,0,588, - 589,3,52,26,0,589,590,5,18,0,0,590,599,1,0,0,0,591,592,5,35,0,0,592,593, - 3,48,24,0,593,594,5,36,0,0,594,595,5,30,0,0,595,596,3,312,156,0,596,597, - 5,31,0,0,597,599,1,0,0,0,598,577,1,0,0,0,598,579,1,0,0,0,598,584,1,0,0, - 0,598,591,1,0,0,0,599,45,1,0,0,0,600,601,5,35,0,0,601,602,5,30,0,0,602, - 603,3,50,25,0,603,604,5,31,0,0,604,605,3,48,24,0,605,635,1,0,0,0,606,607, - 5,35,0,0,607,608,5,30,0,0,608,609,3,50,25,0,609,610,5,31,0,0,610,611,3, - 48,24,0,611,612,5,36,0,0,612,613,3,6,3,0,613,635,1,0,0,0,614,615,5,35, - 0,0,615,616,5,30,0,0,616,617,3,50,25,0,617,618,5,31,0,0,618,619,3,48,24, - 0,619,620,5,36,0,0,620,621,5,17,0,0,621,622,3,52,26,0,622,623,5,18,0,0, - 623,635,1,0,0,0,624,625,5,35,0,0,625,626,5,30,0,0,626,627,3,50,25,0,627, - 628,5,31,0,0,628,629,3,48,24,0,629,630,5,36,0,0,630,631,5,30,0,0,631,632, - 3,312,156,0,632,633,5,31,0,0,633,635,1,0,0,0,634,600,1,0,0,0,634,606,1, - 0,0,0,634,614,1,0,0,0,634,624,1,0,0,0,635,47,1,0,0,0,636,637,3,190,95, - 0,637,49,1,0,0,0,638,641,3,146,73,0,639,641,3,198,99,0,640,638,1,0,0,0, - 640,639,1,0,0,0,641,51,1,0,0,0,642,643,3,54,27,0,643,644,3,56,28,0,644, - 53,1,0,0,0,645,648,3,318,159,0,646,648,3,40,20,0,647,645,1,0,0,0,647,646, - 1,0,0,0,648,651,1,0,0,0,649,647,1,0,0,0,649,650,1,0,0,0,650,55,1,0,0,0, - 651,649,1,0,0,0,652,653,3,58,29,0,653,654,3,60,30,0,654,655,3,2,1,0,655, - 656,5,36,0,0,656,657,3,318,159,0,657,660,1,0,0,0,658,660,3,40,20,0,659, - 652,1,0,0,0,659,658,1,0,0,0,660,663,1,0,0,0,661,659,1,0,0,0,661,662,1, - 0,0,0,662,57,1,0,0,0,663,661,1,0,0,0,664,665,7,4,0,0,665,59,1,0,0,0,666, - 668,3,62,31,0,667,669,5,261,0,0,668,667,1,0,0,0,668,669,1,0,0,0,669,61, - 1,0,0,0,670,680,3,166,83,0,671,680,3,2,1,0,672,680,5,196,0,0,673,680,5, - 197,0,0,674,675,5,202,0,0,675,676,5,39,0,0,676,680,5,264,0,0,677,678,5, - 202,0,0,678,680,3,138,69,0,679,670,1,0,0,0,679,671,1,0,0,0,679,672,1,0, - 0,0,679,673,1,0,0,0,679,674,1,0,0,0,679,677,1,0,0,0,680,63,1,0,0,0,681, - 682,5,198,0,0,682,683,5,40,0,0,683,688,3,2,1,0,684,685,5,198,0,0,685,688, - 3,2,1,0,686,688,5,198,0,0,687,681,1,0,0,0,687,684,1,0,0,0,687,686,1,0, - 0,0,688,65,1,0,0,0,689,690,5,41,0,0,690,691,5,42,0,0,691,692,3,32,16,0, - 692,693,5,43,0,0,693,694,3,68,34,0,694,695,5,44,0,0,695,696,3,0,0,0,696, - 67,1,0,0,0,697,710,6,34,-1,0,698,699,10,5,0,0,699,709,5,186,0,0,700,701, - 10,4,0,0,701,709,5,187,0,0,702,703,10,3,0,0,703,709,5,45,0,0,704,705,10, - 2,0,0,705,709,5,46,0,0,706,707,10,1,0,0,707,709,5,47,0,0,708,698,1,0,0, - 0,708,700,1,0,0,0,708,702,1,0,0,0,708,704,1,0,0,0,708,706,1,0,0,0,709, - 712,1,0,0,0,710,708,1,0,0,0,710,711,1,0,0,0,711,69,1,0,0,0,712,710,1,0, - 0,0,713,714,5,48,0,0,714,715,5,36,0,0,715,716,5,30,0,0,716,717,3,312,156, - 0,717,718,5,31,0,0,718,71,1,0,0,0,719,720,5,49,0,0,720,721,3,2,1,0,721, - 73,1,0,0,0,722,726,5,50,0,0,723,725,3,76,38,0,724,723,1,0,0,0,725,728, - 1,0,0,0,726,724,1,0,0,0,726,727,1,0,0,0,727,729,1,0,0,0,728,726,1,0,0, - 0,729,730,3,2,1,0,730,731,3,204,102,0,731,732,3,78,39,0,732,733,3,80,40, - 0,733,75,1,0,0,0,734,772,5,51,0,0,735,772,5,52,0,0,736,772,5,199,0,0,737, - 772,5,202,0,0,738,772,5,221,0,0,739,772,5,53,0,0,740,772,5,54,0,0,741, - 772,5,55,0,0,742,772,5,56,0,0,743,772,5,244,0,0,744,772,5,15,0,0,745,772, - 5,224,0,0,746,772,5,57,0,0,747,772,5,58,0,0,748,772,5,59,0,0,749,772,5, - 60,0,0,750,772,5,61,0,0,751,752,5,62,0,0,752,772,5,51,0,0,753,754,5,62, - 0,0,754,772,5,52,0,0,755,756,5,62,0,0,756,772,5,63,0,0,757,758,5,62,0, - 0,758,772,5,64,0,0,759,760,5,62,0,0,760,772,5,65,0,0,761,762,5,62,0,0, - 762,772,5,66,0,0,763,772,5,67,0,0,764,772,5,68,0,0,765,772,5,69,0,0,766, - 767,5,70,0,0,767,768,5,30,0,0,768,769,3,32,16,0,769,770,5,31,0,0,770,772, - 1,0,0,0,771,734,1,0,0,0,771,735,1,0,0,0,771,736,1,0,0,0,771,737,1,0,0, - 0,771,738,1,0,0,0,771,739,1,0,0,0,771,740,1,0,0,0,771,741,1,0,0,0,771, - 742,1,0,0,0,771,743,1,0,0,0,771,744,1,0,0,0,771,745,1,0,0,0,771,746,1, - 0,0,0,771,747,1,0,0,0,771,748,1,0,0,0,771,749,1,0,0,0,771,750,1,0,0,0, - 771,751,1,0,0,0,771,753,1,0,0,0,771,755,1,0,0,0,771,757,1,0,0,0,771,759, - 1,0,0,0,771,761,1,0,0,0,771,763,1,0,0,0,771,764,1,0,0,0,771,765,1,0,0, - 0,771,766,1,0,0,0,772,77,1,0,0,0,773,777,1,0,0,0,774,775,5,71,0,0,775, - 777,3,146,73,0,776,773,1,0,0,0,776,774,1,0,0,0,777,79,1,0,0,0,778,782, - 1,0,0,0,779,780,5,72,0,0,780,782,3,84,42,0,781,778,1,0,0,0,781,779,1,0, - 0,0,782,81,1,0,0,0,783,785,3,220,110,0,784,783,1,0,0,0,785,788,1,0,0,0, - 786,784,1,0,0,0,786,787,1,0,0,0,787,83,1,0,0,0,788,786,1,0,0,0,789,790, - 3,146,73,0,790,791,5,28,0,0,791,793,1,0,0,0,792,789,1,0,0,0,793,796,1, - 0,0,0,794,792,1,0,0,0,794,795,1,0,0,0,795,797,1,0,0,0,796,794,1,0,0,0, - 797,798,3,146,73,0,798,85,1,0,0,0,799,800,7,5,0,0,800,87,1,0,0,0,801,802, - 3,86,43,0,802,803,3,32,16,0,803,804,5,264,0,0,804,905,1,0,0,0,805,806, - 3,86,43,0,806,807,3,32,16,0,807,905,1,0,0,0,808,809,3,86,43,0,809,810, - 3,32,16,0,810,811,5,75,0,0,811,812,3,32,16,0,812,813,5,264,0,0,813,905, - 1,0,0,0,814,815,3,86,43,0,815,816,3,32,16,0,816,817,5,75,0,0,817,818,3, - 32,16,0,818,905,1,0,0,0,819,820,3,86,43,0,820,821,3,32,16,0,821,822,5, - 75,0,0,822,823,3,32,16,0,823,824,5,28,0,0,824,825,3,32,16,0,825,826,5, - 264,0,0,826,905,1,0,0,0,827,828,3,86,43,0,828,829,3,32,16,0,829,830,5, - 75,0,0,830,831,3,32,16,0,831,832,5,28,0,0,832,833,3,32,16,0,833,905,1, - 0,0,0,834,835,3,86,43,0,835,836,3,32,16,0,836,837,5,28,0,0,837,838,3,32, - 16,0,838,839,5,75,0,0,839,840,3,32,16,0,840,841,5,264,0,0,841,905,1,0, - 0,0,842,843,3,86,43,0,843,844,3,32,16,0,844,845,5,28,0,0,845,846,3,32, - 16,0,846,847,5,75,0,0,847,848,3,32,16,0,848,905,1,0,0,0,849,850,3,86,43, - 0,850,851,3,32,16,0,851,852,5,28,0,0,852,853,3,32,16,0,853,854,5,75,0, - 0,854,855,3,32,16,0,855,856,5,28,0,0,856,857,3,32,16,0,857,858,5,264,0, - 0,858,905,1,0,0,0,859,860,3,86,43,0,860,861,3,32,16,0,861,862,5,28,0,0, - 862,863,3,32,16,0,863,864,5,75,0,0,864,865,3,32,16,0,865,866,5,28,0,0, - 866,867,3,32,16,0,867,905,1,0,0,0,868,869,3,86,43,0,869,870,3,32,16,0, - 870,871,5,263,0,0,871,905,1,0,0,0,872,873,3,86,43,0,873,874,3,32,16,0, - 874,875,5,75,0,0,875,876,3,32,16,0,876,877,5,263,0,0,877,905,1,0,0,0,878, - 879,3,86,43,0,879,880,3,32,16,0,880,881,5,75,0,0,881,882,3,32,16,0,882, - 883,5,28,0,0,883,884,3,32,16,0,884,885,5,263,0,0,885,905,1,0,0,0,886,887, - 3,86,43,0,887,888,3,32,16,0,888,889,5,28,0,0,889,890,3,32,16,0,890,891, - 5,75,0,0,891,892,3,32,16,0,892,893,5,263,0,0,893,905,1,0,0,0,894,895,3, - 86,43,0,895,896,3,32,16,0,896,897,5,28,0,0,897,898,3,32,16,0,898,899,5, - 75,0,0,899,900,3,32,16,0,900,901,5,28,0,0,901,902,3,32,16,0,902,903,5, - 263,0,0,903,905,1,0,0,0,904,801,1,0,0,0,904,805,1,0,0,0,904,808,1,0,0, - 0,904,814,1,0,0,0,904,819,1,0,0,0,904,827,1,0,0,0,904,834,1,0,0,0,904, - 842,1,0,0,0,904,849,1,0,0,0,904,859,1,0,0,0,904,868,1,0,0,0,904,872,1, - 0,0,0,904,878,1,0,0,0,904,886,1,0,0,0,904,894,1,0,0,0,905,89,1,0,0,0,906, - 910,5,21,0,0,907,909,3,92,46,0,908,907,1,0,0,0,909,912,1,0,0,0,910,908, - 1,0,0,0,910,911,1,0,0,0,911,913,1,0,0,0,912,910,1,0,0,0,913,914,3,2,1, - 0,914,915,3,94,47,0,915,916,5,180,0,0,916,917,5,36,0,0,917,918,5,30,0, - 0,918,919,3,312,156,0,919,920,5,31,0,0,920,921,3,94,47,0,921,933,1,0,0, - 0,922,926,5,21,0,0,923,925,3,92,46,0,924,923,1,0,0,0,925,928,1,0,0,0,926, - 924,1,0,0,0,926,927,1,0,0,0,927,929,1,0,0,0,928,926,1,0,0,0,929,930,3, - 2,1,0,930,931,3,94,47,0,931,933,1,0,0,0,932,906,1,0,0,0,932,922,1,0,0, - 0,933,91,1,0,0,0,934,935,5,76,0,0,935,93,1,0,0,0,936,939,1,0,0,0,937,939, - 5,298,0,0,938,936,1,0,0,0,938,937,1,0,0,0,939,95,1,0,0,0,940,941,7,6,0, - 0,941,97,1,0,0,0,942,944,3,96,48,0,943,942,1,0,0,0,944,947,1,0,0,0,945, - 943,1,0,0,0,945,946,1,0,0,0,946,99,1,0,0,0,947,945,1,0,0,0,948,949,5,275, - 0,0,949,101,1,0,0,0,950,951,5,276,0,0,951,103,1,0,0,0,952,953,5,277,0, - 0,953,105,1,0,0,0,954,955,5,278,0,0,955,107,1,0,0,0,956,957,5,279,0,0, - 957,109,1,0,0,0,958,959,5,282,0,0,959,111,1,0,0,0,960,961,5,280,0,0,961, - 113,1,0,0,0,962,963,5,286,0,0,963,115,1,0,0,0,964,965,5,284,0,0,965,117, - 1,0,0,0,966,967,5,285,0,0,967,119,1,0,0,0,968,969,5,281,0,0,969,121,1, - 0,0,0,970,971,5,287,0,0,971,123,1,0,0,0,972,973,5,283,0,0,973,125,1,0, - 0,0,974,1057,3,100,50,0,975,976,3,102,51,0,976,977,3,32,16,0,977,1057, - 1,0,0,0,978,979,3,102,51,0,979,980,3,0,0,0,980,1057,1,0,0,0,981,982,3, - 104,52,0,982,983,3,32,16,0,983,1057,1,0,0,0,984,985,3,106,53,0,985,986, - 3,34,17,0,986,1057,1,0,0,0,987,988,3,108,54,0,988,989,3,36,18,0,989,1057, - 1,0,0,0,990,991,3,108,54,0,991,992,3,34,17,0,992,1057,1,0,0,0,993,994, - 3,108,54,0,994,995,5,30,0,0,995,996,3,312,156,0,996,997,5,31,0,0,997,1057, - 1,0,0,0,998,999,3,108,54,0,999,1000,5,84,0,0,1000,1001,5,30,0,0,1001,1002, - 3,312,156,0,1002,1003,5,31,0,0,1003,1057,1,0,0,0,1004,1005,3,110,55,0, - 1005,1006,3,32,16,0,1006,1057,1,0,0,0,1007,1008,3,110,55,0,1008,1009,3, - 0,0,0,1009,1057,1,0,0,0,1010,1011,3,112,56,0,1011,1012,3,190,95,0,1012, - 1057,1,0,0,0,1013,1014,3,114,57,0,1014,1015,3,200,100,0,1015,1057,1,0, - 0,0,1016,1017,3,114,57,0,1017,1018,3,196,98,0,1018,1057,1,0,0,0,1019,1020, - 3,116,58,0,1020,1021,3,146,73,0,1021,1057,1,0,0,0,1022,1023,3,118,59,0, - 1023,1024,3,6,3,0,1024,1057,1,0,0,0,1025,1026,3,118,59,0,1026,1027,5,224, - 0,0,1027,1028,5,30,0,0,1028,1029,3,6,3,0,1029,1030,5,31,0,0,1030,1057, - 1,0,0,0,1031,1032,3,118,59,0,1032,1033,5,84,0,0,1033,1034,5,30,0,0,1034, - 1035,3,312,156,0,1035,1036,5,31,0,0,1036,1057,1,0,0,0,1037,1038,3,120, - 60,0,1038,1039,3,192,96,0,1039,1040,3,160,80,0,1040,1041,3,134,67,0,1041, - 1057,1,0,0,0,1042,1043,3,122,61,0,1043,1044,3,50,25,0,1044,1057,1,0,0, - 0,1045,1046,3,122,61,0,1046,1047,3,32,16,0,1047,1057,1,0,0,0,1048,1049, - 3,124,62,0,1049,1050,5,30,0,0,1050,1051,3,128,64,0,1051,1052,5,31,0,0, - 1052,1057,1,0,0,0,1053,1054,3,124,62,0,1054,1055,5,85,0,0,1055,1057,1, - 0,0,0,1056,974,1,0,0,0,1056,975,1,0,0,0,1056,978,1,0,0,0,1056,981,1,0, - 0,0,1056,984,1,0,0,0,1056,987,1,0,0,0,1056,990,1,0,0,0,1056,993,1,0,0, - 0,1056,998,1,0,0,0,1056,1004,1,0,0,0,1056,1007,1,0,0,0,1056,1010,1,0,0, - 0,1056,1013,1,0,0,0,1056,1016,1,0,0,0,1056,1019,1,0,0,0,1056,1022,1,0, - 0,0,1056,1025,1,0,0,0,1056,1031,1,0,0,0,1056,1037,1,0,0,0,1056,1042,1, - 0,0,0,1056,1045,1,0,0,0,1056,1048,1,0,0,0,1056,1053,1,0,0,0,1057,127,1, - 0,0,0,1058,1075,1,0,0,0,1059,1062,3,0,0,0,1060,1062,3,32,16,0,1061,1059, - 1,0,0,0,1061,1060,1,0,0,0,1062,1063,1,0,0,0,1063,1064,5,28,0,0,1064,1066, - 1,0,0,0,1065,1061,1,0,0,0,1066,1069,1,0,0,0,1067,1065,1,0,0,0,1067,1068, - 1,0,0,0,1068,1072,1,0,0,0,1069,1067,1,0,0,0,1070,1073,3,0,0,0,1071,1073, - 3,32,16,0,1072,1070,1,0,0,0,1072,1071,1,0,0,0,1073,1075,1,0,0,0,1074,1058, - 1,0,0,0,1074,1067,1,0,0,0,1075,129,1,0,0,0,1076,1082,5,86,0,0,1077,1078, - 3,160,80,0,1078,1079,5,28,0,0,1079,1081,1,0,0,0,1080,1077,1,0,0,0,1081, - 1084,1,0,0,0,1082,1080,1,0,0,0,1082,1083,1,0,0,0,1083,1085,1,0,0,0,1084, - 1082,1,0,0,0,1085,1086,3,160,80,0,1086,1087,5,87,0,0,1087,131,1,0,0,0, - 1088,1094,5,42,0,0,1089,1090,3,168,84,0,1090,1091,5,28,0,0,1091,1093,1, - 0,0,0,1092,1089,1,0,0,0,1093,1096,1,0,0,0,1094,1092,1,0,0,0,1094,1095, - 1,0,0,0,1095,1097,1,0,0,0,1096,1094,1,0,0,0,1097,1098,3,168,84,0,1098, - 1099,5,43,0,0,1099,133,1,0,0,0,1100,1106,5,30,0,0,1101,1102,3,136,68,0, - 1102,1103,5,28,0,0,1103,1105,1,0,0,0,1104,1101,1,0,0,0,1105,1108,1,0,0, - 0,1106,1104,1,0,0,0,1106,1107,1,0,0,0,1107,1109,1,0,0,0,1108,1106,1,0, - 0,0,1109,1110,3,136,68,0,1110,1111,5,31,0,0,1111,1114,1,0,0,0,1112,1114, - 5,85,0,0,1113,1100,1,0,0,0,1113,1112,1,0,0,0,1114,135,1,0,0,0,1115,1123, - 5,177,0,0,1116,1117,3,252,126,0,1117,1118,3,160,80,0,1118,1120,3,248,124, - 0,1119,1121,3,0,0,0,1120,1119,1,0,0,0,1120,1121,1,0,0,0,1121,1123,1,0, - 0,0,1122,1115,1,0,0,0,1122,1116,1,0,0,0,1123,137,1,0,0,0,1124,1125,5,42, - 0,0,1125,1126,3,2,1,0,1126,1127,5,43,0,0,1127,1128,3,140,70,0,1128,1150, - 1,0,0,0,1129,1130,5,42,0,0,1130,1131,3,196,98,0,1131,1132,5,43,0,0,1132, - 1133,3,140,70,0,1133,1150,1,0,0,0,1134,1135,5,42,0,0,1135,1136,5,262,0, - 0,1136,1137,5,43,0,0,1137,1150,3,140,70,0,1138,1139,5,42,0,0,1139,1140, - 5,198,0,0,1140,1141,3,2,1,0,1141,1142,5,43,0,0,1142,1143,3,140,70,0,1143, - 1150,1,0,0,0,1144,1150,3,140,70,0,1145,1150,3,196,98,0,1146,1150,5,257, - 0,0,1147,1150,5,258,0,0,1148,1150,5,259,0,0,1149,1124,1,0,0,0,1149,1129, - 1,0,0,0,1149,1134,1,0,0,0,1149,1138,1,0,0,0,1149,1144,1,0,0,0,1149,1145, - 1,0,0,0,1149,1146,1,0,0,0,1149,1147,1,0,0,0,1149,1148,1,0,0,0,1150,139, - 1,0,0,0,1151,1152,3,2,1,0,1152,1153,5,88,0,0,1153,1155,1,0,0,0,1154,1151, - 1,0,0,0,1155,1158,1,0,0,0,1156,1154,1,0,0,0,1156,1157,1,0,0,0,1157,1159, - 1,0,0,0,1158,1156,1,0,0,0,1159,1160,3,2,1,0,1160,141,1,0,0,0,1161,1163, - 3,144,72,0,1162,1161,1,0,0,0,1163,1166,1,0,0,0,1164,1162,1,0,0,0,1164, - 1165,1,0,0,0,1165,143,1,0,0,0,1166,1164,1,0,0,0,1167,1168,5,180,0,0,1168, - 1169,5,89,0,0,1169,1173,3,32,16,0,1170,1173,3,174,87,0,1171,1173,3,344, - 172,0,1172,1167,1,0,0,0,1172,1170,1,0,0,0,1172,1171,1,0,0,0,1173,145,1, - 0,0,0,1174,1186,3,138,69,0,1175,1176,5,42,0,0,1176,1177,3,2,1,0,1177,1178, - 5,43,0,0,1178,1186,1,0,0,0,1179,1180,5,42,0,0,1180,1181,5,198,0,0,1181, - 1182,3,2,1,0,1182,1183,5,43,0,0,1183,1186,1,0,0,0,1184,1186,3,160,80,0, - 1185,1174,1,0,0,0,1185,1175,1,0,0,0,1185,1179,1,0,0,0,1185,1184,1,0,0, - 0,1186,147,1,0,0,0,1187,1196,1,0,0,0,1188,1192,3,152,76,0,1189,1191,3, - 150,75,0,1190,1189,1,0,0,0,1191,1194,1,0,0,0,1192,1190,1,0,0,0,1192,1193, - 1,0,0,0,1193,1196,1,0,0,0,1194,1192,1,0,0,0,1195,1187,1,0,0,0,1195,1188, - 1,0,0,0,1196,149,1,0,0,0,1197,1215,5,262,0,0,1198,1215,5,261,0,0,1199, - 1200,5,42,0,0,1200,1201,3,32,16,0,1201,1202,5,43,0,0,1202,1215,1,0,0,0, - 1203,1204,5,42,0,0,1204,1205,3,32,16,0,1205,1206,5,266,0,0,1206,1207,3, - 32,16,0,1207,1208,5,43,0,0,1208,1215,1,0,0,0,1209,1210,5,42,0,0,1210,1211, - 5,266,0,0,1211,1212,3,32,16,0,1212,1213,5,43,0,0,1213,1215,1,0,0,0,1214, - 1197,1,0,0,0,1214,1198,1,0,0,0,1214,1199,1,0,0,0,1214,1203,1,0,0,0,1214, - 1209,1,0,0,0,1215,151,1,0,0,0,1216,1309,1,0,0,0,1217,1218,5,203,0,0,1218, - 1219,5,30,0,0,1219,1220,3,6,3,0,1220,1221,5,28,0,0,1221,1222,3,6,3,0,1222, - 1223,5,28,0,0,1223,1224,3,6,3,0,1224,1225,5,28,0,0,1225,1226,3,6,3,0,1226, - 1227,5,31,0,0,1227,1309,1,0,0,0,1228,1229,5,203,0,0,1229,1230,5,30,0,0, - 1230,1231,3,6,3,0,1231,1232,5,28,0,0,1232,1233,3,6,3,0,1233,1234,5,31, - 0,0,1234,1309,1,0,0,0,1235,1236,5,204,0,0,1236,1237,5,205,0,0,1237,1238, - 5,42,0,0,1238,1239,3,32,16,0,1239,1240,5,43,0,0,1240,1309,1,0,0,0,1241, - 1242,5,204,0,0,1242,1243,5,206,0,0,1243,1244,5,42,0,0,1244,1245,3,32,16, - 0,1245,1246,5,43,0,0,1246,1247,3,148,74,0,1247,1309,1,0,0,0,1248,1309, - 5,207,0,0,1249,1309,5,208,0,0,1250,1309,5,209,0,0,1251,1309,5,201,0,0, - 1252,1309,5,183,0,0,1253,1309,5,184,0,0,1254,1309,5,185,0,0,1255,1309, - 5,186,0,0,1256,1309,5,187,0,0,1257,1309,5,188,0,0,1258,1309,5,189,0,0, - 1259,1309,5,210,0,0,1260,1309,5,190,0,0,1261,1309,5,191,0,0,1262,1309, - 5,192,0,0,1263,1309,5,193,0,0,1264,1309,5,211,0,0,1265,1309,5,212,0,0, - 1266,1309,5,213,0,0,1267,1309,5,214,0,0,1268,1309,5,215,0,0,1269,1309, - 5,216,0,0,1270,1309,5,217,0,0,1271,1272,5,218,0,0,1272,1309,3,154,77,0, - 1273,1274,5,219,0,0,1274,1309,3,154,77,0,1275,1309,5,220,0,0,1276,1277, - 5,221,0,0,1277,1309,3,154,77,0,1278,1279,5,222,0,0,1279,1309,3,156,78, - 0,1280,1281,5,222,0,0,1281,1282,3,156,78,0,1282,1283,5,28,0,0,1283,1284, - 3,6,3,0,1284,1309,1,0,0,0,1285,1309,5,194,0,0,1286,1309,5,195,0,0,1287, - 1288,5,90,0,0,1288,1309,5,184,0,0,1289,1290,5,90,0,0,1290,1309,5,185,0, - 0,1291,1292,5,90,0,0,1292,1309,5,186,0,0,1293,1294,5,90,0,0,1294,1309, - 5,187,0,0,1295,1296,5,62,0,0,1296,1309,5,220,0,0,1297,1309,5,223,0,0,1298, - 1299,5,224,0,0,1299,1309,5,213,0,0,1300,1309,5,225,0,0,1301,1302,5,207, - 0,0,1302,1309,5,183,0,0,1303,1309,5,226,0,0,1304,1309,5,228,0,0,1305,1306, - 5,34,0,0,1306,1309,5,227,0,0,1307,1309,3,2,1,0,1308,1216,1,0,0,0,1308, - 1217,1,0,0,0,1308,1228,1,0,0,0,1308,1235,1,0,0,0,1308,1241,1,0,0,0,1308, - 1248,1,0,0,0,1308,1249,1,0,0,0,1308,1250,1,0,0,0,1308,1251,1,0,0,0,1308, - 1252,1,0,0,0,1308,1253,1,0,0,0,1308,1254,1,0,0,0,1308,1255,1,0,0,0,1308, - 1256,1,0,0,0,1308,1257,1,0,0,0,1308,1258,1,0,0,0,1308,1259,1,0,0,0,1308, - 1260,1,0,0,0,1308,1261,1,0,0,0,1308,1262,1,0,0,0,1308,1263,1,0,0,0,1308, - 1264,1,0,0,0,1308,1265,1,0,0,0,1308,1266,1,0,0,0,1308,1267,1,0,0,0,1308, - 1268,1,0,0,0,1308,1269,1,0,0,0,1308,1270,1,0,0,0,1308,1271,1,0,0,0,1308, - 1273,1,0,0,0,1308,1275,1,0,0,0,1308,1276,1,0,0,0,1308,1278,1,0,0,0,1308, - 1280,1,0,0,0,1308,1285,1,0,0,0,1308,1286,1,0,0,0,1308,1287,1,0,0,0,1308, - 1289,1,0,0,0,1308,1291,1,0,0,0,1308,1293,1,0,0,0,1308,1295,1,0,0,0,1308, - 1297,1,0,0,0,1308,1298,1,0,0,0,1308,1300,1,0,0,0,1308,1301,1,0,0,0,1308, - 1303,1,0,0,0,1308,1304,1,0,0,0,1308,1305,1,0,0,0,1308,1307,1,0,0,0,1309, - 153,1,0,0,0,1310,1318,1,0,0,0,1311,1312,5,30,0,0,1312,1313,5,91,0,0,1313, - 1314,5,36,0,0,1314,1315,3,32,16,0,1315,1316,5,31,0,0,1316,1318,1,0,0,0, - 1317,1310,1,0,0,0,1317,1311,1,0,0,0,1318,155,1,0,0,0,1319,1328,1,0,0,0, - 1320,1324,3,158,79,0,1321,1323,7,7,0,0,1322,1321,1,0,0,0,1323,1326,1,0, - 0,0,1324,1322,1,0,0,0,1324,1325,1,0,0,0,1325,1328,1,0,0,0,1326,1324,1, - 0,0,0,1327,1319,1,0,0,0,1327,1320,1,0,0,0,1328,157,1,0,0,0,1329,1330,7, - 8,0,0,1330,159,1,0,0,0,1331,1335,3,164,82,0,1332,1334,3,162,81,0,1333, - 1332,1,0,0,0,1334,1337,1,0,0,0,1335,1333,1,0,0,0,1335,1336,1,0,0,0,1336, - 161,1,0,0,0,1337,1335,1,0,0,0,1338,1357,5,261,0,0,1339,1340,5,42,0,0,1340, - 1357,5,43,0,0,1341,1357,3,132,66,0,1342,1357,5,260,0,0,1343,1357,5,262, - 0,0,1344,1357,5,92,0,0,1345,1346,5,93,0,0,1346,1347,5,30,0,0,1347,1348, - 3,146,73,0,1348,1349,5,31,0,0,1349,1357,1,0,0,0,1350,1351,5,94,0,0,1351, - 1352,5,30,0,0,1352,1353,3,146,73,0,1353,1354,5,31,0,0,1354,1357,1,0,0, - 0,1355,1357,3,130,65,0,1356,1338,1,0,0,0,1356,1339,1,0,0,0,1356,1341,1, - 0,0,0,1356,1342,1,0,0,0,1356,1343,1,0,0,0,1356,1344,1,0,0,0,1356,1345, - 1,0,0,0,1356,1350,1,0,0,0,1356,1355,1,0,0,0,1357,163,1,0,0,0,1358,1359, - 5,39,0,0,1359,1389,3,138,69,0,1360,1389,5,197,0,0,1361,1362,5,199,0,0, - 1362,1363,5,39,0,0,1363,1389,3,138,69,0,1364,1365,5,200,0,0,1365,1389, - 3,138,69,0,1366,1367,5,226,0,0,1367,1368,3,192,96,0,1368,1369,3,160,80, - 0,1369,1370,5,262,0,0,1370,1371,3,134,67,0,1371,1389,1,0,0,0,1372,1373, - 5,253,0,0,1373,1389,3,32,16,0,1374,1375,5,252,0,0,1375,1389,3,32,16,0, - 1376,1377,5,253,0,0,1377,1389,3,2,1,0,1378,1379,5,252,0,0,1379,1389,3, - 2,1,0,1380,1389,5,254,0,0,1381,1389,5,201,0,0,1382,1389,3,170,85,0,1383, - 1389,3,172,86,0,1384,1389,3,166,83,0,1385,1389,3,2,1,0,1386,1387,5,177, - 0,0,1387,1389,3,160,80,0,1388,1358,1,0,0,0,1388,1360,1,0,0,0,1388,1361, - 1,0,0,0,1388,1364,1,0,0,0,1388,1366,1,0,0,0,1388,1372,1,0,0,0,1388,1374, - 1,0,0,0,1388,1376,1,0,0,0,1388,1378,1,0,0,0,1388,1380,1,0,0,0,1388,1381, - 1,0,0,0,1388,1382,1,0,0,0,1388,1383,1,0,0,0,1388,1384,1,0,0,0,1388,1385, - 1,0,0,0,1388,1386,1,0,0,0,1389,165,1,0,0,0,1390,1412,5,181,0,0,1391,1412, - 5,182,0,0,1392,1412,5,183,0,0,1393,1412,5,184,0,0,1394,1412,5,185,0,0, - 1395,1412,5,186,0,0,1396,1412,5,187,0,0,1397,1412,5,188,0,0,1398,1412, - 5,189,0,0,1399,1412,5,190,0,0,1400,1412,5,191,0,0,1401,1412,5,192,0,0, - 1402,1412,5,193,0,0,1403,1404,5,90,0,0,1404,1412,5,184,0,0,1405,1406,5, - 90,0,0,1406,1412,5,185,0,0,1407,1408,5,90,0,0,1408,1412,5,186,0,0,1409, - 1410,5,90,0,0,1410,1412,5,187,0,0,1411,1390,1,0,0,0,1411,1391,1,0,0,0, - 1411,1392,1,0,0,0,1411,1393,1,0,0,0,1411,1394,1,0,0,0,1411,1395,1,0,0, - 0,1411,1396,1,0,0,0,1411,1397,1,0,0,0,1411,1398,1,0,0,0,1411,1399,1,0, - 0,0,1411,1400,1,0,0,0,1411,1401,1,0,0,0,1411,1402,1,0,0,0,1411,1403,1, - 0,0,0,1411,1405,1,0,0,0,1411,1407,1,0,0,0,1411,1409,1,0,0,0,1412,167,1, - 0,0,0,1413,1424,1,0,0,0,1414,1424,5,177,0,0,1415,1424,3,32,16,0,1416,1417, - 3,32,16,0,1417,1418,5,177,0,0,1418,1419,3,32,16,0,1419,1424,1,0,0,0,1420, - 1421,3,32,16,0,1421,1422,5,177,0,0,1422,1424,1,0,0,0,1423,1413,1,0,0,0, - 1423,1414,1,0,0,0,1423,1415,1,0,0,0,1423,1416,1,0,0,0,1423,1420,1,0,0, - 0,1424,169,1,0,0,0,1425,1426,5,1,0,0,1426,1427,5,194,0,0,1427,171,1,0, - 0,0,1428,1432,5,1,0,0,1429,1430,5,90,0,0,1430,1433,5,194,0,0,1431,1433, - 5,195,0,0,1432,1429,1,0,0,0,1432,1431,1,0,0,0,1433,173,1,0,0,0,1434,1435, - 5,294,0,0,1435,1436,3,188,94,0,1436,1437,3,146,73,0,1437,1438,5,30,0,0, - 1438,1439,3,180,90,0,1439,1440,5,31,0,0,1440,1482,1,0,0,0,1441,1442,5, - 294,0,0,1442,1443,3,188,94,0,1443,1444,3,146,73,0,1444,1445,5,36,0,0,1445, - 1446,5,17,0,0,1446,1447,3,52,26,0,1447,1448,5,18,0,0,1448,1482,1,0,0,0, - 1449,1450,5,294,0,0,1450,1451,3,188,94,0,1451,1452,3,146,73,0,1452,1482, - 1,0,0,0,1453,1454,5,295,0,0,1454,1455,3,188,94,0,1455,1457,5,36,0,0,1456, - 1458,5,84,0,0,1457,1456,1,0,0,0,1457,1458,1,0,0,0,1458,1459,1,0,0,0,1459, - 1460,5,30,0,0,1460,1461,3,312,156,0,1461,1462,5,31,0,0,1462,1482,1,0,0, - 0,1463,1464,5,295,0,0,1464,1465,3,188,94,0,1465,1466,5,84,0,0,1466,1467, - 5,30,0,0,1467,1468,3,312,156,0,1468,1469,5,31,0,0,1469,1482,1,0,0,0,1470, - 1471,5,295,0,0,1471,1472,3,188,94,0,1472,1473,3,6,3,0,1473,1482,1,0,0, - 0,1474,1475,5,295,0,0,1475,1476,3,188,94,0,1476,1477,5,36,0,0,1477,1478, - 5,17,0,0,1478,1479,3,176,88,0,1479,1480,5,18,0,0,1480,1482,1,0,0,0,1481, - 1434,1,0,0,0,1481,1441,1,0,0,0,1481,1449,1,0,0,0,1481,1453,1,0,0,0,1481, - 1463,1,0,0,0,1481,1470,1,0,0,0,1481,1474,1,0,0,0,1482,175,1,0,0,0,1483, - 1494,1,0,0,0,1484,1485,3,178,89,0,1485,1486,5,28,0,0,1486,1488,1,0,0,0, - 1487,1484,1,0,0,0,1488,1491,1,0,0,0,1489,1487,1,0,0,0,1489,1490,1,0,0, - 0,1490,1492,1,0,0,0,1491,1489,1,0,0,0,1492,1494,3,178,89,0,1493,1483,1, - 0,0,0,1493,1489,1,0,0,0,1494,177,1,0,0,0,1495,1496,5,39,0,0,1496,1497, - 5,264,0,0,1497,1498,5,36,0,0,1498,1499,5,17,0,0,1499,1500,3,56,28,0,1500, - 1501,5,18,0,0,1501,1509,1,0,0,0,1502,1503,3,146,73,0,1503,1504,5,36,0, - 0,1504,1505,5,17,0,0,1505,1506,3,56,28,0,1506,1507,5,18,0,0,1507,1509, - 1,0,0,0,1508,1495,1,0,0,0,1508,1502,1,0,0,0,1509,179,1,0,0,0,1510,1511, - 3,182,91,0,1511,1512,5,28,0,0,1512,1514,1,0,0,0,1513,1510,1,0,0,0,1514, - 1517,1,0,0,0,1515,1513,1,0,0,0,1515,1516,1,0,0,0,1516,1518,1,0,0,0,1517, - 1515,1,0,0,0,1518,1519,3,182,91,0,1519,181,1,0,0,0,1520,1521,3,6,3,0,1521, - 1522,5,36,0,0,1522,1523,3,186,93,0,1523,183,1,0,0,0,1524,1525,7,9,0,0, - 1525,185,1,0,0,0,1526,1561,3,184,92,0,1527,1561,3,32,16,0,1528,1529,5, - 186,0,0,1529,1530,5,30,0,0,1530,1531,3,32,16,0,1531,1532,5,31,0,0,1532, - 1561,1,0,0,0,1533,1561,3,6,3,0,1534,1535,3,138,69,0,1535,1536,5,30,0,0, - 1536,1537,5,184,0,0,1537,1538,5,75,0,0,1538,1539,3,32,16,0,1539,1540,5, - 31,0,0,1540,1561,1,0,0,0,1541,1542,3,138,69,0,1542,1543,5,30,0,0,1543, - 1544,5,185,0,0,1544,1545,5,75,0,0,1545,1546,3,32,16,0,1546,1547,5,31,0, - 0,1547,1561,1,0,0,0,1548,1549,3,138,69,0,1549,1550,5,30,0,0,1550,1551, - 5,186,0,0,1551,1552,5,75,0,0,1552,1553,3,32,16,0,1553,1554,5,31,0,0,1554, - 1561,1,0,0,0,1555,1556,3,138,69,0,1556,1557,5,30,0,0,1557,1558,3,32,16, - 0,1558,1559,5,31,0,0,1559,1561,1,0,0,0,1560,1526,1,0,0,0,1560,1527,1,0, - 0,0,1560,1528,1,0,0,0,1560,1533,1,0,0,0,1560,1534,1,0,0,0,1560,1541,1, - 0,0,0,1560,1548,1,0,0,0,1560,1555,1,0,0,0,1561,187,1,0,0,0,1562,1563,7, - 10,0,0,1563,189,1,0,0,0,1564,1565,3,192,96,0,1565,1566,3,160,80,0,1566, - 1567,3,146,73,0,1567,1568,5,176,0,0,1568,1570,3,264,132,0,1569,1571,3, - 130,65,0,1570,1569,1,0,0,0,1570,1571,1,0,0,0,1571,1572,1,0,0,0,1572,1573, - 3,134,67,0,1573,1599,1,0,0,0,1574,1575,3,192,96,0,1575,1576,3,160,80,0, - 1576,1577,3,146,73,0,1577,1578,5,176,0,0,1578,1579,3,264,132,0,1579,1580, - 3,218,109,0,1580,1581,3,134,67,0,1581,1599,1,0,0,0,1582,1583,3,192,96, - 0,1583,1584,3,160,80,0,1584,1586,3,264,132,0,1585,1587,3,130,65,0,1586, - 1585,1,0,0,0,1586,1587,1,0,0,0,1587,1588,1,0,0,0,1588,1589,3,134,67,0, - 1589,1599,1,0,0,0,1590,1591,3,192,96,0,1591,1592,3,160,80,0,1592,1593, - 3,264,132,0,1593,1594,3,218,109,0,1594,1595,3,134,67,0,1595,1599,1,0,0, - 0,1596,1599,3,196,98,0,1597,1599,3,2,1,0,1598,1564,1,0,0,0,1598,1574,1, - 0,0,0,1598,1582,1,0,0,0,1598,1590,1,0,0,0,1598,1596,1,0,0,0,1598,1597, - 1,0,0,0,1599,191,1,0,0,0,1600,1601,5,243,0,0,1601,1611,3,192,96,0,1602, - 1603,5,244,0,0,1603,1611,3,192,96,0,1604,1611,3,194,97,0,1605,1606,5,112, - 0,0,1606,1607,5,30,0,0,1607,1608,3,32,16,0,1608,1609,5,31,0,0,1609,1611, - 1,0,0,0,1610,1600,1,0,0,0,1610,1602,1,0,0,0,1610,1604,1,0,0,0,1610,1605, - 1,0,0,0,1611,193,1,0,0,0,1612,1625,1,0,0,0,1613,1625,5,245,0,0,1614,1625, - 5,246,0,0,1615,1616,5,247,0,0,1616,1625,5,248,0,0,1617,1618,5,247,0,0, - 1618,1625,5,249,0,0,1619,1620,5,247,0,0,1620,1625,5,250,0,0,1621,1622, - 5,247,0,0,1622,1625,5,251,0,0,1623,1625,5,247,0,0,1624,1612,1,0,0,0,1624, - 1613,1,0,0,0,1624,1614,1,0,0,0,1624,1615,1,0,0,0,1624,1617,1,0,0,0,1624, - 1619,1,0,0,0,1624,1621,1,0,0,0,1624,1623,1,0,0,0,1625,195,1,0,0,0,1626, - 1627,5,113,0,0,1627,1628,5,30,0,0,1628,1629,3,32,16,0,1629,1630,5,31,0, - 0,1630,197,1,0,0,0,1631,1632,5,226,0,0,1632,1637,3,190,95,0,1633,1634, - 5,37,0,0,1634,1637,3,200,100,0,1635,1637,3,196,98,0,1636,1631,1,0,0,0, - 1636,1633,1,0,0,0,1636,1635,1,0,0,0,1637,199,1,0,0,0,1638,1639,3,160,80, - 0,1639,1640,3,146,73,0,1640,1641,5,176,0,0,1641,1642,3,2,1,0,1642,1648, - 1,0,0,0,1643,1644,3,160,80,0,1644,1645,3,2,1,0,1645,1648,1,0,0,0,1646, - 1648,3,2,1,0,1647,1638,1,0,0,0,1647,1643,1,0,0,0,1647,1646,1,0,0,0,1648, - 201,1,0,0,0,1649,1650,3,146,73,0,1650,1651,5,28,0,0,1651,1653,1,0,0,0, - 1652,1649,1,0,0,0,1653,1656,1,0,0,0,1654,1652,1,0,0,0,1654,1655,1,0,0, - 0,1655,1657,1,0,0,0,1656,1654,1,0,0,0,1657,1658,3,146,73,0,1658,203,1, - 0,0,0,1659,1665,1,0,0,0,1660,1661,5,86,0,0,1661,1662,3,212,106,0,1662, - 1663,5,87,0,0,1663,1665,1,0,0,0,1664,1659,1,0,0,0,1664,1660,1,0,0,0,1665, - 205,1,0,0,0,1666,1678,5,266,0,0,1667,1678,5,114,0,0,1668,1678,5,39,0,0, - 1669,1678,5,200,0,0,1670,1678,5,115,0,0,1671,1678,5,116,0,0,1672,1673, - 5,70,0,0,1673,1674,5,30,0,0,1674,1675,3,32,16,0,1675,1676,5,31,0,0,1676, - 1678,1,0,0,0,1677,1666,1,0,0,0,1677,1667,1,0,0,0,1677,1668,1,0,0,0,1677, - 1669,1,0,0,0,1677,1670,1,0,0,0,1677,1671,1,0,0,0,1677,1672,1,0,0,0,1678, - 207,1,0,0,0,1679,1681,3,206,103,0,1680,1679,1,0,0,0,1681,1684,1,0,0,0, - 1682,1680,1,0,0,0,1682,1683,1,0,0,0,1683,209,1,0,0,0,1684,1682,1,0,0,0, - 1685,1687,3,208,104,0,1686,1688,3,214,107,0,1687,1686,1,0,0,0,1687,1688, - 1,0,0,0,1688,1689,1,0,0,0,1689,1690,3,2,1,0,1690,211,1,0,0,0,1691,1692, - 3,210,105,0,1692,1693,5,28,0,0,1693,1695,1,0,0,0,1694,1691,1,0,0,0,1695, - 1698,1,0,0,0,1696,1694,1,0,0,0,1696,1697,1,0,0,0,1697,1699,1,0,0,0,1698, - 1696,1,0,0,0,1699,1700,3,210,105,0,1700,213,1,0,0,0,1701,1702,5,30,0,0, - 1702,1703,3,202,101,0,1703,1704,5,31,0,0,1704,215,1,0,0,0,1705,1708,1, - 0,0,0,1706,1708,3,218,109,0,1707,1705,1,0,0,0,1707,1706,1,0,0,0,1708,217, - 1,0,0,0,1709,1710,5,86,0,0,1710,1711,5,42,0,0,1711,1712,3,32,16,0,1712, - 1713,5,43,0,0,1713,1714,5,87,0,0,1714,219,1,0,0,0,1715,1716,3,256,128, - 0,1716,1717,5,17,0,0,1717,1718,3,268,134,0,1718,1719,5,18,0,0,1719,1832, - 1,0,0,0,1720,1721,3,74,37,0,1721,1722,5,17,0,0,1722,1723,3,82,41,0,1723, - 1724,5,18,0,0,1724,1832,1,0,0,0,1725,1726,3,232,116,0,1726,1727,5,17,0, - 0,1727,1728,3,236,118,0,1728,1729,5,18,0,0,1729,1832,1,0,0,0,1730,1731, - 3,240,120,0,1731,1732,5,17,0,0,1732,1733,3,244,122,0,1733,1734,5,18,0, - 0,1734,1832,1,0,0,0,1735,1832,3,222,111,0,1736,1832,3,296,148,0,1737,1832, - 3,174,87,0,1738,1832,3,88,44,0,1739,1832,3,342,171,0,1740,1741,5,117,0, - 0,1741,1832,3,32,16,0,1742,1743,5,118,0,0,1743,1832,3,32,16,0,1744,1745, - 3,354,177,0,1745,1746,5,17,0,0,1746,1747,3,358,179,0,1747,1748,5,18,0, - 0,1748,1832,1,0,0,0,1749,1750,5,302,0,0,1750,1751,3,146,73,0,1751,1752, - 5,176,0,0,1752,1753,3,264,132,0,1753,1754,5,119,0,0,1754,1755,3,192,96, - 0,1755,1756,3,160,80,0,1756,1757,3,146,73,0,1757,1758,5,176,0,0,1758,1759, - 3,264,132,0,1759,1760,3,134,67,0,1760,1832,1,0,0,0,1761,1762,5,302,0,0, - 1762,1763,5,226,0,0,1763,1764,3,192,96,0,1764,1765,3,160,80,0,1765,1766, - 3,146,73,0,1766,1767,5,176,0,0,1767,1768,3,264,132,0,1768,1769,3,216,108, - 0,1769,1770,3,134,67,0,1770,1771,5,119,0,0,1771,1772,5,226,0,0,1772,1773, - 3,192,96,0,1773,1774,3,160,80,0,1774,1775,3,146,73,0,1775,1776,5,176,0, - 0,1776,1777,3,264,132,0,1777,1778,3,216,108,0,1778,1779,3,134,67,0,1779, - 1832,1,0,0,0,1780,1832,3,26,13,0,1781,1832,3,40,20,0,1782,1783,5,255,0, - 0,1783,1784,5,196,0,0,1784,1785,5,42,0,0,1785,1786,3,32,16,0,1786,1790, - 5,43,0,0,1787,1789,3,342,171,0,1788,1787,1,0,0,0,1789,1792,1,0,0,0,1790, - 1788,1,0,0,0,1790,1791,1,0,0,0,1791,1832,1,0,0,0,1792,1790,1,0,0,0,1793, - 1794,5,255,0,0,1794,1795,5,196,0,0,1795,1799,3,2,1,0,1796,1798,3,342,171, - 0,1797,1796,1,0,0,0,1798,1801,1,0,0,0,1799,1797,1,0,0,0,1799,1800,1,0, - 0,0,1800,1832,1,0,0,0,1801,1799,1,0,0,0,1802,1803,5,255,0,0,1803,1804, - 5,256,0,0,1804,1805,5,42,0,0,1805,1806,3,32,16,0,1806,1807,5,43,0,0,1807, - 1808,5,28,0,0,1808,1812,3,146,73,0,1809,1811,3,342,171,0,1810,1809,1,0, - 0,0,1811,1814,1,0,0,0,1812,1810,1,0,0,0,1812,1813,1,0,0,0,1813,1832,1, - 0,0,0,1814,1812,1,0,0,0,1815,1816,5,255,0,0,1816,1817,5,256,0,0,1817,1818, - 3,2,1,0,1818,1819,5,28,0,0,1819,1823,3,146,73,0,1820,1822,3,342,171,0, - 1821,1820,1,0,0,0,1822,1825,1,0,0,0,1823,1821,1,0,0,0,1823,1824,1,0,0, - 0,1824,1832,1,0,0,0,1825,1823,1,0,0,0,1826,1827,5,120,0,0,1827,1828,5, - 196,0,0,1828,1829,3,146,73,0,1829,1830,3,44,22,0,1830,1832,1,0,0,0,1831, - 1715,1,0,0,0,1831,1720,1,0,0,0,1831,1725,1,0,0,0,1831,1730,1,0,0,0,1831, - 1735,1,0,0,0,1831,1736,1,0,0,0,1831,1737,1,0,0,0,1831,1738,1,0,0,0,1831, - 1739,1,0,0,0,1831,1740,1,0,0,0,1831,1742,1,0,0,0,1831,1744,1,0,0,0,1831, - 1749,1,0,0,0,1831,1761,1,0,0,0,1831,1780,1,0,0,0,1831,1781,1,0,0,0,1831, - 1782,1,0,0,0,1831,1793,1,0,0,0,1831,1802,1,0,0,0,1831,1815,1,0,0,0,1831, - 1826,1,0,0,0,1832,221,1,0,0,0,1833,1834,5,121,0,0,1834,1843,3,230,115, - 0,1835,1842,3,224,112,0,1836,1837,5,122,0,0,1837,1838,5,30,0,0,1838,1839, - 3,250,125,0,1839,1840,5,31,0,0,1840,1842,1,0,0,0,1841,1835,1,0,0,0,1841, - 1836,1,0,0,0,1842,1845,1,0,0,0,1843,1841,1,0,0,0,1843,1844,1,0,0,0,1844, - 1846,1,0,0,0,1845,1843,1,0,0,0,1846,1847,3,160,80,0,1847,1848,3,2,1,0, - 1848,1849,3,226,113,0,1849,1850,3,228,114,0,1850,223,1,0,0,0,1851,1871, - 5,123,0,0,1852,1871,5,51,0,0,1853,1871,5,52,0,0,1854,1871,5,63,0,0,1855, - 1871,5,124,0,0,1856,1871,5,69,0,0,1857,1871,5,68,0,0,1858,1871,5,64,0, - 0,1859,1871,5,65,0,0,1860,1871,5,66,0,0,1861,1871,5,125,0,0,1862,1871, - 5,126,0,0,1863,1871,5,127,0,0,1864,1871,5,16,0,0,1865,1866,5,70,0,0,1866, - 1867,5,30,0,0,1867,1868,3,32,16,0,1868,1869,5,31,0,0,1869,1871,1,0,0,0, - 1870,1851,1,0,0,0,1870,1852,1,0,0,0,1870,1853,1,0,0,0,1870,1854,1,0,0, - 0,1870,1855,1,0,0,0,1870,1856,1,0,0,0,1870,1857,1,0,0,0,1870,1858,1,0, - 0,0,1870,1859,1,0,0,0,1870,1860,1,0,0,0,1870,1861,1,0,0,0,1870,1862,1, - 0,0,0,1870,1863,1,0,0,0,1870,1864,1,0,0,0,1870,1865,1,0,0,0,1871,225,1, - 0,0,0,1872,1878,1,0,0,0,1873,1874,5,44,0,0,1874,1878,3,0,0,0,1875,1876, - 5,44,0,0,1876,1878,3,32,16,0,1877,1872,1,0,0,0,1877,1873,1,0,0,0,1877, - 1875,1,0,0,0,1878,227,1,0,0,0,1879,1883,1,0,0,0,1880,1881,5,36,0,0,1881, - 1883,3,316,158,0,1882,1879,1,0,0,0,1882,1880,1,0,0,0,1883,229,1,0,0,0, - 1884,1890,1,0,0,0,1885,1886,5,42,0,0,1886,1887,3,32,16,0,1887,1888,5,43, - 0,0,1888,1890,1,0,0,0,1889,1884,1,0,0,0,1889,1885,1,0,0,0,1890,231,1,0, - 0,0,1891,1895,5,128,0,0,1892,1894,3,234,117,0,1893,1892,1,0,0,0,1894,1897, - 1,0,0,0,1895,1893,1,0,0,0,1895,1896,1,0,0,0,1896,1898,1,0,0,0,1897,1895, - 1,0,0,0,1898,1899,3,146,73,0,1899,1900,3,2,1,0,1900,1910,1,0,0,0,1901, - 1905,5,128,0,0,1902,1904,3,234,117,0,1903,1902,1,0,0,0,1904,1907,1,0,0, - 0,1905,1903,1,0,0,0,1905,1906,1,0,0,0,1906,1908,1,0,0,0,1907,1905,1,0, - 0,0,1908,1910,3,2,1,0,1909,1891,1,0,0,0,1909,1901,1,0,0,0,1910,233,1,0, - 0,0,1911,1912,7,11,0,0,1912,235,1,0,0,0,1913,1915,3,238,119,0,1914,1913, - 1,0,0,0,1915,1918,1,0,0,0,1916,1914,1,0,0,0,1916,1917,1,0,0,0,1917,237, - 1,0,0,0,1918,1916,1,0,0,0,1919,1920,5,129,0,0,1920,1932,3,190,95,0,1921, - 1922,5,130,0,0,1922,1932,3,190,95,0,1923,1924,5,131,0,0,1924,1932,3,190, - 95,0,1925,1926,5,132,0,0,1926,1932,3,190,95,0,1927,1932,3,88,44,0,1928, - 1932,3,342,171,0,1929,1932,3,26,13,0,1930,1932,3,40,20,0,1931,1919,1,0, - 0,0,1931,1921,1,0,0,0,1931,1923,1,0,0,0,1931,1925,1,0,0,0,1931,1927,1, - 0,0,0,1931,1928,1,0,0,0,1931,1929,1,0,0,0,1931,1930,1,0,0,0,1932,239,1, - 0,0,0,1933,1937,5,133,0,0,1934,1936,3,242,121,0,1935,1934,1,0,0,0,1936, - 1939,1,0,0,0,1937,1935,1,0,0,0,1937,1938,1,0,0,0,1938,1940,1,0,0,0,1939, - 1937,1,0,0,0,1940,1941,3,192,96,0,1941,1942,3,160,80,0,1942,1943,3,2,1, - 0,1943,1944,3,134,67,0,1944,1945,3,228,114,0,1945,241,1,0,0,0,1946,1947, - 7,11,0,0,1947,243,1,0,0,0,1948,1950,3,246,123,0,1949,1948,1,0,0,0,1950, - 1953,1,0,0,0,1951,1949,1,0,0,0,1951,1952,1,0,0,0,1952,245,1,0,0,0,1953, - 1951,1,0,0,0,1954,1955,5,134,0,0,1955,1965,3,190,95,0,1956,1957,5,135, - 0,0,1957,1965,3,190,95,0,1958,1959,5,132,0,0,1959,1965,3,190,95,0,1960, - 1965,3,342,171,0,1961,1965,3,88,44,0,1962,1965,3,26,13,0,1963,1965,3,40, - 20,0,1964,1954,1,0,0,0,1964,1956,1,0,0,0,1964,1958,1,0,0,0,1964,1960,1, - 0,0,0,1964,1961,1,0,0,0,1964,1962,1,0,0,0,1964,1963,1,0,0,0,1965,247,1, - 0,0,0,1966,1973,1,0,0,0,1967,1968,5,122,0,0,1968,1969,5,30,0,0,1969,1970, - 3,250,125,0,1970,1971,5,31,0,0,1971,1973,1,0,0,0,1972,1966,1,0,0,0,1972, - 1967,1,0,0,0,1973,249,1,0,0,0,1974,1984,3,148,74,0,1975,1977,5,17,0,0, - 1976,1978,3,314,157,0,1977,1976,1,0,0,0,1978,1979,1,0,0,0,1979,1977,1, - 0,0,0,1979,1980,1,0,0,0,1980,1981,1,0,0,0,1981,1982,5,18,0,0,1982,1984, - 1,0,0,0,1983,1974,1,0,0,0,1983,1975,1,0,0,0,1984,251,1,0,0,0,1985,1987, - 3,254,127,0,1986,1985,1,0,0,0,1987,1990,1,0,0,0,1988,1986,1,0,0,0,1988, - 1989,1,0,0,0,1989,253,1,0,0,0,1990,1988,1,0,0,0,1991,1992,5,42,0,0,1992, - 1993,5,136,0,0,1993,2005,5,43,0,0,1994,1995,5,42,0,0,1995,1996,5,137,0, - 0,1996,2005,5,43,0,0,1997,1998,5,42,0,0,1998,1999,5,138,0,0,1999,2005, - 5,43,0,0,2000,2001,5,42,0,0,2001,2002,3,32,16,0,2002,2003,5,43,0,0,2003, - 2005,1,0,0,0,2004,1991,1,0,0,0,2004,1994,1,0,0,0,2004,1997,1,0,0,0,2004, - 2000,1,0,0,0,2005,255,1,0,0,0,2006,2011,5,139,0,0,2007,2010,3,258,129, - 0,2008,2010,3,260,130,0,2009,2007,1,0,0,0,2009,2008,1,0,0,0,2010,2013, - 1,0,0,0,2011,2009,1,0,0,0,2011,2012,1,0,0,0,2012,2014,1,0,0,0,2013,2011, - 1,0,0,0,2014,2015,3,192,96,0,2015,2016,3,252,126,0,2016,2017,3,160,80, - 0,2017,2018,3,248,124,0,2018,2019,3,264,132,0,2019,2020,3,204,102,0,2020, - 2024,3,134,67,0,2021,2023,3,266,133,0,2022,2021,1,0,0,0,2023,2026,1,0, - 0,0,2024,2022,1,0,0,0,2024,2025,1,0,0,0,2025,257,1,0,0,0,2026,2024,1,0, - 0,0,2027,2051,5,123,0,0,2028,2051,5,51,0,0,2029,2051,5,52,0,0,2030,2051, - 5,63,0,0,2031,2051,5,140,0,0,2032,2051,5,68,0,0,2033,2051,5,141,0,0,2034, - 2051,5,142,0,0,2035,2051,5,54,0,0,2036,2051,5,64,0,0,2037,2051,5,65,0, - 0,2038,2051,5,66,0,0,2039,2051,5,125,0,0,2040,2051,5,143,0,0,2041,2051, - 5,144,0,0,2042,2051,5,69,0,0,2043,2051,5,145,0,0,2044,2051,5,146,0,0,2045, - 2046,5,70,0,0,2046,2047,5,30,0,0,2047,2048,3,32,16,0,2048,2049,5,31,0, - 0,2049,2051,1,0,0,0,2050,2027,1,0,0,0,2050,2028,1,0,0,0,2050,2029,1,0, - 0,0,2050,2030,1,0,0,0,2050,2031,1,0,0,0,2050,2032,1,0,0,0,2050,2033,1, - 0,0,0,2050,2034,1,0,0,0,2050,2035,1,0,0,0,2050,2036,1,0,0,0,2050,2037, - 1,0,0,0,2050,2038,1,0,0,0,2050,2039,1,0,0,0,2050,2040,1,0,0,0,2050,2041, - 1,0,0,0,2050,2042,1,0,0,0,2050,2043,1,0,0,0,2050,2044,1,0,0,0,2050,2045, - 1,0,0,0,2051,259,1,0,0,0,2052,2053,5,147,0,0,2053,2059,5,30,0,0,2054,2057, - 3,6,3,0,2055,2056,5,34,0,0,2056,2058,3,6,3,0,2057,2055,1,0,0,0,2057,2058, - 1,0,0,0,2058,2060,1,0,0,0,2059,2054,1,0,0,0,2059,2060,1,0,0,0,2060,2064, - 1,0,0,0,2061,2063,3,262,131,0,2062,2061,1,0,0,0,2063,2066,1,0,0,0,2064, - 2062,1,0,0,0,2064,2065,1,0,0,0,2065,2067,1,0,0,0,2066,2064,1,0,0,0,2067, - 2071,5,31,0,0,2068,2069,5,147,0,0,2069,2071,5,85,0,0,2070,2052,1,0,0,0, - 2070,2068,1,0,0,0,2071,261,1,0,0,0,2072,2100,5,148,0,0,2073,2100,5,224, - 0,0,2074,2100,5,57,0,0,2075,2100,5,58,0,0,2076,2100,5,149,0,0,2077,2100, - 5,150,0,0,2078,2100,5,248,0,0,2079,2100,5,249,0,0,2080,2100,5,250,0,0, - 2081,2100,5,251,0,0,2082,2083,5,151,0,0,2083,2084,5,75,0,0,2084,2100,5, - 152,0,0,2085,2086,5,151,0,0,2086,2087,5,75,0,0,2087,2100,5,153,0,0,2088, - 2089,5,154,0,0,2089,2090,5,75,0,0,2090,2100,5,152,0,0,2091,2092,5,154, - 0,0,2092,2093,5,75,0,0,2093,2100,5,153,0,0,2094,2095,5,70,0,0,2095,2096, - 5,30,0,0,2096,2097,3,32,16,0,2097,2098,5,31,0,0,2098,2100,1,0,0,0,2099, - 2072,1,0,0,0,2099,2073,1,0,0,0,2099,2074,1,0,0,0,2099,2075,1,0,0,0,2099, - 2076,1,0,0,0,2099,2077,1,0,0,0,2099,2078,1,0,0,0,2099,2079,1,0,0,0,2099, - 2080,1,0,0,0,2099,2081,1,0,0,0,2099,2082,1,0,0,0,2099,2085,1,0,0,0,2099, - 2088,1,0,0,0,2099,2091,1,0,0,0,2099,2094,1,0,0,0,2100,263,1,0,0,0,2101, - 2105,5,116,0,0,2102,2105,5,155,0,0,2103,2105,3,2,1,0,2104,2101,1,0,0,0, - 2104,2102,1,0,0,0,2104,2103,1,0,0,0,2105,265,1,0,0,0,2106,2128,5,1,0,0, - 2107,2128,5,2,0,0,2108,2128,5,156,0,0,2109,2128,5,3,0,0,2110,2128,5,4, - 0,0,2111,2128,5,247,0,0,2112,2128,5,5,0,0,2113,2128,5,6,0,0,2114,2128, - 5,7,0,0,2115,2128,5,8,0,0,2116,2128,5,9,0,0,2117,2128,5,10,0,0,2118,2128, - 5,11,0,0,2119,2128,5,12,0,0,2120,2128,5,13,0,0,2121,2128,5,14,0,0,2122, - 2123,5,70,0,0,2123,2124,5,30,0,0,2124,2125,3,32,16,0,2125,2126,5,31,0, - 0,2126,2128,1,0,0,0,2127,2106,1,0,0,0,2127,2107,1,0,0,0,2127,2108,1,0, - 0,0,2127,2109,1,0,0,0,2127,2110,1,0,0,0,2127,2111,1,0,0,0,2127,2112,1, - 0,0,0,2127,2113,1,0,0,0,2127,2114,1,0,0,0,2127,2115,1,0,0,0,2127,2116, - 1,0,0,0,2127,2117,1,0,0,0,2127,2118,1,0,0,0,2127,2119,1,0,0,0,2127,2120, - 1,0,0,0,2127,2121,1,0,0,0,2127,2122,1,0,0,0,2128,267,1,0,0,0,2129,2131, - 3,270,135,0,2130,2129,1,0,0,0,2131,2134,1,0,0,0,2132,2130,1,0,0,0,2132, - 2133,1,0,0,0,2133,269,1,0,0,0,2134,2132,1,0,0,0,2135,2244,3,126,63,0,2136, - 2137,5,296,0,0,2137,2244,3,32,16,0,2138,2244,3,278,139,0,2139,2140,5,297, - 0,0,2140,2244,3,32,16,0,2141,2142,5,300,0,0,2142,2244,3,134,67,0,2143, - 2144,5,300,0,0,2144,2145,5,157,0,0,2145,2244,3,134,67,0,2146,2244,5,298, - 0,0,2147,2244,5,299,0,0,2148,2244,3,296,148,0,2149,2244,3,272,136,0,2150, - 2244,3,174,87,0,2151,2244,3,88,44,0,2152,2244,3,26,13,0,2153,2244,3,274, - 137,0,2154,2244,3,40,20,0,2155,2156,5,301,0,0,2156,2157,5,42,0,0,2157, - 2158,3,32,16,0,2158,2159,5,43,0,0,2159,2244,1,0,0,0,2160,2161,5,301,0, - 0,2161,2162,5,42,0,0,2162,2163,3,32,16,0,2163,2164,5,43,0,0,2164,2165, - 5,34,0,0,2165,2166,3,0,0,0,2166,2244,1,0,0,0,2167,2168,5,303,0,0,2168, - 2169,3,32,16,0,2169,2170,5,75,0,0,2170,2171,3,32,16,0,2171,2244,1,0,0, - 0,2172,2173,5,302,0,0,2173,2174,3,146,73,0,2174,2175,5,176,0,0,2175,2176, - 3,264,132,0,2176,2244,1,0,0,0,2177,2178,5,302,0,0,2178,2179,5,226,0,0, - 2179,2180,3,192,96,0,2180,2181,3,160,80,0,2181,2182,3,146,73,0,2182,2183, - 5,176,0,0,2183,2184,3,264,132,0,2184,2185,3,216,108,0,2185,2186,3,134, - 67,0,2186,2244,1,0,0,0,2187,2244,3,276,138,0,2188,2189,5,255,0,0,2189, - 2190,5,196,0,0,2190,2191,5,42,0,0,2191,2192,3,32,16,0,2192,2196,5,43,0, - 0,2193,2195,3,342,171,0,2194,2193,1,0,0,0,2195,2198,1,0,0,0,2196,2194, - 1,0,0,0,2196,2197,1,0,0,0,2197,2244,1,0,0,0,2198,2196,1,0,0,0,2199,2200, - 5,255,0,0,2200,2201,5,196,0,0,2201,2205,3,2,1,0,2202,2204,3,342,171,0, - 2203,2202,1,0,0,0,2204,2207,1,0,0,0,2205,2203,1,0,0,0,2205,2206,1,0,0, - 0,2206,2244,1,0,0,0,2207,2205,1,0,0,0,2208,2209,5,255,0,0,2209,2210,5, - 256,0,0,2210,2211,5,42,0,0,2211,2212,3,32,16,0,2212,2213,5,43,0,0,2213, - 2214,5,28,0,0,2214,2218,3,146,73,0,2215,2217,3,342,171,0,2216,2215,1,0, - 0,0,2217,2220,1,0,0,0,2218,2216,1,0,0,0,2218,2219,1,0,0,0,2219,2244,1, - 0,0,0,2220,2218,1,0,0,0,2221,2222,5,255,0,0,2222,2223,5,256,0,0,2223,2224, - 3,2,1,0,2224,2225,5,28,0,0,2225,2229,3,146,73,0,2226,2228,3,342,171,0, - 2227,2226,1,0,0,0,2228,2231,1,0,0,0,2229,2227,1,0,0,0,2229,2230,1,0,0, - 0,2230,2244,1,0,0,0,2231,2229,1,0,0,0,2232,2233,5,255,0,0,2233,2234,5, - 42,0,0,2234,2235,3,32,16,0,2235,2236,5,43,0,0,2236,2240,3,228,114,0,2237, - 2239,3,342,171,0,2238,2237,1,0,0,0,2239,2242,1,0,0,0,2240,2238,1,0,0,0, - 2240,2241,1,0,0,0,2241,2244,1,0,0,0,2242,2240,1,0,0,0,2243,2135,1,0,0, - 0,2243,2136,1,0,0,0,2243,2138,1,0,0,0,2243,2139,1,0,0,0,2243,2141,1,0, - 0,0,2243,2143,1,0,0,0,2243,2146,1,0,0,0,2243,2147,1,0,0,0,2243,2148,1, - 0,0,0,2243,2149,1,0,0,0,2243,2150,1,0,0,0,2243,2151,1,0,0,0,2243,2152, - 1,0,0,0,2243,2153,1,0,0,0,2243,2154,1,0,0,0,2243,2155,1,0,0,0,2243,2160, - 1,0,0,0,2243,2167,1,0,0,0,2243,2172,1,0,0,0,2243,2177,1,0,0,0,2243,2187, - 1,0,0,0,2243,2188,1,0,0,0,2243,2199,1,0,0,0,2243,2208,1,0,0,0,2243,2221, - 1,0,0,0,2243,2232,1,0,0,0,2244,271,1,0,0,0,2245,2246,3,0,0,0,2246,2247, - 5,75,0,0,2247,273,1,0,0,0,2248,2251,3,44,22,0,2249,2251,3,46,23,0,2250, - 2248,1,0,0,0,2250,2249,1,0,0,0,2251,275,1,0,0,0,2252,2253,5,17,0,0,2253, - 2254,3,268,134,0,2254,2255,5,18,0,0,2255,277,1,0,0,0,2256,2257,3,282,141, - 0,2257,2258,3,280,140,0,2258,279,1,0,0,0,2259,2261,3,284,142,0,2260,2259, - 1,0,0,0,2261,2262,1,0,0,0,2262,2260,1,0,0,0,2262,2263,1,0,0,0,2263,281, - 1,0,0,0,2264,2265,5,158,0,0,2265,2277,3,276,138,0,2266,2267,5,158,0,0, - 2267,2268,3,0,0,0,2268,2269,5,159,0,0,2269,2270,3,0,0,0,2270,2277,1,0, - 0,0,2271,2272,5,158,0,0,2272,2273,3,32,16,0,2273,2274,5,159,0,0,2274,2275, - 3,32,16,0,2275,2277,1,0,0,0,2276,2264,1,0,0,0,2276,2266,1,0,0,0,2276,2271, - 1,0,0,0,2277,283,1,0,0,0,2278,2279,3,288,144,0,2279,2280,3,294,147,0,2280, - 2291,1,0,0,0,2281,2282,3,286,143,0,2282,2283,3,294,147,0,2283,2291,1,0, - 0,0,2284,2285,3,290,145,0,2285,2286,3,294,147,0,2286,2291,1,0,0,0,2287, - 2288,3,292,146,0,2288,2289,3,294,147,0,2289,2291,1,0,0,0,2290,2278,1,0, - 0,0,2290,2281,1,0,0,0,2290,2284,1,0,0,0,2290,2287,1,0,0,0,2291,285,1,0, - 0,0,2292,2293,5,160,0,0,2293,2299,3,276,138,0,2294,2295,5,160,0,0,2295, - 2299,3,0,0,0,2296,2297,5,160,0,0,2297,2299,3,32,16,0,2298,2292,1,0,0,0, - 2298,2294,1,0,0,0,2298,2296,1,0,0,0,2299,287,1,0,0,0,2300,2301,5,161,0, - 0,2301,2302,3,146,73,0,2302,289,1,0,0,0,2303,2304,5,162,0,0,2304,291,1, - 0,0,0,2305,2306,5,163,0,0,2306,293,1,0,0,0,2307,2319,3,276,138,0,2308, - 2309,5,164,0,0,2309,2310,3,0,0,0,2310,2311,5,159,0,0,2311,2312,3,0,0,0, - 2312,2319,1,0,0,0,2313,2314,5,164,0,0,2314,2315,3,32,16,0,2315,2316,5, - 159,0,0,2316,2317,3,32,16,0,2317,2319,1,0,0,0,2318,2307,1,0,0,0,2318,2308, - 1,0,0,0,2318,2313,1,0,0,0,2319,295,1,0,0,0,2320,2321,3,298,149,0,2321, - 2322,3,302,151,0,2322,297,1,0,0,0,2323,2324,5,165,0,0,2324,2325,3,300, - 150,0,2325,2326,3,0,0,0,2326,2327,5,36,0,0,2327,2331,1,0,0,0,2328,2329, - 5,165,0,0,2329,2331,3,300,150,0,2330,2323,1,0,0,0,2330,2328,1,0,0,0,2331, - 299,1,0,0,0,2332,2336,1,0,0,0,2333,2336,5,166,0,0,2334,2336,5,2,0,0,2335, - 2332,1,0,0,0,2335,2333,1,0,0,0,2335,2334,1,0,0,0,2336,301,1,0,0,0,2337, - 2338,5,17,0,0,2338,2339,3,304,152,0,2339,2340,5,18,0,0,2340,2347,1,0,0, - 0,2341,2343,3,308,154,0,2342,2341,1,0,0,0,2343,2344,1,0,0,0,2344,2342, - 1,0,0,0,2344,2345,1,0,0,0,2345,2347,1,0,0,0,2346,2337,1,0,0,0,2346,2342, - 1,0,0,0,2347,303,1,0,0,0,2348,2349,3,308,154,0,2349,2350,5,28,0,0,2350, - 2352,1,0,0,0,2351,2348,1,0,0,0,2352,2355,1,0,0,0,2353,2351,1,0,0,0,2353, - 2354,1,0,0,0,2354,2356,1,0,0,0,2355,2353,1,0,0,0,2356,2357,3,308,154,0, - 2357,305,1,0,0,0,2358,2364,1,0,0,0,2359,2360,5,42,0,0,2360,2361,3,32,16, - 0,2361,2362,5,43,0,0,2362,2364,1,0,0,0,2363,2358,1,0,0,0,2363,2359,1,0, - 0,0,2364,307,1,0,0,0,2365,2366,5,181,0,0,2366,2367,5,262,0,0,2367,2368, - 5,30,0,0,2368,2369,3,6,3,0,2369,2370,5,31,0,0,2370,2432,1,0,0,0,2371,2372, - 5,260,0,0,2372,2373,5,30,0,0,2373,2374,3,0,0,0,2374,2375,5,31,0,0,2375, - 2432,1,0,0,0,2376,2377,5,260,0,0,2377,2432,3,0,0,0,2378,2379,5,84,0,0, - 2379,2380,5,30,0,0,2380,2381,3,312,156,0,2381,2382,5,31,0,0,2382,2432, - 1,0,0,0,2383,2384,5,188,0,0,2384,2385,5,30,0,0,2385,2386,3,36,18,0,2386, - 2387,5,31,0,0,2387,2388,3,306,153,0,2388,2432,1,0,0,0,2389,2390,5,189, - 0,0,2390,2391,5,30,0,0,2391,2392,3,36,18,0,2392,2393,5,31,0,0,2393,2394, - 3,306,153,0,2394,2432,1,0,0,0,2395,2396,5,187,0,0,2396,2397,5,30,0,0,2397, - 2398,3,34,17,0,2398,2399,5,31,0,0,2399,2400,3,306,153,0,2400,2432,1,0, - 0,0,2401,2402,5,186,0,0,2402,2403,5,30,0,0,2403,2404,3,32,16,0,2404,2405, - 5,31,0,0,2405,2406,3,306,153,0,2406,2432,1,0,0,0,2407,2408,5,185,0,0,2408, - 2409,5,30,0,0,2409,2410,3,32,16,0,2410,2411,5,31,0,0,2411,2412,3,306,153, - 0,2412,2432,1,0,0,0,2413,2414,5,184,0,0,2414,2415,5,30,0,0,2415,2416,3, - 32,16,0,2416,2417,5,31,0,0,2417,2418,3,306,153,0,2418,2432,1,0,0,0,2419, - 2420,5,188,0,0,2420,2432,3,306,153,0,2421,2422,5,189,0,0,2422,2432,3,306, - 153,0,2423,2424,5,187,0,0,2424,2432,3,306,153,0,2425,2426,5,186,0,0,2426, - 2432,3,306,153,0,2427,2428,5,185,0,0,2428,2432,3,306,153,0,2429,2430,5, - 184,0,0,2430,2432,3,306,153,0,2431,2365,1,0,0,0,2431,2371,1,0,0,0,2431, - 2376,1,0,0,0,2431,2378,1,0,0,0,2431,2383,1,0,0,0,2431,2389,1,0,0,0,2431, - 2395,1,0,0,0,2431,2401,1,0,0,0,2431,2407,1,0,0,0,2431,2413,1,0,0,0,2431, - 2419,1,0,0,0,2431,2421,1,0,0,0,2431,2423,1,0,0,0,2431,2425,1,0,0,0,2431, - 2427,1,0,0,0,2431,2429,1,0,0,0,2432,309,1,0,0,0,2433,2434,5,188,0,0,2434, - 2435,5,30,0,0,2435,2436,3,36,18,0,2436,2437,5,31,0,0,2437,2509,1,0,0,0, - 2438,2439,5,189,0,0,2439,2440,5,30,0,0,2440,2441,3,36,18,0,2441,2442,5, - 31,0,0,2442,2509,1,0,0,0,2443,2444,5,188,0,0,2444,2445,5,30,0,0,2445,2446, - 3,32,16,0,2446,2447,5,31,0,0,2447,2509,1,0,0,0,2448,2449,5,189,0,0,2449, - 2450,5,30,0,0,2450,2451,3,34,17,0,2451,2452,5,31,0,0,2452,2509,1,0,0,0, - 2453,2454,5,187,0,0,2454,2455,5,30,0,0,2455,2456,3,34,17,0,2456,2457,5, - 31,0,0,2457,2509,1,0,0,0,2458,2459,5,186,0,0,2459,2460,5,30,0,0,2460,2461, - 3,32,16,0,2461,2462,5,31,0,0,2462,2509,1,0,0,0,2463,2464,5,185,0,0,2464, - 2465,5,30,0,0,2465,2466,3,32,16,0,2466,2467,5,31,0,0,2467,2509,1,0,0,0, - 2468,2469,5,184,0,0,2469,2470,5,30,0,0,2470,2471,3,32,16,0,2471,2472,5, - 31,0,0,2472,2509,1,0,0,0,2473,2474,5,193,0,0,2474,2475,5,30,0,0,2475,2476, - 3,34,17,0,2476,2477,5,31,0,0,2477,2509,1,0,0,0,2478,2479,5,192,0,0,2479, - 2480,5,30,0,0,2480,2481,3,32,16,0,2481,2482,5,31,0,0,2482,2509,1,0,0,0, - 2483,2484,5,191,0,0,2484,2485,5,30,0,0,2485,2486,3,32,16,0,2486,2487,5, - 31,0,0,2487,2509,1,0,0,0,2488,2489,5,190,0,0,2489,2490,5,30,0,0,2490,2491, - 3,32,16,0,2491,2492,5,31,0,0,2492,2509,1,0,0,0,2493,2494,5,181,0,0,2494, - 2495,5,30,0,0,2495,2496,3,32,16,0,2496,2497,5,31,0,0,2497,2509,1,0,0,0, - 2498,2499,5,183,0,0,2499,2500,5,30,0,0,2500,2501,3,184,92,0,2501,2502, - 5,31,0,0,2502,2509,1,0,0,0,2503,2504,5,84,0,0,2504,2505,5,30,0,0,2505, - 2506,3,312,156,0,2506,2507,5,31,0,0,2507,2509,1,0,0,0,2508,2433,1,0,0, - 0,2508,2438,1,0,0,0,2508,2443,1,0,0,0,2508,2448,1,0,0,0,2508,2453,1,0, - 0,0,2508,2458,1,0,0,0,2508,2463,1,0,0,0,2508,2468,1,0,0,0,2508,2473,1, - 0,0,0,2508,2478,1,0,0,0,2508,2483,1,0,0,0,2508,2488,1,0,0,0,2508,2493, - 1,0,0,0,2508,2498,1,0,0,0,2508,2503,1,0,0,0,2509,311,1,0,0,0,2510,2512, - 3,314,157,0,2511,2510,1,0,0,0,2512,2515,1,0,0,0,2513,2511,1,0,0,0,2513, - 2514,1,0,0,0,2514,313,1,0,0,0,2515,2513,1,0,0,0,2516,2517,7,12,0,0,2517, - 315,1,0,0,0,2518,2522,3,310,155,0,2519,2522,3,6,3,0,2520,2522,5,179,0, - 0,2521,2518,1,0,0,0,2521,2519,1,0,0,0,2521,2520,1,0,0,0,2522,317,1,0,0, - 0,2523,2672,3,310,155,0,2524,2525,5,182,0,0,2525,2526,5,30,0,0,2526,2527, - 5,179,0,0,2527,2672,5,31,0,0,2528,2529,5,182,0,0,2529,2530,5,30,0,0,2530, - 2531,5,264,0,0,2531,2672,5,31,0,0,2532,2533,5,196,0,0,2533,2534,5,30,0, - 0,2534,2535,5,39,0,0,2535,2536,5,264,0,0,2536,2672,5,31,0,0,2537,2538, - 5,196,0,0,2538,2539,5,30,0,0,2539,2540,3,138,69,0,2540,2541,5,31,0,0,2541, - 2672,1,0,0,0,2542,2543,5,196,0,0,2543,2544,5,30,0,0,2544,2545,5,179,0, - 0,2545,2672,5,31,0,0,2546,2547,5,197,0,0,2547,2548,5,30,0,0,2548,2549, - 3,318,159,0,2549,2550,5,31,0,0,2550,2672,1,0,0,0,2551,2552,5,188,0,0,2552, - 2553,5,42,0,0,2553,2554,3,32,16,0,2554,2555,5,43,0,0,2555,2556,5,30,0, - 0,2556,2557,3,320,160,0,2557,2558,5,31,0,0,2558,2672,1,0,0,0,2559,2560, - 5,189,0,0,2560,2561,5,42,0,0,2561,2562,3,32,16,0,2562,2563,5,43,0,0,2563, - 2564,5,30,0,0,2564,2565,3,322,161,0,2565,2566,5,31,0,0,2566,2672,1,0,0, - 0,2567,2568,5,187,0,0,2568,2569,5,42,0,0,2569,2570,3,32,16,0,2570,2571, - 5,43,0,0,2571,2572,5,30,0,0,2572,2573,3,324,162,0,2573,2574,5,31,0,0,2574, - 2672,1,0,0,0,2575,2576,5,186,0,0,2576,2577,5,42,0,0,2577,2578,3,32,16, - 0,2578,2579,5,43,0,0,2579,2580,5,30,0,0,2580,2581,3,326,163,0,2581,2582, - 5,31,0,0,2582,2672,1,0,0,0,2583,2584,5,185,0,0,2584,2585,5,42,0,0,2585, - 2586,3,32,16,0,2586,2587,5,43,0,0,2587,2588,5,30,0,0,2588,2589,3,328,164, - 0,2589,2590,5,31,0,0,2590,2672,1,0,0,0,2591,2592,5,184,0,0,2592,2593,5, - 42,0,0,2593,2594,3,32,16,0,2594,2595,5,43,0,0,2595,2596,5,30,0,0,2596, - 2597,3,330,165,0,2597,2598,5,31,0,0,2598,2672,1,0,0,0,2599,2600,5,193, - 0,0,2600,2601,5,42,0,0,2601,2602,3,32,16,0,2602,2603,5,43,0,0,2603,2604, - 5,30,0,0,2604,2605,3,324,162,0,2605,2606,5,31,0,0,2606,2672,1,0,0,0,2607, - 2608,5,192,0,0,2608,2609,5,42,0,0,2609,2610,3,32,16,0,2610,2611,5,43,0, - 0,2611,2612,5,30,0,0,2612,2613,3,326,163,0,2613,2614,5,31,0,0,2614,2672, - 1,0,0,0,2615,2616,5,191,0,0,2616,2617,5,42,0,0,2617,2618,3,32,16,0,2618, - 2619,5,43,0,0,2619,2620,5,30,0,0,2620,2621,3,328,164,0,2621,2622,5,31, - 0,0,2622,2672,1,0,0,0,2623,2624,5,190,0,0,2624,2625,5,42,0,0,2625,2626, - 3,32,16,0,2626,2627,5,43,0,0,2627,2628,5,30,0,0,2628,2629,3,330,165,0, - 2629,2630,5,31,0,0,2630,2672,1,0,0,0,2631,2632,5,181,0,0,2632,2633,5,42, - 0,0,2633,2634,3,32,16,0,2634,2635,5,43,0,0,2635,2636,5,30,0,0,2636,2637, - 3,328,164,0,2637,2638,5,31,0,0,2638,2672,1,0,0,0,2639,2640,5,183,0,0,2640, - 2641,5,42,0,0,2641,2642,3,32,16,0,2642,2643,5,43,0,0,2643,2644,5,30,0, - 0,2644,2645,3,332,166,0,2645,2646,5,31,0,0,2646,2672,1,0,0,0,2647,2648, - 5,182,0,0,2648,2649,5,42,0,0,2649,2650,3,32,16,0,2650,2651,5,43,0,0,2651, - 2652,5,30,0,0,2652,2653,3,334,167,0,2653,2654,5,31,0,0,2654,2672,1,0,0, - 0,2655,2656,5,196,0,0,2656,2657,5,42,0,0,2657,2658,3,32,16,0,2658,2659, - 5,43,0,0,2659,2660,5,30,0,0,2660,2661,3,336,168,0,2661,2662,5,31,0,0,2662, - 2672,1,0,0,0,2663,2664,5,197,0,0,2664,2665,5,42,0,0,2665,2666,3,32,16, - 0,2666,2667,5,43,0,0,2667,2668,5,30,0,0,2668,2669,3,340,170,0,2669,2670, - 5,31,0,0,2670,2672,1,0,0,0,2671,2523,1,0,0,0,2671,2524,1,0,0,0,2671,2528, - 1,0,0,0,2671,2532,1,0,0,0,2671,2537,1,0,0,0,2671,2542,1,0,0,0,2671,2546, - 1,0,0,0,2671,2551,1,0,0,0,2671,2559,1,0,0,0,2671,2567,1,0,0,0,2671,2575, - 1,0,0,0,2671,2583,1,0,0,0,2671,2591,1,0,0,0,2671,2599,1,0,0,0,2671,2607, - 1,0,0,0,2671,2615,1,0,0,0,2671,2623,1,0,0,0,2671,2631,1,0,0,0,2671,2639, - 1,0,0,0,2671,2647,1,0,0,0,2671,2655,1,0,0,0,2671,2663,1,0,0,0,2672,319, - 1,0,0,0,2673,2676,3,36,18,0,2674,2676,3,32,16,0,2675,2673,1,0,0,0,2675, - 2674,1,0,0,0,2676,2679,1,0,0,0,2677,2675,1,0,0,0,2677,2678,1,0,0,0,2678, - 321,1,0,0,0,2679,2677,1,0,0,0,2680,2683,3,36,18,0,2681,2683,3,34,17,0, - 2682,2680,1,0,0,0,2682,2681,1,0,0,0,2683,2686,1,0,0,0,2684,2682,1,0,0, - 0,2684,2685,1,0,0,0,2685,323,1,0,0,0,2686,2684,1,0,0,0,2687,2689,3,34, - 17,0,2688,2687,1,0,0,0,2689,2692,1,0,0,0,2690,2688,1,0,0,0,2690,2691,1, - 0,0,0,2691,325,1,0,0,0,2692,2690,1,0,0,0,2693,2695,3,32,16,0,2694,2693, - 1,0,0,0,2695,2698,1,0,0,0,2696,2694,1,0,0,0,2696,2697,1,0,0,0,2697,327, - 1,0,0,0,2698,2696,1,0,0,0,2699,2701,3,32,16,0,2700,2699,1,0,0,0,2701,2704, - 1,0,0,0,2702,2700,1,0,0,0,2702,2703,1,0,0,0,2703,329,1,0,0,0,2704,2702, - 1,0,0,0,2705,2707,3,32,16,0,2706,2705,1,0,0,0,2707,2710,1,0,0,0,2708,2706, - 1,0,0,0,2708,2709,1,0,0,0,2709,331,1,0,0,0,2710,2708,1,0,0,0,2711,2713, - 3,184,92,0,2712,2711,1,0,0,0,2713,2716,1,0,0,0,2714,2712,1,0,0,0,2714, - 2715,1,0,0,0,2715,333,1,0,0,0,2716,2714,1,0,0,0,2717,2719,7,13,0,0,2718, - 2717,1,0,0,0,2719,2722,1,0,0,0,2720,2718,1,0,0,0,2720,2721,1,0,0,0,2721, - 335,1,0,0,0,2722,2720,1,0,0,0,2723,2725,3,338,169,0,2724,2723,1,0,0,0, - 2725,2728,1,0,0,0,2726,2724,1,0,0,0,2726,2727,1,0,0,0,2727,337,1,0,0,0, - 2728,2726,1,0,0,0,2729,2734,5,179,0,0,2730,2731,5,39,0,0,2731,2734,5,264, - 0,0,2732,2734,3,138,69,0,2733,2729,1,0,0,0,2733,2730,1,0,0,0,2733,2732, - 1,0,0,0,2734,339,1,0,0,0,2735,2737,3,318,159,0,2736,2735,1,0,0,0,2737, - 2740,1,0,0,0,2738,2736,1,0,0,0,2738,2739,1,0,0,0,2739,341,1,0,0,0,2740, - 2738,1,0,0,0,2741,2745,3,44,22,0,2742,2745,3,46,23,0,2743,2745,3,2,1,0, - 2744,2741,1,0,0,0,2744,2742,1,0,0,0,2744,2743,1,0,0,0,2745,343,1,0,0,0, - 2746,2747,7,14,0,0,2747,2748,5,36,0,0,2748,2749,5,30,0,0,2749,2750,3,312, - 156,0,2750,2751,5,31,0,0,2751,2772,1,0,0,0,2752,2753,5,169,0,0,2753,2754, - 3,38,19,0,2754,2755,5,75,0,0,2755,2756,3,38,19,0,2756,2757,5,75,0,0,2757, - 2758,3,38,19,0,2758,2759,5,75,0,0,2759,2760,3,38,19,0,2760,2772,1,0,0, - 0,2761,2762,5,170,0,0,2762,2772,3,6,3,0,2763,2764,5,170,0,0,2764,2765, - 5,36,0,0,2765,2766,5,30,0,0,2766,2767,3,312,156,0,2767,2768,5,31,0,0,2768, - 2772,1,0,0,0,2769,2772,3,342,171,0,2770,2772,3,40,20,0,2771,2746,1,0,0, - 0,2771,2752,1,0,0,0,2771,2761,1,0,0,0,2771,2763,1,0,0,0,2771,2769,1,0, - 0,0,2771,2770,1,0,0,0,2772,345,1,0,0,0,2773,2774,5,25,0,0,2774,2775,5, - 40,0,0,2775,2776,3,98,49,0,2776,2777,3,2,1,0,2777,2786,1,0,0,0,2778,2779, - 5,25,0,0,2779,2780,5,40,0,0,2780,2781,3,98,49,0,2781,2782,3,2,1,0,2782, - 2783,5,34,0,0,2783,2784,3,2,1,0,2784,2786,1,0,0,0,2785,2773,1,0,0,0,2785, - 2778,1,0,0,0,2786,347,1,0,0,0,2787,2789,3,350,175,0,2788,2787,1,0,0,0, - 2789,2792,1,0,0,0,2790,2788,1,0,0,0,2790,2791,1,0,0,0,2791,349,1,0,0,0, - 2792,2790,1,0,0,0,2793,2794,5,180,0,0,2794,2795,5,36,0,0,2795,2796,5,30, - 0,0,2796,2797,3,312,156,0,2797,2798,5,31,0,0,2798,2808,1,0,0,0,2799,2808, - 3,344,172,0,2800,2801,5,171,0,0,2801,2802,5,36,0,0,2802,2803,5,30,0,0, - 2803,2804,3,312,156,0,2804,2805,5,31,0,0,2805,2808,1,0,0,0,2806,2808,5, - 55,0,0,2807,2793,1,0,0,0,2807,2799,1,0,0,0,2807,2800,1,0,0,0,2807,2806, - 1,0,0,0,2808,351,1,0,0,0,2809,2810,5,50,0,0,2810,2814,5,40,0,0,2811,2813, - 3,356,178,0,2812,2811,1,0,0,0,2813,2816,1,0,0,0,2814,2812,1,0,0,0,2814, - 2815,1,0,0,0,2815,2817,1,0,0,0,2816,2814,1,0,0,0,2817,2818,3,2,1,0,2818, - 353,1,0,0,0,2819,2823,5,301,0,0,2820,2822,3,356,178,0,2821,2820,1,0,0, - 0,2822,2825,1,0,0,0,2823,2821,1,0,0,0,2823,2824,1,0,0,0,2824,2826,1,0, - 0,0,2825,2823,1,0,0,0,2826,2827,3,2,1,0,2827,355,1,0,0,0,2828,2844,5,52, - 0,0,2829,2844,5,51,0,0,2830,2844,5,172,0,0,2831,2832,5,62,0,0,2832,2844, - 5,51,0,0,2833,2834,5,62,0,0,2834,2844,5,52,0,0,2835,2836,5,62,0,0,2836, - 2844,5,63,0,0,2837,2838,5,62,0,0,2838,2844,5,64,0,0,2839,2840,5,62,0,0, - 2840,2844,5,65,0,0,2841,2842,5,62,0,0,2842,2844,5,66,0,0,2843,2828,1,0, - 0,0,2843,2829,1,0,0,0,2843,2830,1,0,0,0,2843,2831,1,0,0,0,2843,2833,1, - 0,0,0,2843,2835,1,0,0,0,2843,2837,1,0,0,0,2843,2839,1,0,0,0,2843,2841, - 1,0,0,0,2844,357,1,0,0,0,2845,2847,3,360,180,0,2846,2845,1,0,0,0,2847, - 2850,1,0,0,0,2848,2846,1,0,0,0,2848,2849,1,0,0,0,2849,359,1,0,0,0,2850, - 2848,1,0,0,0,2851,2852,5,21,0,0,2852,2865,3,2,1,0,2853,2854,5,50,0,0,2854, - 2855,5,40,0,0,2855,2865,3,140,70,0,2856,2857,5,25,0,0,2857,2858,5,40,0, - 0,2858,2865,3,2,1,0,2859,2865,3,196,98,0,2860,2861,5,50,0,0,2861,2865, - 3,32,16,0,2862,2865,3,342,171,0,2863,2865,3,40,20,0,2864,2851,1,0,0,0, - 2864,2853,1,0,0,0,2864,2856,1,0,0,0,2864,2859,1,0,0,0,2864,2860,1,0,0, - 0,2864,2862,1,0,0,0,2864,2863,1,0,0,0,2865,361,1,0,0,0,2866,2870,5,274, - 0,0,2867,2869,3,364,182,0,2868,2867,1,0,0,0,2869,2872,1,0,0,0,2870,2868, - 1,0,0,0,2870,2871,1,0,0,0,2871,2873,1,0,0,0,2872,2870,1,0,0,0,2873,2886, - 3,2,1,0,2874,2878,5,274,0,0,2875,2877,3,364,182,0,2876,2875,1,0,0,0,2877, - 2880,1,0,0,0,2878,2876,1,0,0,0,2878,2879,1,0,0,0,2879,2881,1,0,0,0,2880, - 2878,1,0,0,0,2881,2882,3,2,1,0,2882,2883,5,34,0,0,2883,2884,3,2,1,0,2884, - 2886,1,0,0,0,2885,2866,1,0,0,0,2885,2874,1,0,0,0,2886,363,1,0,0,0,2887, - 2888,7,15,0,0,2888,365,1,0,0,0,2889,2891,3,368,184,0,2890,2889,1,0,0,0, - 2891,2894,1,0,0,0,2892,2890,1,0,0,0,2892,2893,1,0,0,0,2893,367,1,0,0,0, - 2894,2892,1,0,0,0,2895,2896,5,21,0,0,2896,2897,3,2,1,0,2897,2898,5,44, - 0,0,2898,2899,3,32,16,0,2899,2906,1,0,0,0,2900,2901,5,25,0,0,2901,2902, - 5,40,0,0,2902,2906,3,2,1,0,2903,2906,3,342,171,0,2904,2906,3,40,20,0,2905, - 2895,1,0,0,0,2905,2900,1,0,0,0,2905,2903,1,0,0,0,2905,2904,1,0,0,0,2906, - 369,1,0,0,0,172,378,383,391,399,452,493,502,526,530,548,575,598,634,640, - 647,649,659,661,668,679,687,708,710,726,771,776,781,786,794,904,910,926, - 932,938,945,1056,1061,1067,1072,1074,1082,1094,1106,1113,1120,1122,1149, - 1156,1164,1172,1185,1192,1195,1214,1308,1317,1324,1327,1335,1356,1388, - 1411,1423,1432,1457,1481,1489,1493,1508,1515,1560,1570,1586,1598,1610, - 1624,1636,1647,1654,1664,1677,1682,1687,1696,1707,1790,1799,1812,1823, - 1831,1841,1843,1870,1877,1882,1889,1895,1905,1909,1916,1931,1937,1951, - 1964,1972,1979,1983,1988,2004,2009,2011,2024,2050,2057,2059,2064,2070, - 2099,2104,2127,2132,2196,2205,2218,2229,2240,2243,2250,2262,2276,2290, - 2298,2318,2330,2335,2344,2346,2353,2363,2431,2508,2513,2521,2671,2675, - 2677,2682,2684,2690,2696,2702,2708,2714,2720,2726,2733,2738,2744,2771, - 2785,2790,2807,2814,2823,2843,2848,2864,2870,2878,2885,2892,2905 + 1,154,1,154,1,154,1,154,1,154,3,154,3365,8,154,1,155,1,155,1,155,1,155, + 1,155,1,155,5,155,3373,8,155,10,155,12,155,3376,9,155,1,156,1,156,1,156, + 1,156,1,156,1,156,5,156,3384,8,156,10,156,12,156,3387,9,156,1,157,1,157, + 1,157,5,157,3392,8,157,10,157,12,157,3395,9,157,1,158,1,158,1,158,5,158, + 3400,8,158,10,158,12,158,3403,9,158,1,159,1,159,1,159,5,159,3408,8,159, + 10,159,12,159,3411,9,159,1,160,1,160,1,160,5,160,3416,8,160,10,160,12, + 160,3419,9,160,1,161,1,161,1,161,5,161,3424,8,161,10,161,12,161,3427,9, + 161,1,162,1,162,1,162,1,162,5,162,3433,8,162,10,162,12,162,3436,9,162, + 1,163,1,163,1,163,5,163,3441,8,163,10,163,12,163,3444,9,163,1,164,1,164, + 1,164,1,164,1,164,1,164,1,164,1,164,3,164,3454,8,164,1,165,1,165,1,165, + 5,165,3459,8,165,10,165,12,165,3462,9,165,1,166,1,166,1,166,1,166,1,166, + 1,166,1,166,1,166,1,166,3,166,3473,8,166,1,167,1,167,1,167,1,167,1,167, + 1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167, + 1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167,1,167, + 1,167,1,167,1,167,3,167,3507,8,167,1,168,1,168,1,168,1,168,1,168,1,168, + 1,169,1,169,1,169,1,169,1,169,1,169,1,169,1,169,1,169,1,169,1,169,1,169, + 1,169,1,169,3,169,3529,8,169,1,170,1,170,1,170,5,170,3534,8,170,10,170, + 12,170,3537,9,170,1,171,1,171,1,171,1,171,1,171,1,171,1,171,1,171,1,171, + 1,171,1,171,1,171,1,171,1,171,1,171,1,171,1,171,1,171,1,171,3,171,3558, + 8,171,1,172,1,172,1,172,1,172,1,172,1,172,1,173,1,173,1,173,1,173,1,173, + 1,173,1,174,1,174,1,174,1,174,1,174,1,175,1,175,1,175,5,175,3580,8,175, + 10,175,12,175,3583,9,175,1,176,1,176,1,176,1,176,1,176,1,176,1,176,1,176, + 1,176,1,176,1,176,1,176,1,176,1,176,1,176,3,176,3600,8,176,1,177,1,177, + 1,177,5,177,3605,8,177,10,177,12,177,3608,9,177,1,178,1,178,1,178,1,178, + 1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178, + 1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,1,178,3,178,3635,8,178, + 1,179,1,179,1,179,1,179,1,179,1,179,1,180,1,180,1,180,1,180,1,180,1,180, + 1,180,1,180,1,180,1,180,1,180,1,180,3,180,3655,8,180,1,181,1,181,1,181, + 5,181,3660,8,181,10,181,12,181,3663,9,181,1,182,1,182,1,183,1,183,1,183, + 5,183,3670,8,183,10,183,12,183,3673,9,183,1,184,1,184,1,184,1,184,1,184, + 1,184,1,184,1,184,1,184,1,184,1,184,1,184,1,184,1,184,1,184,3,184,3690, + 8,184,1,184,0,0,185,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36, + 38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84, + 86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,120,122,124, + 126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160, + 162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196, + 198,200,202,204,206,208,210,212,214,216,218,220,222,224,226,228,230,232, + 234,236,238,240,242,244,246,248,250,252,254,256,258,260,262,264,266,268, + 270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,304, + 306,308,310,312,314,316,318,320,322,324,326,328,330,332,334,336,338,340, + 342,344,346,348,350,352,354,356,358,360,362,364,366,368,0,17,6,0,1,15, + 199,199,243,243,247,247,264,264,289,289,5,0,16,16,199,199,243,243,264, + 264,288,289,1,0,263,264,1,0,173,174,1,0,37,38,2,0,45,47,186,187,1,0,73, + 74,3,0,2,2,61,61,77,83,2,0,229,229,260,261,1,0,95,96,1,0,97,111,1,0,188, + 189,1,0,184,186,1,0,184,189,2,0,173,173,289,290,1,0,167,168,1,0,51,52, + 4131,0,370,1,0,0,0,2,388,1,0,0,0,4,390,1,0,0,0,6,397,1,0,0,0,8,406,1,0, + 0,0,10,495,1,0,0,0,12,497,1,0,0,0,14,501,1,0,0,0,16,505,1,0,0,0,18,510, + 1,0,0,0,20,514,1,0,0,0,22,518,1,0,0,0,24,526,1,0,0,0,26,546,1,0,0,0,28, + 548,1,0,0,0,30,550,1,0,0,0,32,562,1,0,0,0,34,564,1,0,0,0,36,587,1,0,0, + 0,38,594,1,0,0,0,40,612,1,0,0,0,42,644,1,0,0,0,44,672,1,0,0,0,46,712,1, + 0,0,0,48,714,1,0,0,0,50,723,1,0,0,0,52,725,1,0,0,0,54,735,1,0,0,0,56,748, + 1,0,0,0,58,751,1,0,0,0,60,754,1,0,0,0,62,778,1,0,0,0,64,791,1,0,0,0,66, + 793,1,0,0,0,68,807,1,0,0,0,70,812,1,0,0,0,72,814,1,0,0,0,74,821,1,0,0, + 0,76,825,1,0,0,0,78,904,1,0,0,0,80,911,1,0,0,0,82,918,1,0,0,0,84,923,1, + 0,0,0,86,932,1,0,0,0,88,938,1,0,0,0,90,991,1,0,0,0,92,993,1,0,0,0,94,1017, + 1,0,0,0,96,1022,1,0,0,0,98,1024,1,0,0,0,100,1031,1,0,0,0,102,1059,1,0, + 0,0,104,1139,1,0,0,0,106,1141,1,0,0,0,108,1170,1,0,0,0,110,1172,1,0,0, + 0,112,1186,1,0,0,0,114,1215,1,0,0,0,116,1227,1,0,0,0,118,1266,1,0,0,0, + 120,1274,1,0,0,0,122,1285,1,0,0,0,124,1299,1,0,0,0,126,1318,1,0,0,0,128, + 1331,1,0,0,0,130,1355,1,0,0,0,132,1502,1,0,0,0,134,1512,1,0,0,0,136,1524, + 1,0,0,0,138,1606,1,0,0,0,140,1608,1,0,0,0,142,1647,1,0,0,0,144,1707,1, + 0,0,0,146,1747,1,0,0,0,148,1763,1,0,0,0,150,1765,1,0,0,0,152,1769,1,0, + 0,0,154,1831,1,0,0,0,156,1846,1,0,0,0,158,1863,1,0,0,0,160,1871,1,0,0, + 0,162,1877,1,0,0,0,164,1882,1,0,0,0,166,1929,1,0,0,0,168,1931,1,0,0,0, + 170,1975,1,0,0,0,172,1994,1,0,0,0,174,2015,1,0,0,0,176,2017,1,0,0,0,178, + 2034,1,0,0,0,180,2049,1,0,0,0,182,2057,1,0,0,0,184,2069,1,0,0,0,186,2089, + 1,0,0,0,188,2096,1,0,0,0,190,2099,1,0,0,0,192,2112,1,0,0,0,194,2118,1, + 0,0,0,196,2124,1,0,0,0,198,2128,1,0,0,0,200,2285,1,0,0,0,202,2287,1,0, + 0,0,204,2343,1,0,0,0,206,2354,1,0,0,0,208,2361,1,0,0,0,210,2369,1,0,0, + 0,212,2396,1,0,0,0,214,2402,1,0,0,0,216,2407,1,0,0,0,218,2436,1,0,0,0, + 220,2438,1,0,0,0,222,2458,1,0,0,0,224,2463,1,0,0,0,226,2488,1,0,0,0,228, + 2497,1,0,0,0,230,2512,1,0,0,0,232,2519,1,0,0,0,234,2539,1,0,0,0,236,2541, + 1,0,0,0,238,2612,1,0,0,0,240,2637,1,0,0,0,242,2681,1,0,0,0,244,2690,1, + 0,0,0,246,2730,1,0,0,0,248,2735,1,0,0,0,250,2775,1,0,0,0,252,2777,1,0, + 0,0,254,2783,1,0,0,0,256,2791,1,0,0,0,258,2811,1,0,0,0,260,2878,1,0,0, + 0,262,2880,1,0,0,0,264,2890,1,0,0,0,266,2892,1,0,0,0,268,2896,1,0,0,0, + 270,2902,1,0,0,0,272,2922,1,0,0,0,274,2940,1,0,0,0,276,2954,1,0,0,0,278, + 2956,1,0,0,0,280,2959,1,0,0,0,282,2961,1,0,0,0,284,2978,1,0,0,0,286,2980, + 1,0,0,0,288,2993,1,0,0,0,290,3000,1,0,0,0,292,3011,1,0,0,0,294,3018,1, + 0,0,0,296,3029,1,0,0,0,298,3079,1,0,0,0,300,3171,1,0,0,0,302,3178,1,0, + 0,0,304,3181,1,0,0,0,306,3191,1,0,0,0,308,3364,1,0,0,0,310,3374,1,0,0, + 0,312,3385,1,0,0,0,314,3393,1,0,0,0,316,3401,1,0,0,0,318,3409,1,0,0,0, + 320,3417,1,0,0,0,322,3425,1,0,0,0,324,3434,1,0,0,0,326,3442,1,0,0,0,328, + 3453,1,0,0,0,330,3460,1,0,0,0,332,3472,1,0,0,0,334,3506,1,0,0,0,336,3508, + 1,0,0,0,338,3528,1,0,0,0,340,3535,1,0,0,0,342,3557,1,0,0,0,344,3559,1, + 0,0,0,346,3565,1,0,0,0,348,3571,1,0,0,0,350,3581,1,0,0,0,352,3599,1,0, + 0,0,354,3606,1,0,0,0,356,3634,1,0,0,0,358,3636,1,0,0,0,360,3654,1,0,0, + 0,362,3661,1,0,0,0,364,3664,1,0,0,0,366,3671,1,0,0,0,368,3689,1,0,0,0, + 370,371,7,0,0,0,371,1,1,0,0,0,372,373,5,288,0,0,373,389,6,1,-1,0,374,375, + 3,4,2,0,375,376,6,1,-1,0,376,377,5,265,0,0,377,379,1,0,0,0,378,374,1,0, + 0,0,379,382,1,0,0,0,380,378,1,0,0,0,380,381,1,0,0,0,381,383,1,0,0,0,382, + 380,1,0,0,0,383,384,3,4,2,0,384,385,6,1,-1,0,385,389,1,0,0,0,386,387,5, + 264,0,0,387,389,6,1,-1,0,388,372,1,0,0,0,388,380,1,0,0,0,388,386,1,0,0, + 0,389,3,1,0,0,0,390,391,7,1,0,0,391,5,1,0,0,0,392,393,5,263,0,0,393,394, + 6,3,-1,0,394,396,5,266,0,0,395,392,1,0,0,0,396,399,1,0,0,0,397,395,1,0, + 0,0,397,398,1,0,0,0,398,400,1,0,0,0,399,397,1,0,0,0,400,401,5,263,0,0, + 401,402,6,3,-1,0,402,7,1,0,0,0,403,405,3,10,5,0,404,403,1,0,0,0,405,408, + 1,0,0,0,406,404,1,0,0,0,406,407,1,0,0,0,407,9,1,0,0,0,408,406,1,0,0,0, + 409,410,3,76,38,0,410,411,5,17,0,0,411,412,3,84,42,0,412,413,5,18,0,0, + 413,496,1,0,0,0,414,415,3,74,37,0,415,416,5,17,0,0,416,417,3,8,4,0,417, + 418,5,18,0,0,418,496,1,0,0,0,419,420,3,236,118,0,420,421,5,17,0,0,421, + 422,3,248,124,0,422,423,5,18,0,0,423,496,1,0,0,0,424,496,3,202,101,0,425, + 426,6,5,-1,0,426,427,3,286,143,0,427,428,6,5,-1,0,428,496,1,0,0,0,429, + 430,6,5,-1,0,430,431,3,72,36,0,431,432,6,5,-1,0,432,496,1,0,0,0,433,434, + 6,5,-1,0,434,435,3,66,33,0,435,436,6,5,-1,0,436,496,1,0,0,0,437,438,6, + 5,-1,0,438,439,3,90,45,0,439,440,6,5,-1,0,440,496,1,0,0,0,441,442,6,5, + -1,0,442,443,3,92,46,0,443,444,6,5,-1,0,444,496,1,0,0,0,445,446,6,5,-1, + 0,446,447,3,22,11,0,447,448,6,5,-1,0,448,496,1,0,0,0,449,450,6,5,-1,0, + 450,451,3,336,168,0,451,452,6,5,-1,0,452,496,1,0,0,0,453,454,6,5,-1,0, + 454,455,3,344,172,0,455,456,6,5,-1,0,456,496,1,0,0,0,457,458,6,5,-1,0, + 458,459,3,358,179,0,459,460,6,5,-1,0,460,496,1,0,0,0,461,462,6,5,-1,0, + 462,463,3,64,32,0,463,464,6,5,-1,0,464,496,1,0,0,0,465,466,6,5,-1,0,466, + 467,3,154,77,0,467,468,6,5,-1,0,468,496,1,0,0,0,469,470,3,332,166,0,470, + 471,6,5,-1,0,471,496,1,0,0,0,472,473,6,5,-1,0,473,496,3,12,6,0,474,475, + 6,5,-1,0,475,496,3,14,7,0,476,477,6,5,-1,0,477,496,3,16,8,0,478,479,6, + 5,-1,0,479,496,3,18,9,0,480,481,6,5,-1,0,481,496,3,20,10,0,482,483,6,5, + -1,0,483,484,3,26,13,0,484,485,6,5,-1,0,485,496,1,0,0,0,486,487,6,5,-1, + 0,487,488,3,42,21,0,488,489,6,5,-1,0,489,496,1,0,0,0,490,491,6,5,-1,0, + 491,496,3,40,20,0,492,496,3,30,15,0,493,494,6,5,-1,0,494,496,3,24,12,0, + 495,409,1,0,0,0,495,414,1,0,0,0,495,419,1,0,0,0,495,424,1,0,0,0,495,425, + 1,0,0,0,495,429,1,0,0,0,495,433,1,0,0,0,495,437,1,0,0,0,495,441,1,0,0, + 0,495,445,1,0,0,0,495,449,1,0,0,0,495,453,1,0,0,0,495,457,1,0,0,0,495, + 461,1,0,0,0,495,465,1,0,0,0,495,469,1,0,0,0,495,472,1,0,0,0,495,474,1, + 0,0,0,495,476,1,0,0,0,495,478,1,0,0,0,495,480,1,0,0,0,495,482,1,0,0,0, + 495,486,1,0,0,0,495,490,1,0,0,0,495,492,1,0,0,0,495,493,1,0,0,0,496,11, + 1,0,0,0,497,498,5,19,0,0,498,499,3,32,16,0,499,500,6,6,-1,0,500,13,1,0, + 0,0,501,502,5,20,0,0,502,503,3,32,16,0,503,504,6,7,-1,0,504,15,1,0,0,0, + 505,506,5,21,0,0,506,507,5,22,0,0,507,508,3,32,16,0,508,509,6,8,-1,0,509, + 17,1,0,0,0,510,511,5,23,0,0,511,512,3,34,17,0,512,513,6,9,-1,0,513,19, + 1,0,0,0,514,515,5,24,0,0,515,516,3,34,17,0,516,517,6,10,-1,0,517,21,1, + 0,0,0,518,519,5,25,0,0,519,520,3,100,50,0,520,521,3,2,1,0,521,522,5,17, + 0,0,522,523,3,122,61,0,523,524,5,18,0,0,524,525,6,11,-1,0,525,23,1,0,0, + 0,526,527,5,26,0,0,527,25,1,0,0,0,528,529,5,27,0,0,529,530,3,28,14,0,530, + 531,6,13,-1,0,531,547,1,0,0,0,532,533,5,27,0,0,533,534,3,28,14,0,534,535, + 5,28,0,0,535,536,3,28,14,0,536,537,6,13,-1,0,537,547,1,0,0,0,538,539,5, + 27,0,0,539,540,3,28,14,0,540,541,5,28,0,0,541,542,3,28,14,0,542,543,5, + 28,0,0,543,544,3,28,14,0,544,545,6,13,-1,0,545,547,1,0,0,0,546,528,1,0, + 0,0,546,532,1,0,0,0,546,538,1,0,0,0,547,27,1,0,0,0,548,549,7,2,0,0,549, + 29,1,0,0,0,550,551,5,29,0,0,551,557,5,17,0,0,552,553,3,118,59,0,553,554, + 6,15,-1,0,554,556,1,0,0,0,555,552,1,0,0,0,556,559,1,0,0,0,557,555,1,0, + 0,0,557,558,1,0,0,0,558,560,1,0,0,0,559,557,1,0,0,0,560,561,5,18,0,0,561, + 31,1,0,0,0,562,563,5,173,0,0,563,33,1,0,0,0,564,565,7,3,0,0,565,35,1,0, + 0,0,566,567,5,175,0,0,567,588,6,18,-1,0,568,569,3,32,16,0,569,570,5,265, + 0,0,570,571,6,18,-1,0,571,588,1,0,0,0,572,573,3,32,16,0,573,574,6,18,-1, + 0,574,588,1,0,0,0,575,576,5,188,0,0,576,577,5,30,0,0,577,578,3,32,16,0, + 578,579,5,31,0,0,579,580,6,18,-1,0,580,588,1,0,0,0,581,582,5,189,0,0,582, + 583,5,30,0,0,583,584,3,34,17,0,584,585,5,31,0,0,585,586,6,18,-1,0,586, + 588,1,0,0,0,587,566,1,0,0,0,587,568,1,0,0,0,587,572,1,0,0,0,587,575,1, + 0,0,0,587,581,1,0,0,0,588,37,1,0,0,0,589,590,3,32,16,0,590,591,6,19,-1, + 0,591,595,1,0,0,0,592,593,5,262,0,0,593,595,6,19,-1,0,594,589,1,0,0,0, + 594,592,1,0,0,0,595,39,1,0,0,0,596,597,5,267,0,0,597,613,5,289,0,0,598, + 599,5,267,0,0,599,600,5,289,0,0,600,613,5,263,0,0,601,602,5,268,0,0,602, + 613,5,289,0,0,603,604,5,269,0,0,604,613,5,289,0,0,605,606,5,270,0,0,606, + 613,5,289,0,0,607,613,5,271,0,0,608,613,5,272,0,0,609,610,5,273,0,0,610, + 613,5,263,0,0,611,613,5,32,0,0,612,596,1,0,0,0,612,598,1,0,0,0,612,601, + 1,0,0,0,612,603,1,0,0,0,612,605,1,0,0,0,612,607,1,0,0,0,612,608,1,0,0, + 0,612,609,1,0,0,0,612,611,1,0,0,0,613,41,1,0,0,0,614,615,5,33,0,0,615, + 616,3,140,70,0,616,617,5,34,0,0,617,618,3,2,1,0,618,619,6,21,-1,0,619, + 645,1,0,0,0,620,621,5,33,0,0,621,622,3,118,59,0,622,623,5,34,0,0,623,624, + 3,2,1,0,624,625,6,21,-1,0,625,645,1,0,0,0,626,627,5,33,0,0,627,628,3,178, + 89,0,628,629,5,34,0,0,629,630,3,2,1,0,630,631,6,21,-1,0,631,645,1,0,0, + 0,632,633,5,33,0,0,633,634,3,44,22,0,634,635,5,34,0,0,635,636,3,2,1,0, + 636,637,6,21,-1,0,637,645,1,0,0,0,638,639,5,33,0,0,639,640,3,46,23,0,640, + 641,5,34,0,0,641,642,3,2,1,0,642,643,6,21,-1,0,643,645,1,0,0,0,644,614, + 1,0,0,0,644,620,1,0,0,0,644,626,1,0,0,0,644,632,1,0,0,0,644,638,1,0,0, + 0,645,43,1,0,0,0,646,647,5,35,0,0,647,648,3,48,24,0,648,649,6,22,-1,0, + 649,673,1,0,0,0,650,651,5,35,0,0,651,652,3,48,24,0,652,653,5,36,0,0,653, + 654,3,6,3,0,654,655,6,22,-1,0,655,673,1,0,0,0,656,657,5,35,0,0,657,658, + 3,48,24,0,658,659,5,36,0,0,659,660,5,17,0,0,660,661,3,52,26,0,661,662, + 5,18,0,0,662,663,6,22,-1,0,663,673,1,0,0,0,664,665,5,35,0,0,665,666,3, + 48,24,0,666,667,5,36,0,0,667,668,5,30,0,0,668,669,3,302,151,0,669,670, + 5,31,0,0,670,671,6,22,-1,0,671,673,1,0,0,0,672,646,1,0,0,0,672,650,1,0, + 0,0,672,656,1,0,0,0,672,664,1,0,0,0,673,45,1,0,0,0,674,675,5,35,0,0,675, + 676,5,30,0,0,676,677,3,50,25,0,677,678,5,31,0,0,678,679,3,48,24,0,679, + 680,6,23,-1,0,680,713,1,0,0,0,681,682,5,35,0,0,682,683,5,30,0,0,683,684, + 3,50,25,0,684,685,5,31,0,0,685,686,3,48,24,0,686,687,5,36,0,0,687,688, + 3,6,3,0,688,689,6,23,-1,0,689,713,1,0,0,0,690,691,5,35,0,0,691,692,5,30, + 0,0,692,693,3,50,25,0,693,694,5,31,0,0,694,695,3,48,24,0,695,696,5,36, + 0,0,696,697,5,17,0,0,697,698,3,52,26,0,698,699,5,18,0,0,699,700,6,23,-1, + 0,700,713,1,0,0,0,701,702,5,35,0,0,702,703,5,30,0,0,703,704,3,50,25,0, + 704,705,5,31,0,0,705,706,3,48,24,0,706,707,5,36,0,0,707,708,5,30,0,0,708, + 709,3,302,151,0,709,710,5,31,0,0,710,711,6,23,-1,0,711,713,1,0,0,0,712, + 674,1,0,0,0,712,681,1,0,0,0,712,690,1,0,0,0,712,701,1,0,0,0,713,47,1,0, + 0,0,714,715,3,170,85,0,715,716,6,24,-1,0,716,49,1,0,0,0,717,718,3,126, + 63,0,718,719,6,25,-1,0,719,724,1,0,0,0,720,721,3,178,89,0,721,722,6,25, + -1,0,722,724,1,0,0,0,723,717,1,0,0,0,723,720,1,0,0,0,724,51,1,0,0,0,725, + 726,3,54,27,0,726,727,3,56,28,0,727,728,6,26,-1,0,728,53,1,0,0,0,729,730, + 3,308,154,0,730,731,6,27,-1,0,731,734,1,0,0,0,732,734,3,40,20,0,733,729, + 1,0,0,0,733,732,1,0,0,0,734,737,1,0,0,0,735,733,1,0,0,0,735,736,1,0,0, + 0,736,55,1,0,0,0,737,735,1,0,0,0,738,739,3,58,29,0,739,740,3,60,30,0,740, + 741,3,2,1,0,741,742,5,36,0,0,742,743,3,308,154,0,743,744,6,28,-1,0,744, + 747,1,0,0,0,745,747,3,40,20,0,746,738,1,0,0,0,746,745,1,0,0,0,747,750, + 1,0,0,0,748,746,1,0,0,0,748,749,1,0,0,0,749,57,1,0,0,0,750,748,1,0,0,0, + 751,752,7,4,0,0,752,753,6,29,-1,0,753,59,1,0,0,0,754,756,3,62,31,0,755, + 757,5,261,0,0,756,755,1,0,0,0,756,757,1,0,0,0,757,758,1,0,0,0,758,759, + 6,30,-1,0,759,61,1,0,0,0,760,761,3,146,73,0,761,762,6,31,-1,0,762,779, + 1,0,0,0,763,764,3,2,1,0,764,765,6,31,-1,0,765,779,1,0,0,0,766,767,5,196, + 0,0,767,779,6,31,-1,0,768,769,5,197,0,0,769,779,6,31,-1,0,770,771,5,202, + 0,0,771,772,5,39,0,0,772,773,5,264,0,0,773,779,6,31,-1,0,774,775,5,202, + 0,0,775,776,3,118,59,0,776,777,6,31,-1,0,777,779,1,0,0,0,778,760,1,0,0, + 0,778,763,1,0,0,0,778,766,1,0,0,0,778,768,1,0,0,0,778,770,1,0,0,0,778, + 774,1,0,0,0,779,63,1,0,0,0,780,781,5,198,0,0,781,782,5,40,0,0,782,783, + 3,2,1,0,783,784,6,32,-1,0,784,792,1,0,0,0,785,786,5,198,0,0,786,787,3, + 2,1,0,787,788,6,32,-1,0,788,792,1,0,0,0,789,790,5,198,0,0,790,792,6,32, + -1,0,791,780,1,0,0,0,791,785,1,0,0,0,791,789,1,0,0,0,792,65,1,0,0,0,793, + 794,5,41,0,0,794,795,5,42,0,0,795,796,3,32,16,0,796,797,5,43,0,0,797,798, + 3,68,34,0,798,799,5,44,0,0,799,800,3,0,0,0,800,801,6,33,-1,0,801,67,1, + 0,0,0,802,803,3,70,35,0,803,804,6,34,-1,0,804,806,1,0,0,0,805,802,1,0, + 0,0,806,809,1,0,0,0,807,805,1,0,0,0,807,808,1,0,0,0,808,810,1,0,0,0,809, + 807,1,0,0,0,810,811,6,34,-1,0,811,69,1,0,0,0,812,813,7,5,0,0,813,71,1, + 0,0,0,814,815,5,48,0,0,815,816,5,36,0,0,816,817,5,30,0,0,817,818,3,302, + 151,0,818,819,5,31,0,0,819,820,6,36,-1,0,820,73,1,0,0,0,821,822,5,49,0, + 0,822,823,3,2,1,0,823,824,6,37,-1,0,824,75,1,0,0,0,825,831,5,50,0,0,826, + 827,3,78,39,0,827,828,6,38,-1,0,828,830,1,0,0,0,829,826,1,0,0,0,830,833, + 1,0,0,0,831,829,1,0,0,0,831,832,1,0,0,0,832,834,1,0,0,0,833,831,1,0,0, + 0,834,835,3,2,1,0,835,836,3,184,92,0,836,837,3,80,40,0,837,838,3,82,41, + 0,838,839,6,38,-1,0,839,77,1,0,0,0,840,841,5,51,0,0,841,905,6,39,-1,0, + 842,843,5,52,0,0,843,905,6,39,-1,0,844,845,5,199,0,0,845,905,6,39,-1,0, + 846,847,5,202,0,0,847,905,6,39,-1,0,848,849,5,221,0,0,849,905,6,39,-1, + 0,850,851,5,53,0,0,851,905,6,39,-1,0,852,853,5,54,0,0,853,905,6,39,-1, + 0,854,855,5,55,0,0,855,905,6,39,-1,0,856,857,5,56,0,0,857,905,6,39,-1, + 0,858,859,5,244,0,0,859,905,6,39,-1,0,860,861,5,15,0,0,861,905,6,39,-1, + 0,862,863,5,224,0,0,863,905,6,39,-1,0,864,865,5,57,0,0,865,905,6,39,-1, + 0,866,867,5,58,0,0,867,905,6,39,-1,0,868,869,5,59,0,0,869,905,6,39,-1, + 0,870,871,5,60,0,0,871,905,6,39,-1,0,872,873,5,61,0,0,873,905,6,39,-1, + 0,874,875,5,62,0,0,875,876,5,51,0,0,876,905,6,39,-1,0,877,878,5,62,0,0, + 878,879,5,52,0,0,879,905,6,39,-1,0,880,881,5,62,0,0,881,882,5,63,0,0,882, + 905,6,39,-1,0,883,884,5,62,0,0,884,885,5,64,0,0,885,905,6,39,-1,0,886, + 887,5,62,0,0,887,888,5,65,0,0,888,905,6,39,-1,0,889,890,5,62,0,0,890,891, + 5,66,0,0,891,905,6,39,-1,0,892,893,5,67,0,0,893,905,6,39,-1,0,894,895, + 5,68,0,0,895,905,6,39,-1,0,896,897,5,69,0,0,897,905,6,39,-1,0,898,899, + 5,70,0,0,899,900,5,30,0,0,900,901,3,32,16,0,901,902,5,31,0,0,902,903,6, + 39,-1,0,903,905,1,0,0,0,904,840,1,0,0,0,904,842,1,0,0,0,904,844,1,0,0, + 0,904,846,1,0,0,0,904,848,1,0,0,0,904,850,1,0,0,0,904,852,1,0,0,0,904, + 854,1,0,0,0,904,856,1,0,0,0,904,858,1,0,0,0,904,860,1,0,0,0,904,862,1, + 0,0,0,904,864,1,0,0,0,904,866,1,0,0,0,904,868,1,0,0,0,904,870,1,0,0,0, + 904,872,1,0,0,0,904,874,1,0,0,0,904,877,1,0,0,0,904,880,1,0,0,0,904,883, + 1,0,0,0,904,886,1,0,0,0,904,889,1,0,0,0,904,892,1,0,0,0,904,894,1,0,0, + 0,904,896,1,0,0,0,904,898,1,0,0,0,905,79,1,0,0,0,906,912,1,0,0,0,907,908, + 5,71,0,0,908,909,3,126,63,0,909,910,6,40,-1,0,910,912,1,0,0,0,911,906, + 1,0,0,0,911,907,1,0,0,0,912,81,1,0,0,0,913,919,1,0,0,0,914,915,5,72,0, + 0,915,916,3,86,43,0,916,917,6,41,-1,0,917,919,1,0,0,0,918,913,1,0,0,0, + 918,914,1,0,0,0,919,83,1,0,0,0,920,922,3,200,100,0,921,920,1,0,0,0,922, + 925,1,0,0,0,923,921,1,0,0,0,923,924,1,0,0,0,924,85,1,0,0,0,925,923,1,0, + 0,0,926,927,3,126,63,0,927,928,6,43,-1,0,928,929,5,28,0,0,929,931,1,0, + 0,0,930,926,1,0,0,0,931,934,1,0,0,0,932,930,1,0,0,0,932,933,1,0,0,0,933, + 935,1,0,0,0,934,932,1,0,0,0,935,936,3,126,63,0,936,937,6,43,-1,0,937,87, + 1,0,0,0,938,939,7,6,0,0,939,89,1,0,0,0,940,941,3,88,44,0,941,943,3,32, + 16,0,942,944,7,2,0,0,943,942,1,0,0,0,943,944,1,0,0,0,944,945,1,0,0,0,945, + 946,6,45,-1,0,946,992,1,0,0,0,947,948,3,88,44,0,948,949,3,32,16,0,949, + 950,5,75,0,0,950,952,3,32,16,0,951,953,7,2,0,0,952,951,1,0,0,0,952,953, + 1,0,0,0,953,954,1,0,0,0,954,955,6,45,-1,0,955,992,1,0,0,0,956,957,3,88, + 44,0,957,958,3,32,16,0,958,959,5,75,0,0,959,960,3,32,16,0,960,961,5,28, + 0,0,961,963,3,32,16,0,962,964,7,2,0,0,963,962,1,0,0,0,963,964,1,0,0,0, + 964,965,1,0,0,0,965,966,6,45,-1,0,966,992,1,0,0,0,967,968,3,88,44,0,968, + 969,3,32,16,0,969,970,5,28,0,0,970,971,3,32,16,0,971,972,5,75,0,0,972, + 974,3,32,16,0,973,975,7,2,0,0,974,973,1,0,0,0,974,975,1,0,0,0,975,976, + 1,0,0,0,976,977,6,45,-1,0,977,992,1,0,0,0,978,979,3,88,44,0,979,980,3, + 32,16,0,980,981,5,28,0,0,981,982,3,32,16,0,982,983,5,75,0,0,983,984,3, + 32,16,0,984,985,5,28,0,0,985,987,3,32,16,0,986,988,7,2,0,0,987,986,1,0, + 0,0,987,988,1,0,0,0,988,989,1,0,0,0,989,990,6,45,-1,0,990,992,1,0,0,0, + 991,940,1,0,0,0,991,947,1,0,0,0,991,956,1,0,0,0,991,967,1,0,0,0,991,978, + 1,0,0,0,992,91,1,0,0,0,993,999,5,21,0,0,994,995,3,94,47,0,995,996,6,46, + -1,0,996,998,1,0,0,0,997,994,1,0,0,0,998,1001,1,0,0,0,999,997,1,0,0,0, + 999,1000,1,0,0,0,1000,1002,1,0,0,0,1001,999,1,0,0,0,1002,1003,3,2,1,0, + 1003,1004,6,46,-1,0,1004,1005,3,96,48,0,1005,1015,6,46,-1,0,1006,1007, + 5,180,0,0,1007,1008,5,36,0,0,1008,1009,5,30,0,0,1009,1010,3,302,151,0, + 1010,1011,5,31,0,0,1011,1012,6,46,-1,0,1012,1013,3,96,48,0,1013,1014,6, + 46,-1,0,1014,1016,1,0,0,0,1015,1006,1,0,0,0,1015,1016,1,0,0,0,1016,93, + 1,0,0,0,1017,1018,5,76,0,0,1018,95,1,0,0,0,1019,1023,1,0,0,0,1020,1021, + 5,298,0,0,1021,1023,6,48,-1,0,1022,1019,1,0,0,0,1022,1020,1,0,0,0,1023, + 97,1,0,0,0,1024,1025,7,7,0,0,1025,99,1,0,0,0,1026,1027,3,98,49,0,1027, + 1028,6,50,-1,0,1028,1030,1,0,0,0,1029,1026,1,0,0,0,1030,1033,1,0,0,0,1031, + 1029,1,0,0,0,1031,1032,1,0,0,0,1032,101,1,0,0,0,1033,1031,1,0,0,0,1034, + 1060,3,104,52,0,1035,1036,5,280,0,0,1036,1037,3,170,85,0,1037,1038,6,51, + -1,0,1038,1060,1,0,0,0,1039,1040,5,286,0,0,1040,1041,3,180,90,0,1041,1042, + 6,51,-1,0,1042,1060,1,0,0,0,1043,1044,5,286,0,0,1044,1045,3,176,88,0,1045, + 1046,6,51,-1,0,1046,1060,1,0,0,0,1047,1048,5,284,0,0,1048,1049,3,126,63, + 0,1049,1050,6,51,-1,0,1050,1060,1,0,0,0,1051,1052,5,281,0,0,1052,1053, + 3,106,53,0,1053,1054,6,51,-1,0,1054,1060,1,0,0,0,1055,1056,5,287,0,0,1056, + 1057,3,50,25,0,1057,1058,6,51,-1,0,1058,1060,1,0,0,0,1059,1034,1,0,0,0, + 1059,1035,1,0,0,0,1059,1039,1,0,0,0,1059,1043,1,0,0,0,1059,1047,1,0,0, + 0,1059,1051,1,0,0,0,1059,1055,1,0,0,0,1060,103,1,0,0,0,1061,1062,5,275, + 0,0,1062,1140,6,52,-1,0,1063,1064,5,276,0,0,1064,1065,3,32,16,0,1065,1066, + 6,52,-1,0,1066,1140,1,0,0,0,1067,1068,5,276,0,0,1068,1069,3,0,0,0,1069, + 1070,6,52,-1,0,1070,1140,1,0,0,0,1071,1072,5,277,0,0,1072,1073,3,32,16, + 0,1073,1074,6,52,-1,0,1074,1140,1,0,0,0,1075,1076,5,278,0,0,1076,1077, + 3,34,17,0,1077,1078,6,52,-1,0,1078,1140,1,0,0,0,1079,1080,5,279,0,0,1080, + 1081,3,36,18,0,1081,1082,6,52,-1,0,1082,1140,1,0,0,0,1083,1084,5,279,0, + 0,1084,1085,3,34,17,0,1085,1086,6,52,-1,0,1086,1140,1,0,0,0,1087,1088, + 5,279,0,0,1088,1089,5,30,0,0,1089,1090,3,302,151,0,1090,1091,5,31,0,0, + 1091,1092,6,52,-1,0,1092,1140,1,0,0,0,1093,1094,5,279,0,0,1094,1095,5, + 84,0,0,1095,1096,5,30,0,0,1096,1097,3,302,151,0,1097,1098,5,31,0,0,1098, + 1099,6,52,-1,0,1099,1140,1,0,0,0,1100,1101,5,282,0,0,1101,1102,3,32,16, + 0,1102,1103,6,52,-1,0,1103,1140,1,0,0,0,1104,1105,5,282,0,0,1105,1106, + 3,0,0,0,1106,1107,6,52,-1,0,1107,1140,1,0,0,0,1108,1109,5,285,0,0,1109, + 1110,3,6,3,0,1110,1111,6,52,-1,0,1111,1140,1,0,0,0,1112,1113,5,285,0,0, + 1113,1114,5,224,0,0,1114,1115,5,30,0,0,1115,1116,3,6,3,0,1116,1117,5,31, + 0,0,1117,1118,6,52,-1,0,1118,1140,1,0,0,0,1119,1120,5,285,0,0,1120,1121, + 5,84,0,0,1121,1122,5,30,0,0,1122,1123,3,302,151,0,1123,1124,5,31,0,0,1124, + 1125,6,52,-1,0,1125,1140,1,0,0,0,1126,1127,5,287,0,0,1127,1128,3,32,16, + 0,1128,1129,6,52,-1,0,1129,1140,1,0,0,0,1130,1131,5,283,0,0,1131,1137, + 6,52,-1,0,1132,1133,5,30,0,0,1133,1134,3,108,54,0,1134,1135,5,31,0,0,1135, + 1138,1,0,0,0,1136,1138,5,85,0,0,1137,1132,1,0,0,0,1137,1136,1,0,0,0,1138, + 1140,1,0,0,0,1139,1061,1,0,0,0,1139,1063,1,0,0,0,1139,1067,1,0,0,0,1139, + 1071,1,0,0,0,1139,1075,1,0,0,0,1139,1079,1,0,0,0,1139,1083,1,0,0,0,1139, + 1087,1,0,0,0,1139,1093,1,0,0,0,1139,1100,1,0,0,0,1139,1104,1,0,0,0,1139, + 1108,1,0,0,0,1139,1112,1,0,0,0,1139,1119,1,0,0,0,1139,1126,1,0,0,0,1139, + 1130,1,0,0,0,1140,105,1,0,0,0,1141,1142,3,172,86,0,1142,1143,3,140,70, + 0,1143,1144,3,114,57,0,1144,1145,6,53,-1,0,1145,107,1,0,0,0,1146,1171, + 1,0,0,0,1147,1148,3,0,0,0,1148,1149,6,54,-1,0,1149,1154,1,0,0,0,1150,1151, + 3,32,16,0,1151,1152,6,54,-1,0,1152,1154,1,0,0,0,1153,1147,1,0,0,0,1153, + 1150,1,0,0,0,1154,1155,1,0,0,0,1155,1156,5,28,0,0,1156,1158,1,0,0,0,1157, + 1153,1,0,0,0,1158,1161,1,0,0,0,1159,1157,1,0,0,0,1159,1160,1,0,0,0,1160, + 1168,1,0,0,0,1161,1159,1,0,0,0,1162,1163,3,0,0,0,1163,1164,6,54,-1,0,1164, + 1169,1,0,0,0,1165,1166,3,32,16,0,1166,1167,6,54,-1,0,1167,1169,1,0,0,0, + 1168,1162,1,0,0,0,1168,1165,1,0,0,0,1169,1171,1,0,0,0,1170,1146,1,0,0, + 0,1170,1159,1,0,0,0,1171,109,1,0,0,0,1172,1179,5,86,0,0,1173,1174,3,140, + 70,0,1174,1175,6,55,-1,0,1175,1176,5,28,0,0,1176,1178,1,0,0,0,1177,1173, + 1,0,0,0,1178,1181,1,0,0,0,1179,1177,1,0,0,0,1179,1180,1,0,0,0,1180,1182, + 1,0,0,0,1181,1179,1,0,0,0,1182,1183,3,140,70,0,1183,1184,6,55,-1,0,1184, + 1185,5,87,0,0,1185,111,1,0,0,0,1186,1193,5,42,0,0,1187,1188,3,148,74,0, + 1188,1189,6,56,-1,0,1189,1190,5,28,0,0,1190,1192,1,0,0,0,1191,1187,1,0, + 0,0,1192,1195,1,0,0,0,1193,1191,1,0,0,0,1193,1194,1,0,0,0,1194,1196,1, + 0,0,0,1195,1193,1,0,0,0,1196,1197,3,148,74,0,1197,1198,6,56,-1,0,1198, + 1199,5,43,0,0,1199,113,1,0,0,0,1200,1207,5,30,0,0,1201,1202,3,116,58,0, + 1202,1203,6,57,-1,0,1203,1204,5,28,0,0,1204,1206,1,0,0,0,1205,1201,1,0, + 0,0,1206,1209,1,0,0,0,1207,1205,1,0,0,0,1207,1208,1,0,0,0,1208,1210,1, + 0,0,0,1209,1207,1,0,0,0,1210,1211,3,116,58,0,1211,1212,6,57,-1,0,1212, + 1213,5,31,0,0,1213,1216,1,0,0,0,1214,1216,5,85,0,0,1215,1200,1,0,0,0,1215, + 1214,1,0,0,0,1216,115,1,0,0,0,1217,1218,5,177,0,0,1218,1228,6,58,-1,0, + 1219,1220,3,232,116,0,1220,1221,3,140,70,0,1221,1223,3,228,114,0,1222, + 1224,3,0,0,0,1223,1222,1,0,0,0,1223,1224,1,0,0,0,1224,1225,1,0,0,0,1225, + 1226,6,58,-1,0,1226,1228,1,0,0,0,1227,1217,1,0,0,0,1227,1219,1,0,0,0,1228, + 117,1,0,0,0,1229,1230,5,42,0,0,1230,1231,3,2,1,0,1231,1232,5,43,0,0,1232, + 1233,3,120,60,0,1233,1234,6,59,-1,0,1234,1267,1,0,0,0,1235,1236,5,42,0, + 0,1236,1237,3,176,88,0,1237,1238,5,43,0,0,1238,1239,3,120,60,0,1239,1240, + 6,59,-1,0,1240,1267,1,0,0,0,1241,1242,5,42,0,0,1242,1243,5,262,0,0,1243, + 1244,5,43,0,0,1244,1245,3,120,60,0,1245,1246,6,59,-1,0,1246,1267,1,0,0, + 0,1247,1248,5,42,0,0,1248,1249,5,198,0,0,1249,1250,3,2,1,0,1250,1251,5, + 43,0,0,1251,1252,3,120,60,0,1252,1253,6,59,-1,0,1253,1267,1,0,0,0,1254, + 1255,3,120,60,0,1255,1256,6,59,-1,0,1256,1267,1,0,0,0,1257,1258,3,176, + 88,0,1258,1259,6,59,-1,0,1259,1267,1,0,0,0,1260,1261,5,257,0,0,1261,1267, + 6,59,-1,0,1262,1263,5,258,0,0,1263,1267,6,59,-1,0,1264,1265,5,259,0,0, + 1265,1267,6,59,-1,0,1266,1229,1,0,0,0,1266,1235,1,0,0,0,1266,1241,1,0, + 0,0,1266,1247,1,0,0,0,1266,1254,1,0,0,0,1266,1257,1,0,0,0,1266,1260,1, + 0,0,0,1266,1262,1,0,0,0,1266,1264,1,0,0,0,1267,119,1,0,0,0,1268,1269,3, + 2,1,0,1269,1270,6,60,-1,0,1270,1271,5,88,0,0,1271,1273,1,0,0,0,1272,1268, + 1,0,0,0,1273,1276,1,0,0,0,1274,1272,1,0,0,0,1274,1275,1,0,0,0,1275,1277, + 1,0,0,0,1276,1274,1,0,0,0,1277,1278,3,2,1,0,1278,1279,6,60,-1,0,1279,121, + 1,0,0,0,1280,1281,3,124,62,0,1281,1282,6,61,-1,0,1282,1284,1,0,0,0,1283, + 1280,1,0,0,0,1284,1287,1,0,0,0,1285,1283,1,0,0,0,1285,1286,1,0,0,0,1286, + 123,1,0,0,0,1287,1285,1,0,0,0,1288,1289,5,180,0,0,1289,1290,5,89,0,0,1290, + 1291,3,32,16,0,1291,1292,6,62,-1,0,1292,1300,1,0,0,0,1293,1294,3,154,77, + 0,1294,1295,6,62,-1,0,1295,1300,1,0,0,0,1296,1297,3,334,167,0,1297,1298, + 6,62,-1,0,1298,1300,1,0,0,0,1299,1288,1,0,0,0,1299,1293,1,0,0,0,1299,1296, + 1,0,0,0,1300,125,1,0,0,0,1301,1302,3,118,59,0,1302,1303,6,63,-1,0,1303, + 1319,1,0,0,0,1304,1305,5,42,0,0,1305,1306,3,2,1,0,1306,1307,5,43,0,0,1307, + 1308,6,63,-1,0,1308,1319,1,0,0,0,1309,1310,5,42,0,0,1310,1311,5,198,0, + 0,1311,1312,3,2,1,0,1312,1313,5,43,0,0,1313,1314,6,63,-1,0,1314,1319,1, + 0,0,0,1315,1316,3,140,70,0,1316,1317,6,63,-1,0,1317,1319,1,0,0,0,1318, + 1301,1,0,0,0,1318,1304,1,0,0,0,1318,1309,1,0,0,0,1318,1315,1,0,0,0,1319, + 127,1,0,0,0,1320,1332,1,0,0,0,1321,1322,3,132,66,0,1322,1328,6,64,-1,0, + 1323,1324,3,130,65,0,1324,1325,6,64,-1,0,1325,1327,1,0,0,0,1326,1323,1, + 0,0,0,1327,1330,1,0,0,0,1328,1326,1,0,0,0,1328,1329,1,0,0,0,1329,1332, + 1,0,0,0,1330,1328,1,0,0,0,1331,1320,1,0,0,0,1331,1321,1,0,0,0,1332,129, + 1,0,0,0,1333,1334,5,262,0,0,1334,1356,6,65,-1,0,1335,1336,5,261,0,0,1336, + 1356,6,65,-1,0,1337,1338,5,42,0,0,1338,1339,3,32,16,0,1339,1340,5,43,0, + 0,1340,1341,6,65,-1,0,1341,1356,1,0,0,0,1342,1343,5,42,0,0,1343,1344,3, + 32,16,0,1344,1345,5,266,0,0,1345,1346,3,32,16,0,1346,1347,5,43,0,0,1347, + 1348,6,65,-1,0,1348,1356,1,0,0,0,1349,1350,5,42,0,0,1350,1351,5,266,0, + 0,1351,1352,3,32,16,0,1352,1353,5,43,0,0,1353,1354,6,65,-1,0,1354,1356, + 1,0,0,0,1355,1333,1,0,0,0,1355,1335,1,0,0,0,1355,1337,1,0,0,0,1355,1342, + 1,0,0,0,1355,1349,1,0,0,0,1356,131,1,0,0,0,1357,1503,6,66,-1,0,1358,1359, + 5,203,0,0,1359,1360,5,30,0,0,1360,1361,3,6,3,0,1361,1362,5,28,0,0,1362, + 1363,3,6,3,0,1363,1364,5,28,0,0,1364,1365,3,6,3,0,1365,1366,5,28,0,0,1366, + 1367,3,6,3,0,1367,1368,5,31,0,0,1368,1369,6,66,-1,0,1369,1503,1,0,0,0, + 1370,1371,5,203,0,0,1371,1372,5,30,0,0,1372,1373,3,6,3,0,1373,1374,5,28, + 0,0,1374,1375,3,6,3,0,1375,1376,5,31,0,0,1376,1377,6,66,-1,0,1377,1503, + 1,0,0,0,1378,1379,5,204,0,0,1379,1380,5,205,0,0,1380,1381,5,42,0,0,1381, + 1382,3,32,16,0,1382,1383,5,43,0,0,1383,1384,6,66,-1,0,1384,1503,1,0,0, + 0,1385,1386,5,204,0,0,1386,1387,5,206,0,0,1387,1388,5,42,0,0,1388,1389, + 3,32,16,0,1389,1390,5,43,0,0,1390,1391,3,128,64,0,1391,1392,6,66,-1,0, + 1392,1503,1,0,0,0,1393,1394,5,207,0,0,1394,1503,6,66,-1,0,1395,1396,5, + 208,0,0,1396,1503,6,66,-1,0,1397,1398,5,209,0,0,1398,1503,6,66,-1,0,1399, + 1400,5,201,0,0,1400,1503,6,66,-1,0,1401,1402,5,183,0,0,1402,1503,6,66, + -1,0,1403,1404,5,184,0,0,1404,1503,6,66,-1,0,1405,1406,5,185,0,0,1406, + 1503,6,66,-1,0,1407,1408,5,186,0,0,1408,1503,6,66,-1,0,1409,1410,5,187, + 0,0,1410,1503,6,66,-1,0,1411,1412,5,188,0,0,1412,1503,6,66,-1,0,1413,1414, + 5,189,0,0,1414,1503,6,66,-1,0,1415,1416,5,210,0,0,1416,1503,6,66,-1,0, + 1417,1418,5,190,0,0,1418,1503,6,66,-1,0,1419,1420,5,191,0,0,1420,1503, + 6,66,-1,0,1421,1422,5,192,0,0,1422,1503,6,66,-1,0,1423,1424,5,193,0,0, + 1424,1503,6,66,-1,0,1425,1426,5,211,0,0,1426,1503,6,66,-1,0,1427,1428, + 5,212,0,0,1428,1503,6,66,-1,0,1429,1430,5,213,0,0,1430,1503,6,66,-1,0, + 1431,1432,5,214,0,0,1432,1503,6,66,-1,0,1433,1434,5,215,0,0,1434,1503, + 6,66,-1,0,1435,1436,5,216,0,0,1436,1503,6,66,-1,0,1437,1438,5,217,0,0, + 1438,1503,6,66,-1,0,1439,1440,5,218,0,0,1440,1441,3,134,67,0,1441,1442, + 6,66,-1,0,1442,1503,1,0,0,0,1443,1444,5,219,0,0,1444,1445,3,134,67,0,1445, + 1446,6,66,-1,0,1446,1503,1,0,0,0,1447,1448,5,220,0,0,1448,1503,6,66,-1, + 0,1449,1450,5,221,0,0,1450,1451,3,134,67,0,1451,1452,6,66,-1,0,1452,1503, + 1,0,0,0,1453,1454,5,222,0,0,1454,1455,3,136,68,0,1455,1456,6,66,-1,0,1456, + 1503,1,0,0,0,1457,1458,5,222,0,0,1458,1459,3,136,68,0,1459,1460,5,28,0, + 0,1460,1461,3,6,3,0,1461,1462,6,66,-1,0,1462,1503,1,0,0,0,1463,1464,5, + 194,0,0,1464,1503,6,66,-1,0,1465,1466,5,195,0,0,1466,1503,6,66,-1,0,1467, + 1468,5,90,0,0,1468,1469,5,184,0,0,1469,1503,6,66,-1,0,1470,1471,5,90,0, + 0,1471,1472,5,185,0,0,1472,1503,6,66,-1,0,1473,1474,5,90,0,0,1474,1475, + 5,186,0,0,1475,1503,6,66,-1,0,1476,1477,5,90,0,0,1477,1478,5,187,0,0,1478, + 1503,6,66,-1,0,1479,1480,5,62,0,0,1480,1481,5,220,0,0,1481,1503,6,66,-1, + 0,1482,1483,5,223,0,0,1483,1503,6,66,-1,0,1484,1485,5,224,0,0,1485,1486, + 5,213,0,0,1486,1503,6,66,-1,0,1487,1488,5,225,0,0,1488,1503,6,66,-1,0, + 1489,1490,5,207,0,0,1490,1491,5,183,0,0,1491,1503,6,66,-1,0,1492,1493, + 5,226,0,0,1493,1503,6,66,-1,0,1494,1495,5,228,0,0,1495,1503,6,66,-1,0, + 1496,1497,5,34,0,0,1497,1498,5,227,0,0,1498,1503,6,66,-1,0,1499,1500,3, + 2,1,0,1500,1501,6,66,-1,0,1501,1503,1,0,0,0,1502,1357,1,0,0,0,1502,1358, + 1,0,0,0,1502,1370,1,0,0,0,1502,1378,1,0,0,0,1502,1385,1,0,0,0,1502,1393, + 1,0,0,0,1502,1395,1,0,0,0,1502,1397,1,0,0,0,1502,1399,1,0,0,0,1502,1401, + 1,0,0,0,1502,1403,1,0,0,0,1502,1405,1,0,0,0,1502,1407,1,0,0,0,1502,1409, + 1,0,0,0,1502,1411,1,0,0,0,1502,1413,1,0,0,0,1502,1415,1,0,0,0,1502,1417, + 1,0,0,0,1502,1419,1,0,0,0,1502,1421,1,0,0,0,1502,1423,1,0,0,0,1502,1425, + 1,0,0,0,1502,1427,1,0,0,0,1502,1429,1,0,0,0,1502,1431,1,0,0,0,1502,1433, + 1,0,0,0,1502,1435,1,0,0,0,1502,1437,1,0,0,0,1502,1439,1,0,0,0,1502,1443, + 1,0,0,0,1502,1447,1,0,0,0,1502,1449,1,0,0,0,1502,1453,1,0,0,0,1502,1457, + 1,0,0,0,1502,1463,1,0,0,0,1502,1465,1,0,0,0,1502,1467,1,0,0,0,1502,1470, + 1,0,0,0,1502,1473,1,0,0,0,1502,1476,1,0,0,0,1502,1479,1,0,0,0,1502,1482, + 1,0,0,0,1502,1484,1,0,0,0,1502,1487,1,0,0,0,1502,1489,1,0,0,0,1502,1492, + 1,0,0,0,1502,1494,1,0,0,0,1502,1496,1,0,0,0,1502,1499,1,0,0,0,1503,133, + 1,0,0,0,1504,1513,1,0,0,0,1505,1506,5,30,0,0,1506,1507,5,91,0,0,1507,1508, + 5,36,0,0,1508,1509,3,32,16,0,1509,1510,5,31,0,0,1510,1511,6,67,-1,0,1511, + 1513,1,0,0,0,1512,1504,1,0,0,0,1512,1505,1,0,0,0,1513,135,1,0,0,0,1514, + 1525,1,0,0,0,1515,1516,3,138,69,0,1516,1521,6,68,-1,0,1517,1518,7,8,0, + 0,1518,1520,6,68,-1,0,1519,1517,1,0,0,0,1520,1523,1,0,0,0,1521,1519,1, + 0,0,0,1521,1522,1,0,0,0,1522,1525,1,0,0,0,1523,1521,1,0,0,0,1524,1514, + 1,0,0,0,1524,1515,1,0,0,0,1525,137,1,0,0,0,1526,1527,5,178,0,0,1527,1607, + 6,69,-1,0,1528,1529,5,207,0,0,1529,1607,6,69,-1,0,1530,1531,5,208,0,0, + 1531,1607,6,69,-1,0,1532,1533,5,201,0,0,1533,1607,6,69,-1,0,1534,1535, + 5,183,0,0,1535,1607,6,69,-1,0,1536,1537,5,184,0,0,1537,1607,6,69,-1,0, + 1538,1539,5,185,0,0,1539,1607,6,69,-1,0,1540,1541,5,186,0,0,1541,1607, + 6,69,-1,0,1542,1543,5,187,0,0,1543,1607,6,69,-1,0,1544,1545,5,188,0,0, + 1545,1607,6,69,-1,0,1546,1547,5,189,0,0,1547,1607,6,69,-1,0,1548,1549, + 5,190,0,0,1549,1607,6,69,-1,0,1550,1551,5,191,0,0,1551,1607,6,69,-1,0, + 1552,1553,5,192,0,0,1553,1607,6,69,-1,0,1554,1555,5,193,0,0,1555,1607, + 6,69,-1,0,1556,1557,5,262,0,0,1557,1607,6,69,-1,0,1558,1559,5,211,0,0, + 1559,1607,6,69,-1,0,1560,1561,5,212,0,0,1561,1607,6,69,-1,0,1562,1563, + 5,213,0,0,1563,1607,6,69,-1,0,1564,1565,5,214,0,0,1565,1607,6,69,-1,0, + 1566,1567,5,215,0,0,1567,1607,6,69,-1,0,1568,1569,5,218,0,0,1569,1607, + 6,69,-1,0,1570,1571,5,219,0,0,1571,1607,6,69,-1,0,1572,1573,5,222,0,0, + 1573,1607,6,69,-1,0,1574,1575,5,194,0,0,1575,1607,6,69,-1,0,1576,1577, + 5,195,0,0,1577,1607,6,69,-1,0,1578,1579,5,210,0,0,1579,1607,6,69,-1,0, + 1580,1581,5,230,0,0,1581,1607,6,69,-1,0,1582,1583,5,231,0,0,1583,1607, + 6,69,-1,0,1584,1585,5,232,0,0,1585,1607,6,69,-1,0,1586,1587,5,233,0,0, + 1587,1607,6,69,-1,0,1588,1589,5,234,0,0,1589,1607,6,69,-1,0,1590,1591, + 5,235,0,0,1591,1607,6,69,-1,0,1592,1593,5,236,0,0,1593,1607,6,69,-1,0, + 1594,1595,5,237,0,0,1595,1607,6,69,-1,0,1596,1597,5,238,0,0,1597,1607, + 6,69,-1,0,1598,1599,5,239,0,0,1599,1607,6,69,-1,0,1600,1601,5,240,0,0, + 1601,1607,6,69,-1,0,1602,1603,5,241,0,0,1603,1607,6,69,-1,0,1604,1605, + 5,242,0,0,1605,1607,6,69,-1,0,1606,1526,1,0,0,0,1606,1528,1,0,0,0,1606, + 1530,1,0,0,0,1606,1532,1,0,0,0,1606,1534,1,0,0,0,1606,1536,1,0,0,0,1606, + 1538,1,0,0,0,1606,1540,1,0,0,0,1606,1542,1,0,0,0,1606,1544,1,0,0,0,1606, + 1546,1,0,0,0,1606,1548,1,0,0,0,1606,1550,1,0,0,0,1606,1552,1,0,0,0,1606, + 1554,1,0,0,0,1606,1556,1,0,0,0,1606,1558,1,0,0,0,1606,1560,1,0,0,0,1606, + 1562,1,0,0,0,1606,1564,1,0,0,0,1606,1566,1,0,0,0,1606,1568,1,0,0,0,1606, + 1570,1,0,0,0,1606,1572,1,0,0,0,1606,1574,1,0,0,0,1606,1576,1,0,0,0,1606, + 1578,1,0,0,0,1606,1580,1,0,0,0,1606,1582,1,0,0,0,1606,1584,1,0,0,0,1606, + 1586,1,0,0,0,1606,1588,1,0,0,0,1606,1590,1,0,0,0,1606,1592,1,0,0,0,1606, + 1594,1,0,0,0,1606,1596,1,0,0,0,1606,1598,1,0,0,0,1606,1600,1,0,0,0,1606, + 1602,1,0,0,0,1606,1604,1,0,0,0,1607,139,1,0,0,0,1608,1609,3,144,72,0,1609, + 1615,6,70,-1,0,1610,1611,3,142,71,0,1611,1612,6,70,-1,0,1612,1614,1,0, + 0,0,1613,1610,1,0,0,0,1614,1617,1,0,0,0,1615,1613,1,0,0,0,1615,1616,1, + 0,0,0,1616,141,1,0,0,0,1617,1615,1,0,0,0,1618,1619,5,261,0,0,1619,1648, + 6,71,-1,0,1620,1621,5,42,0,0,1621,1622,5,43,0,0,1622,1648,6,71,-1,0,1623, + 1624,3,112,56,0,1624,1625,6,71,-1,0,1625,1648,1,0,0,0,1626,1627,5,260, + 0,0,1627,1648,6,71,-1,0,1628,1629,5,262,0,0,1629,1648,6,71,-1,0,1630,1631, + 5,92,0,0,1631,1648,6,71,-1,0,1632,1633,5,93,0,0,1633,1634,5,30,0,0,1634, + 1635,3,126,63,0,1635,1636,5,31,0,0,1636,1637,6,71,-1,0,1637,1648,1,0,0, + 0,1638,1639,5,94,0,0,1639,1640,5,30,0,0,1640,1641,3,126,63,0,1641,1642, + 5,31,0,0,1642,1643,6,71,-1,0,1643,1648,1,0,0,0,1644,1645,3,110,55,0,1645, + 1646,6,71,-1,0,1646,1648,1,0,0,0,1647,1618,1,0,0,0,1647,1620,1,0,0,0,1647, + 1623,1,0,0,0,1647,1626,1,0,0,0,1647,1628,1,0,0,0,1647,1630,1,0,0,0,1647, + 1632,1,0,0,0,1647,1638,1,0,0,0,1647,1644,1,0,0,0,1648,143,1,0,0,0,1649, + 1650,5,39,0,0,1650,1651,3,118,59,0,1651,1652,6,72,-1,0,1652,1708,1,0,0, + 0,1653,1654,5,197,0,0,1654,1708,6,72,-1,0,1655,1656,5,199,0,0,1656,1657, + 5,39,0,0,1657,1658,3,118,59,0,1658,1659,6,72,-1,0,1659,1708,1,0,0,0,1660, + 1661,5,200,0,0,1661,1662,3,118,59,0,1662,1663,6,72,-1,0,1663,1708,1,0, + 0,0,1664,1665,5,226,0,0,1665,1666,3,172,86,0,1666,1667,3,140,70,0,1667, + 1668,5,262,0,0,1668,1669,3,114,57,0,1669,1670,6,72,-1,0,1670,1708,1,0, + 0,0,1671,1672,5,253,0,0,1672,1673,3,32,16,0,1673,1674,6,72,-1,0,1674,1708, + 1,0,0,0,1675,1676,5,252,0,0,1676,1677,3,32,16,0,1677,1678,6,72,-1,0,1678, + 1708,1,0,0,0,1679,1680,5,253,0,0,1680,1681,3,2,1,0,1681,1682,6,72,-1,0, + 1682,1708,1,0,0,0,1683,1684,5,252,0,0,1684,1685,3,2,1,0,1685,1686,6,72, + -1,0,1686,1708,1,0,0,0,1687,1688,5,254,0,0,1688,1708,6,72,-1,0,1689,1690, + 5,201,0,0,1690,1708,6,72,-1,0,1691,1692,3,150,75,0,1692,1693,6,72,-1,0, + 1693,1708,1,0,0,0,1694,1695,3,152,76,0,1695,1696,6,72,-1,0,1696,1708,1, + 0,0,0,1697,1698,3,146,73,0,1698,1699,6,72,-1,0,1699,1708,1,0,0,0,1700, + 1701,3,2,1,0,1701,1702,6,72,-1,0,1702,1708,1,0,0,0,1703,1704,5,177,0,0, + 1704,1705,3,140,70,0,1705,1706,6,72,-1,0,1706,1708,1,0,0,0,1707,1649,1, + 0,0,0,1707,1653,1,0,0,0,1707,1655,1,0,0,0,1707,1660,1,0,0,0,1707,1664, + 1,0,0,0,1707,1671,1,0,0,0,1707,1675,1,0,0,0,1707,1679,1,0,0,0,1707,1683, + 1,0,0,0,1707,1687,1,0,0,0,1707,1689,1,0,0,0,1707,1691,1,0,0,0,1707,1694, + 1,0,0,0,1707,1697,1,0,0,0,1707,1700,1,0,0,0,1707,1703,1,0,0,0,1708,145, + 1,0,0,0,1709,1710,5,181,0,0,1710,1748,6,73,-1,0,1711,1712,5,182,0,0,1712, + 1748,6,73,-1,0,1713,1714,5,183,0,0,1714,1748,6,73,-1,0,1715,1716,5,184, + 0,0,1716,1748,6,73,-1,0,1717,1718,5,185,0,0,1718,1748,6,73,-1,0,1719,1720, + 5,186,0,0,1720,1748,6,73,-1,0,1721,1722,5,187,0,0,1722,1748,6,73,-1,0, + 1723,1724,5,188,0,0,1724,1748,6,73,-1,0,1725,1726,5,189,0,0,1726,1748, + 6,73,-1,0,1727,1728,5,190,0,0,1728,1748,6,73,-1,0,1729,1730,5,191,0,0, + 1730,1748,6,73,-1,0,1731,1732,5,192,0,0,1732,1748,6,73,-1,0,1733,1734, + 5,193,0,0,1734,1748,6,73,-1,0,1735,1736,5,90,0,0,1736,1737,5,184,0,0,1737, + 1748,6,73,-1,0,1738,1739,5,90,0,0,1739,1740,5,185,0,0,1740,1748,6,73,-1, + 0,1741,1742,5,90,0,0,1742,1743,5,186,0,0,1743,1748,6,73,-1,0,1744,1745, + 5,90,0,0,1745,1746,5,187,0,0,1746,1748,6,73,-1,0,1747,1709,1,0,0,0,1747, + 1711,1,0,0,0,1747,1713,1,0,0,0,1747,1715,1,0,0,0,1747,1717,1,0,0,0,1747, + 1719,1,0,0,0,1747,1721,1,0,0,0,1747,1723,1,0,0,0,1747,1725,1,0,0,0,1747, + 1727,1,0,0,0,1747,1729,1,0,0,0,1747,1731,1,0,0,0,1747,1733,1,0,0,0,1747, + 1735,1,0,0,0,1747,1738,1,0,0,0,1747,1741,1,0,0,0,1747,1744,1,0,0,0,1748, + 147,1,0,0,0,1749,1764,1,0,0,0,1750,1764,5,177,0,0,1751,1752,3,32,16,0, + 1752,1753,6,74,-1,0,1753,1764,1,0,0,0,1754,1755,3,32,16,0,1755,1756,5, + 177,0,0,1756,1757,3,32,16,0,1757,1758,6,74,-1,0,1758,1764,1,0,0,0,1759, + 1760,3,32,16,0,1760,1761,5,177,0,0,1761,1762,6,74,-1,0,1762,1764,1,0,0, + 0,1763,1749,1,0,0,0,1763,1750,1,0,0,0,1763,1751,1,0,0,0,1763,1754,1,0, + 0,0,1763,1759,1,0,0,0,1764,149,1,0,0,0,1765,1766,5,1,0,0,1766,1767,5,194, + 0,0,1767,1768,6,75,-1,0,1768,151,1,0,0,0,1769,1773,5,1,0,0,1770,1771,5, + 90,0,0,1771,1774,5,194,0,0,1772,1774,5,195,0,0,1773,1770,1,0,0,0,1773, + 1772,1,0,0,0,1774,1775,1,0,0,0,1775,1776,6,76,-1,0,1776,153,1,0,0,0,1777, + 1778,5,294,0,0,1778,1779,3,168,84,0,1779,1780,3,126,63,0,1780,1781,5,30, + 0,0,1781,1782,3,160,80,0,1782,1783,5,31,0,0,1783,1784,6,77,-1,0,1784,1832, + 1,0,0,0,1785,1786,5,294,0,0,1786,1787,3,168,84,0,1787,1788,3,126,63,0, + 1788,1789,5,36,0,0,1789,1790,5,17,0,0,1790,1791,3,52,26,0,1791,1792,5, + 18,0,0,1792,1793,6,77,-1,0,1793,1832,1,0,0,0,1794,1795,5,294,0,0,1795, + 1796,3,168,84,0,1796,1797,3,126,63,0,1797,1798,6,77,-1,0,1798,1832,1,0, + 0,0,1799,1800,5,295,0,0,1800,1801,3,168,84,0,1801,1803,5,36,0,0,1802,1804, + 5,84,0,0,1803,1802,1,0,0,0,1803,1804,1,0,0,0,1804,1805,1,0,0,0,1805,1806, + 5,30,0,0,1806,1807,3,302,151,0,1807,1808,5,31,0,0,1808,1809,6,77,-1,0, + 1809,1832,1,0,0,0,1810,1811,5,295,0,0,1811,1812,3,168,84,0,1812,1813,5, + 84,0,0,1813,1814,5,30,0,0,1814,1815,3,302,151,0,1815,1816,5,31,0,0,1816, + 1817,6,77,-1,0,1817,1832,1,0,0,0,1818,1819,5,295,0,0,1819,1820,3,168,84, + 0,1820,1821,3,6,3,0,1821,1822,6,77,-1,0,1822,1832,1,0,0,0,1823,1824,5, + 295,0,0,1824,1825,3,168,84,0,1825,1826,5,36,0,0,1826,1827,5,17,0,0,1827, + 1828,3,156,78,0,1828,1829,5,18,0,0,1829,1830,6,77,-1,0,1830,1832,1,0,0, + 0,1831,1777,1,0,0,0,1831,1785,1,0,0,0,1831,1794,1,0,0,0,1831,1799,1,0, + 0,0,1831,1810,1,0,0,0,1831,1818,1,0,0,0,1831,1823,1,0,0,0,1832,155,1,0, + 0,0,1833,1847,1,0,0,0,1834,1835,3,158,79,0,1835,1836,6,78,-1,0,1836,1837, + 5,28,0,0,1837,1839,1,0,0,0,1838,1834,1,0,0,0,1839,1842,1,0,0,0,1840,1838, + 1,0,0,0,1840,1841,1,0,0,0,1841,1843,1,0,0,0,1842,1840,1,0,0,0,1843,1844, + 3,158,79,0,1844,1845,6,78,-1,0,1845,1847,1,0,0,0,1846,1833,1,0,0,0,1846, + 1840,1,0,0,0,1847,157,1,0,0,0,1848,1849,5,39,0,0,1849,1850,5,264,0,0,1850, + 1851,5,36,0,0,1851,1852,5,17,0,0,1852,1853,3,56,28,0,1853,1854,5,18,0, + 0,1854,1855,6,79,-1,0,1855,1864,1,0,0,0,1856,1857,3,126,63,0,1857,1858, + 5,36,0,0,1858,1859,5,17,0,0,1859,1860,3,56,28,0,1860,1861,5,18,0,0,1861, + 1862,6,79,-1,0,1862,1864,1,0,0,0,1863,1848,1,0,0,0,1863,1856,1,0,0,0,1864, + 159,1,0,0,0,1865,1866,3,162,81,0,1866,1867,6,80,-1,0,1867,1868,5,28,0, + 0,1868,1870,1,0,0,0,1869,1865,1,0,0,0,1870,1873,1,0,0,0,1871,1869,1,0, + 0,0,1871,1872,1,0,0,0,1872,1874,1,0,0,0,1873,1871,1,0,0,0,1874,1875,3, + 162,81,0,1875,1876,6,80,-1,0,1876,161,1,0,0,0,1877,1878,3,6,3,0,1878,1879, + 5,36,0,0,1879,1880,3,166,83,0,1880,1881,6,81,-1,0,1881,163,1,0,0,0,1882, + 1883,7,9,0,0,1883,165,1,0,0,0,1884,1885,3,164,82,0,1885,1886,6,83,-1,0, + 1886,1930,1,0,0,0,1887,1888,3,32,16,0,1888,1889,6,83,-1,0,1889,1930,1, + 0,0,0,1890,1891,5,186,0,0,1891,1892,5,30,0,0,1892,1893,3,32,16,0,1893, + 1894,5,31,0,0,1894,1895,6,83,-1,0,1895,1930,1,0,0,0,1896,1897,3,6,3,0, + 1897,1898,6,83,-1,0,1898,1930,1,0,0,0,1899,1900,3,118,59,0,1900,1901,5, + 30,0,0,1901,1902,5,184,0,0,1902,1903,5,75,0,0,1903,1904,3,32,16,0,1904, + 1905,5,31,0,0,1905,1906,6,83,-1,0,1906,1930,1,0,0,0,1907,1908,3,118,59, + 0,1908,1909,5,30,0,0,1909,1910,5,185,0,0,1910,1911,5,75,0,0,1911,1912, + 3,32,16,0,1912,1913,5,31,0,0,1913,1914,6,83,-1,0,1914,1930,1,0,0,0,1915, + 1916,3,118,59,0,1916,1917,5,30,0,0,1917,1918,5,186,0,0,1918,1919,5,75, + 0,0,1919,1920,3,32,16,0,1920,1921,5,31,0,0,1921,1922,6,83,-1,0,1922,1930, + 1,0,0,0,1923,1924,3,118,59,0,1924,1925,5,30,0,0,1925,1926,3,32,16,0,1926, + 1927,5,31,0,0,1927,1928,6,83,-1,0,1928,1930,1,0,0,0,1929,1884,1,0,0,0, + 1929,1887,1,0,0,0,1929,1890,1,0,0,0,1929,1896,1,0,0,0,1929,1899,1,0,0, + 0,1929,1907,1,0,0,0,1929,1915,1,0,0,0,1929,1923,1,0,0,0,1930,167,1,0,0, + 0,1931,1932,7,10,0,0,1932,169,1,0,0,0,1933,1934,3,172,86,0,1934,1935,3, + 140,70,0,1935,1936,3,126,63,0,1936,1937,5,176,0,0,1937,1939,3,244,122, + 0,1938,1940,3,110,55,0,1939,1938,1,0,0,0,1939,1940,1,0,0,0,1940,1941,1, + 0,0,0,1941,1942,3,114,57,0,1942,1943,6,85,-1,0,1943,1976,1,0,0,0,1944, + 1945,3,172,86,0,1945,1946,3,140,70,0,1946,1947,3,126,63,0,1947,1948,5, + 176,0,0,1948,1949,3,244,122,0,1949,1950,3,198,99,0,1950,1951,3,114,57, + 0,1951,1952,6,85,-1,0,1952,1976,1,0,0,0,1953,1954,3,172,86,0,1954,1955, + 3,140,70,0,1955,1957,3,244,122,0,1956,1958,3,110,55,0,1957,1956,1,0,0, + 0,1957,1958,1,0,0,0,1958,1959,1,0,0,0,1959,1960,3,114,57,0,1960,1961,6, + 85,-1,0,1961,1976,1,0,0,0,1962,1963,3,172,86,0,1963,1964,3,140,70,0,1964, + 1965,3,244,122,0,1965,1966,3,198,99,0,1966,1967,3,114,57,0,1967,1968,6, + 85,-1,0,1968,1976,1,0,0,0,1969,1970,3,176,88,0,1970,1971,6,85,-1,0,1971, + 1976,1,0,0,0,1972,1973,3,2,1,0,1973,1974,6,85,-1,0,1974,1976,1,0,0,0,1975, + 1933,1,0,0,0,1975,1944,1,0,0,0,1975,1953,1,0,0,0,1975,1962,1,0,0,0,1975, + 1969,1,0,0,0,1975,1972,1,0,0,0,1976,171,1,0,0,0,1977,1978,5,243,0,0,1978, + 1979,3,172,86,0,1979,1980,6,86,-1,0,1980,1995,1,0,0,0,1981,1982,5,244, + 0,0,1982,1983,3,172,86,0,1983,1984,6,86,-1,0,1984,1995,1,0,0,0,1985,1986, + 3,174,87,0,1986,1987,6,86,-1,0,1987,1995,1,0,0,0,1988,1989,5,112,0,0,1989, + 1990,5,30,0,0,1990,1991,3,32,16,0,1991,1992,5,31,0,0,1992,1993,6,86,-1, + 0,1993,1995,1,0,0,0,1994,1977,1,0,0,0,1994,1981,1,0,0,0,1994,1985,1,0, + 0,0,1994,1988,1,0,0,0,1995,173,1,0,0,0,1996,2016,1,0,0,0,1997,1998,5,245, + 0,0,1998,2016,6,87,-1,0,1999,2000,5,246,0,0,2000,2016,6,87,-1,0,2001,2002, + 5,247,0,0,2002,2003,5,248,0,0,2003,2016,6,87,-1,0,2004,2005,5,247,0,0, + 2005,2006,5,249,0,0,2006,2016,6,87,-1,0,2007,2008,5,247,0,0,2008,2009, + 5,250,0,0,2009,2016,6,87,-1,0,2010,2011,5,247,0,0,2011,2012,5,251,0,0, + 2012,2016,6,87,-1,0,2013,2014,5,247,0,0,2014,2016,6,87,-1,0,2015,1996, + 1,0,0,0,2015,1997,1,0,0,0,2015,1999,1,0,0,0,2015,2001,1,0,0,0,2015,2004, + 1,0,0,0,2015,2007,1,0,0,0,2015,2010,1,0,0,0,2015,2013,1,0,0,0,2016,175, + 1,0,0,0,2017,2018,5,113,0,0,2018,2019,5,30,0,0,2019,2020,3,32,16,0,2020, + 2021,5,31,0,0,2021,2022,6,88,-1,0,2022,177,1,0,0,0,2023,2024,5,226,0,0, + 2024,2025,3,170,85,0,2025,2026,6,89,-1,0,2026,2035,1,0,0,0,2027,2028,5, + 37,0,0,2028,2029,3,180,90,0,2029,2030,6,89,-1,0,2030,2035,1,0,0,0,2031, + 2032,3,176,88,0,2032,2033,6,89,-1,0,2033,2035,1,0,0,0,2034,2023,1,0,0, + 0,2034,2027,1,0,0,0,2034,2031,1,0,0,0,2035,179,1,0,0,0,2036,2037,3,140, + 70,0,2037,2038,3,126,63,0,2038,2039,5,176,0,0,2039,2040,3,2,1,0,2040,2041, + 6,90,-1,0,2041,2050,1,0,0,0,2042,2043,3,140,70,0,2043,2044,3,2,1,0,2044, + 2045,6,90,-1,0,2045,2050,1,0,0,0,2046,2047,3,2,1,0,2047,2048,6,90,-1,0, + 2048,2050,1,0,0,0,2049,2036,1,0,0,0,2049,2042,1,0,0,0,2049,2046,1,0,0, + 0,2050,181,1,0,0,0,2051,2052,3,126,63,0,2052,2053,6,91,-1,0,2053,2054, + 5,28,0,0,2054,2056,1,0,0,0,2055,2051,1,0,0,0,2056,2059,1,0,0,0,2057,2055, + 1,0,0,0,2057,2058,1,0,0,0,2058,2060,1,0,0,0,2059,2057,1,0,0,0,2060,2061, + 3,126,63,0,2061,2062,6,91,-1,0,2062,183,1,0,0,0,2063,2070,1,0,0,0,2064, + 2065,5,86,0,0,2065,2066,3,192,96,0,2066,2067,5,87,0,0,2067,2068,6,92,-1, + 0,2068,2070,1,0,0,0,2069,2063,1,0,0,0,2069,2064,1,0,0,0,2070,185,1,0,0, + 0,2071,2072,5,266,0,0,2072,2090,6,93,-1,0,2073,2074,5,114,0,0,2074,2090, + 6,93,-1,0,2075,2076,5,39,0,0,2076,2090,6,93,-1,0,2077,2078,5,200,0,0,2078, + 2090,6,93,-1,0,2079,2080,5,115,0,0,2080,2090,6,93,-1,0,2081,2082,5,116, + 0,0,2082,2090,6,93,-1,0,2083,2084,5,70,0,0,2084,2085,5,30,0,0,2085,2086, + 3,32,16,0,2086,2087,5,31,0,0,2087,2088,6,93,-1,0,2088,2090,1,0,0,0,2089, + 2071,1,0,0,0,2089,2073,1,0,0,0,2089,2075,1,0,0,0,2089,2077,1,0,0,0,2089, + 2079,1,0,0,0,2089,2081,1,0,0,0,2089,2083,1,0,0,0,2090,187,1,0,0,0,2091, + 2092,3,186,93,0,2092,2093,6,94,-1,0,2093,2095,1,0,0,0,2094,2091,1,0,0, + 0,2095,2098,1,0,0,0,2096,2094,1,0,0,0,2096,2097,1,0,0,0,2097,189,1,0,0, + 0,2098,2096,1,0,0,0,2099,2101,3,188,94,0,2100,2102,3,194,97,0,2101,2100, + 1,0,0,0,2101,2102,1,0,0,0,2102,2103,1,0,0,0,2103,2104,3,2,1,0,2104,2105, + 6,95,-1,0,2105,191,1,0,0,0,2106,2107,3,190,95,0,2107,2108,6,96,-1,0,2108, + 2109,5,28,0,0,2109,2111,1,0,0,0,2110,2106,1,0,0,0,2111,2114,1,0,0,0,2112, + 2110,1,0,0,0,2112,2113,1,0,0,0,2113,2115,1,0,0,0,2114,2112,1,0,0,0,2115, + 2116,3,190,95,0,2116,2117,6,96,-1,0,2117,193,1,0,0,0,2118,2119,5,30,0, + 0,2119,2120,3,182,91,0,2120,2121,5,31,0,0,2121,2122,6,97,-1,0,2122,195, + 1,0,0,0,2123,2125,3,198,99,0,2124,2123,1,0,0,0,2124,2125,1,0,0,0,2125, + 2126,1,0,0,0,2126,2127,6,98,-1,0,2127,197,1,0,0,0,2128,2129,5,86,0,0,2129, + 2130,5,42,0,0,2130,2131,3,32,16,0,2131,2132,5,43,0,0,2132,2133,5,87,0, + 0,2133,2134,6,99,-1,0,2134,199,1,0,0,0,2135,2136,3,236,118,0,2136,2137, + 5,17,0,0,2137,2138,3,248,124,0,2138,2139,5,18,0,0,2139,2286,1,0,0,0,2140, + 2141,3,76,38,0,2141,2142,5,17,0,0,2142,2143,3,84,42,0,2143,2144,5,18,0, + 0,2144,2286,1,0,0,0,2145,2146,3,212,106,0,2146,2147,6,100,-1,0,2147,2148, + 5,17,0,0,2148,2149,3,216,108,0,2149,2150,5,18,0,0,2150,2286,1,0,0,0,2151, + 2152,3,220,110,0,2152,2153,6,100,-1,0,2153,2154,5,17,0,0,2154,2155,3,224, + 112,0,2155,2156,5,18,0,0,2156,2286,1,0,0,0,2157,2286,3,202,101,0,2158, + 2159,3,286,143,0,2159,2160,6,100,-1,0,2160,2286,1,0,0,0,2161,2162,3,154, + 77,0,2162,2163,6,100,-1,0,2163,2286,1,0,0,0,2164,2165,3,90,45,0,2165,2166, + 6,100,-1,0,2166,2286,1,0,0,0,2167,2168,3,332,166,0,2168,2169,6,100,-1, + 0,2169,2286,1,0,0,0,2170,2171,5,117,0,0,2171,2172,3,32,16,0,2172,2173, + 6,100,-1,0,2173,2286,1,0,0,0,2174,2175,5,118,0,0,2175,2176,3,32,16,0,2176, + 2177,6,100,-1,0,2177,2286,1,0,0,0,2178,2179,3,348,174,0,2179,2180,5,17, + 0,0,2180,2181,3,354,177,0,2181,2182,5,18,0,0,2182,2183,6,100,-1,0,2183, + 2286,1,0,0,0,2184,2185,5,302,0,0,2185,2186,3,126,63,0,2186,2187,5,176, + 0,0,2187,2188,3,244,122,0,2188,2189,5,119,0,0,2189,2190,3,172,86,0,2190, + 2191,3,140,70,0,2191,2192,3,126,63,0,2192,2193,5,176,0,0,2193,2194,3,244, + 122,0,2194,2195,3,114,57,0,2195,2196,6,100,-1,0,2196,2286,1,0,0,0,2197, + 2198,5,302,0,0,2198,2199,5,226,0,0,2199,2200,3,172,86,0,2200,2201,3,140, + 70,0,2201,2202,3,126,63,0,2202,2203,5,176,0,0,2203,2204,3,244,122,0,2204, + 2205,3,196,98,0,2205,2206,3,114,57,0,2206,2207,5,119,0,0,2207,2208,5,226, + 0,0,2208,2209,3,172,86,0,2209,2210,3,140,70,0,2210,2211,3,126,63,0,2211, + 2212,5,176,0,0,2212,2213,3,244,122,0,2213,2214,3,196,98,0,2214,2215,3, + 114,57,0,2215,2216,6,100,-1,0,2216,2286,1,0,0,0,2217,2218,3,26,13,0,2218, + 2219,6,100,-1,0,2219,2286,1,0,0,0,2220,2221,3,40,20,0,2221,2222,6,100, + -1,0,2222,2286,1,0,0,0,2223,2224,5,255,0,0,2224,2225,5,196,0,0,2225,2226, + 5,42,0,0,2226,2227,3,32,16,0,2227,2228,5,43,0,0,2228,2234,6,100,-1,0,2229, + 2230,3,332,166,0,2230,2231,6,100,-1,0,2231,2233,1,0,0,0,2232,2229,1,0, + 0,0,2233,2236,1,0,0,0,2234,2232,1,0,0,0,2234,2235,1,0,0,0,2235,2286,1, + 0,0,0,2236,2234,1,0,0,0,2237,2238,5,255,0,0,2238,2239,5,196,0,0,2239,2240, + 3,2,1,0,2240,2246,6,100,-1,0,2241,2242,3,332,166,0,2242,2243,6,100,-1, + 0,2243,2245,1,0,0,0,2244,2241,1,0,0,0,2245,2248,1,0,0,0,2246,2244,1,0, + 0,0,2246,2247,1,0,0,0,2247,2286,1,0,0,0,2248,2246,1,0,0,0,2249,2250,5, + 255,0,0,2250,2251,5,256,0,0,2251,2252,5,42,0,0,2252,2253,3,32,16,0,2253, + 2254,5,43,0,0,2254,2255,5,28,0,0,2255,2256,3,126,63,0,2256,2262,6,100, + -1,0,2257,2258,3,332,166,0,2258,2259,6,100,-1,0,2259,2261,1,0,0,0,2260, + 2257,1,0,0,0,2261,2264,1,0,0,0,2262,2260,1,0,0,0,2262,2263,1,0,0,0,2263, + 2286,1,0,0,0,2264,2262,1,0,0,0,2265,2266,5,255,0,0,2266,2267,5,256,0,0, + 2267,2268,3,2,1,0,2268,2269,5,28,0,0,2269,2270,3,126,63,0,2270,2276,6, + 100,-1,0,2271,2272,3,332,166,0,2272,2273,6,100,-1,0,2273,2275,1,0,0,0, + 2274,2271,1,0,0,0,2275,2278,1,0,0,0,2276,2274,1,0,0,0,2276,2277,1,0,0, + 0,2277,2286,1,0,0,0,2278,2276,1,0,0,0,2279,2280,5,120,0,0,2280,2281,5, + 196,0,0,2281,2282,3,126,63,0,2282,2283,3,44,22,0,2283,2284,6,100,-1,0, + 2284,2286,1,0,0,0,2285,2135,1,0,0,0,2285,2140,1,0,0,0,2285,2145,1,0,0, + 0,2285,2151,1,0,0,0,2285,2157,1,0,0,0,2285,2158,1,0,0,0,2285,2161,1,0, + 0,0,2285,2164,1,0,0,0,2285,2167,1,0,0,0,2285,2170,1,0,0,0,2285,2174,1, + 0,0,0,2285,2178,1,0,0,0,2285,2184,1,0,0,0,2285,2197,1,0,0,0,2285,2217, + 1,0,0,0,2285,2220,1,0,0,0,2285,2223,1,0,0,0,2285,2237,1,0,0,0,2285,2249, + 1,0,0,0,2285,2265,1,0,0,0,2285,2279,1,0,0,0,2286,201,1,0,0,0,2287,2288, + 5,121,0,0,2288,2300,3,210,105,0,2289,2290,3,204,102,0,2290,2291,6,101, + -1,0,2291,2299,1,0,0,0,2292,2293,5,122,0,0,2293,2294,5,30,0,0,2294,2295, + 3,230,115,0,2295,2296,5,31,0,0,2296,2297,6,101,-1,0,2297,2299,1,0,0,0, + 2298,2289,1,0,0,0,2298,2292,1,0,0,0,2299,2302,1,0,0,0,2300,2298,1,0,0, + 0,2300,2301,1,0,0,0,2301,2303,1,0,0,0,2302,2300,1,0,0,0,2303,2304,3,140, + 70,0,2304,2305,3,2,1,0,2305,2306,3,206,103,0,2306,2307,3,208,104,0,2307, + 2308,6,101,-1,0,2308,203,1,0,0,0,2309,2310,5,123,0,0,2310,2344,6,102,-1, + 0,2311,2312,5,51,0,0,2312,2344,6,102,-1,0,2313,2314,5,52,0,0,2314,2344, + 6,102,-1,0,2315,2316,5,63,0,0,2316,2344,6,102,-1,0,2317,2318,5,124,0,0, + 2318,2344,6,102,-1,0,2319,2320,5,69,0,0,2320,2344,6,102,-1,0,2321,2322, + 5,68,0,0,2322,2344,6,102,-1,0,2323,2324,5,64,0,0,2324,2344,6,102,-1,0, + 2325,2326,5,65,0,0,2326,2344,6,102,-1,0,2327,2328,5,66,0,0,2328,2344,6, + 102,-1,0,2329,2330,5,125,0,0,2330,2344,6,102,-1,0,2331,2332,5,126,0,0, + 2332,2344,6,102,-1,0,2333,2334,5,127,0,0,2334,2344,6,102,-1,0,2335,2336, + 5,16,0,0,2336,2344,6,102,-1,0,2337,2338,5,70,0,0,2338,2339,5,30,0,0,2339, + 2340,3,32,16,0,2340,2341,5,31,0,0,2341,2342,6,102,-1,0,2342,2344,1,0,0, + 0,2343,2309,1,0,0,0,2343,2311,1,0,0,0,2343,2313,1,0,0,0,2343,2315,1,0, + 0,0,2343,2317,1,0,0,0,2343,2319,1,0,0,0,2343,2321,1,0,0,0,2343,2323,1, + 0,0,0,2343,2325,1,0,0,0,2343,2327,1,0,0,0,2343,2329,1,0,0,0,2343,2331, + 1,0,0,0,2343,2333,1,0,0,0,2343,2335,1,0,0,0,2343,2337,1,0,0,0,2344,205, + 1,0,0,0,2345,2355,1,0,0,0,2346,2347,5,44,0,0,2347,2348,3,0,0,0,2348,2349, + 6,103,-1,0,2349,2355,1,0,0,0,2350,2351,5,44,0,0,2351,2352,3,32,16,0,2352, + 2353,6,103,-1,0,2353,2355,1,0,0,0,2354,2345,1,0,0,0,2354,2346,1,0,0,0, + 2354,2350,1,0,0,0,2355,207,1,0,0,0,2356,2362,1,0,0,0,2357,2358,5,36,0, + 0,2358,2359,3,306,153,0,2359,2360,6,104,-1,0,2360,2362,1,0,0,0,2361,2356, + 1,0,0,0,2361,2357,1,0,0,0,2362,209,1,0,0,0,2363,2370,1,0,0,0,2364,2365, + 5,42,0,0,2365,2366,3,32,16,0,2366,2367,5,43,0,0,2367,2368,6,105,-1,0,2368, + 2370,1,0,0,0,2369,2363,1,0,0,0,2369,2364,1,0,0,0,2370,211,1,0,0,0,2371, + 2377,5,128,0,0,2372,2373,3,214,107,0,2373,2374,6,106,-1,0,2374,2376,1, + 0,0,0,2375,2372,1,0,0,0,2376,2379,1,0,0,0,2377,2375,1,0,0,0,2377,2378, + 1,0,0,0,2378,2380,1,0,0,0,2379,2377,1,0,0,0,2380,2381,3,126,63,0,2381, + 2382,3,2,1,0,2382,2383,6,106,-1,0,2383,2397,1,0,0,0,2384,2390,5,128,0, + 0,2385,2386,3,214,107,0,2386,2387,6,106,-1,0,2387,2389,1,0,0,0,2388,2385, + 1,0,0,0,2389,2392,1,0,0,0,2390,2388,1,0,0,0,2390,2391,1,0,0,0,2391,2393, + 1,0,0,0,2392,2390,1,0,0,0,2393,2394,3,2,1,0,2394,2395,6,106,-1,0,2395, + 2397,1,0,0,0,2396,2371,1,0,0,0,2396,2384,1,0,0,0,2397,213,1,0,0,0,2398, + 2399,5,69,0,0,2399,2403,6,107,-1,0,2400,2401,5,68,0,0,2401,2403,6,107, + -1,0,2402,2398,1,0,0,0,2402,2400,1,0,0,0,2403,215,1,0,0,0,2404,2406,3, + 218,109,0,2405,2404,1,0,0,0,2406,2409,1,0,0,0,2407,2405,1,0,0,0,2407,2408, + 1,0,0,0,2408,217,1,0,0,0,2409,2407,1,0,0,0,2410,2411,5,129,0,0,2411,2412, + 3,170,85,0,2412,2413,6,109,-1,0,2413,2437,1,0,0,0,2414,2415,5,130,0,0, + 2415,2416,3,170,85,0,2416,2417,6,109,-1,0,2417,2437,1,0,0,0,2418,2419, + 5,131,0,0,2419,2420,3,170,85,0,2420,2421,6,109,-1,0,2421,2437,1,0,0,0, + 2422,2423,5,132,0,0,2423,2424,3,170,85,0,2424,2425,6,109,-1,0,2425,2437, + 1,0,0,0,2426,2427,3,90,45,0,2427,2428,6,109,-1,0,2428,2437,1,0,0,0,2429, + 2430,3,332,166,0,2430,2431,6,109,-1,0,2431,2437,1,0,0,0,2432,2433,3,26, + 13,0,2433,2434,6,109,-1,0,2434,2437,1,0,0,0,2435,2437,3,40,20,0,2436,2410, + 1,0,0,0,2436,2414,1,0,0,0,2436,2418,1,0,0,0,2436,2422,1,0,0,0,2436,2426, + 1,0,0,0,2436,2429,1,0,0,0,2436,2432,1,0,0,0,2436,2435,1,0,0,0,2437,219, + 1,0,0,0,2438,2444,5,133,0,0,2439,2440,3,222,111,0,2440,2441,6,110,-1,0, + 2441,2443,1,0,0,0,2442,2439,1,0,0,0,2443,2446,1,0,0,0,2444,2442,1,0,0, + 0,2444,2445,1,0,0,0,2445,2447,1,0,0,0,2446,2444,1,0,0,0,2447,2448,3,172, + 86,0,2448,2449,3,140,70,0,2449,2450,3,2,1,0,2450,2451,3,114,57,0,2451, + 2452,3,208,104,0,2452,2453,6,110,-1,0,2453,221,1,0,0,0,2454,2455,5,69, + 0,0,2455,2459,6,111,-1,0,2456,2457,5,68,0,0,2457,2459,6,111,-1,0,2458, + 2454,1,0,0,0,2458,2456,1,0,0,0,2459,223,1,0,0,0,2460,2462,3,226,113,0, + 2461,2460,1,0,0,0,2462,2465,1,0,0,0,2463,2461,1,0,0,0,2463,2464,1,0,0, + 0,2464,225,1,0,0,0,2465,2463,1,0,0,0,2466,2467,5,134,0,0,2467,2468,3,170, + 85,0,2468,2469,6,113,-1,0,2469,2489,1,0,0,0,2470,2471,5,135,0,0,2471,2472, + 3,170,85,0,2472,2473,6,113,-1,0,2473,2489,1,0,0,0,2474,2475,5,132,0,0, + 2475,2476,3,170,85,0,2476,2477,6,113,-1,0,2477,2489,1,0,0,0,2478,2479, + 3,332,166,0,2479,2480,6,113,-1,0,2480,2489,1,0,0,0,2481,2482,3,90,45,0, + 2482,2483,6,113,-1,0,2483,2489,1,0,0,0,2484,2485,3,26,13,0,2485,2486,6, + 113,-1,0,2486,2489,1,0,0,0,2487,2489,3,40,20,0,2488,2466,1,0,0,0,2488, + 2470,1,0,0,0,2488,2474,1,0,0,0,2488,2478,1,0,0,0,2488,2481,1,0,0,0,2488, + 2484,1,0,0,0,2488,2487,1,0,0,0,2489,227,1,0,0,0,2490,2498,6,114,-1,0,2491, + 2492,5,122,0,0,2492,2493,5,30,0,0,2493,2494,3,230,115,0,2494,2495,5,31, + 0,0,2495,2496,6,114,-1,0,2496,2498,1,0,0,0,2497,2490,1,0,0,0,2497,2491, + 1,0,0,0,2498,229,1,0,0,0,2499,2500,3,128,64,0,2500,2501,6,115,-1,0,2501, + 2513,1,0,0,0,2502,2506,5,17,0,0,2503,2504,3,304,152,0,2504,2505,6,115, + -1,0,2505,2507,1,0,0,0,2506,2503,1,0,0,0,2507,2508,1,0,0,0,2508,2506,1, + 0,0,0,2508,2509,1,0,0,0,2509,2510,1,0,0,0,2510,2511,5,18,0,0,2511,2513, + 1,0,0,0,2512,2499,1,0,0,0,2512,2502,1,0,0,0,2513,231,1,0,0,0,2514,2515, + 3,234,117,0,2515,2516,6,116,-1,0,2516,2518,1,0,0,0,2517,2514,1,0,0,0,2518, + 2521,1,0,0,0,2519,2517,1,0,0,0,2519,2520,1,0,0,0,2520,233,1,0,0,0,2521, + 2519,1,0,0,0,2522,2523,5,42,0,0,2523,2524,5,136,0,0,2524,2525,5,43,0,0, + 2525,2540,6,117,-1,0,2526,2527,5,42,0,0,2527,2528,5,137,0,0,2528,2529, + 5,43,0,0,2529,2540,6,117,-1,0,2530,2531,5,42,0,0,2531,2532,5,138,0,0,2532, + 2533,5,43,0,0,2533,2540,6,117,-1,0,2534,2535,5,42,0,0,2535,2536,3,32,16, + 0,2536,2537,5,43,0,0,2537,2538,6,117,-1,0,2538,2540,1,0,0,0,2539,2522, + 1,0,0,0,2539,2526,1,0,0,0,2539,2530,1,0,0,0,2539,2534,1,0,0,0,2540,235, + 1,0,0,0,2541,2550,5,139,0,0,2542,2543,3,238,119,0,2543,2544,6,118,-1,0, + 2544,2549,1,0,0,0,2545,2546,3,240,120,0,2546,2547,6,118,-1,0,2547,2549, + 1,0,0,0,2548,2542,1,0,0,0,2548,2545,1,0,0,0,2549,2552,1,0,0,0,2550,2548, + 1,0,0,0,2550,2551,1,0,0,0,2551,2553,1,0,0,0,2552,2550,1,0,0,0,2553,2554, + 3,172,86,0,2554,2555,3,232,116,0,2555,2556,3,140,70,0,2556,2557,3,228, + 114,0,2557,2558,3,244,122,0,2558,2559,3,184,92,0,2559,2565,3,114,57,0, + 2560,2561,3,246,123,0,2561,2562,6,118,-1,0,2562,2564,1,0,0,0,2563,2560, + 1,0,0,0,2564,2567,1,0,0,0,2565,2563,1,0,0,0,2565,2566,1,0,0,0,2566,2568, + 1,0,0,0,2567,2565,1,0,0,0,2568,2569,6,118,-1,0,2569,237,1,0,0,0,2570,2571, + 5,123,0,0,2571,2613,6,119,-1,0,2572,2573,5,51,0,0,2573,2613,6,119,-1,0, + 2574,2575,5,52,0,0,2575,2613,6,119,-1,0,2576,2577,5,63,0,0,2577,2613,6, + 119,-1,0,2578,2579,5,140,0,0,2579,2613,6,119,-1,0,2580,2581,5,68,0,0,2581, + 2613,6,119,-1,0,2582,2583,5,141,0,0,2583,2613,6,119,-1,0,2584,2585,5,142, + 0,0,2585,2613,6,119,-1,0,2586,2587,5,54,0,0,2587,2613,6,119,-1,0,2588, + 2589,5,64,0,0,2589,2613,6,119,-1,0,2590,2591,5,65,0,0,2591,2613,6,119, + -1,0,2592,2593,5,66,0,0,2593,2613,6,119,-1,0,2594,2595,5,125,0,0,2595, + 2613,6,119,-1,0,2596,2597,5,143,0,0,2597,2613,6,119,-1,0,2598,2599,5,144, + 0,0,2599,2613,6,119,-1,0,2600,2601,5,69,0,0,2601,2613,6,119,-1,0,2602, + 2603,5,145,0,0,2603,2613,6,119,-1,0,2604,2605,5,146,0,0,2605,2613,6,119, + -1,0,2606,2607,5,70,0,0,2607,2608,5,30,0,0,2608,2609,3,32,16,0,2609,2610, + 5,31,0,0,2610,2611,6,119,-1,0,2611,2613,1,0,0,0,2612,2570,1,0,0,0,2612, + 2572,1,0,0,0,2612,2574,1,0,0,0,2612,2576,1,0,0,0,2612,2578,1,0,0,0,2612, + 2580,1,0,0,0,2612,2582,1,0,0,0,2612,2584,1,0,0,0,2612,2586,1,0,0,0,2612, + 2588,1,0,0,0,2612,2590,1,0,0,0,2612,2592,1,0,0,0,2612,2594,1,0,0,0,2612, + 2596,1,0,0,0,2612,2598,1,0,0,0,2612,2600,1,0,0,0,2612,2602,1,0,0,0,2612, + 2604,1,0,0,0,2612,2606,1,0,0,0,2613,239,1,0,0,0,2614,2615,5,147,0,0,2615, + 2624,5,30,0,0,2616,2617,3,6,3,0,2617,2622,6,120,-1,0,2618,2619,5,34,0, + 0,2619,2620,3,6,3,0,2620,2621,6,120,-1,0,2621,2623,1,0,0,0,2622,2618,1, + 0,0,0,2622,2623,1,0,0,0,2623,2625,1,0,0,0,2624,2616,1,0,0,0,2624,2625, + 1,0,0,0,2625,2631,1,0,0,0,2626,2627,3,242,121,0,2627,2628,6,120,-1,0,2628, + 2630,1,0,0,0,2629,2626,1,0,0,0,2630,2633,1,0,0,0,2631,2629,1,0,0,0,2631, + 2632,1,0,0,0,2632,2634,1,0,0,0,2633,2631,1,0,0,0,2634,2638,5,31,0,0,2635, + 2636,5,147,0,0,2636,2638,5,85,0,0,2637,2614,1,0,0,0,2637,2635,1,0,0,0, + 2638,241,1,0,0,0,2639,2640,5,148,0,0,2640,2682,6,121,-1,0,2641,2642,5, + 224,0,0,2642,2682,6,121,-1,0,2643,2644,5,57,0,0,2644,2682,6,121,-1,0,2645, + 2646,5,58,0,0,2646,2682,6,121,-1,0,2647,2648,5,149,0,0,2648,2682,6,121, + -1,0,2649,2650,5,150,0,0,2650,2682,6,121,-1,0,2651,2652,5,248,0,0,2652, + 2682,6,121,-1,0,2653,2654,5,249,0,0,2654,2682,6,121,-1,0,2655,2656,5,250, + 0,0,2656,2682,6,121,-1,0,2657,2658,5,251,0,0,2658,2682,6,121,-1,0,2659, + 2660,5,151,0,0,2660,2661,5,75,0,0,2661,2662,5,152,0,0,2662,2682,6,121, + -1,0,2663,2664,5,151,0,0,2664,2665,5,75,0,0,2665,2666,5,153,0,0,2666,2682, + 6,121,-1,0,2667,2668,5,154,0,0,2668,2669,5,75,0,0,2669,2670,5,152,0,0, + 2670,2682,6,121,-1,0,2671,2672,5,154,0,0,2672,2673,5,75,0,0,2673,2674, + 5,153,0,0,2674,2682,6,121,-1,0,2675,2676,5,70,0,0,2676,2677,5,30,0,0,2677, + 2678,3,32,16,0,2678,2679,5,31,0,0,2679,2680,6,121,-1,0,2680,2682,1,0,0, + 0,2681,2639,1,0,0,0,2681,2641,1,0,0,0,2681,2643,1,0,0,0,2681,2645,1,0, + 0,0,2681,2647,1,0,0,0,2681,2649,1,0,0,0,2681,2651,1,0,0,0,2681,2653,1, + 0,0,0,2681,2655,1,0,0,0,2681,2657,1,0,0,0,2681,2659,1,0,0,0,2681,2663, + 1,0,0,0,2681,2667,1,0,0,0,2681,2671,1,0,0,0,2681,2675,1,0,0,0,2682,243, + 1,0,0,0,2683,2684,5,116,0,0,2684,2691,6,122,-1,0,2685,2686,5,155,0,0,2686, + 2691,6,122,-1,0,2687,2688,3,2,1,0,2688,2689,6,122,-1,0,2689,2691,1,0,0, + 0,2690,2683,1,0,0,0,2690,2685,1,0,0,0,2690,2687,1,0,0,0,2691,245,1,0,0, + 0,2692,2693,5,1,0,0,2693,2731,6,123,-1,0,2694,2695,5,2,0,0,2695,2731,6, + 123,-1,0,2696,2697,5,156,0,0,2697,2731,6,123,-1,0,2698,2699,5,3,0,0,2699, + 2731,6,123,-1,0,2700,2701,5,4,0,0,2701,2731,6,123,-1,0,2702,2703,5,247, + 0,0,2703,2731,6,123,-1,0,2704,2705,5,5,0,0,2705,2731,6,123,-1,0,2706,2707, + 5,6,0,0,2707,2731,6,123,-1,0,2708,2709,5,7,0,0,2709,2731,6,123,-1,0,2710, + 2711,5,8,0,0,2711,2731,6,123,-1,0,2712,2713,5,9,0,0,2713,2731,6,123,-1, + 0,2714,2715,5,10,0,0,2715,2731,6,123,-1,0,2716,2717,5,11,0,0,2717,2731, + 6,123,-1,0,2718,2719,5,12,0,0,2719,2731,6,123,-1,0,2720,2721,5,13,0,0, + 2721,2731,6,123,-1,0,2722,2723,5,14,0,0,2723,2731,6,123,-1,0,2724,2725, + 5,70,0,0,2725,2726,5,30,0,0,2726,2727,3,32,16,0,2727,2728,5,31,0,0,2728, + 2729,6,123,-1,0,2729,2731,1,0,0,0,2730,2692,1,0,0,0,2730,2694,1,0,0,0, + 2730,2696,1,0,0,0,2730,2698,1,0,0,0,2730,2700,1,0,0,0,2730,2702,1,0,0, + 0,2730,2704,1,0,0,0,2730,2706,1,0,0,0,2730,2708,1,0,0,0,2730,2710,1,0, + 0,0,2730,2712,1,0,0,0,2730,2714,1,0,0,0,2730,2716,1,0,0,0,2730,2718,1, + 0,0,0,2730,2720,1,0,0,0,2730,2722,1,0,0,0,2730,2724,1,0,0,0,2731,247,1, + 0,0,0,2732,2734,3,250,125,0,2733,2732,1,0,0,0,2734,2737,1,0,0,0,2735,2733, + 1,0,0,0,2735,2736,1,0,0,0,2736,249,1,0,0,0,2737,2735,1,0,0,0,2738,2776, + 3,102,51,0,2739,2740,5,296,0,0,2740,2741,3,32,16,0,2741,2742,6,125,-1, + 0,2742,2776,1,0,0,0,2743,2776,3,268,134,0,2744,2745,5,297,0,0,2745,2746, + 3,32,16,0,2746,2747,6,125,-1,0,2747,2776,1,0,0,0,2748,2749,5,298,0,0,2749, + 2776,6,125,-1,0,2750,2751,5,299,0,0,2751,2776,6,125,-1,0,2752,2776,3,262, + 131,0,2753,2776,3,266,133,0,2754,2776,3,252,126,0,2755,2756,3,286,143, + 0,2756,2757,6,125,-1,0,2757,2776,1,0,0,0,2758,2759,3,154,77,0,2759,2760, + 6,125,-1,0,2760,2776,1,0,0,0,2761,2762,3,90,45,0,2762,2763,6,125,-1,0, + 2763,2776,1,0,0,0,2764,2765,3,26,13,0,2765,2766,6,125,-1,0,2766,2776,1, + 0,0,0,2767,2768,3,264,132,0,2768,2769,6,125,-1,0,2769,2776,1,0,0,0,2770, + 2776,3,40,20,0,2771,2776,3,254,127,0,2772,2776,3,256,128,0,2773,2776,3, + 258,129,0,2774,2776,3,260,130,0,2775,2738,1,0,0,0,2775,2739,1,0,0,0,2775, + 2743,1,0,0,0,2775,2744,1,0,0,0,2775,2748,1,0,0,0,2775,2750,1,0,0,0,2775, + 2752,1,0,0,0,2775,2753,1,0,0,0,2775,2754,1,0,0,0,2775,2755,1,0,0,0,2775, + 2758,1,0,0,0,2775,2761,1,0,0,0,2775,2764,1,0,0,0,2775,2767,1,0,0,0,2775, + 2770,1,0,0,0,2775,2771,1,0,0,0,2775,2772,1,0,0,0,2775,2773,1,0,0,0,2775, + 2774,1,0,0,0,2776,251,1,0,0,0,2777,2779,5,300,0,0,2778,2780,5,157,0,0, + 2779,2778,1,0,0,0,2779,2780,1,0,0,0,2780,2781,1,0,0,0,2781,2782,3,114, + 57,0,2782,253,1,0,0,0,2783,2784,5,301,0,0,2784,2785,5,42,0,0,2785,2786, + 3,32,16,0,2786,2789,5,43,0,0,2787,2788,5,34,0,0,2788,2790,3,0,0,0,2789, + 2787,1,0,0,0,2789,2790,1,0,0,0,2790,255,1,0,0,0,2791,2792,5,303,0,0,2792, + 2793,3,32,16,0,2793,2794,5,75,0,0,2794,2795,3,32,16,0,2795,257,1,0,0,0, + 2796,2797,5,302,0,0,2797,2798,3,126,63,0,2798,2799,5,176,0,0,2799,2800, + 3,244,122,0,2800,2812,1,0,0,0,2801,2802,5,302,0,0,2802,2803,5,226,0,0, + 2803,2804,3,172,86,0,2804,2805,3,140,70,0,2805,2806,3,126,63,0,2806,2807, + 5,176,0,0,2807,2808,3,244,122,0,2808,2809,3,196,98,0,2809,2810,3,114,57, + 0,2810,2812,1,0,0,0,2811,2796,1,0,0,0,2811,2801,1,0,0,0,2812,259,1,0,0, + 0,2813,2814,5,255,0,0,2814,2815,5,196,0,0,2815,2816,5,42,0,0,2816,2817, + 3,32,16,0,2817,2823,5,43,0,0,2818,2819,3,332,166,0,2819,2820,6,130,-1, + 0,2820,2822,1,0,0,0,2821,2818,1,0,0,0,2822,2825,1,0,0,0,2823,2821,1,0, + 0,0,2823,2824,1,0,0,0,2824,2879,1,0,0,0,2825,2823,1,0,0,0,2826,2827,5, + 255,0,0,2827,2828,5,196,0,0,2828,2834,3,2,1,0,2829,2830,3,332,166,0,2830, + 2831,6,130,-1,0,2831,2833,1,0,0,0,2832,2829,1,0,0,0,2833,2836,1,0,0,0, + 2834,2832,1,0,0,0,2834,2835,1,0,0,0,2835,2879,1,0,0,0,2836,2834,1,0,0, + 0,2837,2838,5,255,0,0,2838,2839,5,256,0,0,2839,2840,5,42,0,0,2840,2841, + 3,32,16,0,2841,2842,5,43,0,0,2842,2843,5,28,0,0,2843,2849,3,126,63,0,2844, + 2845,3,332,166,0,2845,2846,6,130,-1,0,2846,2848,1,0,0,0,2847,2844,1,0, + 0,0,2848,2851,1,0,0,0,2849,2847,1,0,0,0,2849,2850,1,0,0,0,2850,2879,1, + 0,0,0,2851,2849,1,0,0,0,2852,2853,5,255,0,0,2853,2854,5,256,0,0,2854,2855, + 3,2,1,0,2855,2856,5,28,0,0,2856,2862,3,126,63,0,2857,2858,3,332,166,0, + 2858,2859,6,130,-1,0,2859,2861,1,0,0,0,2860,2857,1,0,0,0,2861,2864,1,0, + 0,0,2862,2860,1,0,0,0,2862,2863,1,0,0,0,2863,2879,1,0,0,0,2864,2862,1, + 0,0,0,2865,2866,5,255,0,0,2866,2867,5,42,0,0,2867,2868,3,32,16,0,2868, + 2869,5,43,0,0,2869,2875,3,208,104,0,2870,2871,3,332,166,0,2871,2872,6, + 130,-1,0,2872,2874,1,0,0,0,2873,2870,1,0,0,0,2874,2877,1,0,0,0,2875,2873, + 1,0,0,0,2875,2876,1,0,0,0,2876,2879,1,0,0,0,2877,2875,1,0,0,0,2878,2813, + 1,0,0,0,2878,2826,1,0,0,0,2878,2837,1,0,0,0,2878,2852,1,0,0,0,2878,2865, + 1,0,0,0,2879,261,1,0,0,0,2880,2881,3,0,0,0,2881,2882,5,75,0,0,2882,2883, + 6,131,-1,0,2883,263,1,0,0,0,2884,2885,3,44,22,0,2885,2886,6,132,-1,0,2886, + 2891,1,0,0,0,2887,2888,3,46,23,0,2888,2889,6,132,-1,0,2889,2891,1,0,0, + 0,2890,2884,1,0,0,0,2890,2887,1,0,0,0,2891,265,1,0,0,0,2892,2893,5,17, + 0,0,2893,2894,3,248,124,0,2894,2895,5,18,0,0,2895,267,1,0,0,0,2896,2897, + 3,272,136,0,2897,2898,3,270,135,0,2898,269,1,0,0,0,2899,2900,3,274,137, + 0,2900,2901,6,135,-1,0,2901,2903,1,0,0,0,2902,2899,1,0,0,0,2903,2904,1, + 0,0,0,2904,2902,1,0,0,0,2904,2905,1,0,0,0,2905,271,1,0,0,0,2906,2907,5, + 158,0,0,2907,2908,3,266,133,0,2908,2909,6,136,-1,0,2909,2923,1,0,0,0,2910, + 2911,5,158,0,0,2911,2912,3,0,0,0,2912,2913,5,159,0,0,2913,2914,3,0,0,0, + 2914,2915,6,136,-1,0,2915,2923,1,0,0,0,2916,2917,5,158,0,0,2917,2918,3, + 32,16,0,2918,2919,5,159,0,0,2919,2920,3,32,16,0,2920,2921,6,136,-1,0,2921, + 2923,1,0,0,0,2922,2906,1,0,0,0,2922,2910,1,0,0,0,2922,2916,1,0,0,0,2923, + 273,1,0,0,0,2924,2925,3,278,139,0,2925,2926,3,284,142,0,2926,2927,6,137, + -1,0,2927,2941,1,0,0,0,2928,2929,3,276,138,0,2929,2930,3,284,142,0,2930, + 2931,6,137,-1,0,2931,2941,1,0,0,0,2932,2933,3,280,140,0,2933,2934,3,284, + 142,0,2934,2935,6,137,-1,0,2935,2941,1,0,0,0,2936,2937,3,282,141,0,2937, + 2938,3,284,142,0,2938,2939,6,137,-1,0,2939,2941,1,0,0,0,2940,2924,1,0, + 0,0,2940,2928,1,0,0,0,2940,2932,1,0,0,0,2940,2936,1,0,0,0,2941,275,1,0, + 0,0,2942,2943,5,160,0,0,2943,2944,3,266,133,0,2944,2945,6,138,-1,0,2945, + 2955,1,0,0,0,2946,2947,5,160,0,0,2947,2948,3,0,0,0,2948,2949,6,138,-1, + 0,2949,2955,1,0,0,0,2950,2951,5,160,0,0,2951,2952,3,32,16,0,2952,2953, + 6,138,-1,0,2953,2955,1,0,0,0,2954,2942,1,0,0,0,2954,2946,1,0,0,0,2954, + 2950,1,0,0,0,2955,277,1,0,0,0,2956,2957,5,161,0,0,2957,2958,3,126,63,0, + 2958,279,1,0,0,0,2959,2960,5,162,0,0,2960,281,1,0,0,0,2961,2962,5,163, + 0,0,2962,283,1,0,0,0,2963,2964,3,266,133,0,2964,2965,6,142,-1,0,2965,2979, + 1,0,0,0,2966,2967,5,164,0,0,2967,2968,3,0,0,0,2968,2969,5,159,0,0,2969, + 2970,3,0,0,0,2970,2971,6,142,-1,0,2971,2979,1,0,0,0,2972,2973,5,164,0, + 0,2973,2974,3,32,16,0,2974,2975,5,159,0,0,2975,2976,3,32,16,0,2976,2977, + 6,142,-1,0,2977,2979,1,0,0,0,2978,2963,1,0,0,0,2978,2966,1,0,0,0,2978, + 2972,1,0,0,0,2979,285,1,0,0,0,2980,2981,3,288,144,0,2981,2982,3,292,146, + 0,2982,287,1,0,0,0,2983,2984,5,165,0,0,2984,2985,3,290,145,0,2985,2986, + 3,0,0,0,2986,2987,5,36,0,0,2987,2988,6,144,-1,0,2988,2994,1,0,0,0,2989, + 2990,5,165,0,0,2990,2991,3,290,145,0,2991,2992,6,144,-1,0,2992,2994,1, + 0,0,0,2993,2983,1,0,0,0,2993,2989,1,0,0,0,2994,289,1,0,0,0,2995,3001,1, + 0,0,0,2996,2997,5,166,0,0,2997,3001,6,145,-1,0,2998,2999,5,2,0,0,2999, + 3001,6,145,-1,0,3000,2995,1,0,0,0,3000,2996,1,0,0,0,3000,2998,1,0,0,0, + 3001,291,1,0,0,0,3002,3003,5,17,0,0,3003,3004,3,294,147,0,3004,3005,5, + 18,0,0,3005,3012,1,0,0,0,3006,3008,3,298,149,0,3007,3006,1,0,0,0,3008, + 3009,1,0,0,0,3009,3007,1,0,0,0,3009,3010,1,0,0,0,3010,3012,1,0,0,0,3011, + 3002,1,0,0,0,3011,3007,1,0,0,0,3012,293,1,0,0,0,3013,3014,3,298,149,0, + 3014,3015,5,28,0,0,3015,3017,1,0,0,0,3016,3013,1,0,0,0,3017,3020,1,0,0, + 0,3018,3016,1,0,0,0,3018,3019,1,0,0,0,3019,3021,1,0,0,0,3020,3018,1,0, + 0,0,3021,3022,3,298,149,0,3022,295,1,0,0,0,3023,3030,1,0,0,0,3024,3025, + 5,42,0,0,3025,3026,3,32,16,0,3026,3027,5,43,0,0,3027,3028,6,148,-1,0,3028, + 3030,1,0,0,0,3029,3023,1,0,0,0,3029,3024,1,0,0,0,3030,297,1,0,0,0,3031, + 3032,5,181,0,0,3032,3033,5,262,0,0,3033,3034,5,30,0,0,3034,3035,3,6,3, + 0,3035,3036,5,31,0,0,3036,3037,6,149,-1,0,3037,3080,1,0,0,0,3038,3039, + 5,260,0,0,3039,3040,5,30,0,0,3040,3041,3,0,0,0,3041,3042,5,31,0,0,3042, + 3043,6,149,-1,0,3043,3080,1,0,0,0,3044,3045,5,260,0,0,3045,3046,3,0,0, + 0,3046,3047,6,149,-1,0,3047,3080,1,0,0,0,3048,3049,5,84,0,0,3049,3050, + 5,30,0,0,3050,3051,3,302,151,0,3051,3052,5,31,0,0,3052,3053,6,149,-1,0, + 3053,3080,1,0,0,0,3054,3055,7,11,0,0,3055,3056,5,30,0,0,3056,3057,3,36, + 18,0,3057,3058,5,31,0,0,3058,3059,3,296,148,0,3059,3060,6,149,-1,0,3060, + 3080,1,0,0,0,3061,3062,5,187,0,0,3062,3063,5,30,0,0,3063,3064,3,34,17, + 0,3064,3065,5,31,0,0,3065,3066,3,296,148,0,3066,3067,6,149,-1,0,3067,3080, + 1,0,0,0,3068,3069,7,12,0,0,3069,3070,5,30,0,0,3070,3071,3,32,16,0,3071, + 3072,5,31,0,0,3072,3073,3,296,148,0,3073,3074,6,149,-1,0,3074,3080,1,0, + 0,0,3075,3076,7,13,0,0,3076,3077,3,296,148,0,3077,3078,6,149,-1,0,3078, + 3080,1,0,0,0,3079,3031,1,0,0,0,3079,3038,1,0,0,0,3079,3044,1,0,0,0,3079, + 3048,1,0,0,0,3079,3054,1,0,0,0,3079,3061,1,0,0,0,3079,3068,1,0,0,0,3079, + 3075,1,0,0,0,3080,299,1,0,0,0,3081,3082,5,188,0,0,3082,3083,5,30,0,0,3083, + 3084,3,36,18,0,3084,3085,5,31,0,0,3085,3086,6,150,-1,0,3086,3172,1,0,0, + 0,3087,3088,5,189,0,0,3088,3089,5,30,0,0,3089,3090,3,36,18,0,3090,3091, + 5,31,0,0,3091,3092,6,150,-1,0,3092,3172,1,0,0,0,3093,3094,5,188,0,0,3094, + 3095,5,30,0,0,3095,3096,3,32,16,0,3096,3097,5,31,0,0,3097,3098,6,150,-1, + 0,3098,3172,1,0,0,0,3099,3100,5,189,0,0,3100,3101,5,30,0,0,3101,3102,3, + 34,17,0,3102,3103,5,31,0,0,3103,3104,6,150,-1,0,3104,3172,1,0,0,0,3105, + 3106,5,187,0,0,3106,3107,5,30,0,0,3107,3108,3,34,17,0,3108,3109,5,31,0, + 0,3109,3110,6,150,-1,0,3110,3172,1,0,0,0,3111,3112,5,186,0,0,3112,3113, + 5,30,0,0,3113,3114,3,32,16,0,3114,3115,5,31,0,0,3115,3116,6,150,-1,0,3116, + 3172,1,0,0,0,3117,3118,5,185,0,0,3118,3119,5,30,0,0,3119,3120,3,32,16, + 0,3120,3121,5,31,0,0,3121,3122,6,150,-1,0,3122,3172,1,0,0,0,3123,3124, + 5,184,0,0,3124,3125,5,30,0,0,3125,3126,3,32,16,0,3126,3127,5,31,0,0,3127, + 3128,6,150,-1,0,3128,3172,1,0,0,0,3129,3130,5,193,0,0,3130,3131,5,30,0, + 0,3131,3132,3,34,17,0,3132,3133,5,31,0,0,3133,3134,6,150,-1,0,3134,3172, + 1,0,0,0,3135,3136,5,192,0,0,3136,3137,5,30,0,0,3137,3138,3,32,16,0,3138, + 3139,5,31,0,0,3139,3140,6,150,-1,0,3140,3172,1,0,0,0,3141,3142,5,191,0, + 0,3142,3143,5,30,0,0,3143,3144,3,32,16,0,3144,3145,5,31,0,0,3145,3146, + 6,150,-1,0,3146,3172,1,0,0,0,3147,3148,5,190,0,0,3148,3149,5,30,0,0,3149, + 3150,3,32,16,0,3150,3151,5,31,0,0,3151,3152,6,150,-1,0,3152,3172,1,0,0, + 0,3153,3154,5,181,0,0,3154,3155,5,30,0,0,3155,3156,3,32,16,0,3156,3157, + 5,31,0,0,3157,3158,6,150,-1,0,3158,3172,1,0,0,0,3159,3160,5,183,0,0,3160, + 3161,5,30,0,0,3161,3162,3,164,82,0,3162,3163,5,31,0,0,3163,3164,6,150, + -1,0,3164,3172,1,0,0,0,3165,3166,5,84,0,0,3166,3167,5,30,0,0,3167,3168, + 3,302,151,0,3168,3169,5,31,0,0,3169,3170,6,150,-1,0,3170,3172,1,0,0,0, + 3171,3081,1,0,0,0,3171,3087,1,0,0,0,3171,3093,1,0,0,0,3171,3099,1,0,0, + 0,3171,3105,1,0,0,0,3171,3111,1,0,0,0,3171,3117,1,0,0,0,3171,3123,1,0, + 0,0,3171,3129,1,0,0,0,3171,3135,1,0,0,0,3171,3141,1,0,0,0,3171,3147,1, + 0,0,0,3171,3153,1,0,0,0,3171,3159,1,0,0,0,3171,3165,1,0,0,0,3172,301,1, + 0,0,0,3173,3174,3,304,152,0,3174,3175,6,151,-1,0,3175,3177,1,0,0,0,3176, + 3173,1,0,0,0,3177,3180,1,0,0,0,3178,3176,1,0,0,0,3178,3179,1,0,0,0,3179, + 303,1,0,0,0,3180,3178,1,0,0,0,3181,3182,7,14,0,0,3182,305,1,0,0,0,3183, + 3184,3,300,150,0,3184,3185,6,153,-1,0,3185,3192,1,0,0,0,3186,3187,3,6, + 3,0,3187,3188,6,153,-1,0,3188,3192,1,0,0,0,3189,3190,5,179,0,0,3190,3192, + 6,153,-1,0,3191,3183,1,0,0,0,3191,3186,1,0,0,0,3191,3189,1,0,0,0,3192, + 307,1,0,0,0,3193,3194,3,300,150,0,3194,3195,6,154,-1,0,3195,3365,1,0,0, + 0,3196,3197,5,182,0,0,3197,3198,5,30,0,0,3198,3199,5,179,0,0,3199,3200, + 5,31,0,0,3200,3365,6,154,-1,0,3201,3202,5,182,0,0,3202,3203,5,30,0,0,3203, + 3204,5,264,0,0,3204,3205,5,31,0,0,3205,3365,6,154,-1,0,3206,3207,5,196, + 0,0,3207,3208,5,30,0,0,3208,3209,5,39,0,0,3209,3210,5,264,0,0,3210,3211, + 5,31,0,0,3211,3365,6,154,-1,0,3212,3213,5,196,0,0,3213,3214,5,30,0,0,3214, + 3215,3,118,59,0,3215,3216,5,31,0,0,3216,3217,6,154,-1,0,3217,3365,1,0, + 0,0,3218,3219,5,196,0,0,3219,3220,5,30,0,0,3220,3221,5,179,0,0,3221,3222, + 5,31,0,0,3222,3365,6,154,-1,0,3223,3224,5,197,0,0,3224,3225,5,30,0,0,3225, + 3226,3,308,154,0,3226,3227,5,31,0,0,3227,3228,6,154,-1,0,3228,3365,1,0, + 0,0,3229,3230,5,188,0,0,3230,3231,5,42,0,0,3231,3232,3,32,16,0,3232,3233, + 5,43,0,0,3233,3234,5,30,0,0,3234,3235,3,310,155,0,3235,3236,5,31,0,0,3236, + 3237,6,154,-1,0,3237,3365,1,0,0,0,3238,3239,5,189,0,0,3239,3240,5,42,0, + 0,3240,3241,3,32,16,0,3241,3242,5,43,0,0,3242,3243,5,30,0,0,3243,3244, + 3,312,156,0,3244,3245,5,31,0,0,3245,3246,6,154,-1,0,3246,3365,1,0,0,0, + 3247,3248,5,187,0,0,3248,3249,5,42,0,0,3249,3250,3,32,16,0,3250,3251,5, + 43,0,0,3251,3252,5,30,0,0,3252,3253,3,314,157,0,3253,3254,5,31,0,0,3254, + 3255,6,154,-1,0,3255,3365,1,0,0,0,3256,3257,5,186,0,0,3257,3258,5,42,0, + 0,3258,3259,3,32,16,0,3259,3260,5,43,0,0,3260,3261,5,30,0,0,3261,3262, + 3,316,158,0,3262,3263,5,31,0,0,3263,3264,6,154,-1,0,3264,3365,1,0,0,0, + 3265,3266,5,185,0,0,3266,3267,5,42,0,0,3267,3268,3,32,16,0,3268,3269,5, + 43,0,0,3269,3270,5,30,0,0,3270,3271,3,318,159,0,3271,3272,5,31,0,0,3272, + 3273,6,154,-1,0,3273,3365,1,0,0,0,3274,3275,5,184,0,0,3275,3276,5,42,0, + 0,3276,3277,3,32,16,0,3277,3278,5,43,0,0,3278,3279,5,30,0,0,3279,3280, + 3,320,160,0,3280,3281,5,31,0,0,3281,3282,6,154,-1,0,3282,3365,1,0,0,0, + 3283,3284,5,193,0,0,3284,3285,5,42,0,0,3285,3286,3,32,16,0,3286,3287,5, + 43,0,0,3287,3288,5,30,0,0,3288,3289,3,314,157,0,3289,3290,5,31,0,0,3290, + 3291,6,154,-1,0,3291,3365,1,0,0,0,3292,3293,5,192,0,0,3293,3294,5,42,0, + 0,3294,3295,3,32,16,0,3295,3296,5,43,0,0,3296,3297,5,30,0,0,3297,3298, + 3,316,158,0,3298,3299,5,31,0,0,3299,3300,6,154,-1,0,3300,3365,1,0,0,0, + 3301,3302,5,191,0,0,3302,3303,5,42,0,0,3303,3304,3,32,16,0,3304,3305,5, + 43,0,0,3305,3306,5,30,0,0,3306,3307,3,318,159,0,3307,3308,5,31,0,0,3308, + 3309,6,154,-1,0,3309,3365,1,0,0,0,3310,3311,5,190,0,0,3311,3312,5,42,0, + 0,3312,3313,3,32,16,0,3313,3314,5,43,0,0,3314,3315,5,30,0,0,3315,3316, + 3,320,160,0,3316,3317,5,31,0,0,3317,3318,6,154,-1,0,3318,3365,1,0,0,0, + 3319,3320,5,181,0,0,3320,3321,5,42,0,0,3321,3322,3,32,16,0,3322,3323,5, + 43,0,0,3323,3324,5,30,0,0,3324,3325,3,318,159,0,3325,3326,5,31,0,0,3326, + 3327,6,154,-1,0,3327,3365,1,0,0,0,3328,3329,5,183,0,0,3329,3330,5,42,0, + 0,3330,3331,3,32,16,0,3331,3332,5,43,0,0,3332,3333,5,30,0,0,3333,3334, + 3,322,161,0,3334,3335,5,31,0,0,3335,3336,6,154,-1,0,3336,3365,1,0,0,0, + 3337,3338,5,182,0,0,3338,3339,5,42,0,0,3339,3340,3,32,16,0,3340,3341,5, + 43,0,0,3341,3342,5,30,0,0,3342,3343,3,324,162,0,3343,3344,5,31,0,0,3344, + 3345,6,154,-1,0,3345,3365,1,0,0,0,3346,3347,5,196,0,0,3347,3348,5,42,0, + 0,3348,3349,3,32,16,0,3349,3350,5,43,0,0,3350,3351,5,30,0,0,3351,3352, + 3,326,163,0,3352,3353,5,31,0,0,3353,3354,6,154,-1,0,3354,3365,1,0,0,0, + 3355,3356,5,197,0,0,3356,3357,5,42,0,0,3357,3358,3,32,16,0,3358,3359,5, + 43,0,0,3359,3360,5,30,0,0,3360,3361,3,330,165,0,3361,3362,5,31,0,0,3362, + 3363,6,154,-1,0,3363,3365,1,0,0,0,3364,3193,1,0,0,0,3364,3196,1,0,0,0, + 3364,3201,1,0,0,0,3364,3206,1,0,0,0,3364,3212,1,0,0,0,3364,3218,1,0,0, + 0,3364,3223,1,0,0,0,3364,3229,1,0,0,0,3364,3238,1,0,0,0,3364,3247,1,0, + 0,0,3364,3256,1,0,0,0,3364,3265,1,0,0,0,3364,3274,1,0,0,0,3364,3283,1, + 0,0,0,3364,3292,1,0,0,0,3364,3301,1,0,0,0,3364,3310,1,0,0,0,3364,3319, + 1,0,0,0,3364,3328,1,0,0,0,3364,3337,1,0,0,0,3364,3346,1,0,0,0,3364,3355, + 1,0,0,0,3365,309,1,0,0,0,3366,3367,3,36,18,0,3367,3368,6,155,-1,0,3368, + 3373,1,0,0,0,3369,3370,3,32,16,0,3370,3371,6,155,-1,0,3371,3373,1,0,0, + 0,3372,3366,1,0,0,0,3372,3369,1,0,0,0,3373,3376,1,0,0,0,3374,3372,1,0, + 0,0,3374,3375,1,0,0,0,3375,311,1,0,0,0,3376,3374,1,0,0,0,3377,3378,3,36, + 18,0,3378,3379,6,156,-1,0,3379,3384,1,0,0,0,3380,3381,3,34,17,0,3381,3382, + 6,156,-1,0,3382,3384,1,0,0,0,3383,3377,1,0,0,0,3383,3380,1,0,0,0,3384, + 3387,1,0,0,0,3385,3383,1,0,0,0,3385,3386,1,0,0,0,3386,313,1,0,0,0,3387, + 3385,1,0,0,0,3388,3389,3,34,17,0,3389,3390,6,157,-1,0,3390,3392,1,0,0, + 0,3391,3388,1,0,0,0,3392,3395,1,0,0,0,3393,3391,1,0,0,0,3393,3394,1,0, + 0,0,3394,315,1,0,0,0,3395,3393,1,0,0,0,3396,3397,3,32,16,0,3397,3398,6, + 158,-1,0,3398,3400,1,0,0,0,3399,3396,1,0,0,0,3400,3403,1,0,0,0,3401,3399, + 1,0,0,0,3401,3402,1,0,0,0,3402,317,1,0,0,0,3403,3401,1,0,0,0,3404,3405, + 3,32,16,0,3405,3406,6,159,-1,0,3406,3408,1,0,0,0,3407,3404,1,0,0,0,3408, + 3411,1,0,0,0,3409,3407,1,0,0,0,3409,3410,1,0,0,0,3410,319,1,0,0,0,3411, + 3409,1,0,0,0,3412,3413,3,32,16,0,3413,3414,6,160,-1,0,3414,3416,1,0,0, + 0,3415,3412,1,0,0,0,3416,3419,1,0,0,0,3417,3415,1,0,0,0,3417,3418,1,0, + 0,0,3418,321,1,0,0,0,3419,3417,1,0,0,0,3420,3421,3,164,82,0,3421,3422, + 6,161,-1,0,3422,3424,1,0,0,0,3423,3420,1,0,0,0,3424,3427,1,0,0,0,3425, + 3423,1,0,0,0,3425,3426,1,0,0,0,3426,323,1,0,0,0,3427,3425,1,0,0,0,3428, + 3429,5,179,0,0,3429,3433,6,162,-1,0,3430,3431,5,264,0,0,3431,3433,6,162, + -1,0,3432,3428,1,0,0,0,3432,3430,1,0,0,0,3433,3436,1,0,0,0,3434,3432,1, + 0,0,0,3434,3435,1,0,0,0,3435,325,1,0,0,0,3436,3434,1,0,0,0,3437,3438,3, + 328,164,0,3438,3439,6,163,-1,0,3439,3441,1,0,0,0,3440,3437,1,0,0,0,3441, + 3444,1,0,0,0,3442,3440,1,0,0,0,3442,3443,1,0,0,0,3443,327,1,0,0,0,3444, + 3442,1,0,0,0,3445,3446,5,179,0,0,3446,3454,6,164,-1,0,3447,3448,5,39,0, + 0,3448,3449,5,264,0,0,3449,3454,6,164,-1,0,3450,3451,3,118,59,0,3451,3452, + 6,164,-1,0,3452,3454,1,0,0,0,3453,3445,1,0,0,0,3453,3447,1,0,0,0,3453, + 3450,1,0,0,0,3454,329,1,0,0,0,3455,3456,3,308,154,0,3456,3457,6,165,-1, + 0,3457,3459,1,0,0,0,3458,3455,1,0,0,0,3459,3462,1,0,0,0,3460,3458,1,0, + 0,0,3460,3461,1,0,0,0,3461,331,1,0,0,0,3462,3460,1,0,0,0,3463,3464,3,44, + 22,0,3464,3465,6,166,-1,0,3465,3473,1,0,0,0,3466,3467,3,46,23,0,3467,3468, + 6,166,-1,0,3468,3473,1,0,0,0,3469,3470,3,2,1,0,3470,3471,6,166,-1,0,3471, + 3473,1,0,0,0,3472,3463,1,0,0,0,3472,3466,1,0,0,0,3472,3469,1,0,0,0,3473, + 333,1,0,0,0,3474,3475,7,15,0,0,3475,3476,5,36,0,0,3476,3477,5,30,0,0,3477, + 3478,3,302,151,0,3478,3479,5,31,0,0,3479,3480,6,167,-1,0,3480,3507,1,0, + 0,0,3481,3482,5,169,0,0,3482,3483,3,38,19,0,3483,3484,5,75,0,0,3484,3485, + 3,38,19,0,3485,3486,5,75,0,0,3486,3487,3,38,19,0,3487,3488,5,75,0,0,3488, + 3489,3,38,19,0,3489,3490,6,167,-1,0,3490,3507,1,0,0,0,3491,3492,5,170, + 0,0,3492,3493,3,6,3,0,3493,3494,6,167,-1,0,3494,3507,1,0,0,0,3495,3496, + 5,170,0,0,3496,3497,5,36,0,0,3497,3498,5,30,0,0,3498,3499,3,302,151,0, + 3499,3500,5,31,0,0,3500,3501,6,167,-1,0,3501,3507,1,0,0,0,3502,3503,3, + 332,166,0,3503,3504,6,167,-1,0,3504,3507,1,0,0,0,3505,3507,3,40,20,0,3506, + 3474,1,0,0,0,3506,3481,1,0,0,0,3506,3491,1,0,0,0,3506,3495,1,0,0,0,3506, + 3502,1,0,0,0,3506,3505,1,0,0,0,3507,335,1,0,0,0,3508,3509,3,338,169,0, + 3509,3510,5,17,0,0,3510,3511,3,340,170,0,3511,3512,5,18,0,0,3512,3513, + 6,168,-1,0,3513,337,1,0,0,0,3514,3515,5,25,0,0,3515,3516,5,40,0,0,3516, + 3517,3,100,50,0,3517,3518,3,2,1,0,3518,3519,6,169,-1,0,3519,3529,1,0,0, + 0,3520,3521,5,25,0,0,3521,3522,5,40,0,0,3522,3523,3,100,50,0,3523,3524, + 3,2,1,0,3524,3525,5,34,0,0,3525,3526,3,2,1,0,3526,3527,6,169,-1,0,3527, + 3529,1,0,0,0,3528,3514,1,0,0,0,3528,3520,1,0,0,0,3529,339,1,0,0,0,3530, + 3531,3,342,171,0,3531,3532,6,170,-1,0,3532,3534,1,0,0,0,3533,3530,1,0, + 0,0,3534,3537,1,0,0,0,3535,3533,1,0,0,0,3535,3536,1,0,0,0,3536,341,1,0, + 0,0,3537,3535,1,0,0,0,3538,3539,5,180,0,0,3539,3540,5,36,0,0,3540,3541, + 5,30,0,0,3541,3542,3,302,151,0,3542,3543,5,31,0,0,3543,3544,6,171,-1,0, + 3544,3558,1,0,0,0,3545,3546,3,334,167,0,3546,3547,6,171,-1,0,3547,3558, + 1,0,0,0,3548,3549,5,171,0,0,3549,3550,5,36,0,0,3550,3551,5,30,0,0,3551, + 3552,3,302,151,0,3552,3553,5,31,0,0,3553,3554,6,171,-1,0,3554,3558,1,0, + 0,0,3555,3556,5,55,0,0,3556,3558,6,171,-1,0,3557,3538,1,0,0,0,3557,3545, + 1,0,0,0,3557,3548,1,0,0,0,3557,3555,1,0,0,0,3558,343,1,0,0,0,3559,3560, + 3,346,173,0,3560,3561,5,17,0,0,3561,3562,3,354,177,0,3562,3563,5,18,0, + 0,3563,3564,6,172,-1,0,3564,345,1,0,0,0,3565,3566,5,50,0,0,3566,3567,5, + 40,0,0,3567,3568,3,350,175,0,3568,3569,3,2,1,0,3569,3570,6,173,-1,0,3570, + 347,1,0,0,0,3571,3572,5,301,0,0,3572,3573,3,350,175,0,3573,3574,3,2,1, + 0,3574,3575,6,174,-1,0,3575,349,1,0,0,0,3576,3577,3,352,176,0,3577,3578, + 6,175,-1,0,3578,3580,1,0,0,0,3579,3576,1,0,0,0,3580,3583,1,0,0,0,3581, + 3579,1,0,0,0,3581,3582,1,0,0,0,3582,351,1,0,0,0,3583,3581,1,0,0,0,3584, + 3600,5,52,0,0,3585,3600,5,51,0,0,3586,3600,5,172,0,0,3587,3588,5,62,0, + 0,3588,3600,5,51,0,0,3589,3590,5,62,0,0,3590,3600,5,52,0,0,3591,3592,5, + 62,0,0,3592,3600,5,63,0,0,3593,3594,5,62,0,0,3594,3600,5,64,0,0,3595,3596, + 5,62,0,0,3596,3600,5,65,0,0,3597,3598,5,62,0,0,3598,3600,5,66,0,0,3599, + 3584,1,0,0,0,3599,3585,1,0,0,0,3599,3586,1,0,0,0,3599,3587,1,0,0,0,3599, + 3589,1,0,0,0,3599,3591,1,0,0,0,3599,3593,1,0,0,0,3599,3595,1,0,0,0,3599, + 3597,1,0,0,0,3600,353,1,0,0,0,3601,3602,3,356,178,0,3602,3603,6,177,-1, + 0,3603,3605,1,0,0,0,3604,3601,1,0,0,0,3605,3608,1,0,0,0,3606,3604,1,0, + 0,0,3606,3607,1,0,0,0,3607,355,1,0,0,0,3608,3606,1,0,0,0,3609,3610,5,21, + 0,0,3610,3611,3,2,1,0,3611,3612,6,178,-1,0,3612,3635,1,0,0,0,3613,3614, + 5,50,0,0,3614,3615,5,40,0,0,3615,3616,3,120,60,0,3616,3617,6,178,-1,0, + 3617,3635,1,0,0,0,3618,3619,5,25,0,0,3619,3620,5,40,0,0,3620,3621,3,2, + 1,0,3621,3622,6,178,-1,0,3622,3635,1,0,0,0,3623,3624,3,176,88,0,3624,3625, + 6,178,-1,0,3625,3635,1,0,0,0,3626,3627,5,50,0,0,3627,3628,3,32,16,0,3628, + 3629,6,178,-1,0,3629,3635,1,0,0,0,3630,3631,3,332,166,0,3631,3632,6,178, + -1,0,3632,3635,1,0,0,0,3633,3635,3,40,20,0,3634,3609,1,0,0,0,3634,3613, + 1,0,0,0,3634,3618,1,0,0,0,3634,3623,1,0,0,0,3634,3626,1,0,0,0,3634,3630, + 1,0,0,0,3634,3633,1,0,0,0,3635,357,1,0,0,0,3636,3637,3,360,180,0,3637, + 3638,5,17,0,0,3638,3639,3,366,183,0,3639,3640,5,18,0,0,3640,3641,6,179, + -1,0,3641,359,1,0,0,0,3642,3643,5,274,0,0,3643,3644,3,362,181,0,3644,3645, + 3,2,1,0,3645,3646,6,180,-1,0,3646,3655,1,0,0,0,3647,3648,5,274,0,0,3648, + 3649,3,362,181,0,3649,3650,3,2,1,0,3650,3651,5,34,0,0,3651,3652,3,2,1, + 0,3652,3653,6,180,-1,0,3653,3655,1,0,0,0,3654,3642,1,0,0,0,3654,3647,1, + 0,0,0,3655,361,1,0,0,0,3656,3657,3,364,182,0,3657,3658,6,181,-1,0,3658, + 3660,1,0,0,0,3659,3656,1,0,0,0,3660,3663,1,0,0,0,3661,3659,1,0,0,0,3661, + 3662,1,0,0,0,3662,363,1,0,0,0,3663,3661,1,0,0,0,3664,3665,7,16,0,0,3665, + 365,1,0,0,0,3666,3667,3,368,184,0,3667,3668,6,183,-1,0,3668,3670,1,0,0, + 0,3669,3666,1,0,0,0,3670,3673,1,0,0,0,3671,3669,1,0,0,0,3671,3672,1,0, + 0,0,3672,367,1,0,0,0,3673,3671,1,0,0,0,3674,3675,5,21,0,0,3675,3676,3, + 2,1,0,3676,3677,5,44,0,0,3677,3678,3,32,16,0,3678,3679,6,184,-1,0,3679, + 3690,1,0,0,0,3680,3681,5,25,0,0,3681,3682,5,40,0,0,3682,3683,3,2,1,0,3683, + 3684,6,184,-1,0,3684,3690,1,0,0,0,3685,3686,3,332,166,0,3686,3687,6,184, + -1,0,3687,3690,1,0,0,0,3688,3690,3,40,20,0,3689,3674,1,0,0,0,3689,3680, + 1,0,0,0,3689,3685,1,0,0,0,3689,3688,1,0,0,0,3690,369,1,0,0,0,183,380,388, + 397,406,495,546,557,587,594,612,644,672,712,723,733,735,746,748,756,778, + 791,807,831,904,911,918,923,932,943,952,963,974,987,991,999,1015,1022, + 1031,1059,1137,1139,1153,1159,1168,1170,1179,1193,1207,1215,1223,1227, + 1266,1274,1285,1299,1318,1328,1331,1355,1502,1512,1521,1524,1606,1615, + 1647,1707,1747,1763,1773,1803,1831,1840,1846,1863,1871,1929,1939,1957, + 1975,1994,2015,2034,2049,2057,2069,2089,2096,2101,2112,2124,2234,2246, + 2262,2276,2285,2298,2300,2343,2354,2361,2369,2377,2390,2396,2402,2407, + 2436,2444,2458,2463,2488,2497,2508,2512,2519,2539,2548,2550,2565,2612, + 2622,2624,2631,2637,2681,2690,2730,2735,2775,2779,2789,2811,2823,2834, + 2849,2862,2875,2878,2890,2904,2922,2940,2954,2978,2993,3000,3009,3011, + 3018,3029,3079,3171,3178,3191,3364,3372,3374,3383,3385,3393,3401,3409, + 3417,3425,3432,3434,3442,3453,3460,3472,3506,3528,3535,3557,3581,3599, + 3606,3634,3654,3661,3671,3689 }; public static readonly ATN _ATN = diff --git a/src/tools/ilasm/src/ILAssembler/gen/CILVisitor.cs b/src/tools/ilasm/src/ILAssembler/gen/CILVisitor.cs deleted file mode 100644 index d74d21a93c4052..00000000000000 --- a/src/tools/ilasm/src/ILAssembler/gen/CILVisitor.cs +++ /dev/null @@ -1,1225 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.13.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from CIL.g4 by ANTLR 4.13.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -namespace ILAssembler { -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using IToken = Antlr4.Runtime.IToken; - -/// -/// This interface defines a complete generic visitor for a parse tree produced -/// by . -/// -/// The return type of the visit operation. -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.13.1")] -[System.CLSCompliant(false)] -public interface ICILVisitor : IParseTreeVisitor { - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitId([NotNull] CILParser.IdContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDottedName([NotNull] CILParser.DottedNameContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDottedNamePart([NotNull] CILParser.DottedNamePartContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCompQstring([NotNull] CILParser.CompQstringContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDecls([NotNull] CILParser.DeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDecl([NotNull] CILParser.DeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSubsystem([NotNull] CILParser.SubsystemContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCorflags([NotNull] CILParser.CorflagsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAlignment([NotNull] CILParser.AlignmentContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitImagebase([NotNull] CILParser.ImagebaseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitStackreserve([NotNull] CILParser.StackreserveContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssemblyBlock([NotNull] CILParser.AssemblyBlockContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMscorlib([NotNull] CILParser.MscorlibContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitLanguageDecl([NotNull] CILParser.LanguageDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitLanguageString([NotNull] CILParser.LanguageStringContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTypelist([NotNull] CILParser.TypelistContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInt32([NotNull] CILParser.Int32Context context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInt64([NotNull] CILParser.Int64Context context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFloat64([NotNull] CILParser.Float64Context context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitIntOrWildcard([NotNull] CILParser.IntOrWildcardContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCompControl([NotNull] CILParser.CompControlContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTypedefDecl([NotNull] CILParser.TypedefDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomDescr([NotNull] CILParser.CustomDescrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomDescrWithOwner([NotNull] CILParser.CustomDescrWithOwnerContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomType([NotNull] CILParser.CustomTypeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitOwnerType([NotNull] CILParser.OwnerTypeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomBlobDescr([NotNull] CILParser.CustomBlobDescrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomBlobArgs([NotNull] CILParser.CustomBlobArgsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomBlobNVPairs([NotNull] CILParser.CustomBlobNVPairsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFieldOrProp([NotNull] CILParser.FieldOrPropContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSerializType([NotNull] CILParser.SerializTypeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSerializTypeElement([NotNull] CILParser.SerializTypeElementContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitModuleHead([NotNull] CILParser.ModuleHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVtfixupDecl([NotNull] CILParser.VtfixupDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVtfixupAttr([NotNull] CILParser.VtfixupAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVtableDecl([NotNull] CILParser.VtableDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNameSpaceHead([NotNull] CILParser.NameSpaceHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitClassHead([NotNull] CILParser.ClassHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitClassAttr([NotNull] CILParser.ClassAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExtendsClause([NotNull] CILParser.ExtendsClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitImplClause([NotNull] CILParser.ImplClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitClassDecls([NotNull] CILParser.ClassDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitImplList([NotNull] CILParser.ImplListContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitEsHead([NotNull] CILParser.EsHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExtSourceSpec([NotNull] CILParser.ExtSourceSpecContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFileDecl([NotNull] CILParser.FileDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFileAttr([NotNull] CILParser.FileAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFileEntry([NotNull] CILParser.FileEntryContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAsmAttrAny([NotNull] CILParser.AsmAttrAnyContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAsmAttr([NotNull] CILParser.AsmAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_none([NotNull] CILParser.Instr_noneContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_var([NotNull] CILParser.Instr_varContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_i([NotNull] CILParser.Instr_iContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_i8([NotNull] CILParser.Instr_i8Context context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_r([NotNull] CILParser.Instr_rContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_brtarget([NotNull] CILParser.Instr_brtargetContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_method([NotNull] CILParser.Instr_methodContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_field([NotNull] CILParser.Instr_fieldContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_type([NotNull] CILParser.Instr_typeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_string([NotNull] CILParser.Instr_stringContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_sig([NotNull] CILParser.Instr_sigContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_tok([NotNull] CILParser.Instr_tokContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr_switch([NotNull] CILParser.Instr_switchContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInstr([NotNull] CILParser.InstrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitLabels([NotNull] CILParser.LabelsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTypeArgs([NotNull] CILParser.TypeArgsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitBounds([NotNull] CILParser.BoundsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSigArgs([NotNull] CILParser.SigArgsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSigArg([NotNull] CILParser.SigArgContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitClassName([NotNull] CILParser.ClassNameContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSlashedName([NotNull] CILParser.SlashedNameContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssemblyDecls([NotNull] CILParser.AssemblyDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssemblyDecl([NotNull] CILParser.AssemblyDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTypeSpec([NotNull] CILParser.TypeSpecContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNativeType([NotNull] CILParser.NativeTypeContext context); - /// - /// Visit a parse tree produced by the PointerNativeType - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitPointerNativeType([NotNull] CILParser.PointerNativeTypeContext context); - /// - /// Visit a parse tree produced by the PointerArrayTypeNoSizeData - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitPointerArrayTypeNoSizeData([NotNull] CILParser.PointerArrayTypeNoSizeDataContext context); - /// - /// Visit a parse tree produced by the PointerArrayTypeSize - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitPointerArrayTypeSize([NotNull] CILParser.PointerArrayTypeSizeContext context); - /// - /// Visit a parse tree produced by the PointerArrayTypeSizeParamIndex - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitPointerArrayTypeSizeParamIndex([NotNull] CILParser.PointerArrayTypeSizeParamIndexContext context); - /// - /// Visit a parse tree produced by the PointerArrayTypeParamIndex - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitPointerArrayTypeParamIndex([NotNull] CILParser.PointerArrayTypeParamIndexContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNativeTypeElement([NotNull] CILParser.NativeTypeElementContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitIidParamIndex([NotNull] CILParser.IidParamIndexContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVariantType([NotNull] CILParser.VariantTypeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVariantTypeElement([NotNull] CILParser.VariantTypeElementContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitType([NotNull] CILParser.TypeContext context); - /// - /// Visit a parse tree produced by the SZArrayModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitSZArrayModifier([NotNull] CILParser.SZArrayModifierContext context); - /// - /// Visit a parse tree produced by the ArrayModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitArrayModifier([NotNull] CILParser.ArrayModifierContext context); - /// - /// Visit a parse tree produced by the ByRefModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitByRefModifier([NotNull] CILParser.ByRefModifierContext context); - /// - /// Visit a parse tree produced by the PtrModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitPtrModifier([NotNull] CILParser.PtrModifierContext context); - /// - /// Visit a parse tree produced by the PinnedModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitPinnedModifier([NotNull] CILParser.PinnedModifierContext context); - /// - /// Visit a parse tree produced by the RequiredModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitRequiredModifier([NotNull] CILParser.RequiredModifierContext context); - /// - /// Visit a parse tree produced by the OptionalModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitOptionalModifier([NotNull] CILParser.OptionalModifierContext context); - /// - /// Visit a parse tree produced by the GenericArgumentsModifier - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitGenericArgumentsModifier([NotNull] CILParser.GenericArgumentsModifierContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitElementType([NotNull] CILParser.ElementTypeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSimpleType([NotNull] CILParser.SimpleTypeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitBound([NotNull] CILParser.BoundContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNativeInt([NotNull] CILParser.NativeIntContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNativeUint([NotNull] CILParser.NativeUintContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSecDecl([NotNull] CILParser.SecDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSecAttrSetBlob([NotNull] CILParser.SecAttrSetBlobContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSecAttrBlob([NotNull] CILParser.SecAttrBlobContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNameValPairs([NotNull] CILParser.NameValPairsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNameValPair([NotNull] CILParser.NameValPairContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTruefalse([NotNull] CILParser.TruefalseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCaValue([NotNull] CILParser.CaValueContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSecAction([NotNull] CILParser.SecActionContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethodRef([NotNull] CILParser.MethodRefContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCallConv([NotNull] CILParser.CallConvContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCallKind([NotNull] CILParser.CallKindContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMdtoken([NotNull] CILParser.MdtokenContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMemberRef([NotNull] CILParser.MemberRefContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFieldRef([NotNull] CILParser.FieldRefContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTypeList([NotNull] CILParser.TypeListContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTyparsClause([NotNull] CILParser.TyparsClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTyparAttrib([NotNull] CILParser.TyparAttribContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTyparAttribs([NotNull] CILParser.TyparAttribsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTypar([NotNull] CILParser.TyparContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTypars([NotNull] CILParser.TyparsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTyBound([NotNull] CILParser.TyBoundContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitGenArity([NotNull] CILParser.GenArityContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitGenArityNotEmpty([NotNull] CILParser.GenArityNotEmptyContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitClassDecl([NotNull] CILParser.ClassDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFieldDecl([NotNull] CILParser.FieldDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFieldAttr([NotNull] CILParser.FieldAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAtOpt([NotNull] CILParser.AtOptContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitInitOpt([NotNull] CILParser.InitOptContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitRepeatOpt([NotNull] CILParser.RepeatOptContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitEventHead([NotNull] CILParser.EventHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitEventAttr([NotNull] CILParser.EventAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitEventDecls([NotNull] CILParser.EventDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitEventDecl([NotNull] CILParser.EventDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitPropHead([NotNull] CILParser.PropHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitPropAttr([NotNull] CILParser.PropAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitPropDecls([NotNull] CILParser.PropDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitPropDecl([NotNull] CILParser.PropDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMarshalClause([NotNull] CILParser.MarshalClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMarshalBlob([NotNull] CILParser.MarshalBlobContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitParamAttr([NotNull] CILParser.ParamAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitParamAttrElement([NotNull] CILParser.ParamAttrElementContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethodHead([NotNull] CILParser.MethodHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethAttr([NotNull] CILParser.MethAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitPinvImpl([NotNull] CILParser.PinvImplContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitPinvAttr([NotNull] CILParser.PinvAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethodName([NotNull] CILParser.MethodNameContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitImplAttr([NotNull] CILParser.ImplAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethodDecls([NotNull] CILParser.MethodDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethodDecl([NotNull] CILParser.MethodDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitLabelDecl([NotNull] CILParser.LabelDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomDescrInMethodBody([NotNull] CILParser.CustomDescrInMethodBodyContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitScopeBlock([NotNull] CILParser.ScopeBlockContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSehBlock([NotNull] CILParser.SehBlockContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSehClauses([NotNull] CILParser.SehClausesContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTryBlock([NotNull] CILParser.TryBlockContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSehClause([NotNull] CILParser.SehClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFilterClause([NotNull] CILParser.FilterClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCatchClause([NotNull] CILParser.CatchClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFinallyClause([NotNull] CILParser.FinallyClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFaultClause([NotNull] CILParser.FaultClauseContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitHandlerBlock([NotNull] CILParser.HandlerBlockContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDataDecl([NotNull] CILParser.DataDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDdHead([NotNull] CILParser.DdHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitTls([NotNull] CILParser.TlsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDdBody([NotNull] CILParser.DdBodyContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDdItemList([NotNull] CILParser.DdItemListContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDdItemCount([NotNull] CILParser.DdItemCountContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitDdItem([NotNull] CILParser.DdItemContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFieldSerInit([NotNull] CILParser.FieldSerInitContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitBytes([NotNull] CILParser.BytesContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitHexbyte([NotNull] CILParser.HexbyteContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFieldInit([NotNull] CILParser.FieldInitContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSerInit([NotNull] CILParser.SerInitContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitF32seq([NotNull] CILParser.F32seqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitF64seq([NotNull] CILParser.F64seqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitI64seq([NotNull] CILParser.I64seqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitI32seq([NotNull] CILParser.I32seqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitI16seq([NotNull] CILParser.I16seqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitI8seq([NotNull] CILParser.I8seqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitBoolSeq([NotNull] CILParser.BoolSeqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitSqstringSeq([NotNull] CILParser.SqstringSeqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitClassSeq([NotNull] CILParser.ClassSeqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitClassSeqElement([NotNull] CILParser.ClassSeqElementContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitObjSeq([NotNull] CILParser.ObjSeqContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitCustomAttrDecl([NotNull] CILParser.CustomAttrDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAsmOrRefDecl([NotNull] CILParser.AsmOrRefDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssemblyRefHead([NotNull] CILParser.AssemblyRefHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssemblyRefDecls([NotNull] CILParser.AssemblyRefDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssemblyRefDecl([NotNull] CILParser.AssemblyRefDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExptypeHead([NotNull] CILParser.ExptypeHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExportHead([NotNull] CILParser.ExportHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExptAttr([NotNull] CILParser.ExptAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExptypeDecls([NotNull] CILParser.ExptypeDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExptypeDecl([NotNull] CILParser.ExptypeDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitManifestResHead([NotNull] CILParser.ManifestResHeadContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitManresAttr([NotNull] CILParser.ManresAttrContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitManifestResDecls([NotNull] CILParser.ManifestResDeclsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitManifestResDecl([NotNull] CILParser.ManifestResDeclContext context); -} -} // namespace ILAssembler diff --git a/src/tools/ilasm/src/ILAssembler/gen/ilasm-generator.csproj b/src/tools/ilasm/src/ILAssembler/gen/ilasm-generator.csproj index e4b7699a7e0634..9d5efdadea9022 100644 --- a/src/tools/ilasm/src/ILAssembler/gen/ilasm-generator.csproj +++ b/src/tools/ilasm/src/ILAssembler/gen/ilasm-generator.csproj @@ -2,7 +2,7 @@ $(NetCoreAppToolCurrent) - true + false enable $(NoWarn);CS3021 true @@ -21,6 +21,7 @@ false + false false ILAssembler $(ProjectDir) @@ -44,4 +45,14 @@ + + + + + + + diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler.csproj b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler.csproj new file mode 100644 index 00000000000000..d5a9549b600108 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler.csproj @@ -0,0 +1,11 @@ + + + + ILAssembler + ref + enable + ILAssembler + $(NetCoreAppToolCurrent) + + + diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/CompilationResult.cs b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/CompilationResult.cs new file mode 100644 index 00000000000000..ce87f9d898c1b8 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/CompilationResult.cs @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler +{ + public sealed class CompilationResult + { + internal CompilationResult() { } + + public System.Reflection.Metadata.BlobContentId Serialize(System.Reflection.Metadata.BlobBuilder builder) { throw null; } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Diagnostic.cs b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Diagnostic.cs new file mode 100644 index 00000000000000..f1d97027369858 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Diagnostic.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler +{ + public record Diagnostic(string Id, DiagnosticSeverity Severity, string Message, Location Location); + + public static class DiagnosticIds + { + public const string AbstractMethodNotInAbstractType = "ILA0021"; + public const string ArgumentNotFound = "ILA0018"; + public const string AssemblyNotFound = "ILA0014"; + public const string BaseOutsideClass = "ILA0004"; + public const string ByteArrayTooShort = "ILA0016"; + public const string DeprecatedCustomMarshaller = "ILA0025"; + public const string DeprecatedNativeType = "ILA0024"; + public const string DuplicateMethod = "ILA0030"; + public const string ExportedTypeNotFound = "ILA0015"; + public const string FileNotFound = "ILA0013"; + public const string GenericParameterIndexOutOfRange = "ILA0027"; + public const string GenericParameterNotFound = "ILA0011"; + public const string InvalidMetadataToken = "ILA0012"; + public const string InvalidPInvokeSignature = "ILA0022"; + public const string KeyFileError = "ILA0032"; + public const string LabelNotFound = "ILA0017"; + public const string LiteralOutOfRange = "ILA0001"; + public const string LocalNotFound = "ILA0019"; + public const string MethodTypeParameterOutsideMethod = "ILA0009"; + public const string MissingExportedTypeImplementation = "ILA0031"; + public const string MissingInstanceCallConv = "ILA0023"; + public const string ModuleNotFound = "ILA0007"; + public const string NesterOutsideNestedClass = "ILA0006"; + public const string NoBaseType = "ILA0005"; + public const string ParameterIndexOutOfRange = "ILA0029"; + public const string PseudoCustomAttributeInvalidBlob = "ILA0036"; + public const string PseudoCustomAttributeInvalidGuid = "ILA0037"; + public const string PseudoCustomAttributeInvalidTarget = "ILA0034"; + public const string PseudoCustomAttributeInvalidValue = "ILA0035"; + public const string PseudoCustomAttributeRepeatedArgument = "ILA0039"; + public const string PseudoCustomAttributeUnknownArgument = "ILA0038"; + public const string ThisOutsideClass = "ILA0003"; + public const string TypeNotFound = "ILA0008"; + public const string TypeParameterOutsideType = "ILA0010"; + public const string TypedefNotFound = "ILA0020"; + public const string UnknownGenericParameter = "ILA0028"; + public const string UnsealedValueType = "ILA0002"; + public const string UnsupportedSecurityDeclaration = "ILA0026"; + } + + public enum DiagnosticSeverity + { + Error, + Warning, + Info, + Hidden + } +} diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/DocumentCompiler.cs b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/DocumentCompiler.cs new file mode 100644 index 00000000000000..523df3022e7efc --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/DocumentCompiler.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler +{ + public sealed class DocumentCompiler + { + public (System.Collections.Immutable.ImmutableArray, CompilationResult?) Compile( + System.Collections.Immutable.ImmutableArray documents, + System.Func includedDocumentLoader, + System.Func resourceLocator, + Options options) { throw null; } + + public (System.Collections.Immutable.ImmutableArray, CompilationResult?) Compile( + SourceText document, + System.Func includedDocumentLoader, + System.Func resourceLocator, + Options options) { throw null; } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Location.cs b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Location.cs new file mode 100644 index 00000000000000..73e456f5385d13 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Location.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler +{ + public record Location(SourceSpan Span, SourceText Source); +} diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Options.cs b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Options.cs new file mode 100644 index 00000000000000..8a5c54d0500efe --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/Options.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler +{ + public enum DebugMode + { + Impl, + Opt + } + + public sealed class Options + { + public bool AppContainer { get; set; } + public string? AssemblyName { get; set; } + public System.Reflection.PortableExecutable.CorFlags? CorFlags { get; set; } + public bool Debug { get; set; } + public DebugMode? DebugMode { get; set; } + public bool Deterministic { get; set; } + public bool Dll { get; set; } + public bool ErrorTolerant { get; set; } + public int? FileAlignment { get; set; } + public bool Fold { get; set; } + public bool HighEntropyVA { get; set; } + public long? ImageBase { get; set; } + public string? KeyFile { get; set; } + public System.Reflection.PortableExecutable.Machine? Machine { get; set; } + public string? MetadataVersion { get; set; } + public bool NoAutoInherit { get; set; } + public bool Optimize { get; set; } + public string? OutputFileName { get; set; } + public bool Pdb { get; set; } + public bool Prefer32Bit { get; set; } + public long? StackReserve { get; set; } + public bool StripReloc { get; set; } + public System.Reflection.PortableExecutable.Subsystem? Subsystem { get; set; } + public (ushort Major, ushort Minor)? SubsystemVersion { get; set; } + } +} diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/SourceSpan.cs b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/SourceSpan.cs new file mode 100644 index 00000000000000..fc2a97e1f12d7d --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/SourceSpan.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler +{ + public record SourceSpan(int Start, int Length); +} diff --git a/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/SourceText.cs b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/SourceText.cs new file mode 100644 index 00000000000000..3ce53fec7d4d88 --- /dev/null +++ b/src/tools/ilasm/src/ILAssembler/ref/ILAssembler/SourceText.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace ILAssembler +{ + public record SourceText(string Text, string Path); +} diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/AssemblyTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/AssemblyTests.cs index e49294241a6d21..91756cb6315b67 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/AssemblyTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/AssemblyTests.cs @@ -305,6 +305,28 @@ .class public auto ansi Test { } } + [Fact] + public void AssemblyLegacyLibraryAttribute_IsAccepted() + { + string source = """ + .assembly extern legacy library dependency { } + .assembly legacy library test { } + .class public auto ansi Test { } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + MetadataReader reader = pe.GetMetadataReader(); + + Assert.Equal("test", reader.GetString(reader.GetAssemblyDefinition().Name)); + Assert.Equal( + "dependency", + reader.AssemblyReferences + .Select(reader.GetAssemblyReference) + .Select(reference => reader.GetString(reference.Name)) + .Single(name => name == "dependency")); + } + + [Fact] public void AssemblyArchitecture_SetsArchitectureFlags() { diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/CustomAttributeTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/CustomAttributeTests.cs index 3510309463bde5..6f734e891616d9 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/CustomAttributeTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/CustomAttributeTests.cs @@ -815,6 +815,138 @@ .class public auto ansi Test extends [mscorlib]System.Object }); } + [Fact] + public void CustomAttribute_ObjectArrayWithNestedArrays_DecodesProperly() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi sealed ObjArrAttribute extends [mscorlib]System.Attribute + { + .method public specialname rtspecialname instance void .ctor(object[] values) cil managed + { + ldarg.0 + call instance void [mscorlib]System.Attribute::.ctor() + ret + } + } + .class public auto ansi Test extends [mscorlib]System.Object + { + .custom instance void ObjArrAttribute::.ctor(object[]) = { + object[2](int32[2](1 2) object(string[2]('alpha' nullref))) + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var testType = reader.TypeDefinitions + .Single(handle => reader.GetString(reader.GetTypeDefinition(handle).Name) == "Test"); + var attribute = reader.GetCustomAttribute(Assert.Single(reader.GetCustomAttributes(testType))); + CustomAttributeValue value = attribute.DecodeValue(DocumentCompilerTestHelpers.Decoder); + ImmutableArray> elements = + Assert.IsType>>( + Assert.Single(value.FixedArguments).Value); + + Assert.Collection( + elements, + element => + { + Assert.Equal("int32[]", element.Type); + AssertArrayValue(element.Value, 1, 2); + }, + element => + { + Assert.Equal("string[]", element.Type); + AssertArrayValue(element.Value, "alpha", null); + }); + } + + [Theory] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Test extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor(int32) = { + float32('a') + } + } + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Test extends [mscorlib]System.Object + { + .field public static literal float32 F = float32('a') + } + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Test extends [mscorlib]System.Object + { + .method public static void M(float32 value) cil managed + { + .param [1] = float32('a') + ret + } + } + """)] + public void MalformedScalarInitializer_ReportsDiagnosticsInsteadOfThrowing(string source) + { + ImmutableArray diagnostics = + DocumentCompilerTestHelpers.CompileAndGetDiagnostics(source, new Options()); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Id == "Parser"); + } + + [Fact] + public void MalformedNestedCustomAttributeSequence_DoesNotLeakFramesIntoNextDocument() + { + ImmutableArray documents = + [ + new SourceText(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Broken extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor(object[]) = { + object[2](type[1]([Discarded]Namespace.Type) + """, "broken.il"), + new SourceText(""" + .class public auto ansi Following extends [mscorlib]System.Object + { + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = { } + } + """, "following.il") + ]; + + DocumentCompiler compiler = new(); + var (diagnostics, result) = compiler.Compile( + documents, + _ => { Assert.Fail("Expected no includes"); return default; }, + _ => { Assert.Fail("Expected no resources"); return default; }, + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Id == "Parser"); + Assert.NotNull(result); + + BlobBuilder image = new(); + result!.Serialize(image); + using PEReader pe = new(image.ToImmutableArray()); + MetadataReader reader = pe.GetMetadataReader(); + TypeDefinitionHandle followingHandle = reader.TypeDefinitions + .Single(handle => reader.GetString(reader.GetTypeDefinition(handle).Name) == "Following"); + + Assert.DoesNotContain( + reader.AssemblyReferences.Select(reader.GetAssemblyReference), + reference => reader.GetString(reference.Name) == "Discarded"); + AssertCustomAttributeBlob( + reader, + Assert.Single(reader.GetCustomAttributes(followingHandle))); + } + private static string TypeWithAttribute(string attributeType, string constructor = ".ctor()", string value = "( 01 00 00 00 )") => $$""" .assembly extern mscorlib { } .assembly test { } @@ -1096,6 +1228,66 @@ .class public auto ansi Second extends [mscorlib]System.Object Assert.Equal(TypeAttributes.Serializable, first.Attributes & TypeAttributes.Serializable); } + [Fact] + public void MethodBodyCustomAttributes_PreserveOwnerAndOrder() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Test extends [mscorlib]System.Object + { + .method public static void M(int32 value) cil managed + { + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = (01 00 00 00) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (01 00 00 00) + .param [1] + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (01 00 00 00) + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = (01 00 00 00) + .param type T + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = (01 00 00 00) + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (01 00 00 00) + .param constraint T, [mscorlib]System.IDisposable + .custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = (01 00 00 00) + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = (01 00 00 00) + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + MethodDefinitionHandle methodHandle = Assert.Single(reader.MethodDefinitions); + var method = reader.GetMethodDefinition(methodHandle); + ParameterHandle parameterHandle = method.GetParameters() + .Single(handle => reader.GetParameter(handle).SequenceNumber == 1); + GenericParameterHandle genericParameterHandle = Assert.Single(method.GetGenericParameters()); + GenericParameterConstraintHandle constraintHandle = + Assert.Single(reader.GetGenericParameter(genericParameterHandle).GetConstraints()); + + Assert.Equal( + ["ObsoleteAttribute", "DebuggerHiddenAttribute"], + GetAttributeTypeNames(reader, reader.GetCustomAttributes(methodHandle))); + Assert.Equal( + ["DebuggerHiddenAttribute", "ObsoleteAttribute"], + GetAttributeTypeNames(reader, reader.GetCustomAttributes(parameterHandle))); + Assert.Equal( + ["ObsoleteAttribute", "DebuggerHiddenAttribute"], + GetAttributeTypeNames(reader, reader.GetCustomAttributes(genericParameterHandle))); + Assert.Equal( + ["DebuggerHiddenAttribute", "ObsoleteAttribute"], + GetAttributeTypeNames(reader, reader.GetCustomAttributes(constraintHandle))); + + static string[] GetAttributeTypeNames( + MetadataReader reader, + CustomAttributeHandleCollection attributes) + => attributes + .Select(reader.GetCustomAttribute) + .Select(attribute => reader.GetMemberReference((MemberReferenceHandle)attribute.Constructor)) + .Select(constructor => reader.GetTypeReference((TypeReferenceHandle)constructor.Parent)) + .Select(type => reader.GetString(type.Name)) + .ToArray(); + } + [Fact] public void PseudoCustomAttribute_ZeroArgDescriptor_MalformedBlobSkipped() { diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/DataTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/DataTests.cs index 59f867a02114f2..d94d2274218dff 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/DataTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/DataTests.cs @@ -6,6 +6,7 @@ using System.Buffers.Binary; using System.Collections.Generic; using System.Collections.Immutable; +using System.Globalization; using System.Linq; using System.Reflection; using System.Reflection.Metadata; @@ -196,6 +197,137 @@ .field public static float64 Value at D Assert.Equal(4503599627370496d, BitConverter.Int64BitsToDouble(BinaryPrimitives.ReadInt64LittleEndian(data))); } + [Fact] + public void LargeByteArray_StreamsIntoDataSectionWithoutLosingBytes() + { + const int Length = 64 * 1024; + byte[] expected = new byte[Length]; + for (int i = 0; i < Length; i++) + { + expected[i] = (byte)((i * 31) + 7); + } + + StringBuilder literal = new(Length * 3); + for (int i = 0; i < Length; i++) + { + if (i > 0) + { + literal.Append(i % 32 == 0 ? '\n' : ' '); + } + + literal.Append(expected[i].ToString("X2", CultureInfo.InvariantCulture)); + } + + string source = $$""" + .assembly extern mscorlib { } + .assembly test { } + + .data D_LARGE = bytearray ({{literal}}) + + .class public explicit ansi sealed DataHolder extends [mscorlib]System.ValueType + { + .size 8 + .field [0] public static int8 LargeData at D_LARGE + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var field = reader.FieldDefinitions + .Select(reader.GetFieldDefinition) + .Single(definition => reader.GetString(definition.Name) == "LargeData"); + + Assert.Equal(expected, ReadData(pe, field, Length)); + } + + [Fact] + public void DataDeclaration_SyntaxVariantsPreserveOffsetsAndReferenceFixups() + { + string source = """ + .assembly test { } + .data int8(0xAA) + .data tls TlsData = int8(0x11) + .data cil CilData = int8(0x22) + .data TargetData = int32(0x12345678) + .data ParenthesizedReference = &(TargetData) + .data BareReference = &TargetData + + .class public explicit ansi sealed DataHolder + { + .field [0] public static int8 TlsValue at TlsData + .field [1] public static int8 CilValue at CilData + .field [2] public static int32 TargetValue at TargetData + .field [6] public static int32 ParenthesizedValue at ParenthesizedReference + .field [10] public static int32 BareValue at BareReference + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + MetadataReader reader = pe.GetMetadataReader(); + Dictionary fields = reader.FieldDefinitions + .Select(reader.GetFieldDefinition) + .ToDictionary(field => reader.GetString(field.Name)); + + int tlsRva = fields["TlsValue"].GetRelativeVirtualAddress(); + int cilRva = fields["CilValue"].GetRelativeVirtualAddress(); + int targetRva = fields["TargetValue"].GetRelativeVirtualAddress(); + int parenthesizedRva = fields["ParenthesizedValue"].GetRelativeVirtualAddress(); + int bareRva = fields["BareValue"].GetRelativeVirtualAddress(); + + Assert.Equal(tlsRva + 1, cilRva); + Assert.Equal(cilRva + 1, targetRva); + Assert.Equal(targetRva + sizeof(int), parenthesizedRva); + Assert.Equal(parenthesizedRva + sizeof(int), bareRva); + Assert.Equal(0x11, Assert.Single(ReadData(pe, fields["TlsValue"], 1))); + Assert.Equal(0x22, Assert.Single(ReadData(pe, fields["CilValue"], 1))); + Assert.Equal(0x12345678, BitConverter.ToInt32(ReadData(pe, fields["TargetValue"], sizeof(int)))); + Assert.Equal(targetRva, BitConverter.ToInt32(ReadData(pe, fields["ParenthesizedValue"], sizeof(int)))); + Assert.Equal(targetRva, BitConverter.ToInt32(ReadData(pe, fields["BareValue"], sizeof(int)))); + } + + [Fact] + public void MalformedDataDeclaration_DoesNotLeakBytesOrLabelIntoNextDocument() + { + ImmutableArray documents = + [ + new SourceText(""" + .assembly test { } + .data Broken = { int8(0xAA), } + """, "broken.il"), + new SourceText(""" + .data Good = int32(0x12345678) + .class public auto ansi DataHolder + { + .field public static int8 Missing at Broken + .field public static int32 Value at Good + } + """, "valid.il"), + ]; + + var compiler = new DocumentCompiler(); + (ImmutableArray diagnostics, CompilationResult? result) = compiler.Compile( + documents, + _ => throw new InvalidOperationException("Unexpected include"), + _ => throw new InvalidOperationException("Unexpected resource"), + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); + Assert.NotNull(result); + + var image = new BlobBuilder(); + result!.Serialize(image); + using var pe = new PEReader(image.ToImmutableArray()); + MetadataReader reader = pe.GetMetadataReader(); + Dictionary fields = reader.FieldDefinitions + .Select(reader.GetFieldDefinition) + .ToDictionary(field => reader.GetString(field.Name)); + + Assert.Equal(0, fields["Missing"].GetRelativeVirtualAddress()); + Assert.Equal( + 0x12345678, + BitConverter.ToInt32(ReadData(pe, fields["Value"], sizeof(int)))); + } + private static byte[] ReadData(PEReader pe, FieldDefinition field, int length) { int rva = field.GetRelativeVirtualAddress(); diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/DocumentCompilerTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/DocumentCompilerTests.cs index 9ccf33c124cf93..8fc79e9ea39886 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/DocumentCompilerTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/DocumentCompilerTests.cs @@ -55,5 +55,148 @@ .method public static void M(int32 int32 int32) cil managed Assert.Contains("ValidFromDoc1", typeNames); } + + [Fact] + public void TruncatedDocument_DoesNotLeakScopesIntoTheNextDocument() + { + var documents = ImmutableArray.Create( + new SourceText(""" + .assembly extern mscorlib { } + .assembly test { } + .namespace Leaky + { + .class public auto ansi Unterminated + { + .method public static void M() cil managed + { + ret + """, "truncated.il"), + new SourceText(""" + .class public auto ansi AfterTruncation + { + } + """, "next.il")); + + var compiler = new DocumentCompiler(); + var (diagnostics, image) = compiler.Compile( + documents, + _ => throw new InvalidOperationException("Unexpected include"), + _ => throw new InvalidOperationException("Unexpected resource"), + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); + Assert.NotNull(image); + + var imageBuilder = new BlobBuilder(); + image!.Serialize(imageBuilder); + using var pe = new PEReader(imageBuilder.ToImmutableArray()); + var reader = pe.GetMetadataReader(); + var afterTruncation = reader.TypeDefinitions + .Select(reader.GetTypeDefinition) + .Single(type => reader.GetString(type.Name) == "AfterTruncation"); + + Assert.Equal(string.Empty, reader.GetString(afterTruncation.Namespace)); + Assert.True(afterTruncation.GetDeclaringType().IsNil); + } + + [Theory] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Broken + { + .method public static void M(int32 int32 int32) cil managed + { + ret + } + } + .class public auto ansi Following + { + } + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .namespace Broken + { + .class public auto ansi Nested + { + .method public static void M(int32 int32 int32) cil managed + { + ret + } + } + } + .class public auto ansi Following + { + } + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .namespace + { + } + .class public auto ansi Following + { + } + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Broken extends + { + } + .class public auto ansi Following + { + } + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Broken + { + .method public static void M() cil managed + { + .try + { + { + nop nop nop int32 + } + } + finally + { + endfinally + } + ret + } + } + .class public auto ansi Following + { + } + """)] + public void SyntaxErrorInDeclaration_DoesNotLeakScopesIntoFollowingDeclarations(string source) + { + var compiler = new DocumentCompiler(); + var (diagnostics, image) = compiler.Compile( + new SourceText(source, "test.il"), + _ => throw new InvalidOperationException("Unexpected include"), + _ => throw new InvalidOperationException("Unexpected resource"), + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); + Assert.NotNull(image); + + var imageBuilder = new BlobBuilder(); + image!.Serialize(imageBuilder); + using var pe = new PEReader(imageBuilder.ToImmutableArray()); + var reader = pe.GetMetadataReader(); + var following = reader.TypeDefinitions + .Select(reader.GetTypeDefinition) + .Single(type => reader.GetString(type.Name) == "Following"); + + Assert.Equal(string.Empty, reader.GetString(following.Namespace)); + Assert.True(following.GetDeclaringType().IsNil); + } } } diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/EventTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/EventTests.cs index 6ea3a47b34bece..20ddd3f7a3beef 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/EventTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/EventTests.cs @@ -174,5 +174,26 @@ .event specialname rtspecialname MyDelegate Changed [0x01, 0x00, 0x00, 0x00], reader.GetBlobBytes(reader.GetCustomAttribute(Assert.Single(reader.GetCustomAttributes(eventHandle))).Value)); } + + [Fact] + public void EventWithoutType_EmitsNilEventType() + { + string source = """ + .assembly test { } + .class public auto ansi Test + { + .event Changed + { + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var @event = reader.GetEventDefinition(Assert.Single(reader.EventDefinitions)); + + Assert.Equal("Changed", reader.GetString(@event.Name)); + Assert.True(@event.Type.IsNil); + } } } diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/ExceptionHandlingTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/ExceptionHandlingTests.cs index 892136bf565412..86b80c62283695 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/ExceptionHandlingTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/ExceptionHandlingTests.cs @@ -441,5 +441,159 @@ leave.s DONE Assert.True(region.HandlerLength > 0); } + [Fact] + public void MultipleCatchClauses_ResolveCatchTypesBeforeTheirHandlerBodies() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi beforefieldinit Test extends [mscorlib]System.Object + { + .method public static void M() cil managed + { + .maxstack 1 + .try + { + leave.s DONE + } + catch [mscorlib]System.ArgumentException + { + castclass [mscorlib]System.IO.Stream + pop + leave.s DONE + } + catch [mscorlib]System.NotSupportedException + { + castclass [mscorlib]System.Text.StringBuilder + pop + leave.s DONE + } + DONE: + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + + // Native ilasm resolves a catch type as soon as the clause is parsed, so each catch type + // precedes every type its handler body references. + Assert.Equal( + ["System.Object", "System.ValueType", "System.ArgumentException", "System.IO.Stream", "System.NotSupportedException", "System.Text.StringBuilder"], + reader.TypeReferences + .Select(reader.GetTypeReference) + .Select(reference => reader.GetString(reference.Namespace) + "." + reader.GetString(reference.Name)) + .ToArray()); + + var method = reader.MethodDefinitions + .Select(reader.GetMethodDefinition) + .First(definition => reader.GetString(definition.Name) == "M"); + var body = pe.GetMethodBody(method.RelativeVirtualAddress); + + Assert.Equal(2, body.ExceptionRegions.Length); + Assert.All(body.ExceptionRegions, region => Assert.Equal(ExceptionRegionKind.Catch, region.Kind)); + Assert.Equal( + ["System.ArgumentException", "System.NotSupportedException"], + body.ExceptionRegions + .Select(region => reader.GetTypeReference((TypeReferenceHandle)region.CatchType)) + .Select(reference => reader.GetString(reference.Namespace) + "." + reader.GetString(reference.Name)) + .ToArray()); + } + + [Fact] + public void LabelBasedFilterRegion_EmitsExactExceptionRegionBounds() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi beforefieldinit Test extends [mscorlib]System.Object + { + .method public static void M() cil managed + { + .maxstack 1 + .try TRY_START to TRY_END filter FILTER_START handler HANDLER_START to HANDLER_END + TRY_START: + nop + leave.s DONE + TRY_END: + FILTER_START: + pop + ldc.i4.1 + endfilter + HANDLER_START: + pop + leave.s DONE + HANDLER_END: + DONE: + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var method = reader.GetMethodDefinition(Assert.Single(reader.MethodDefinitions)); + var region = Assert.Single(pe.GetMethodBody(method.RelativeVirtualAddress).ExceptionRegions); + + Assert.Equal(ExceptionRegionKind.Filter, region.Kind); + Assert.Equal(0, region.TryOffset); + Assert.Equal(3, region.TryLength); + Assert.Equal(3, region.FilterOffset); + Assert.Equal(7, region.HandlerOffset); + Assert.Equal(3, region.HandlerLength); + } + + [Fact] + public void NestedTryBlocks_EmitInnerRegionBeforeOuterRegion() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi beforefieldinit Test extends [mscorlib]System.Object + { + .method public static void M() cil managed + { + .maxstack 1 + .try + { + .try + { + nop + leave.s INNER_DONE + } + catch [mscorlib]System.Exception + { + pop + leave.s INNER_DONE + } + INNER_DONE: + leave.s DONE + } + finally + { + endfinally + } + DONE: + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var method = reader.GetMethodDefinition(Assert.Single(reader.MethodDefinitions)); + ImmutableArray regions = + pe.GetMethodBody(method.RelativeVirtualAddress).ExceptionRegions; + + Assert.Equal(2, regions.Length); + Assert.Equal(ExceptionRegionKind.Catch, regions[0].Kind); + Assert.Equal(ExceptionRegionKind.Finally, regions[1].Kind); + Assert.True(regions[0].TryOffset >= regions[1].TryOffset); + Assert.True( + regions[0].HandlerOffset + regions[0].HandlerLength <= + regions[1].TryOffset + regions[1].TryLength); + } + } } diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/FieldTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/FieldTests.cs index 0a50dd1e58fe48..a140129e4a2ea8 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/FieldTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/FieldTests.cs @@ -72,6 +72,90 @@ .class public auto ansi B Assert.Single(typeB.GetCustomAttributes()); } + [Fact] + public void TrailingFieldCustomAttribute_DoesNotLeakAcrossNamespaces() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .namespace First + { + .class public auto ansi A + { + .field public static int32 Value + } + } + .class public auto ansi B + { + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = (01 00 00 00) + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var field = reader.GetFieldDefinition(MetadataTokens.FieldDefinitionHandle(1)); + var typeB = reader.TypeDefinitions + .Select(reader.GetTypeDefinition) + .Single(type => reader.GetString(type.Name) == "B"); + + Assert.Empty(field.GetCustomAttributes()); + Assert.Single(typeB.GetCustomAttributes()); + } + + [Fact] + public void TrailingFieldCustomAttribute_BindsToFieldWithinTheSameNamespacedType() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .namespace First + { + .class public auto ansi A + { + .field public static int32 Value + .custom instance void [mscorlib]System.ThreadStaticAttribute::.ctor() = (01 00 00 00) + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var field = reader.GetFieldDefinition(MetadataTokens.FieldDefinitionHandle(1)); + var typeA = reader.TypeDefinitions + .Select(reader.GetTypeDefinition) + .Single(type => reader.GetString(type.Name) == "A"); + + Assert.Single(field.GetCustomAttributes()); + Assert.Empty(typeA.GetCustomAttributes()); + } + + [Fact] + public void TrailingFieldCustomAttribute_DoesNotLeakOutOfNestedClass() + { + string source = """ + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Outer + { + .class nested public auto ansi Inner + { + .field public static int32 Value + } + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = (01 00 00 00) + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var field = reader.GetFieldDefinition(MetadataTokens.FieldDefinitionHandle(1)); + var outer = reader.TypeDefinitions + .Select(reader.GetTypeDefinition) + .Single(type => reader.GetString(type.Name) == "Outer"); + + Assert.Empty(field.GetCustomAttributes()); + Assert.Single(outer.GetCustomAttributes()); + } + [Fact] public void GlobalFieldTrailingCustomAttribute_AttachesToField() { diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/ILAssembler.Tests.csproj b/src/tools/ilasm/tests/ILAssembler.Tests/ILAssembler.Tests.csproj index f621b0e97351f3..4532515e27b6fb 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/ILAssembler.Tests.csproj +++ b/src/tools/ilasm/tests/ILAssembler.Tests/ILAssembler.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/InstructionTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/InstructionTests.cs index 67e4a77013ef1a..c56078168b7570 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/InstructionTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/InstructionTests.cs @@ -46,6 +46,141 @@ br UndefinedLabel Assert.Equal(DiagnosticSeverity.Error, error.Severity); } + [Fact] + public void Diagnostic_SwitchLabelNotFound_PointsToInstruction() + { + string source = """ + .assembly test { } + .class public auto ansi Test + { + .method public static void M() cil managed + { + ldc.i4.0 + switch (UndefinedLabel) + ret + } + } + """; + + var diagnostics = DocumentCompilerTestHelpers.CompileAndGetDiagnostics(source, new Options()); + var error = Assert.Single(diagnostics); + Assert.Equal(DiagnosticIds.LabelNotFound, error.Id); + Assert.Equal(source.IndexOf("switch", StringComparison.Ordinal), error.Location.Span.Start); + } + + [Theory] + [InlineData("ldc.i4")] + [InlineData("ldc.i8")] + [InlineData("ldarg")] + [InlineData("br")] + [InlineData("call instance void")] + [InlineData("ldsfld int32")] + [InlineData("ldsfld mdtoken(")] + [InlineData("box")] + [InlineData("ldtoken")] + [InlineData("calli default void(")] + [InlineData("calli vararg void(class [mscorlib]System.Tuple`1 + { + Assert.Fail("Expected no includes"); + return default; + }, + _ => + { + Assert.Fail("Expected no resources"); + return default; + }, + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Id == "Parser"); + Assert.NotNull(result); + + BlobBuilder image = new(); + result!.Serialize(image); + using PEReader pe = new(image.ToImmutableArray()); + byte[] il = GetMethodIL(pe, "Good"); + + Assert.Equal([0x2A], il); + } + + [Fact] + public void MalformedCalliSignature_DoesNotMaterializeDiscardedReferences() + { + string source = """ + .assembly test { } + .class public auto ansi Test + { + .method public static void Bad() cil managed + { + calli default void(class [Unused]Payload + } + + .method public static void Good() cil managed + { + call void [Used]Target::M() + ret + } + } + """; + + DocumentCompiler compiler = new(); + var (diagnostics, result) = compiler.Compile( + new SourceText(source, "test.il"), + _ => + { + Assert.Fail("Expected no includes"); + return default; + }, + _ => + { + Assert.Fail("Expected no resources"); + return default; + }, + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Id == "Parser"); + Assert.NotNull(result); + + BlobBuilder image = new(); + result!.Serialize(image); + using PEReader pe = new(image.ToImmutableArray()); + MetadataReader reader = pe.GetMetadataReader(); + string[] assemblyReferences = reader.AssemblyReferences + .Select(handle => reader.GetString(reader.GetAssemblyReference(handle).Name)) + .ToArray(); + + Assert.Contains("Used", assemblyReferences); + Assert.DoesNotContain("Unused", assemblyReferences); + Assert.Equal([0x28, 0x01, 0x00, 0x00, 0x0A, 0x2A], GetMethodIL(pe, "Good")); + } + [Fact] public void DataLabelReference_FixedUpCorrectly() @@ -362,6 +497,61 @@ calli vararg void(int32, ..., string, int64) Assert.Equal([PrimitiveTypeCode.Int32, PrimitiveTypeCode.String, PrimitiveTypeCode.Int64], signature.ParameterTypes.ToArray()); } + [Fact] + public void ReferenceAndCalliOperands_NestedSignaturesDecodeCorrectly() + { + string source = """ + .assembly extern mscorlib { } + .assembly Test { } + .class public auto ansi Test + { + .method public static void F() cil managed + { + ldsfld method vararg void *(int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile), ..., string) class [mscorlib]System.Tuple`1>::Callback + pop + call void class [mscorlib]System.Tuple`1>::Invoke(method vararg void *(int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile), ..., string)) + ldc.i4.0 + conv.i + calli vararg void(class [mscorlib]System.Tuple`1>, ..., method vararg void *(int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile), ..., string)) + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + + MemberReference fieldReference = reader.MemberReferences + .Select(reader.GetMemberReference) + .Single(reference => reader.GetString(reference.Name) == "Callback"); + Assert.Equal( + "method void *(int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile), ..., string)", + fieldReference.DecodeFieldSignature(DocumentCompilerTestHelpers.Decoder, genericContext: null)); + + MemberReference methodReference = reader.MemberReferences + .Select(reader.GetMemberReference) + .Single(reference => reader.GetString(reference.Name) == "Invoke"); + MethodSignature methodSignature = + methodReference.DecodeMethodSignature(DocumentCompilerTestHelpers.Decoder, genericContext: null); + Assert.Equal("void", methodSignature.ReturnType); + Assert.Equal( + new[] { "method void *(int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile), ..., string)" }, + methodSignature.ParameterTypes); + + MethodSignature calliSignature = reader + .GetStandaloneSignature(MetadataTokens.StandaloneSignatureHandle(1)) + .DecodeMethodSignature(DocumentCompilerTestHelpers.Decoder, genericContext: null); + Assert.Equal(SignatureCallingConvention.VarArgs, calliSignature.Header.CallingConvention); + Assert.Equal(1, calliSignature.RequiredParameterCount); + Assert.Equal( + new[] + { + "[mscorlib]System.Tuple`1<[mscorlib]System.Tuple`1>", + "method void *(int32 modreq([mscorlib]System.Runtime.CompilerServices.IsVolatile), ..., string)", + }, + calliSignature.ParameterTypes); + } + [Fact] public void MaxStackDirective_IsPreserved() { @@ -609,7 +799,7 @@ .method public static int32 f1() cil managed [Fact] - public void SwitchInstruction_CommaLabels() + public void SwitchInstruction_NamedLabels_EmitsExpectedBranchTable() { string source = """ .assembly extern System.Runtime { } @@ -627,8 +817,54 @@ .method public static void M() cil managed } """; - var diagnostics = DocumentCompilerTestHelpers.CompileAndGetDiagnostics(source, new Options()); - Assert.Empty(diagnostics); + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + byte[] il = GetMethodIL(pe, "M"); + int switchOffset = Array.IndexOf(il, (byte)0x45); + + Assert.True(switchOffset >= 0); + Assert.Equal(3, BitConverter.ToInt32(il, switchOffset + 1)); + Assert.Equal(0, BitConverter.ToInt32(il, switchOffset + 5)); + Assert.Equal(1, BitConverter.ToInt32(il, switchOffset + 9)); + Assert.Equal(2, BitConverter.ToInt32(il, switchOffset + 13)); + } + + [Theory] + [InlineData("ldc.r4", "1.5", 1.5)] + [InlineData("ldc.r8", "1.5", 1.5)] + [InlineData("ldc.r8", ".5", 0.5)] + [InlineData("ldc.r8", "5e+1", 50.0)] + [InlineData("ldc.r8", "-1.25e-2", -0.0125)] + [InlineData("ldc.r8", "float32(0x3F800000)", 1.0)] + public void FloatingPointInstruction_TextAndFloat32BitForms_EmitExpectedValue( + string opcode, + string literal, + double expected) + { + string source = $$""" + .assembly test { } + .class public auto ansi Test + { + .method public static void M() cil managed + { + {{opcode}} {{literal}} + pop + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + byte[] il = GetMethodIL(pe, "M"); + if (opcode == "ldc.r4") + { + Assert.Equal(0x22, il[0]); + Assert.Equal((float)expected, BitConverter.ToSingle(il, 1)); + } + else + { + Assert.Equal(0x23, il[0]); + Assert.Equal(expected, BitConverter.ToDouble(il, 1)); + } } [Fact] @@ -654,6 +890,27 @@ ldc.r8 float64(0x400921FB54442D18) Assert.Equal(Math.PI, BitConverter.ToDouble(il, 1), 14); } + [Fact] + public void FloatingPointInstruction_IntegerOverflow_ReportsDiagnostic() + { + string source = """ + .assembly test { } + .class public auto ansi Test + { + .method public static void M() cil managed + { + ldc.r8 99999999999999999999999999999999 + pop + ret + } + } + """; + + var diagnostics = DocumentCompilerTestHelpers.CompileAndGetDiagnostics(source, new Options()); + var error = Assert.Single(diagnostics); + Assert.Equal(DiagnosticIds.LiteralOutOfRange, error.Id); + } + [Fact] public void FloatingPointInstruction_ByteForms_EmitExpectedConstants() { @@ -766,7 +1023,7 @@ .method public static void M() cil managed } [Fact] - public void LdstrInstruction_ByteArrayAndAnsiForms_EmitExpectedUserStrings() + public void LdstrInstruction_ComposedAnsiAndRawForms_EmitExpectedUserStrings() { string source = """ .assembly extern mscorlib { } @@ -781,7 +1038,19 @@ ldstr bytearray(48 00 69 00) .method public static string GetAnsi() cil managed { - ldstr ansi("AB") + ldstr ansi("A" + "B") + ret + } + + .method public static string GetOddAnsi() cil managed + { + ldstr ansi("A" + "BC") + ret + } + + .method public static string GetComposed() cil managed + { + ldstr "A" + "B" ret } } @@ -792,6 +1061,8 @@ ldstr ansi("AB") Assert.Equal("Hi", ReadLdstrValue(pe, reader, "GetUtf16")); Assert.Equal("\u4241", ReadLdstrValue(pe, reader, "GetAnsi")); + Assert.Equal("\u4241\u0043", ReadLdstrValue(pe, reader, "GetOddAnsi")); + Assert.Equal("AB", ReadLdstrValue(pe, reader, "GetComposed")); } [Fact] @@ -877,6 +1148,30 @@ .method public static int32 M(int32 value) cil managed Assert.Equal(6, BitConverter.ToInt32(il, switchOffset + 9)); } + [Theory] + [InlineData("switch ()")] + [InlineData("switch ( )")] + public void SwitchInstruction_Empty_EmitsEmptyBranchTable(string instruction) + { + string source = $$""" + .assembly test { } + .class public auto ansi Test + { + .method public static void M() cil managed + { + {{instruction}} + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + byte[] il = GetMethodIL(pe, "M"); + + Assert.Equal(0x45, il[0]); + Assert.Equal(0, BitConverter.ToInt32(il, 1)); + } + [Fact] public void LdtokenInstruction_TypeReference_EmitsTypeReferenceToken() { diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/InteropTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/InteropTests.cs index b89648399f5008..256c74b16c59a3 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/InteropTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/InteropTests.cs @@ -184,6 +184,105 @@ .field public marshal({{sizeSyntax}}) int32[] Values Assert.Equal(Convert.FromHexString(expectedHex), reader.GetBlobBytes(field.GetMarshallingDescriptor())); } + [Theory] + [InlineData("{ 2A 50 }", "2A50")] + [InlineData("{ 1E }", "1E")] + [InlineData("{ 00 0A FF }", "000AFF")] + public void RawMarshalBlob_EmitsSuppliedBytes(string blob, string expectedHex) + { + string source = $$""" + .assembly test { } + .class public auto ansi Test + { + .field public marshal({{blob}}) int32[] Values + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var field = reader.GetFieldDefinition(MetadataTokens.FieldDefinitionHandle(1)); + + Assert.Equal(Convert.FromHexString(expectedHex), reader.GetBlobBytes(field.GetMarshallingDescriptor())); + } + + [Fact] + public void MalformedRawMarshalBlob_DoesNotLeakIntoFollowingField() + { + string source = """ + .assembly test { } + .class public auto ansi Test + { + .field public marshal({ }) int32 Bad + .field public marshal({ 2A 50 }) int32[] Good + } + """; + + DocumentCompiler compiler = new(); + var (diagnostics, result) = compiler.Compile( + new SourceText(source, "test.il"), + _ => { Assert.Fail("Expected no includes"); return default; }, + _ => { Assert.Fail("Expected no resources"); return default; }, + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Id == "Parser"); + Assert.NotNull(result); + + BlobBuilder image = new(); + result!.Serialize(image); + using PEReader pe = new(image.ToImmutableArray()); + MetadataReader reader = pe.GetMetadataReader(); + FieldDefinition good = reader.FieldDefinitions + .Select(reader.GetFieldDefinition) + .Single(field => reader.GetString(field.Name) == "Good"); + + Assert.Equal([0x2A, 0x50], reader.GetBlobBytes(good.GetMarshallingDescriptor())); + } + + [Theory] + [InlineData("marshal({")] + [InlineData("marshal(fixed array[2] int32[3 +")] + [InlineData("marshal(custom(\"Marshaller\",")] + public void MalformedNestedMarshal_DoesNotLeakFramesIntoNextDocument(string malformedMarshal) + { + ImmutableArray documents = + [ + new SourceText($$""" + .assembly test { } + .class public auto ansi Broken + { + .method public static void M(object {{malformedMarshal}} + """, "broken.il"), + new SourceText(""" + .class public auto ansi Following + { + .field public marshal(fixed array[2] int16[3+1]) int16[] Values + } + """, "following.il") + ]; + + DocumentCompiler compiler = new(); + var (diagnostics, result) = compiler.Compile( + documents, + _ => { Assert.Fail("Expected no includes"); return default; }, + _ => { Assert.Fail("Expected no resources"); return default; }, + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Id == "Parser"); + Assert.NotNull(result); + + BlobBuilder image = new(); + result!.Serialize(image); + using PEReader pe = new(image.ToImmutableArray()); + MetadataReader reader = pe.GetMetadataReader(); + FieldDefinition field = reader.FieldDefinitions + .Select(reader.GetFieldDefinition) + .Single(field => reader.GetString(field.Name) == "Values"); + + Assert.Equal( + [0x1E, 0x02, 0x2A, 0x05, 0x01, 0x03, 0x01], + reader.GetBlobBytes(field.GetMarshallingDescriptor())); + } + [Theory] [InlineData("int8", UnmanagedType.U1)] [InlineData("int16", UnmanagedType.U2)] diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/MethodTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/MethodTests.cs index 7b887213e7a268..016e8f188da778 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/MethodTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/MethodTests.cs @@ -498,6 +498,98 @@ .class public auto ansi Bar extends [mscorlib]System.Object Assert.Equal("Impl", reader.GetString(reader.GetMemberReference((MemberReferenceHandle)implementation.MethodBody).Name)); } + [Fact] + public void DeferredClassOverride_RemainsOwnedByOuterTypeAcrossNestedType() + { + string source = """ + .assembly extern mscorlib { } + .assembly extern External { } + .assembly TestOverride { } + .class public auto ansi Outer extends [mscorlib]System.Object + { + .override [External]IFoo::M with instance int32 Outer::Impl(string) + .class nested public auto ansi Inner extends [mscorlib]System.Object + { + .method public instance int32 Impl(string value) cil managed + { + ldc.i4.0 + ret + } + } + .method public instance int32 Impl(string value) cil managed + { + ldc.i4.1 + ret + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + var reader = pe.GetMetadataReader(); + var types = reader.TypeDefinitions + .ToDictionary( + handle => reader.GetString(reader.GetTypeDefinition(handle).Name), + handle => (Handle: handle, Definition: reader.GetTypeDefinition(handle))); + + var implementation = reader.GetMethodImplementation( + Assert.Single(types["Outer"].Definition.GetMethodImplementations())); + Assert.Empty(types["Inner"].Definition.GetMethodImplementations()); + Assert.Equal(HandleKind.MethodDefinition, implementation.MethodBody.Kind); + Assert.Equal( + types["Outer"].Handle, + reader.GetMethodDefinition((MethodDefinitionHandle)implementation.MethodBody).GetDeclaringType()); + } + + [Fact] + public void TruncatedNestedMethodHeader_DoesNotLeakMemberStateToFollowingDocument() + { + string malformedSource = """ + .assembly extern mscorlib { } + .assembly malformed { } + .class public auto ansi Outer extends [mscorlib]System.Object + { + .class nested public auto ansi Inner extends [mscorlib]System.Object + { + .method public static void Broken(int32 value + """; + string validSource = """ + .assembly extern mscorlib { } + .assembly valid { } + .class public auto ansi Following extends [mscorlib]System.Object + { + .method public static void Good() cil managed + { + ret + } + } + """; + + var compiler = new DocumentCompiler(); + var (malformedDiagnostics, _) = compiler.Compile( + new SourceText(malformedSource, "malformed.il"), + _ => default!, + _ => default!, + new Options { ErrorTolerant = true }); + var (validDiagnostics, result) = compiler.Compile( + new SourceText(validSource, "valid.il"), + _ => default!, + _ => default!, + new Options()); + + Assert.Contains(malformedDiagnostics, diagnostic => diagnostic.Id == "Parser"); + Assert.Empty(validDiagnostics); + Assert.NotNull(result); + var image = new BlobBuilder(); + result.Serialize(image); + using var pe = new PEReader(image.ToImmutableArray()); + var reader = pe.GetMetadataReader(); + var followingType = reader.TypeDefinitions + .Select(reader.GetTypeDefinition) + .Single(type => reader.GetString(type.Name) == "Following"); + MethodDefinitionHandle goodMethod = Assert.Single(followingType.GetMethods()); + Assert.Equal("Good", reader.GetString(reader.GetMethodDefinition(goodMethod).Name)); + } + [Fact] public void MultipleOverrides_EmitsAllMethodImpls() diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/SecurityTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/SecurityTests.cs index a44d1c521cc6c7..4d84e16057d29c 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/SecurityTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/SecurityTests.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; +using System.Collections.Immutable; using System.Reflection; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; @@ -244,5 +246,95 @@ .method public static void M() cil managed security.Action == DeclarativeSecurityAction.Assert && reader.GetBlobBytes(security.PermissionSet).SequenceEqual((byte[])[0x2F])); } + + [Fact] + public void PermissionSet_VerbalAttributesPreserveNamesAndTypeReferenceOrder() + { + string source = """ + .assembly extern mscorlib { } + .assembly test + { + .permissionset demand = { + [mscorlib]Contoso.FirstPermission = { }, + class 'Contoso.QuotedPermission' = { + property bool Enabled = bool(true) + }, + [mscorlib]Contoso.SecondPermission = { } + } + } + """; + + using var pe = DocumentCompilerTestHelpers.CompileAndGetReader(source, new Options()); + MetadataReader reader = pe.GetMetadataReader(); + DeclarativeSecurityAttribute security = reader.GetDeclarativeSecurityAttribute( + Assert.Single(reader.GetAssemblyDefinition().GetDeclarativeSecurityAttributes())); + BlobReader permissionSet = reader.GetBlobReader(security.PermissionSet); + + Assert.Equal((byte)'.', permissionSet.ReadByte()); + Assert.Equal(3, permissionSet.ReadCompressedInteger()); + Assert.StartsWith( + "Contoso.FirstPermission, mscorlib", + permissionSet.ReadSerializedString(), + StringComparison.Ordinal); + Assert.Equal(0, permissionSet.ReadUInt16()); + Assert.Equal("Contoso.QuotedPermission", permissionSet.ReadSerializedString()); + Assert.Equal(1, permissionSet.ReadUInt16()); + Assert.Equal((byte)CustomAttributeNamedArgumentKind.Property, permissionSet.ReadByte()); + Assert.Equal((byte)SerializationTypeCode.Boolean, permissionSet.ReadByte()); + Assert.Equal("Enabled", permissionSet.ReadSerializedString()); + Assert.True(permissionSet.ReadBoolean()); + Assert.StartsWith( + "Contoso.SecondPermission, mscorlib", + permissionSet.ReadSerializedString(), + StringComparison.Ordinal); + Assert.Equal(0, permissionSet.ReadUInt16()); + Assert.Equal(0, permissionSet.RemainingBytes); + + Assert.Equal( + ["FirstPermission", "SecondPermission"], + reader.TypeReferences + .Select(handle => reader.GetString(reader.GetTypeReference(handle).Name)) + .ToArray()); + } + + [Fact] + public void MalformedPermissionSet_DoesNotLeakAttributesIntoNextDocument() + { + ImmutableArray documents = + [ + new SourceText(""" + .assembly test { } + .permissionset demand = { + class 'Broken.Permission' = { + property bool Enabled = bool(true) + }, + } + """, "broken.il"), + new SourceText(""" + .permissionset assert = (2F) + .class public auto ansi Test { } + """, "valid.il"), + ]; + + var compiler = new DocumentCompiler(); + (ImmutableArray diagnostics, CompilationResult? result) = compiler.Compile( + documents, + _ => throw new InvalidOperationException("Unexpected include"), + _ => throw new InvalidOperationException("Unexpected resource"), + new Options { ErrorTolerant = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); + Assert.NotNull(result); + + var image = new BlobBuilder(); + result!.Serialize(image); + using var pe = new PEReader(image.ToImmutableArray()); + MetadataReader reader = pe.GetMetadataReader(); + DeclarativeSecurityAttribute security = reader.GetDeclarativeSecurityAttribute( + Assert.Single(reader.GetAssemblyDefinition().GetDeclarativeSecurityAttributes())); + + Assert.Equal(DeclarativeSecurityAction.Assert, security.Action); + Assert.Equal([0x2F], reader.GetBlobBytes(security.PermissionSet)); + } } } diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/SourceDirectiveTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/SourceDirectiveTests.cs index cfa11aebdef362..7a2aa3a5ea3f2e 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/SourceDirectiveTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/SourceDirectiveTests.cs @@ -527,5 +527,117 @@ .line 20 "doc2.cs" Assert.Equal(pe.GetMetadataReader().MethodDefinitions.Count, pdbReader.MethodDebugInformation.Count); } + [Fact] + public void MultiDocumentCompile_DoesNotReusePreviousDocumentPath() + { + var documents = ImmutableArray.Create( + new SourceText(""" + .assembly test { } + .class public auto ansi First + { + .method public static void M1() cil managed + { + .line 10 "first.cs" + nop + ret + } + } + """, "first.il"), + new SourceText(""" + .class public auto ansi Second + { + .method public static void M2() cil managed + { + .line 20 + nop + ret + } + } + """, "second.il")); + + var compiler = new DocumentCompiler(); + (ImmutableArray diagnostics, CompilationResult? result) = compiler.Compile( + documents, + _ => throw new InvalidOperationException("Unexpected include"), + _ => throw new InvalidOperationException("Unexpected resource"), + new Options { Pdb = true }); + + Assert.Empty(diagnostics); + Assert.NotNull(result); + + var image = new BlobBuilder(); + result!.Serialize(image); + using var pe = new PEReader(image.ToImmutableArray()); + MetadataReader reader = pe.GetMetadataReader(); + MethodDefinitionHandle firstMethod = reader.MethodDefinitions + .Single(handle => reader.GetString(reader.GetMethodDefinition(handle).Name) == "M1"); + MethodDefinitionHandle secondMethod = reader.MethodDefinitions + .Single(handle => reader.GetString(reader.GetMethodDefinition(handle).Name) == "M2"); + DebugDirectoryEntry embeddedPdb = Assert.Single( + pe.ReadDebugDirectory(), + entry => entry.Type == DebugDirectoryEntryType.EmbeddedPortablePdb); + using MetadataReaderProvider pdbProvider = + pe.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedPdb); + MetadataReader pdbReader = pdbProvider.GetMetadataReader(); + + MethodDebugInformation firstDebugInformation = pdbReader.GetMethodDebugInformation( + MetadataTokens.MethodDebugInformationHandle(MetadataTokens.GetRowNumber(firstMethod))); + MethodDebugInformation secondDebugInformation = pdbReader.GetMethodDebugInformation( + MetadataTokens.MethodDebugInformationHandle(MetadataTokens.GetRowNumber(secondMethod))); + + Assert.False(firstDebugInformation.SequencePointsBlob.IsNil); + Assert.True(secondDebugInformation.SequencePointsBlob.IsNil); + Assert.Contains( + "first.cs", + pdbReader.GetString(pdbReader.GetDocument(firstDebugInformation.Document).Name)); + } + + [Fact] + public void MalformedLanguageDirective_DoesNotPartiallyUpdateGuidState() + { + ImmutableArray documents = + [ + new SourceText($$""" + .assembly test { } + .language '{{CSharpLanguageGuid}}' + .language '{{DocumentTypeGuid}}', + """, "broken.il"), + new SourceText(""" + .class public auto ansi Test + { + .method public static void M() cil managed + { + .line 10 "document.cs" + nop + ret + } + } + """, "valid.il"), + ]; + + var compiler = new DocumentCompiler(); + (ImmutableArray diagnostics, CompilationResult? result) = compiler.Compile( + documents, + _ => throw new InvalidOperationException("Unexpected include"), + _ => throw new InvalidOperationException("Unexpected resource"), + new Options { ErrorTolerant = true, Pdb = true }); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); + Assert.NotNull(result); + + var image = new BlobBuilder(); + result!.Serialize(image); + using var pe = new PEReader(image.ToImmutableArray()); + DebugDirectoryEntry embeddedPdb = Assert.Single( + pe.ReadDebugDirectory(), + entry => entry.Type == DebugDirectoryEntryType.EmbeddedPortablePdb); + using MetadataReaderProvider pdbProvider = + pe.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedPdb); + MetadataReader pdbReader = pdbProvider.GetMetadataReader(); + Document document = pdbReader.GetDocument(Assert.Single(pdbReader.Documents)); + + Assert.Equal(Guid.Parse(CSharpLanguageGuid), pdbReader.GetGuid(document.Language)); + } + } } diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/SyntaxTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/SyntaxTests.cs index 7d2d2ae89a4bb9..b4bbe433189d3e 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/SyntaxTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/SyntaxTests.cs @@ -191,6 +191,196 @@ .method public static int64 M() cil managed } + [Theory] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Test + { + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .namespace NS + { + .class public auto ansi Test + { + .method public static void M() cil managed + { + """)] + [InlineData(".class public auto ansi")] + [InlineData(".method public static void")] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Test + { + .method public static void M() cil managed + { + .try + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi Test + { + .method public static void M(int32 .method cil managed + { + .maxstack 2 + ret + } + } + """)] + [InlineData(""" + .assembly extern mscorlib { } + .assembly test { } + .class public auto ansi + { + .method public instance void M() cil managed + { + .override [mscorlib]System.Object::ToString + ret + } + } + """)] + public void TruncatedDocument_ReportsDiagnosticsInsteadOfThrowing(string source) + { + var diagnostics = DocumentCompilerTestHelpers.CompileAndGetDiagnostics(source, new Options()); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); + } + + [Theory] + [InlineData(".assembly extern { }")] + [InlineData(".mresource public { }")] + [InlineData(".class public auto ansi Test { .event { } }")] + [InlineData(".class public auto ansi Test { .property { } }")] + [InlineData(""" + .class public auto ansi Test + { + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor(string) = { string( } + } + """)] + [InlineData(""" + .class public auto ansi Test + { + .method public static void M(int32,) cil managed + { + ret + } + } + """)] + [InlineData(".class public auto ansi Test { .field public }")] + [InlineData(".typedef")] + [InlineData(".custom")] + [InlineData(".class flags( public Test { }")] + [InlineData(".class public auto ansi Test<+> { }")] + [InlineData(".class public auto ansi Test { .field marshal( int32 F }")] + [InlineData(".class public auto ansi Test { .field public int32 F = bytearray( }")] + [InlineData(""" + .class public auto ansi Test + { + .method pinvokeimpl( public static void M() cil managed + { + ret + } + } + """)] + [InlineData(""" + .class public auto ansi Test + { + .method public static void M(,) cil managed + { + ret + } + } + """)] + [InlineData(""" + .class public auto ansi Test + { + .method public static void M() cil managed + { + .custom + ret + } + } + """)] + [InlineData(".permission demand class X (Name = )")] + [InlineData(".class extern { }")] + [InlineData(".class public auto ansi Test { .export public { } }")] + [InlineData(".assembly extern Name { .ver : }")] + public void MalformedTypedGrammarValues_ReportParserDiagnosticsInsteadOfThrowing(string source) + { + var diagnostics = DocumentCompilerTestHelpers.CompileAndGetDiagnostics(source, new Options()); + + Assert.Contains(diagnostics, diagnostic => diagnostic.Id == "Parser"); + } + + public static TheoryData TruncatedDirectiveMutations + { + get + { + string[] sources = + [ + ".assembly extern Dependency { .publickeytoken = (01 02 03 04) .ver 1:2:3:4 }", + ".mresource public Resource { .assembly extern Dependency }", + ".class extern public Exported { .assembly extern Dependency }", + ".typedef method instance void [mscorlib]System.Object::.ctor() as Constructor", + ".permission demand [mscorlib]System.Security.Permissions.SecurityPermissionAttribute = { }", + """ + .class public auto ansi Test extends [mscorlib]System.Object implements [mscorlib]System.IDisposable + { + .field public marshal(int32) int32 F = int32(1) + .event specialname [mscorlib]System.EventHandler E { } + .property specialname int32 P() { } + .method public static void M(int32 value) cil managed + { + .custom instance void [mscorlib]System.ObsoleteAttribute::.ctor() = (01 00 00 00) + ret + } + } + """ + ]; + + HashSet uniqueMutations = new(StringComparer.Ordinal); + TheoryData mutations = new(); + foreach (string source in sources) + { + for (int i = 1; i < source.Length; i++) + { + if (!char.IsWhiteSpace(source[i - 1]) && + char.IsWhiteSpace(source[i])) + { + string mutation = source.Substring(0, i); + if (uniqueMutations.Add(mutation)) + { + mutations.Add(mutation, false); + mutations.Add(mutation, true); + } + } + } + } + + return mutations; + } + } + + [Theory] + [MemberData(nameof(TruncatedDirectiveMutations))] + public void TruncatedDirectiveMutationCorpus_ReportsDiagnosticsInsteadOfThrowing( + string source, + bool errorTolerant) + { + ImmutableArray diagnostics = + DocumentCompilerTestHelpers.CompileAndGetDiagnostics( + source, + new Options { ErrorTolerant = errorTolerant }); + + Assert.Contains( + diagnostics, + diagnostic => diagnostic.Severity == DiagnosticSeverity.Error); + } + [Fact] public void ParserErrorListener_ReportsSyntaxErrors() { diff --git a/src/tools/ilasm/tests/ILAssembler.Tests/TypedefTests.cs b/src/tools/ilasm/tests/ILAssembler.Tests/TypedefTests.cs index 5f4f3b8fc37d29..e06dacb225d0c5 100644 --- a/src/tools/ilasm/tests/ILAssembler.Tests/TypedefTests.cs +++ b/src/tools/ilasm/tests/ILAssembler.Tests/TypedefTests.cs @@ -175,18 +175,22 @@ ldsfld ValueAlias Assert.Equal(MetadataTokens.GetToken(fieldHandle), fieldToken); - var attributes = reader.GetCustomAttributes(testTypeHandle) + var fieldAttributes = reader.GetCustomAttributes(fieldHandle) .Select(reader.GetCustomAttribute) .Select(attribute => attribute.DecodeValue(DocumentCompilerTestHelpers.Decoder)) .ToArray(); - Assert.Equal(2, attributes.Length); - Assert.Contains(attributes, attribute => attribute.FixedArguments.Length == 0); - Assert.Contains( - attributes, - attribute => - attribute.FixedArguments.Length == 1 && - attribute.FixedArguments[0].Type == "bool" && - Equals(attribute.FixedArguments[0].Value, true)); + CustomAttributeValue fieldAttribute = Assert.Single(fieldAttributes); + Assert.Empty(fieldAttribute.FixedArguments); + + var typeAttributes = reader.GetCustomAttributes(testTypeHandle) + .Select(reader.GetCustomAttribute) + .Select(attribute => attribute.DecodeValue(DocumentCompilerTestHelpers.Decoder)) + .ToArray(); + CustomAttributeValue typeAttribute = Assert.Single(typeAttributes); + CustomAttributeTypedArgument argument = + Assert.Single(typeAttribute.FixedArguments); + Assert.Equal("bool", argument.Type); + Assert.Equal(true, argument.Value); } }