Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
StateMachineMethodTableReader.cs
Go to the documentation of this file.
2
4
5internal readonly struct StateMachineMethodTableReader
6{
7 internal readonly int NumberOfRows;
8
9 private readonly bool _isMethodRefSizeSmall;
10
11 private readonly int _kickoffMethodOffset;
12
13 internal readonly int RowSize;
14
15 internal readonly MemoryBlock Block;
16
17 internal StateMachineMethodTableReader(int numberOfRows, bool declaredSorted, int methodRefSize, MemoryBlock containingBlock, int containingBlockOffset)
18 {
19 NumberOfRows = numberOfRows;
20 _isMethodRefSizeSmall = methodRefSize == 2;
21 _kickoffMethodOffset = methodRefSize;
22 RowSize = _kickoffMethodOffset + methodRefSize;
23 Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, RowSize * numberOfRows);
24 if (numberOfRows > 0 && !declaredSorted)
25 {
26 Throw.TableNotSorted(TableIndex.StateMachineMethod);
27 }
28 }
29
30 internal MethodDefinitionHandle FindKickoffMethod(int moveNextMethodRowId)
31 {
32 int num = Block.BinarySearchReference(NumberOfRows, RowSize, 0, (uint)moveNextMethodRowId, _isMethodRefSizeSmall);
33 if (num < 0)
34 {
35 return default(MethodDefinitionHandle);
36 }
37 return GetKickoffMethod(num + 1);
38 }
39
45}
static void TableNotSorted(TableIndex tableIndex)
Definition Throw.cs:250
int PeekReference(int offset, bool smallRefSize)
unsafe MemoryBlock GetMemoryBlockAt(int offset, int length)
int BinarySearchReference(int rowCount, int rowSize, int referenceOffset, uint referenceValue, bool isReferenceSmall)
StateMachineMethodTableReader(int numberOfRows, bool declaredSorted, int methodRefSize, MemoryBlock containingBlock, int containingBlockOffset)
static MethodDefinitionHandle FromRowId(int rowId)