Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DynamicILInfo.cs
Go to the documentation of this file.
2
3public class DynamicILInfo
4{
6
8
9 private byte[] m_exceptions;
10
11 private byte[] m_code;
12
13 private byte[] m_localSignature;
14
15 private int m_maxStackSize;
16
17 private int m_methodSignature;
18
19 internal byte[] LocalSignature => m_localSignature ?? (m_localSignature = SignatureHelper.GetLocalVarSigHelper().InternalGetSignatureArray());
20
21 internal byte[] Exceptions => m_exceptions;
22
23 internal byte[] Code => m_code;
24
26
28
30
31 internal DynamicILInfo(DynamicMethod method, byte[] methodSignature)
32 {
33 m_scope = new DynamicScope();
34 m_method = method;
35 m_methodSignature = m_scope.GetTokenFor(methodSignature);
36 m_exceptions = Array.Empty<byte>();
37 m_code = Array.Empty<byte>();
38 m_localSignature = Array.Empty<byte>();
39 }
40
42 {
43 dm.m_methodHandle = ModuleHandle.GetDynamicMethod(dm, module, m_method.Name, (byte[])m_scope[m_methodSignature], new DynamicResolver(this));
44 }
45
46 public void SetCode(byte[]? code, int maxStackSize)
47 {
48 m_code = ((code != null) ? ((byte[])code.Clone()) : Array.Empty<byte>());
49 m_maxStackSize = maxStackSize;
50 }
51
52 [CLSCompliant(false)]
53 public unsafe void SetCode(byte* code, int codeSize, int maxStackSize)
54 {
55 if (codeSize < 0)
56 {
58 }
59 if (codeSize > 0 && code == null)
60 {
61 throw new ArgumentNullException("code");
62 }
63 m_code = new Span<byte>(code, codeSize).ToArray();
64 m_maxStackSize = maxStackSize;
65 }
66
67 public void SetExceptions(byte[]? exceptions)
68 {
69 m_exceptions = ((exceptions != null) ? ((byte[])exceptions.Clone()) : Array.Empty<byte>());
70 }
71
72 [CLSCompliant(false)]
73 public unsafe void SetExceptions(byte* exceptions, int exceptionsSize)
74 {
75 if (exceptionsSize < 0)
76 {
78 }
79 if (exceptionsSize > 0 && exceptions == null)
80 {
81 throw new ArgumentNullException("exceptions");
82 }
83 m_exceptions = new Span<byte>(exceptions, exceptionsSize).ToArray();
84 }
85
86 public void SetLocalSignature(byte[]? localSignature)
87 {
88 m_localSignature = ((localSignature != null) ? ((byte[])localSignature.Clone()) : Array.Empty<byte>());
89 }
90
91 [CLSCompliant(false)]
92 public unsafe void SetLocalSignature(byte* localSignature, int signatureSize)
93 {
94 if (signatureSize < 0)
95 {
97 }
98 if (signatureSize > 0 && localSignature == null)
99 {
100 throw new ArgumentNullException("localSignature");
101 }
102 m_localSignature = new Span<byte>(localSignature, signatureSize).ToArray();
103 }
104
106 {
107 return DynamicScope.GetTokenFor(method);
108 }
109
110 public int GetTokenFor(DynamicMethod method)
111 {
112 return DynamicScope.GetTokenFor(method);
113 }
114
115 public int GetTokenFor(RuntimeMethodHandle method, RuntimeTypeHandle contextType)
116 {
117 return DynamicScope.GetTokenFor(method, contextType);
118 }
119
121 {
122 return DynamicScope.GetTokenFor(field);
123 }
124
125 public int GetTokenFor(RuntimeFieldHandle field, RuntimeTypeHandle contextType)
126 {
127 return DynamicScope.GetTokenFor(field, contextType);
128 }
129
131 {
133 }
134
135 public int GetTokenFor(string literal)
136 {
137 return DynamicScope.GetTokenFor(literal);
138 }
139
140 public int GetTokenFor(byte[] signature)
141 {
142 return DynamicScope.GetTokenFor(signature);
143 }
144}
int GetTokenFor(RuntimeMethodHandle method)
int GetTokenFor(RuntimeFieldHandle field)
void SetCode(byte[]? code, int maxStackSize)
unsafe void SetCode(byte *code, int codeSize, int maxStackSize)
int GetTokenFor(RuntimeMethodHandle method, RuntimeTypeHandle contextType)
void GetCallableMethod(RuntimeModule module, DynamicMethod dm)
unsafe void SetLocalSignature(byte *localSignature, int signatureSize)
void SetLocalSignature(byte[]? localSignature)
unsafe void SetExceptions(byte *exceptions, int exceptionsSize)
void SetExceptions(byte[]? exceptions)
int GetTokenFor(RuntimeTypeHandle type)
DynamicILInfo(DynamicMethod method, byte[] methodSignature)
int GetTokenFor(DynamicMethod method)
int GetTokenFor(RuntimeFieldHandle field, RuntimeTypeHandle contextType)
int GetTokenFor(VarArgMethod varArgMethod)
static SignatureHelper GetLocalVarSigHelper()
static string ArgumentOutOfRange_GenericPositive
Definition SR.cs:1018
Definition SR.cs:7
static IRuntimeMethodInfo GetDynamicMethod(DynamicMethod method, RuntimeModule module, string name, byte[] sig, Resolver resolver)
T[] ToArray()
Definition Span.cs:291