Files
RedHotRoast-ios/HybridCLRData/LocalIl2CppData-OSXEditor/il2cpp/libil2cpp/utils/ExceptionSupportStack.h
T
2026-07-17 14:03:00 +08:00

60 lines
1.2 KiB
C++

#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++;
}
#if HYBRIDCLR_UNITY_VERSION >= 20220311
T pop()
{
IL2CPP_ASSERT(!empty());
m_count--;
return m_Storage[m_count];
}
#else
void pop()
{
IL2CPP_ASSERT(!empty());
m_count--;
}
#endif
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;
};
}
}