IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ImportsEncoder.cs
Go to the documentation of this file.
1using System;
2using System.Reflection.Metadata;
3using System.Reflection.Metadata.Ecma335;
4
6{
7
9 {
10
11 readonly BlobBuilder writer;
12 int count;
13
19 public ImportsEncoder(BlobBuilder writer)
20 {
21 this.writer = writer ?? throw new ArgumentNullException(nameof(writer));
22 }
23
27 public int Count => count;
28
29 public void AliasAssemblyReference(BlobHandle alias, AssemblyReferenceHandle assembly)
30 {
31 // <import> ::= AliasAssemblyReference <alias> <target-assembly>
32 writer.WriteByte((byte)ImportDefinitionKind.AliasAssemblyReference);
33 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(alias));
34 writer.WriteCompressedInteger(MetadataTokens.GetRowNumber(assembly));
35 }
36
37 public void AliasType(BlobHandle alias, EntityHandle targetType)
38 {
39 // <import> ::= AliasType <alias> <target-type>
40 writer.WriteByte((byte)ImportDefinitionKind.AliasType);
41 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(alias));
42 writer.WriteCompressedInteger(CodedIndex.TypeDefOrRefOrSpec(targetType));
43 }
44
45 public void ImportType(EntityHandle targetType)
46 {
47 // <import> ::= AliasType <alias> <target-type>
48 writer.WriteByte((byte)ImportDefinitionKind.ImportType);
49 writer.WriteCompressedInteger(CodedIndex.TypeDefOrRefOrSpec(targetType));
50 }
51
52 public void AliasAssemblyNamespace(BlobHandle alias, AssemblyReferenceHandle targetAssembly, BlobHandle namespaceName)
53 {
54 // <import> ::= AliasAssemblyNamespace <alias> <target-assembly> <target-namespace>
55 writer.WriteByte((byte)ImportDefinitionKind.AliasAssemblyNamespace);
56 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(alias));
57 writer.WriteCompressedInteger(MetadataTokens.GetRowNumber(targetAssembly));
58 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(namespaceName));
59 }
60
61 public void ImportAssemblyNamespace(AssemblyReferenceHandle targetAssembly, BlobHandle namespaceName)
62 {
63 // <import> ::= ImportAssemblyNamespace <target-assembly> <target-namespace>
64 writer.WriteByte((byte)ImportDefinitionKind.ImportAssemblyNamespace);
65 writer.WriteCompressedInteger(MetadataTokens.GetRowNumber(targetAssembly));
66 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(namespaceName));
67 }
68
69 public void AliasNamespace(BlobHandle alias, BlobHandle namespaceName)
70 {
71 // <import> ::= AliasNamespace <alias> <target-namespace>
72 writer.WriteByte((byte)ImportDefinitionKind.AliasNamespace);
73 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(alias));
74 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(namespaceName));
75 }
76
77 public void ImportNamespace(BlobHandle namespaceName)
78 {
79 // <import> ::= ImportNamespace <target-namespace>
80 writer.WriteByte((byte)ImportDefinitionKind.ImportNamespace);
81 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(namespaceName));
82 }
83
84 public void ImportReferenceAlias(BlobHandle alias)
85 {
86 // <import> ::= ImportReferenceAlias <alias>
87 writer.WriteByte((byte)ImportDefinitionKind.ImportAssemblyReferenceAlias);
88 writer.WriteCompressedInteger(MetadataTokens.GetHeapOffset(alias));
89 }
90
91 }
92
93}
ImportsEncoder(BlobBuilder writer)
Initializes a new instance.
void ImportReferenceAlias(BlobHandle alias)
void ImportType(EntityHandle targetType)
void AliasAssemblyNamespace(BlobHandle alias, AssemblyReferenceHandle targetAssembly, BlobHandle namespaceName)
void ImportNamespace(BlobHandle namespaceName)
void AliasType(BlobHandle alias, EntityHandle targetType)
void AliasAssemblyReference(BlobHandle alias, AssemblyReferenceHandle assembly)
void AliasNamespace(BlobHandle alias, BlobHandle namespaceName)
void ImportAssemblyNamespace(AssemblyReferenceHandle targetAssembly, BlobHandle namespaceName)
int Count
Gets the number of imports written.