Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
XmlILModule.cs
Go to the documentation of this file.
7
9
10internal sealed class XmlILModule
11{
12 private static long s_assemblyId;
13
14 private static readonly ModuleBuilder s_LREModule = CreateLREModule();
15
17
19
20 private readonly bool _useLRE;
21
22 private readonly bool _emitSymbols;
23
24 public bool EmitSymbols => _emitSymbols;
25
27 {
30 assemblyBuilder.SetCustomAttribute(new CustomAttributeBuilder(XmlILConstructors.Transparent, Array.Empty<object>()));
31 return assemblyBuilder.DefineDynamicModule("System.Xml.Xsl.CompiledQuery");
32 }
33
35 {
37 _emitSymbols = false;
38 _useLRE = false;
39 _methods = new Hashtable();
40 }
41
42 public XmlILModule(bool useLRE, bool emitSymbols)
43 {
46 _methods = new Hashtable();
47 if (!useLRE)
48 {
51 assemblyBuilder.SetCustomAttribute(new CustomAttributeBuilder(XmlILConstructors.Transparent, Array.Empty<object>()));
52 if (emitSymbols)
53 {
55 assemblyBuilder.SetCustomAttribute(new CustomAttributeBuilder(XmlILConstructors.Debuggable, new object[1] { debuggingModes }));
56 }
57 ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule("System.Xml.Xsl.CompiledQuery");
58 _typeBldr = moduleBuilder.DefineType("System.Xml.Xsl.CompiledQuery.Query", TypeAttributes.Public);
59 }
60 }
61
63 {
64 int num = 1;
65 string text = name;
66 bool flag = (xmlAttrs & XmlILMethodAttributes.Raw) != 0;
67 while (_methods[name] != null)
68 {
69 num++;
70 name = text + " (" + num + ")";
71 }
72 if (!flag)
73 {
74 Type[] array = new Type[paramTypes.Length + 1];
76 Array.Copy(paramTypes, 0, array, 1, paramTypes.Length);
78 }
80 if (!_useLRE)
81 {
83 if (_emitSymbols && (xmlAttrs & XmlILMethodAttributes.NonUser) != 0)
84 {
85 methodBuilder.SetCustomAttribute(new CustomAttributeBuilder(XmlILConstructors.StepThrough, Array.Empty<object>()));
86 methodBuilder.SetCustomAttribute(new CustomAttributeBuilder(XmlILConstructors.NonUserCode, Array.Empty<object>()));
87 }
88 if (!flag)
89 {
90 methodBuilder.DefineParameter(1, ParameterAttributes.None, "{urn:schemas-microsoft-com:xslt-debug}runtime");
91 }
92 for (int i = 0; i < paramNames.Length; i++)
93 {
94 if (paramNames[i] != null && paramNames[i].Length != 0)
95 {
96 methodBuilder.DefineParameter(i + (flag ? 1 : 2), ParameterAttributes.None, paramNames[i]);
97 }
98 }
100 }
101 else
102 {
106 }
107 _methods[name] = methodInfo;
108 return methodInfo;
109 }
110
112 {
114 if (dynamicMethod != null)
115 {
117 }
119 if (methodBuilder != null)
120 {
122 }
123 return ((ConstructorBuilder)methInfo).GetILGenerator();
124 }
125
126 public MethodInfo FindMethod(string name)
127 {
128 return (MethodInfo)_methods[name];
129 }
130
131 public FieldInfo DefineInitializedData(string name, byte[] data)
132 {
133 return _typeBldr.DefineInitializedData(name, data, FieldAttributes.Private | FieldAttributes.Static);
134 }
135
137 {
139 }
140
145
146 public void BakeMethods()
147 {
148 if (_useLRE)
149 {
150 return;
151 }
153 Hashtable hashtable = new Hashtable(_methods.Count);
154 foreach (string key in _methods.Keys)
155 {
156 hashtable[key] = type.GetMethod(key, BindingFlags.Static | BindingFlags.NonPublic);
157 }
158 _methods = hashtable;
159 _typeBldr = null;
160 }
161
163 {
164 if (!_useLRE)
165 {
167 }
168 return ((DynamicMethod)_methods[name]).CreateDelegate(typDelegate);
169 }
170
172 {
175 assemblyName.Name = "System.Xml.Xsl.CompiledQuery." + s_assemblyId;
176 return assemblyName;
177 }
178}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
virtual ICollection Keys
Definition Hashtable.cs:532
static ? Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure)
Definition Delegate.cs:152
static AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access)
static int DefineType(QCallModule module, string fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens)
static int DefineMethod(QCallModule module, int tkParent, string name, byte[] signature, int sigLength, MethodAttributes attributes)
FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes)
ConstructorBuilder DefineTypeInitializer()
static int DefineField(QCallModule module, int tkParent, string name, byte[] signature, int sigLength, FieldAttributes attributes)
virtual Type AsType()
Definition TypeInfo.cs:106
static int Increment(ref int location)
static readonly ConstructorInfo Transparent
static readonly ConstructorInfo StepThrough
static readonly ConstructorInfo NonUserCode
static readonly ConstructorInfo Debuggable
static readonly ModuleBuilder s_LREModule
static ModuleBuilder CreateLREModule()
XmlILModule(bool useLRE, bool emitSymbols)
static ILGenerator DefineMethodBody(MethodBase methInfo)
FieldInfo DefineField(string fieldName, Type type)
MethodInfo DefineMethod(string name, Type returnType, Type[] paramTypes, string[] paramNames, XmlILMethodAttributes xmlAttrs)
ConstructorInfo DefineTypeInitializer()
MethodInfo FindMethod(string name)
FieldInfo DefineInitializedData(string name, byte[] data)
static AssemblyName CreateAssemblyName()
Delegate CreateDelegate(string name, Type typDelegate)
XmlILModule(TypeBuilder typeBldr)