blob: 96f62b6958fc7ab95f93068581d9a0f7163a3a9f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//
// ZapInnerPtr.h
//
//
// ZapNode that points into middle of other ZapNode
//
// ======================================================================================
#include "common.h"
#include "zapinnerptr.h"
ZapNode * ZapInnerPtrTable::Get(ZapNode * pBase, SSIZE_T offset)
{
// Nothing to do if the offset is zero
if (offset == 0)
return pBase;
// Flatten the hiearchy of inner ptrs. Inner ptrs pointing to other inner ptrs
// would not work well during the Resolve phase
while (pBase->GetType() == ZapNodeType_InnerPtr)
{
ZapInnerPtr * pWrapper = (ZapInnerPtr *)pBase;
offset += pWrapper->GetOffset();
pBase = pWrapper->GetBase();
}
ZapInnerPtr * pInnerPtr = m_entries.Lookup(InnerPtrKey(pBase, offset));
if (pInnerPtr != NULL)
return pInnerPtr;
switch (offset)
{
case 1:
pInnerPtr = new (m_pWriter->GetHeap()) InnerPtrConst<1>(pBase);
break;
case 2:
pInnerPtr = new (m_pWriter->GetHeap()) InnerPtrConst<2>(pBase);
break;
case 4:
pInnerPtr = new (m_pWriter->GetHeap()) InnerPtrConst<4>(pBase);
break;
case 8:
pInnerPtr = new (m_pWriter->GetHeap()) InnerPtrConst<8>(pBase);
break;
default:
pInnerPtr = new (m_pWriter->GetHeap()) InnerPtrVar(pBase, offset);
break;
}
m_entries.Add(pInnerPtr);
return pInnerPtr;
}
void ZapInnerPtrTable::Resolve()
{
for (InnerPtrTable::Iterator i = m_entries.Begin(), end = m_entries.End(); i != end; i++)
{
(*i)->Resolve();
}
}
|