[VER] v0.3.8-alpha
[Impl][Fix] 更改resolveModulePath实现,使用绝对路径查找内置库
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
#include <cstdint>
|
||||
#include <string_view>
|
||||
|
||||
#define __FCORE_VERSION "0.3.7-alpha"
|
||||
#define __FCORE_VERSION "0.3.8-alpha"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define __FCORE_PLATFORM "Windows"
|
||||
|
||||
22
src/Core/executablePath.hpp
Normal file
22
src/Core/executablePath.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <libloaderapi.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <libloaderapi.h>
|
||||
#endif
|
||||
|
||||
namespace Fig
|
||||
{
|
||||
inline std::filesystem::path getExecutablePath()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
wchar_t buffer[MAX_PATH];
|
||||
GetModuleFileNameW(nullptr, buffer, MAX_PATH);
|
||||
return std::filesystem::path(buffer);
|
||||
#else
|
||||
return std::filesystem::canonical("/proc/self/exe");
|
||||
#endif
|
||||
}
|
||||
}; // namespace Fig
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <Ast/Statements/ErrorFlow.hpp>
|
||||
#include "Value/VariableSlot.hpp"
|
||||
#include <Value/VariableSlot.hpp>
|
||||
#include <Value/value.hpp>
|
||||
#include <Ast/AccessModifier.hpp>
|
||||
#include <Ast/Statements/ImplementSt.hpp>
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <Context/context.hpp>
|
||||
#include <Utils/utils.hpp>
|
||||
#include <Parser/parser.hpp>
|
||||
#include <Core/executablePath.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
@@ -985,8 +986,8 @@ namespace Fig
|
||||
}
|
||||
|
||||
default: assert(false);
|
||||
return Object::getNullInstance(); // ignore warning
|
||||
}
|
||||
return Object::getNullInstance(); // ignore warning
|
||||
}
|
||||
StatementResult Evaluator::evalBlockStatement(Ast::BlockStatement block, ContextPtr ctx)
|
||||
{
|
||||
@@ -1481,6 +1482,14 @@ namespace Fig
|
||||
static const std::vector<fs::path> defaultLibraryPath{"Library", "Library/fpm"};
|
||||
|
||||
std::vector<fs::path> pathToFind(defaultLibraryPath);
|
||||
|
||||
fs::path interpreterPath = getExecutablePath().parent_path();
|
||||
|
||||
for (fs::path &p : pathToFind)
|
||||
{
|
||||
p = interpreterPath / p; // 相对路径 -> 绝对路径
|
||||
}
|
||||
|
||||
pathToFind.insert(
|
||||
pathToFind.begin(),
|
||||
fs::path(this->sourcePath.toBasicString()).parent_path()); // first search module at the source file path
|
||||
|
||||
Reference in New Issue
Block a user