mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
3d74a8f4d4
- Improve type error messages for argument count mismatch in certain cases - Fix type checking variadic returns when the type is incompatible which type checked in certain cases - Reduce size of upvalue objects by 8 bytes on 64-bit platforms - Reduce I$ footprint of interpreter by 1.5KB - Reduce GC pause during atomic stage for programs with a lot of threads - Remove support for bytecode v2
46 lines
890 B
C++
46 lines
890 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);
|
|
}
|
|
|
|
}
|