Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SignatureTypeEncoder.cs
Go to the documentation of this file.
2
3public readonly struct SignatureTypeEncoder
4{
5 public BlobBuilder Builder { get; }
6
8 {
9 Builder = builder;
10 }
11
13 {
14 Builder.WriteByte((byte)value);
15 }
16
17 private void ClassOrValue(bool isValueType)
18 {
19 Builder.WriteByte((byte)(isValueType ? 17 : 18));
20 }
21
22 public void Boolean()
23 {
25 }
26
27 public void Char()
28 {
30 }
31
32 public void SByte()
33 {
35 }
36
37 public void Byte()
38 {
40 }
41
42 public void Int16()
43 {
45 }
46
47 public void UInt16()
48 {
50 }
51
52 public void Int32()
53 {
55 }
56
57 public void UInt32()
58 {
60 }
61
62 public void Int64()
63 {
65 }
66
67 public void UInt64()
68 {
70 }
71
72 public void Single()
73 {
75 }
76
77 public void Double()
78 {
80 }
81
82 public void String()
83 {
85 }
86
87 public void IntPtr()
88 {
90 }
91
92 public void UIntPtr()
93 {
95 }
96
97 public void Object()
98 {
100 }
101
103 {
104 switch (type)
105 {
106 case PrimitiveTypeCode.Boolean:
107 case PrimitiveTypeCode.Char:
108 case PrimitiveTypeCode.SByte:
109 case PrimitiveTypeCode.Byte:
110 case PrimitiveTypeCode.Int16:
111 case PrimitiveTypeCode.UInt16:
112 case PrimitiveTypeCode.Int32:
113 case PrimitiveTypeCode.UInt32:
114 case PrimitiveTypeCode.Int64:
115 case PrimitiveTypeCode.UInt64:
116 case PrimitiveTypeCode.Single:
117 case PrimitiveTypeCode.Double:
118 case PrimitiveTypeCode.String:
119 case PrimitiveTypeCode.IntPtr:
120 case PrimitiveTypeCode.UIntPtr:
121 case PrimitiveTypeCode.Object:
122 Builder.WriteByte((byte)type);
123 break;
124 default:
126 break;
127 }
128 }
129
131 {
132 Builder.WriteByte(20);
133 elementType = this;
134 arrayShape = new ArrayShapeEncoder(Builder);
135 }
136
137 public void Array(Action<SignatureTypeEncoder> elementType, Action<ArrayShapeEncoder> arrayShape)
138 {
139 if (elementType == null)
140 {
141 Throw.ArgumentNull("elementType");
142 }
143 if (arrayShape == null)
144 {
145 Throw.ArgumentNull("arrayShape");
146 }
147 Array(out var elementType2, out var arrayShape2);
148 elementType(elementType2);
149 arrayShape(arrayShape2);
150 }
151
152 public void Type(EntityHandle type, bool isValueType)
153 {
155 ClassOrValue(isValueType);
157 }
158
160 {
161 if (attributes != 0 && attributes != FunctionPointerAttributes.HasThis && attributes != FunctionPointerAttributes.HasExplicitThis)
162 {
163 throw new ArgumentException(System.SR.InvalidSignature, "attributes");
164 }
165 if ((uint)genericParameterCount > 65535u)
166 {
167 Throw.ArgumentOutOfRange("genericParameterCount");
168 }
169 Builder.WriteByte(27);
170 Builder.WriteByte(new SignatureHeader(SignatureKind.Method, convention, (SignatureAttributes)attributes).RawValue);
171 if (genericParameterCount != 0)
172 {
173 Builder.WriteCompressedInteger(genericParameterCount);
174 }
175 return new MethodSignatureEncoder(Builder, convention == SignatureCallingConvention.VarArgs);
176 }
177
178 public GenericTypeArgumentsEncoder GenericInstantiation(EntityHandle genericType, int genericArgumentCount, bool isValueType)
179 {
180 if ((uint)(genericArgumentCount - 1) > 65534u)
181 {
182 Throw.ArgumentOutOfRange("genericArgumentCount");
183 }
184 int value = CodedIndex.TypeDefOrRef(genericType);
185 Builder.WriteByte(21);
186 ClassOrValue(isValueType);
188 Builder.WriteCompressedInteger(genericArgumentCount);
190 }
191
192 public void GenericMethodTypeParameter(int parameterIndex)
193 {
194 if ((uint)parameterIndex > 65535u)
195 {
196 Throw.ArgumentOutOfRange("parameterIndex");
197 }
198 Builder.WriteByte(30);
199 Builder.WriteCompressedInteger(parameterIndex);
200 }
201
202 public void GenericTypeParameter(int parameterIndex)
203 {
204 if ((uint)parameterIndex > 65535u)
205 {
206 Throw.ArgumentOutOfRange("parameterIndex");
207 }
208 Builder.WriteByte(19);
209 Builder.WriteCompressedInteger(parameterIndex);
210 }
211
213 {
214 Builder.WriteByte(15);
215 return this;
216 }
217
218 public void VoidPointer()
219 {
220 Builder.WriteByte(15);
222 }
223
225 {
226 Builder.WriteByte(29);
227 return this;
228 }
229
234}
static int TypeDefOrRef(EntityHandle handle)
static void ArgumentNull(string parameterName)
Definition Throw.cs:110
static void ArgumentOutOfRange(string parameterName)
Definition Throw.cs:145
static string InvalidSignature
Definition SR.cs:106
Definition SR.cs:7
void Array(out SignatureTypeEncoder elementType, out ArrayShapeEncoder arrayShape)
MethodSignatureEncoder FunctionPointer(SignatureCallingConvention convention=SignatureCallingConvention.Default, FunctionPointerAttributes attributes=FunctionPointerAttributes.None, int genericParameterCount=0)
GenericTypeArgumentsEncoder GenericInstantiation(EntityHandle genericType, int genericArgumentCount, bool isValueType)
void Array(Action< SignatureTypeEncoder > elementType, Action< ArrayShapeEncoder > arrayShape)