File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Cpp2IL.Core/Utils/AsmResolver Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ using AsmResolver . DotNet ;
2
+ using AsmResolver . DotNet . Signatures ;
3
+ using Cpp2IL . Core . Model . Contexts ;
4
+
5
+ namespace Cpp2IL . Core . Utils . AsmResolver ;
6
+
7
+ public static class ContextToFieldDescriptor
8
+ {
9
+ private static FieldDefinition GetFieldDefinition ( this FieldAnalysisContext context )
10
+ {
11
+ return context . GetExtraData < FieldDefinition > ( "AsmResolverField" ) ?? throw new ( $ "AsmResolver field not found in method analysis context for { context } ") ;
12
+ }
13
+
14
+ private static FieldSignature ToFieldSignature ( this FieldAnalysisContext context , ModuleDefinition parentModule )
15
+ {
16
+ return new FieldSignature ( context . ToTypeSignature ( parentModule ) ) ;
17
+ }
18
+
19
+ public static IFieldDescriptor ToFieldDescriptor ( this FieldAnalysisContext context , ModuleDefinition parentModule )
20
+ {
21
+ return context is ConcreteGenericFieldAnalysisContext concreteField
22
+ ? concreteField . ToFieldDescriptor ( parentModule )
23
+ : parentModule . DefaultImporter . ImportField ( context . GetFieldDefinition ( ) ) ;
24
+ }
25
+
26
+ public static IFieldDescriptor ToFieldDescriptor ( this ConcreteGenericFieldAnalysisContext context , ModuleDefinition parentModule )
27
+ {
28
+ return new MemberReference (
29
+ context . DeclaringType . ToTypeSignature ( parentModule ) . ToTypeDefOrRef ( ) ,
30
+ context . Name ,
31
+ context . BaseFieldContext . ToFieldSignature ( parentModule ) ) ;
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments