Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CopyCodeAndFixupBranches()

void System.Reflection.Metadata.Ecma335.ControlFlowBuilder.CopyCodeAndFixupBranches ( BlobBuilder srcBuilder,
BlobBuilder dstBuilder )
inlinepackage

Definition at line 175 of file ControlFlowBuilder.cs.

176 {
177 BranchInfo branchInfo = _branches[0];
178 int num = 0;
179 int num2 = 0;
180 int num3 = 0;
181 foreach (Blob blob in srcBuilder.GetBlobs())
182 {
183 while (true)
184 {
185 int num4 = Math.Min(branchInfo.ILOffset - num2, blob.Length - num3);
186 dstBuilder.WriteBytes(blob.Buffer, num3, num4);
187 num2 += num4;
188 num3 += num4;
189 if (num3 == blob.Length)
190 {
191 num3 = 0;
192 break;
193 }
194 int branchOperandSize = branchInfo.OpCode.GetBranchOperandSize();
195 bool flag = branchOperandSize == 1;
196 dstBuilder.WriteByte(blob.Buffer[num3]);
197 int branchDistance = branchInfo.GetBranchDistance(_labels, branchInfo.OpCode, num2, flag);
198 if (flag)
199 {
200 dstBuilder.WriteSByte((sbyte)branchDistance);
201 }
202 else
203 {
204 dstBuilder.WriteInt32(branchDistance);
205 }
206 num2 += 1 + branchOperandSize;
207 num++;
208 branchInfo = ((num != _branches.Count) ? _branches[num] : new BranchInfo(int.MaxValue, default(LabelHandle), ILOpCode.Nop));
209 if (num3 == blob.Length - 1)
210 {
212 break;
213 }
214 num3 += 1 + branchOperandSize;
215 }
216 }
217 }
readonly ImmutableArray< BranchInfo >.Builder _branches
readonly ImmutableArray< int >.Builder _labels

References System.Reflection.Metadata.Ecma335.ControlFlowBuilder._branches, System.Reflection.Metadata.Ecma335.ControlFlowBuilder._labels, System.Reflection.Metadata.Blob.Buffer, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Reflection.Metadata.Blob.Length, System.Reflection.MaxValue, and System.Math.Min().

Referenced by System.Reflection.Metadata.Ecma335.MethodBodyStreamEncoder.AddMethodBody().