mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 13:00:38 +00:00
c755875479
- Implemented [Require by String with Relative Paths](https://github.com/luau-lang/rfcs/blob/master/docs/new-require-by-string-semantics.md) RFC - Implemented [Require by String with Aliases](https://github.com/luau-lang/rfcs/blob/master/docs/require-by-string-aliases.md) RFC with support for `paths` and `alias` arrays in .luarc - Added SUBRK and DIVRK bytecode instructions to speed up constant-number and constant/number operations - Added `--vector-lib`, `--vector-ctor` and `--vector-type` options to luau-compile to support code with vectors New Solver - Correctness fixes to subtyping - Improvements to dataflow analysis Native Code Generation - Added bytecode analysis pass to predict type tags used in operations - Fixed rare cases of numerical loops being generated without an interrupt instruction - Restored optimization data propagation into the linear block - Duplicate buffer length checks are optimized away Miscellaneous - Small performance improvements to new non-strict mode - Introduced more scripts for fuzzing Luau and processing the results, including fuzzer build support for CMake 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: David Cope <dcope@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: 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: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
62 lines
1.4 KiB
C++
62 lines
1.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 "lua.h"
|
|
#include "lualib.h"
|
|
|
|
#include "Luau/Config.h"
|
|
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
class RequireResolver
|
|
{
|
|
public:
|
|
std::string chunkname;
|
|
std::string absolutePath;
|
|
std::string sourceCode;
|
|
|
|
enum class ModuleStatus
|
|
{
|
|
Cached,
|
|
FileRead,
|
|
NotFound
|
|
};
|
|
|
|
struct ResolvedRequire
|
|
{
|
|
ModuleStatus status;
|
|
std::string chunkName;
|
|
std::string absolutePath;
|
|
std::string sourceCode;
|
|
};
|
|
|
|
[[nodiscard]] ResolvedRequire static resolveRequire(lua_State* L, std::string path);
|
|
|
|
private:
|
|
std::string pathToResolve;
|
|
std::string_view sourceChunkname;
|
|
|
|
RequireResolver(lua_State* L, std::string path);
|
|
|
|
ModuleStatus findModule();
|
|
lua_State* L;
|
|
Luau::Config config;
|
|
std::string lastSearchedDir;
|
|
bool isConfigFullyResolved = false;
|
|
|
|
bool isRequireAllowed(std::string_view sourceChunkname);
|
|
bool shouldSearchPathsArray();
|
|
|
|
void resolveAndStoreDefaultPaths();
|
|
ModuleStatus findModuleImpl();
|
|
|
|
std::optional<std::string> getRequiringContextAbsolute();
|
|
std::string getRequiringContextRelative();
|
|
|
|
void substituteAliasIfPresent(std::string& path);
|
|
std::optional<std::string> getAlias(std::string alias);
|
|
|
|
void parseNextConfig();
|
|
void parseConfigInDirectory(const std::string& path);
|
|
};
|