forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionSupportStack.h
More file actions
50 lines (43 loc) · 1.03 KB
/
ExceptionSupportStack.h
File metadata and controls
50 lines (43 loc) · 1.03 KB
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
#pragma once
#include <stdint.h>
namespace il2cpp
{
namespace utils
{
template<typename T, int Size>
class ExceptionSupportStack
{
public:
ExceptionSupportStack() : m_count(0)
{
}
void push(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.
IL2CPP_ASSERT(m_count < Size);
m_Storage[m_count] = value;
m_count++;
}
void pop()
{
IL2CPP_ASSERT(!empty());
m_count--;
}
T top() const
{
IL2CPP_ASSERT(!empty());
return m_Storage[m_count - 1];
}
bool empty() const
{
return m_count == 0;
}
private:
T m_Storage[Size];
int m_count;
};
}
}