mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-03 02:10:53 +01:00
# General This release introduces initial work on a Roundtrippable AST for Luau, and numerous fixes to the new type solver, runtime, and fragment autocomplete. ## Roundtrippable AST To support tooling around source code transformations, we are extending the parser to retain source information so that we can re-emit the initial source code exactly as the author wrote it. We have made numerous changes to the Transpiler, added new AST types such as `AstTypeGroup`, and added source information to AST nodes such as `AstExprInterpString`, `AstExprIfElse`, `AstTypeTable`, `AstTypeReference`, `AstTypeSingletonString`, and `AstTypeTypeof`. ## New Type Solver * Implement `setmetatable` and `getmetatable` type functions. * Fix handling of nested and recursive union type functions to prevent the solver from getting stuck. * Free types in both old and new solver now have an upper and lower bound to resolve mixed mode usage of the solvers in fragment autocomplete. * Fix infinite recursion during normalization of cyclic tables. * Add normalization support for intersections of subclasses with negated superclasses. ## Runtime * Fix compilation error in Luau buffer bit operations for big-endian machines. ## Miscellaneous * Add test and bugfixes to fragment autocomplete. * Fixed `clang-tidy` warnings in `Simplify.cpp`. **Full Changelog**: https://github.com/luau-lang/luau/compare/0.659...0.660 --- Co-authored-by: Ariel Weiss <aaronweiss@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Talha Pathan <tpathan@roblox.com> Co-authored-by: Varun Saini <vsaini@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Varun Saini <61795485+vrn-sn@users.noreply.github.com> Co-authored-by: Alexander Youngblood <ayoungblood@roblox.com> Co-authored-by: Menarul Alam <malam@roblox.com>
169 lines
4.6 KiB
C++
169 lines
4.6 KiB
C++
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
#include "Luau/Ast.h"
|
|
#include "Luau/Cst.h"
|
|
#include "Luau/Common.h"
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
int gCstRttiIndex = 0;
|
|
|
|
CstExprConstantNumber::CstExprConstantNumber(const AstArray<char>& value)
|
|
: CstNode(CstClassIndex())
|
|
, value(value)
|
|
{
|
|
}
|
|
|
|
CstExprConstantString::CstExprConstantString(AstArray<char> sourceString, QuoteStyle quoteStyle, unsigned int blockDepth)
|
|
: CstNode(CstClassIndex())
|
|
, sourceString(sourceString)
|
|
, quoteStyle(quoteStyle)
|
|
, blockDepth(blockDepth)
|
|
{
|
|
LUAU_ASSERT(blockDepth == 0 || quoteStyle == QuoteStyle::QuotedRaw);
|
|
}
|
|
|
|
CstExprCall::CstExprCall(std::optional<Position> openParens, std::optional<Position> closeParens, AstArray<Position> commaPositions)
|
|
: CstNode(CstClassIndex())
|
|
, openParens(openParens)
|
|
, closeParens(closeParens)
|
|
, commaPositions(commaPositions)
|
|
{
|
|
}
|
|
|
|
CstExprIndexExpr::CstExprIndexExpr(Position openBracketPosition, Position closeBracketPosition)
|
|
: CstNode(CstClassIndex())
|
|
, openBracketPosition(openBracketPosition)
|
|
, closeBracketPosition(closeBracketPosition)
|
|
{
|
|
}
|
|
|
|
CstExprTable::CstExprTable(const AstArray<Item>& items)
|
|
: CstNode(CstClassIndex())
|
|
, items(items)
|
|
{
|
|
}
|
|
|
|
CstExprOp::CstExprOp(Position opPosition)
|
|
: CstNode(CstClassIndex())
|
|
, opPosition(opPosition)
|
|
{
|
|
}
|
|
|
|
CstExprIfElse::CstExprIfElse(Position thenPosition, Position elsePosition, bool isElseIf)
|
|
: CstNode(CstClassIndex())
|
|
, thenPosition(thenPosition)
|
|
, elsePosition(elsePosition)
|
|
, isElseIf(isElseIf)
|
|
{
|
|
}
|
|
|
|
CstExprInterpString::CstExprInterpString(AstArray<AstArray<char>> sourceStrings, AstArray<Position> stringPositions)
|
|
: CstNode(CstClassIndex())
|
|
, sourceStrings(sourceStrings)
|
|
, stringPositions(stringPositions)
|
|
{
|
|
}
|
|
|
|
CstStatDo::CstStatDo(Position endPosition)
|
|
: CstNode(CstClassIndex())
|
|
, endPosition(endPosition)
|
|
{
|
|
}
|
|
|
|
CstStatRepeat::CstStatRepeat(Position untilPosition)
|
|
: CstNode(CstClassIndex())
|
|
, untilPosition(untilPosition)
|
|
{
|
|
}
|
|
|
|
CstStatReturn::CstStatReturn(AstArray<Position> commaPositions)
|
|
: CstNode(CstClassIndex())
|
|
, commaPositions(commaPositions)
|
|
{
|
|
}
|
|
|
|
CstStatLocal::CstStatLocal(AstArray<Position> varsCommaPositions, AstArray<Position> valuesCommaPositions)
|
|
: CstNode(CstClassIndex())
|
|
, varsCommaPositions(varsCommaPositions)
|
|
, valuesCommaPositions(valuesCommaPositions)
|
|
{
|
|
}
|
|
|
|
CstStatFor::CstStatFor(Position equalsPosition, Position endCommaPosition, std::optional<Position> stepCommaPosition)
|
|
: CstNode(CstClassIndex())
|
|
, equalsPosition(equalsPosition)
|
|
, endCommaPosition(endCommaPosition)
|
|
, stepCommaPosition(stepCommaPosition)
|
|
{
|
|
}
|
|
|
|
CstStatForIn::CstStatForIn(AstArray<Position> varsCommaPositions, AstArray<Position> valuesCommaPositions)
|
|
: CstNode(CstClassIndex())
|
|
, varsCommaPositions(varsCommaPositions)
|
|
, valuesCommaPositions(valuesCommaPositions)
|
|
{
|
|
}
|
|
|
|
CstStatAssign::CstStatAssign(
|
|
AstArray<Position> varsCommaPositions,
|
|
Position equalsPosition,
|
|
AstArray<Position> valuesCommaPositions
|
|
)
|
|
: CstNode(CstClassIndex())
|
|
, varsCommaPositions(varsCommaPositions)
|
|
, equalsPosition(equalsPosition)
|
|
, valuesCommaPositions(valuesCommaPositions)
|
|
{
|
|
}
|
|
|
|
CstStatCompoundAssign::CstStatCompoundAssign(Position opPosition)
|
|
: CstNode(CstClassIndex())
|
|
, opPosition(opPosition)
|
|
{
|
|
}
|
|
|
|
CstStatLocalFunction::CstStatLocalFunction(Position functionKeywordPosition)
|
|
: CstNode(CstClassIndex())
|
|
, functionKeywordPosition(functionKeywordPosition)
|
|
{
|
|
}
|
|
|
|
CstTypeReference::CstTypeReference(
|
|
std::optional<Position> prefixPointPosition,
|
|
Position openParametersPosition,
|
|
AstArray<Position> parametersCommaPositions,
|
|
Position closeParametersPosition
|
|
)
|
|
: CstNode(CstClassIndex())
|
|
, prefixPointPosition(prefixPointPosition)
|
|
, openParametersPosition(openParametersPosition)
|
|
, parametersCommaPositions(parametersCommaPositions)
|
|
, closeParametersPosition(closeParametersPosition)
|
|
{
|
|
}
|
|
|
|
CstTypeTable::CstTypeTable(AstArray<Item> items, bool isArray)
|
|
: CstNode(CstClassIndex())
|
|
, items(items)
|
|
, isArray(isArray)
|
|
{
|
|
}
|
|
|
|
CstTypeTypeof::CstTypeTypeof(Position openPosition, Position closePosition)
|
|
: CstNode(CstClassIndex())
|
|
, openPosition(openPosition)
|
|
, closePosition(closePosition)
|
|
{
|
|
}
|
|
|
|
CstTypeSingletonString::CstTypeSingletonString(AstArray<char> sourceString, CstExprConstantString::QuoteStyle quoteStyle, unsigned int blockDepth)
|
|
: CstNode(CstClassIndex())
|
|
, sourceString(sourceString)
|
|
, quoteStyle(quoteStyle)
|
|
, blockDepth(blockDepth)
|
|
{
|
|
LUAU_ASSERT(quoteStyle != CstExprConstantString::QuotedInterp);
|
|
}
|
|
|
|
} // namespace Luau
|