Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
LocalScopeTableReader.cs
Go to the documentation of this file.
2
4
5internal readonly struct LocalScopeTableReader
6{
7 internal readonly int NumberOfRows;
8
9 private readonly bool _isMethodRefSmall;
10
11 private readonly bool _isImportScopeRefSmall;
12
13 private readonly bool _isLocalConstantRefSmall;
14
15 private readonly bool _isLocalVariableRefSmall;
16
17 private readonly int _importScopeOffset;
18
19 private readonly int _variableListOffset;
20
21 private readonly int _constantListOffset;
22
23 private readonly int _startOffsetOffset;
24
25 private readonly int _lengthOffset;
26
27 internal readonly int RowSize;
28
29 internal readonly MemoryBlock Block;
30
31 internal LocalScopeTableReader(int numberOfRows, bool declaredSorted, int methodRefSize, int importScopeRefSize, int localVariableRefSize, int localConstantRefSize, MemoryBlock containingBlock, int containingBlockOffset)
32 {
33 NumberOfRows = numberOfRows;
34 _isMethodRefSmall = methodRefSize == 2;
35 _isImportScopeRefSmall = importScopeRefSize == 2;
36 _isLocalVariableRefSmall = localVariableRefSize == 2;
37 _isLocalConstantRefSmall = localConstantRefSize == 2;
38 _importScopeOffset = methodRefSize;
39 _variableListOffset = _importScopeOffset + importScopeRefSize;
40 _constantListOffset = _variableListOffset + localVariableRefSize;
41 _startOffsetOffset = _constantListOffset + localConstantRefSize;
44 Block = containingBlock.GetMemoryBlockAt(containingBlockOffset, RowSize * numberOfRows);
45 if (numberOfRows > 0 && !declaredSorted)
46 {
48 }
49 }
50
56
62
63 internal int GetVariableStart(int rowId)
64 {
65 int num = (rowId - 1) * RowSize;
67 }
68
69 internal int GetConstantStart(int rowId)
70 {
71 int num = (rowId - 1) * RowSize;
73 }
74
75 internal int GetStartOffset(int rowId)
76 {
77 int num = (rowId - 1) * RowSize;
79 }
80
81 internal int GetLength(int rowId)
82 {
83 int num = (rowId - 1) * RowSize;
84 return Block.PeekInt32(num + _lengthOffset);
85 }
86
87 internal int GetEndOffset(int rowId)
88 {
89 int num = (rowId - 1) * RowSize;
91 if ((int)num2 != num2)
92 {
94 }
95 return (int)num2;
96 }
97
98 internal void GetLocalScopeRange(int methodDefRid, out int firstScopeRowId, out int lastScopeRowId)
99 {
100 Block.BinarySearchReferenceRange(NumberOfRows, RowSize, 0, (uint)methodDefRid, _isMethodRefSmall, out var startRowNumber, out var endRowNumber);
101 if (startRowNumber == -1)
102 {
103 firstScopeRowId = 1;
104 lastScopeRowId = 0;
105 }
106 else
107 {
108 firstScopeRowId = startRowNumber + 1;
109 lastScopeRowId = endRowNumber + 1;
110 }
111 }
112}
static void ValueOverflow()
Definition Throw.cs:278
static void TableNotSorted(TableIndex tableIndex)
Definition Throw.cs:250
int PeekReference(int offset, bool smallRefSize)
unsafe MemoryBlock GetMemoryBlockAt(int offset, int length)
void BinarySearchReferenceRange(int rowCount, int rowSize, int referenceOffset, uint referenceValue, bool isReferenceSmall, out int startRowNumber, out int endRowNumber)
unsafe uint PeekUInt32(int offset)
void GetLocalScopeRange(int methodDefRid, out int firstScopeRowId, out int lastScopeRowId)
ImportScopeHandle GetImportScope(LocalScopeHandle handle)
LocalScopeTableReader(int numberOfRows, bool declaredSorted, int methodRefSize, int importScopeRefSize, int localVariableRefSize, int localConstantRefSize, MemoryBlock containingBlock, int containingBlockOffset)
static ImportScopeHandle FromRowId(int rowId)
static MethodDefinitionHandle FromRowId(int rowId)