mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
d141a5c48d
* Fixed exported types not being suggested in autocomplete * `T...` is now convertible to `...any` (Fixes https://github.com/Roblox/luau/issues/767) * Fixed issue with `T?` not being convertible to `T | T` or `T?` (sometimes when internal pointer identity is different) * Fixed potential crash in missing table key error suggestion to use a similar existing key * `lua_topointer` now returns a pointer for strings C++ API Changes: * `prepareModuleScope` callback has moved from TypeChecker to Frontend * For LSPs, AstQuery functions (and `isWithinComment`) can be used without full Frontend data A lot of changes in our two experimental components as well. In our work on the new type-solver, the following issues were fixed: * Fixed table union and intersection indexing * Correct custom type environments are now used * Fixed issue with values of `free & number` type not accepted in numeric operations And these are the changes in native code generation (JIT): * arm64 lowering is almost complete with support for 99% of IR commands and all fastcalls * Fixed x64 assembly encoding for extended byte registers * More external x64 calls are aware of register allocator * `math.min`/`math.max` with more than 2 arguments are now lowered to IR as well * Fixed correctness issues with `math` library calls with multiple results in variadic context and with x64 register conflicts * x64 register allocator learnt to restore values from VM memory instead of always using stack spills * x64 exception unwind information now supports multiple functions and fixes function start offset in Dwarf2 info
83 lines
2.5 KiB
C++
83 lines
2.5 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 <memory>
|
|
|
|
namespace Luau
|
|
{
|
|
|
|
struct Binding;
|
|
struct SourceModule;
|
|
struct Module;
|
|
|
|
struct Type;
|
|
using TypeId = const Type*;
|
|
|
|
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
|