// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details1#pragma once23#include "Luau/FileResolver.h"45#include <memory>6#include <optional>7#include <string>89namespace Luau10{1112class AstExpr;13struct Module;1415using ModulePtr = std::shared_ptr<Module>;1617struct ModuleResolver18{19virtual ~ModuleResolver() {}2021/** Compute a ModuleName from an AST fragment. This AST fragment is generally the argument to the require() function.22*23* @returns The ModuleInfo if the expression is a syntactically legal path.24* @returns std::nullopt if we are unable to determine whether or not the expression is a valid path. Type inference will25* silently assume that it could succeed in this case.26*27* FIXME: This is clearly not the right behaviour longterm. We'll want to adust this interface to be able to signal28* a) success,29* b) Definitive failure (this expression will absolutely cause require() to fail at runtime), and30* c) uncertainty31*/32virtual std::optional<ModuleInfo> resolveModuleInfo(const ModuleName& currentModuleName, const AstExpr& pathExpr) = 0;3334/** Get a typechecked module from its name.35*36* This can return null under two circumstances: the module is unknown at compile time,37* or there's a cycle, and we are still in the middle of typechecking the module.38*/39virtual const ModulePtr getModule(const ModuleName& moduleName) const = 0;4041/** Is a module known at compile time?42*43* This function can be used to distinguish the above two cases.44*/45virtual bool moduleExists(const ModuleName& moduleName) const = 0;4647virtual std::string getHumanReadableModuleName(const ModuleName& moduleName) const = 0;48};4950struct NullModuleResolver : ModuleResolver51{52std::optional<ModuleInfo> resolveModuleInfo(const ModuleName& currentModuleName, const AstExpr& pathExpr) override53{54return std::nullopt;55}56const ModulePtr getModule(const ModuleName& moduleName) const override57{58return nullptr;59}60bool moduleExists(const ModuleName& moduleName) const override61{62return false;63}64std::string getHumanReadableModuleName(const ModuleName& moduleName) const override65{66return moduleName;67}68};6970} // namespace Luau717273