mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 13:00:38 +00:00
76070f8da2
* Reoptimized math.min/max/bit32 builtins assuming at least 2 arguments are used (1-2% lift on some benchmarks) * Type errors that mention function types no longer have redundant parenthesis around return type * Luau REPL now supports --compile=remarks which displays the source code with optimization remarks embedded as comments * Builtin calls are slightly faster when called with 1-2 arguments (~1% improvement in some benchmarks)
45 lines
908 B
C++
45 lines
908 B
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#include "AstQueryDsl.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
FindNthOccurenceOf::FindNthOccurenceOf(Nth nth)
|
|
: requestedNth(nth)
|
|
{
|
|
}
|
|
|
|
bool FindNthOccurenceOf::checkIt(AstNode* n)
|
|
{
|
|
if (theNode)
|
|
return false;
|
|
|
|
if (n->classIndex == requestedNth.classIndex)
|
|
{
|
|
// Human factor: the requestedNth starts from 1 because of the term `nth`.
|
|
if (currentOccurrence + 1 != requestedNth.nth)
|
|
++currentOccurrence;
|
|
else
|
|
theNode = n;
|
|
}
|
|
|
|
return !theNode; // once found, returns false and stops traversal
|
|
}
|
|
|
|
bool FindNthOccurenceOf::visit(AstNode* n)
|
|
{
|
|
return checkIt(n);
|
|
}
|
|
|
|
bool FindNthOccurenceOf::visit(AstType* t)
|
|
{
|
|
return checkIt(t);
|
|
}
|
|
|
|
bool FindNthOccurenceOf::visit(AstTypePack* t)
|
|
{
|
|
return checkIt(t);
|
|
}
|
|
|
|
} // namespace Luau
|