IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
MetadataRW.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
25{
26
30 abstract class MetadataRW
31 {
32
33 internal readonly bool bigStrings;
34 internal readonly bool bigGuids;
35 internal readonly bool bigBlobs;
36 internal readonly bool bigResolutionScope;
37 internal readonly bool bigTypeDefOrRef;
38 internal readonly bool bigMemberRefParent;
39 internal readonly bool bigHasCustomAttribute;
40 internal readonly bool bigCustomAttributeType;
41 internal readonly bool bigMethodDefOrRef;
42 internal readonly bool bigHasConstant;
43 internal readonly bool bigHasSemantics;
44 internal readonly bool bigHasFieldMarshal;
45 internal readonly bool bigHasDeclSecurity;
46 internal readonly bool bigTypeOrMethodDef;
47 internal readonly bool bigMemberForwarded;
48 internal readonly bool bigImplementation;
49 internal readonly bool bigField;
50 internal readonly bool bigMethodDef;
51 internal readonly bool bigParam;
52 internal readonly bool bigTypeDef;
53 internal readonly bool bigProperty;
54 internal readonly bool bigEvent;
55 internal readonly bool bigGenericParam;
56 internal readonly bool bigModuleRef;
57
65 protected MetadataRW(Module module, bool bigStrings, bool bigGuids, bool bigBlobs)
66 {
67 this.bigStrings = bigStrings;
68 this.bigGuids = bigGuids;
69 this.bigBlobs = bigBlobs;
70 this.bigField = module.FieldTable.IsBig;
71 this.bigMethodDef = module.MethodDefTable.IsBig;
72 this.bigParam = module.ParamTable.IsBig;
73 this.bigTypeDef = module.TypeDefTable.IsBig;
74 this.bigProperty = module.PropertyTable.IsBig;
75 this.bigEvent = module.EventTable.IsBig;
76 this.bigGenericParam = module.GenericParamTable.IsBig;
77 this.bigModuleRef = module.ModuleRefTable.IsBig;
78 this.bigResolutionScope = IsBig(2, module.ModuleTable, module.ModuleRefTable, module.AssemblyRefTable, module.TypeRefTable);
79 this.bigTypeDefOrRef = IsBig(2, module.TypeDefTable, module.TypeRefTable, module.TypeSpecTable);
80 this.bigMemberRefParent = IsBig(3, module.TypeDefTable, module.TypeRefTable, module.ModuleRefTable, module.MethodDefTable, module.TypeSpecTable);
81 this.bigMethodDefOrRef = IsBig(1, module.MethodDefTable, module.MemberRefTable);
82 this.bigHasCustomAttribute = IsBig(5, module.MethodDefTable, module.FieldTable, module.TypeRefTable, module.TypeDefTable, module.ParamTable, module.InterfaceImplTable, module.MemberRefTable, module.ModuleTable, module.DeclSecurityTable, module.PropertyTable, module.EventTable, module.StandAloneSigTable, module.ModuleRefTable, module.TypeSpecTable, module.AssemblyTable, module.AssemblyRefTable, module.FileTable, module.ExportedTypeTable, module.ManifestResourceTable, module.GenericParamTable, module.GenericParamConstraint, module.MethodSpecTable);
83 this.bigCustomAttributeType = IsBig(3, module.MethodDefTable, module.MemberRefTable);
84 this.bigHasConstant = IsBig(2, module.FieldTable, module.ParamTable, module.PropertyTable);
85 this.bigHasSemantics = IsBig(1, module.EventTable, module.PropertyTable);
86 this.bigHasFieldMarshal = IsBig(1, module.FieldTable, module.ParamTable);
87 this.bigHasDeclSecurity = IsBig(2, module.TypeDefTable, module.MethodDefTable, module.AssemblyTable);
88 this.bigTypeOrMethodDef = IsBig(1, module.TypeDefTable, module.MethodDefTable);
89 this.bigMemberForwarded = IsBig(1, module.FieldTable, module.MethodDefTable);
90 this.bigImplementation = IsBig(2, module.FileTable, module.AssemblyRefTable, module.ExportedTypeTable);
91 }
92
93 static bool IsBig(int bitsUsed, params Table[] tables)
94 {
95 var limit = 1 << (16 - bitsUsed);
96 foreach (var table in tables)
97 if (table.RowCount >= limit)
98 return true;
99
100 return false;
101 }
102
103 }
104
105}
Base class for MetadataReader and MetadataWriter.
Definition MetadataRW.cs:31
MetadataRW(Module module, bool bigStrings, bool bigGuids, bool bigBlobs)
Initializes a new instance.
Definition MetadataRW.cs:65