mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
fd6250cf9d
### What's Changed - Improve readability of unions and intersections by limiting the number of elements of those types that can be presented on a single line (gated under `FFlag::LuauToStringSimpleCompositeTypesSingleLine`) - Adds a new option to the compiler `--record-stats` to record and output compilation statistics - `if...then...else` expressions are now optimized into `AND/OR` form when possible. ### VM - Add a new `buffer` type to Luau based on the [buffer RFC](https://github.com/Roblox/luau/pull/739) and additional C API functions to work with it; this release does not include the library. - Internal C API to work with string buffers has been updated to align with Lua version more closely ### Native Codegen - Added support for new X64 instruction (rev) and new A64 instruction (bswap) in the assembler - Simplified the way numerical loop condition is translated to IR ### New Type Solver - Operator inference now handled by type families - Created a new system called `Type Paths` to explain why subtyping tests fail in order to improve the quality of error messages. - Systematic changes to implement Data Flow analysis in the new solver (`Breadcrumb` removed and replaced with `RefinementKey`) --- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> --------- Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com>
81 lines
2.4 KiB
C++
81 lines
2.4 KiB
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/Ast.h"
|
|
#include "Luau/Documentation.h"
|
|
#include "Luau/TypeFwd.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct Binding;
|
|
struct SourceModule;
|
|
struct Module;
|
|
|
|
using ScopePtr = std::shared_ptr<struct Scope>;
|
|
|
|
struct ExprOrLocal
|
|
{
|
|
AstExpr* getExpr()
|
|
{
|
|
return expr;
|
|
}
|
|
AstLocal* getLocal()
|
|
{
|
|
return local;
|
|
}
|
|
void setExpr(AstExpr* newExpr)
|
|
{
|
|
expr = newExpr;
|
|
local = nullptr;
|
|
}
|
|
void setLocal(AstLocal* newLocal)
|
|
{
|
|
local = newLocal;
|
|
expr = nullptr;
|
|
}
|
|
std::optional<Location> getLocation()
|
|
{
|
|
return expr ? expr->location : (local ? local->location : std::optional<Location>{});
|
|
}
|
|
std::optional<AstName> getName()
|
|
{
|
|
if (expr)
|
|
{
|
|
if (AstName name = getIdentifier(expr); name.value)
|
|
{
|
|
return name;
|
|
}
|
|
}
|
|
else if (local)
|
|
{
|
|
return local->name;
|
|
}
|
|
return std::nullopt;
|
|
}
|
|
|
|
private:
|
|
AstExpr* expr = nullptr;
|
|
AstLocal* local = nullptr;
|
|
};
|
|
|
|
std::vector<AstNode*> findAncestryAtPositionForAutocomplete(const SourceModule& source, Position pos);
|
|
std::vector<AstNode*> findAncestryAtPositionForAutocomplete(AstStatBlock* root, Position pos);
|
|
std::vector<AstNode*> findAstAncestryOfPosition(const SourceModule& source, Position pos, bool includeTypes = false);
|
|
std::vector<AstNode*> findAstAncestryOfPosition(AstStatBlock* root, Position pos, bool includeTypes = false);
|
|
AstNode* findNodeAtPosition(const SourceModule& source, Position pos);
|
|
AstNode* findNodeAtPosition(AstStatBlock* root, Position pos);
|
|
AstExpr* findExprAtPosition(const SourceModule& source, Position pos);
|
|
ScopePtr findScopeAtPosition(const Module& module, Position pos);
|
|
std::optional<Binding> findBindingAtPosition(const Module& module, const SourceModule& source, Position pos);
|
|
ExprOrLocal findExprOrLocalAtPosition(const SourceModule& source, Position pos);
|
|
|
|
std::optional<TypeId> findTypeAtPosition(const Module& module, const SourceModule& sourceModule, Position pos);
|
|
std::optional<TypeId> findExpectedTypeAtPosition(const Module& module, const SourceModule& sourceModule, Position pos);
|
|
|
|
std::optional<DocumentationSymbol> getDocumentationSymbolAtPosition(const SourceModule& source, const Module& module, Position position);
|
|
|
|
} // namespace Luau
|