mirror of
https://github.com/luau-lang/luau.git
synced 2025-01-19 17:28:06 +00:00
c759cd5581
Some checks failed
benchmark / callgrind (map[branch:main name:luau-lang/benchmark-data], ubuntu-22.04) (push) Has been cancelled
build / macos (push) Has been cancelled
build / macos-arm (push) Has been cancelled
build / ubuntu (push) Has been cancelled
build / windows (Win32) (push) Has been cancelled
build / windows (x64) (push) Has been cancelled
build / coverage (push) Has been cancelled
build / web (push) Has been cancelled
release / macos (push) Has been cancelled
release / ubuntu (push) Has been cancelled
release / windows (push) Has been cancelled
release / web (push) Has been cancelled
# General All code has been re-formatted by `clang-format`; this is not mechanically enforced, so Luau may go out-of-sync over the course of the year. # New Solver * Track free types interior to a block of code on `Scope`, which should reduce the number of free types that remain un-generalized after type checking is complete (e.g.: less errors like `'a <: number is incompatible with number`). # Autocomplete * Fragment autocomplete now does *not* provide suggestions within comments (matching non-fragment autocomplete behavior). * Autocomplete now respects iteration and recursion limits (some hangs will now early exit with a "unification too complex error," some crashes will now become internal complier exceptions). # Runtime * Add a limit to how many Luau codegen slot nodes addresses can be in use at the same time (fixes #1605, fixes #1558). * Added constant folding for vector arithmetic (fixes #1553). * Added support for `buffer.readbits` and `buffer.writebits` (see: https://github.com/luau-lang/rfcs/pull/18). --- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Hunter Goldstein <hgoldstein@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
86 lines
2.1 KiB
C++
86 lines
2.1 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/Parser.h"
|
|
#include "Luau/AutocompleteTypes.h"
|
|
#include "Luau/DenseHash.h"
|
|
#include "Luau/Module.h"
|
|
#include "Luau/Frontend.h"
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace Luau
|
|
{
|
|
struct FrontendOptions;
|
|
|
|
enum class FragmentTypeCheckStatus
|
|
{
|
|
Success,
|
|
SkipAutocomplete,
|
|
};
|
|
|
|
struct FragmentAutocompleteAncestryResult
|
|
{
|
|
DenseHashMap<AstName, AstLocal*> localMap{AstName()};
|
|
std::vector<AstLocal*> localStack;
|
|
std::vector<AstNode*> ancestry;
|
|
AstStat* nearestStatement = nullptr;
|
|
};
|
|
|
|
struct FragmentParseResult
|
|
{
|
|
std::string fragmentToParse;
|
|
AstStatBlock* root = nullptr;
|
|
std::vector<AstNode*> ancestry;
|
|
AstStat* nearestStatement = nullptr;
|
|
std::vector<Comment> commentLocations;
|
|
std::unique_ptr<Allocator> alloc = std::make_unique<Allocator>();
|
|
};
|
|
|
|
struct FragmentTypeCheckResult
|
|
{
|
|
ModulePtr incrementalModule = nullptr;
|
|
ScopePtr freshScope;
|
|
std::vector<AstNode*> ancestry;
|
|
};
|
|
|
|
struct FragmentAutocompleteResult
|
|
{
|
|
ModulePtr incrementalModule;
|
|
Scope* freshScope;
|
|
TypeArena arenaForAutocomplete;
|
|
AutocompleteResult acResults;
|
|
};
|
|
|
|
FragmentAutocompleteAncestryResult findAncestryForFragmentParse(AstStatBlock* root, const Position& cursorPos);
|
|
|
|
FragmentParseResult parseFragment(
|
|
const SourceModule& srcModule,
|
|
std::string_view src,
|
|
const Position& cursorPos,
|
|
std::optional<Position> fragmentEndPosition
|
|
);
|
|
|
|
std::pair<FragmentTypeCheckStatus, FragmentTypeCheckResult> typecheckFragment(
|
|
Frontend& frontend,
|
|
const ModuleName& moduleName,
|
|
const Position& cursorPos,
|
|
std::optional<FrontendOptions> opts,
|
|
std::string_view src,
|
|
std::optional<Position> fragmentEndPosition
|
|
);
|
|
|
|
FragmentAutocompleteResult fragmentAutocomplete(
|
|
Frontend& frontend,
|
|
std::string_view src,
|
|
const ModuleName& moduleName,
|
|
Position cursorPosition,
|
|
std::optional<FrontendOptions> opts,
|
|
StringCompletionCallback callback,
|
|
std::optional<Position> fragmentEndPosition = std::nullopt
|
|
);
|
|
|
|
|
|
} // namespace Luau
|