mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
be52bd91e4
* Fixed garbage data in module scopes when type graph is not retained * LOP_MOVE with the same source and target registers is no longer generated (Fixes https://github.com/Roblox/luau/issues/793)
52 lines
930 B
C++
52 lines
930 B
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#pragma once
|
|
|
|
#include "Luau/Common.h"
|
|
#include "Luau/Error.h"
|
|
|
|
#include <stdexcept>
|
|
#include <exception>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct RecursionLimitException : public InternalCompilerError
|
|
{
|
|
RecursionLimitException()
|
|
: InternalCompilerError("Internal recursion counter limit exceeded")
|
|
{
|
|
}
|
|
};
|
|
|
|
struct RecursionCounter
|
|
{
|
|
RecursionCounter(int* count)
|
|
: count(count)
|
|
{
|
|
++(*count);
|
|
}
|
|
|
|
~RecursionCounter()
|
|
{
|
|
LUAU_ASSERT(*count > 0);
|
|
--(*count);
|
|
}
|
|
|
|
protected:
|
|
int* count;
|
|
};
|
|
|
|
struct RecursionLimiter : RecursionCounter
|
|
{
|
|
RecursionLimiter(int* count, int limit)
|
|
: RecursionCounter(count)
|
|
{
|
|
if (limit > 0 && *count > limit)
|
|
{
|
|
throw RecursionLimitException();
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace Luau
|