IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ModuleTable.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2012 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*/
24using System.Diagnostics;
25using System.Reflection.Metadata;
26using System.Reflection.Metadata.Ecma335;
27
29
31{
32 sealed class ModuleTable : Table<ModuleTable.Record>
33 {
34
35 internal struct Record
36 {
37
38 internal short Generation;
39 internal StringHandle Name; // -> StringHeap
40 internal GuidHandle Mvid; // -> GuidHeap
41 internal GuidHandle EncId; // -> GuidHeap
42 internal GuidHandle EncBaseId; // -> GuidHeap
43
44 }
45
46 internal const int Index = 0x00;
47
48 internal override void Read(IKVM.Reflection.Reader.MetadataReader mr)
49 {
50 for (int i = 0; i < records.Length; i++)
51 {
52 records[i].Generation = mr.ReadInt16();
53 records[i].Name = MetadataTokens.StringHandle(mr.ReadStringIndex());
54 records[i].Mvid = MetadataTokens.GuidHandle(mr.ReadGuidIndex());
55 records[i].EncId = MetadataTokens.GuidHandle(mr.ReadGuidIndex());
56 records[i].EncBaseId = MetadataTokens.GuidHandle(mr.ReadGuidIndex());
57 }
58 }
59
60 internal override void Write(ModuleBuilder module)
61 {
62 for (int i = 0; i < rowCount; i++)
63 {
64 var h = module.Metadata.AddModule(
65 records[i].Generation,
66 records[i].Name,
67 records[i].Mvid,
68 records[i].EncId,
69 records[i].EncBaseId);
70
71 Debug.Assert(MetadataTokens.GetRowNumber(h) == i + 1);
72 }
73 }
74
75 internal void Add(short generation, StringHandle name, GuidHandle mvid, GuidHandle encid, GuidHandle encbaseid)
76 {
77 var record = new Record();
78 record.Generation = generation;
79 record.Name = name;
80 record.Mvid = mvid;
81 record.EncId = encid;
82 record.EncBaseId = encbaseid;
83 AddRecord(record);
84 }
85
86 }
87
88}
global::java.lang.invoke.LambdaForm.Name Name