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
| #pragma once
|
| #include <stdint.h>
|
| namespace il2cpp
| {
| namespace utils
| {
| class LeaveTargetStack
| {
| public:
| LeaveTargetStack(void* storage) : m_Storage((int32_t*)storage), m_currentIndex(-1)
| {
| }
|
| void push(int32_t value)
| {
| // This function is rather unsafe. We don't track the size of storage,
| // and assume the caller will not push more values than it has allocated.
| // This function should only be used from generated code, where
| // we control the calls to this function.
| m_currentIndex++;
| m_Storage[m_currentIndex] = value;
| }
|
| void pop()
| {
| if (m_currentIndex >= 0)
| m_currentIndex--;
| }
|
| int32_t top() const
| {
| return m_Storage[m_currentIndex];
| }
|
| bool empty() const
| {
| return m_currentIndex == -1;
| }
|
| private:
| int32_t* m_Storage;
| int m_currentIndex;
| };
| }
| }
|
|