/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; using dnlib.DotNet.MD; namespace dnSpy.AsmEditor.Compiler.MDEditor { static class RawRowColumnReader { public delegate uint ReadColumnDelegate(ref TRow row, int index) where TRow : struct; public static Delegate GetDelegate(Table table) { switch (table) { case Table.Module: return ReadModuleColumn; case Table.TypeRef: return ReadTypeRefColumn; case Table.TypeDef: return ReadTypeDefColumn; case Table.FieldPtr: return ReadFieldPtrColumn; case Table.Field: return ReadFieldColumn; case Table.MethodPtr: return ReadMethodPtrColumn; case Table.Method: return ReadMethodColumn; case Table.ParamPtr: return ReadParamPtrColumn; case Table.Param: return ReadParamColumn; case Table.InterfaceImpl: return ReadInterfaceImplColumn; case Table.MemberRef: return ReadMemberRefColumn; case Table.Constant: return ReadConstantColumn; case Table.CustomAttribute: return ReadCustomAttributeColumn; case Table.FieldMarshal: return ReadFieldMarshalColumn; case Table.DeclSecurity: return ReadDeclSecurityColumn; case Table.ClassLayout: return ReadClassLayoutColumn; case Table.FieldLayout: return ReadFieldLayoutColumn; case Table.StandAloneSig: return ReadStandAloneSigColumn; case Table.EventMap: return ReadEventMapColumn; case Table.EventPtr: return ReadEventPtrColumn; case Table.Event: return ReadEventColumn; case Table.PropertyMap: return ReadPropertyMapColumn; case Table.PropertyPtr: return ReadPropertyPtrColumn; case Table.Property: return ReadPropertyColumn; case Table.MethodSemantics: return ReadMethodSemanticsColumn; case Table.MethodImpl: return ReadMethodImplColumn; case Table.ModuleRef: return ReadModuleRefColumn; case Table.TypeSpec: return ReadTypeSpecColumn; case Table.ImplMap: return ReadImplMapColumn; case Table.FieldRVA: return ReadFieldRVAColumn; case Table.ENCLog: return ReadENCLogColumn; case Table.ENCMap: return ReadENCMapColumn; case Table.Assembly: return ReadAssemblyColumn; case Table.AssemblyProcessor: return ReadAssemblyProcessorColumn; case Table.AssemblyOS: return ReadAssemblyOSColumn; case Table.AssemblyRef: return ReadAssemblyRefColumn; case Table.AssemblyRefProcessor: return ReadAssemblyRefProcessorColumn; case Table.AssemblyRefOS: return ReadAssemblyRefOSColumn; case Table.File: return ReadFileColumn; case Table.ExportedType: return ReadExportedTypeColumn; case Table.ManifestResource: return ReadManifestResourceColumn; case Table.NestedClass: return ReadNestedClassColumn; case Table.GenericParam: return ReadGenericParamColumn; case Table.MethodSpec: return ReadMethodSpecColumn; case Table.GenericParamConstraint: return ReadGenericParamConstraintColumn; case Table.Document: return ReadDocumentColumn; case Table.MethodDebugInformation: return ReadMethodDebugInformationColumn; case Table.LocalScope: return ReadLocalScopeColumn; case Table.LocalVariable: return ReadLocalVariableColumn; case Table.LocalConstant: return ReadLocalConstantColumn; case Table.ImportScope: return ReadImportScopeColumn; case Table.StateMachineMethod: return ReadStateMachineMethodColumn; case Table.CustomDebugInformation: return ReadCustomDebugInformationColumn; default: throw new ArgumentOutOfRangeException(nameof(table)); } } public static readonly ReadColumnDelegate ReadModuleColumn = ReadModuleColumnMethod; public static readonly ReadColumnDelegate ReadTypeRefColumn = ReadTypeRefColumnMethod; public static readonly ReadColumnDelegate ReadTypeDefColumn = ReadTypeDefColumnMethod; public static readonly ReadColumnDelegate ReadFieldPtrColumn = ReadFieldPtrColumnMethod; public static readonly ReadColumnDelegate ReadFieldColumn = ReadFieldColumnMethod; public static readonly ReadColumnDelegate ReadMethodPtrColumn = ReadMethodPtrColumnMethod; public static readonly ReadColumnDelegate ReadMethodColumn = ReadMethodColumnMethod; public static readonly ReadColumnDelegate ReadParamPtrColumn = ReadParamPtrColumnMethod; public static readonly ReadColumnDelegate ReadParamColumn = ReadParamColumnMethod; public static readonly ReadColumnDelegate ReadInterfaceImplColumn = ReadInterfaceImplColumnMethod; public static readonly ReadColumnDelegate ReadMemberRefColumn = ReadMemberRefColumnMethod; public static readonly ReadColumnDelegate ReadConstantColumn = ReadConstantColumnMethod; public static readonly ReadColumnDelegate ReadCustomAttributeColumn = ReadCustomAttributeColumnMethod; public static readonly ReadColumnDelegate ReadFieldMarshalColumn = ReadFieldMarshalColumnMethod; public static readonly ReadColumnDelegate ReadDeclSecurityColumn = ReadDeclSecurityColumnMethod; public static readonly ReadColumnDelegate ReadClassLayoutColumn = ReadClassLayoutColumnMethod; public static readonly ReadColumnDelegate ReadFieldLayoutColumn = ReadFieldLayoutColumnMethod; public static readonly ReadColumnDelegate ReadStandAloneSigColumn = ReadStandAloneSigColumnMethod; public static readonly ReadColumnDelegate ReadEventMapColumn = ReadEventMapColumnMethod; public static readonly ReadColumnDelegate ReadEventPtrColumn = ReadEventPtrColumnMethod; public static readonly ReadColumnDelegate ReadEventColumn = ReadEventColumnMethod; public static readonly ReadColumnDelegate ReadPropertyMapColumn = ReadPropertyMapColumnMethod; public static readonly ReadColumnDelegate ReadPropertyPtrColumn = ReadPropertyPtrColumnMethod; public static readonly ReadColumnDelegate ReadPropertyColumn = ReadPropertyColumnMethod; public static readonly ReadColumnDelegate ReadMethodSemanticsColumn = ReadMethodSemanticsColumnMethod; public static readonly ReadColumnDelegate ReadMethodImplColumn = ReadMethodImplColumnMethod; public static readonly ReadColumnDelegate ReadModuleRefColumn = ReadModuleRefColumnMethod; public static readonly ReadColumnDelegate ReadTypeSpecColumn = ReadTypeSpecColumnMethod; public static readonly ReadColumnDelegate ReadImplMapColumn = ReadImplMapColumnMethod; public static readonly ReadColumnDelegate ReadFieldRVAColumn = ReadFieldRVAColumnMethod; public static readonly ReadColumnDelegate ReadENCLogColumn = ReadENCLogColumnMethod; public static readonly ReadColumnDelegate ReadENCMapColumn = ReadENCMapColumnMethod; public static readonly ReadColumnDelegate ReadAssemblyColumn = ReadAssemblyColumnMethod; public static readonly ReadColumnDelegate ReadAssemblyProcessorColumn = ReadAssemblyProcessorColumnMethod; public static readonly ReadColumnDelegate ReadAssemblyOSColumn = ReadAssemblyOSColumnMethod; public static readonly ReadColumnDelegate ReadAssemblyRefColumn = ReadAssemblyRefColumnMethod; public static readonly ReadColumnDelegate ReadAssemblyRefProcessorColumn = ReadAssemblyRefProcessorColumnMethod; public static readonly ReadColumnDelegate ReadAssemblyRefOSColumn = ReadAssemblyRefOSColumnMethod; public static readonly ReadColumnDelegate ReadFileColumn = ReadFileColumnMethod; public static readonly ReadColumnDelegate ReadExportedTypeColumn = ReadExportedTypeColumnMethod; public static readonly ReadColumnDelegate ReadManifestResourceColumn = ReadManifestResourceColumnMethod; public static readonly ReadColumnDelegate ReadNestedClassColumn = ReadNestedClassColumnMethod; public static readonly ReadColumnDelegate ReadGenericParamColumn = ReadGenericParamColumnMethod; public static readonly ReadColumnDelegate ReadMethodSpecColumn = ReadMethodSpecColumnMethod; public static readonly ReadColumnDelegate ReadGenericParamConstraintColumn = ReadGenericParamConstraintColumnMethod; public static readonly ReadColumnDelegate ReadDocumentColumn = ReadDocumentColumnMethod; public static readonly ReadColumnDelegate ReadMethodDebugInformationColumn = ReadMethodDebugInformationColumnMethod; public static readonly ReadColumnDelegate ReadLocalScopeColumn = ReadLocalScopeColumnMethod; public static readonly ReadColumnDelegate ReadLocalVariableColumn = ReadLocalVariableColumnMethod; public static readonly ReadColumnDelegate ReadLocalConstantColumn = ReadLocalConstantColumnMethod; public static readonly ReadColumnDelegate ReadImportScopeColumn = ReadImportScopeColumnMethod; public static readonly ReadColumnDelegate ReadStateMachineMethodColumn = ReadStateMachineMethodColumnMethod; public static readonly ReadColumnDelegate ReadCustomDebugInformationColumn = ReadCustomDebugInformationColumnMethod; static uint ReadModuleColumnMethod(ref RawModuleRow row, int index) => row[index]; static uint ReadTypeRefColumnMethod(ref RawTypeRefRow row, int index) => row[index]; static uint ReadTypeDefColumnMethod(ref RawTypeDefRow row, int index) => row[index]; static uint ReadFieldPtrColumnMethod(ref RawFieldPtrRow row, int index) => row[index]; static uint ReadFieldColumnMethod(ref RawFieldRow row, int index) => row[index]; static uint ReadMethodPtrColumnMethod(ref RawMethodPtrRow row, int index) => row[index]; static uint ReadMethodColumnMethod(ref RawMethodRow row, int index) => row[index]; static uint ReadParamPtrColumnMethod(ref RawParamPtrRow row, int index) => row[index]; static uint ReadParamColumnMethod(ref RawParamRow row, int index) => row[index]; static uint ReadInterfaceImplColumnMethod(ref RawInterfaceImplRow row, int index) => row[index]; static uint ReadMemberRefColumnMethod(ref RawMemberRefRow row, int index) => row[index]; static uint ReadConstantColumnMethod(ref RawConstantRow row, int index) => row[index]; static uint ReadCustomAttributeColumnMethod(ref RawCustomAttributeRow row, int index) => row[index]; static uint ReadFieldMarshalColumnMethod(ref RawFieldMarshalRow row, int index) => row[index]; static uint ReadDeclSecurityColumnMethod(ref RawDeclSecurityRow row, int index) => row[index]; static uint ReadClassLayoutColumnMethod(ref RawClassLayoutRow row, int index) => row[index]; static uint ReadFieldLayoutColumnMethod(ref RawFieldLayoutRow row, int index) => row[index]; static uint ReadStandAloneSigColumnMethod(ref RawStandAloneSigRow row, int index) => row[index]; static uint ReadEventMapColumnMethod(ref RawEventMapRow row, int index) => row[index]; static uint ReadEventPtrColumnMethod(ref RawEventPtrRow row, int index) => row[index]; static uint ReadEventColumnMethod(ref RawEventRow row, int index) => row[index]; static uint ReadPropertyMapColumnMethod(ref RawPropertyMapRow row, int index) => row[index]; static uint ReadPropertyPtrColumnMethod(ref RawPropertyPtrRow row, int index) => row[index]; static uint ReadPropertyColumnMethod(ref RawPropertyRow row, int index) => row[index]; static uint ReadMethodSemanticsColumnMethod(ref RawMethodSemanticsRow row, int index) => row[index]; static uint ReadMethodImplColumnMethod(ref RawMethodImplRow row, int index) => row[index]; static uint ReadModuleRefColumnMethod(ref RawModuleRefRow row, int index) => row[index]; static uint ReadTypeSpecColumnMethod(ref RawTypeSpecRow row, int index) => row[index]; static uint ReadImplMapColumnMethod(ref RawImplMapRow row, int index) => row[index]; static uint ReadFieldRVAColumnMethod(ref RawFieldRVARow row, int index) => row[index]; static uint ReadENCLogColumnMethod(ref RawENCLogRow row, int index) => row[index]; static uint ReadENCMapColumnMethod(ref RawENCMapRow row, int index) => row[index]; static uint ReadAssemblyColumnMethod(ref RawAssemblyRow row, int index) => row[index]; static uint ReadAssemblyProcessorColumnMethod(ref RawAssemblyProcessorRow row, int index) => row[index]; static uint ReadAssemblyOSColumnMethod(ref RawAssemblyOSRow row, int index) => row[index]; static uint ReadAssemblyRefColumnMethod(ref RawAssemblyRefRow row, int index) => row[index]; static uint ReadAssemblyRefProcessorColumnMethod(ref RawAssemblyRefProcessorRow row, int index) => row[index]; static uint ReadAssemblyRefOSColumnMethod(ref RawAssemblyRefOSRow row, int index) => row[index]; static uint ReadFileColumnMethod(ref RawFileRow row, int index) => row[index]; static uint ReadExportedTypeColumnMethod(ref RawExportedTypeRow row, int index) => row[index]; static uint ReadManifestResourceColumnMethod(ref RawManifestResourceRow row, int index) => row[index]; static uint ReadNestedClassColumnMethod(ref RawNestedClassRow row, int index) => row[index]; static uint ReadGenericParamColumnMethod(ref RawGenericParamRow row, int index) => row[index]; static uint ReadMethodSpecColumnMethod(ref RawMethodSpecRow row, int index) => row[index]; static uint ReadGenericParamConstraintColumnMethod(ref RawGenericParamConstraintRow row, int index) => row[index]; static uint ReadDocumentColumnMethod(ref RawDocumentRow row, int index) => row[index]; static uint ReadMethodDebugInformationColumnMethod(ref RawMethodDebugInformationRow row, int index) => row[index]; static uint ReadLocalScopeColumnMethod(ref RawLocalScopeRow row, int index) => row[index]; static uint ReadLocalVariableColumnMethod(ref RawLocalVariableRow row, int index) => row[index]; static uint ReadLocalConstantColumnMethod(ref RawLocalConstantRow row, int index) => row[index]; static uint ReadImportScopeColumnMethod(ref RawImportScopeRow row, int index) => row[index]; static uint ReadStateMachineMethodColumnMethod(ref RawStateMachineMethodRow row, int index) => row[index]; static uint ReadCustomDebugInformationColumnMethod(ref RawCustomDebugInformationRow row, int index) => row[index]; } }