[VER] v0.3.8-alpha

[Impl][Fix] 更改resolveModulePath实现,使用绝对路径查找内置库
This commit is contained in:
2026-01-14 21:31:11 +08:00
parent 99e00492f5
commit 13fdbec0c4
3 changed files with 35 additions and 4 deletions

View File

@@ -4,7 +4,7 @@
#include <cstdint> #include <cstdint>
#include <string_view> #include <string_view>
#define __FCORE_VERSION "0.3.7-alpha" #define __FCORE_VERSION "0.3.8-alpha"
#if defined(_WIN32) #if defined(_WIN32)
#define __FCORE_PLATFORM "Windows" #define __FCORE_PLATFORM "Windows"

View 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

View File

@@ -1,5 +1,5 @@
#include <Ast/Statements/ErrorFlow.hpp> #include <Ast/Statements/ErrorFlow.hpp>
#include "Value/VariableSlot.hpp" #include <Value/VariableSlot.hpp>
#include <Value/value.hpp> #include <Value/value.hpp>
#include <Ast/AccessModifier.hpp> #include <Ast/AccessModifier.hpp>
#include <Ast/Statements/ImplementSt.hpp> #include <Ast/Statements/ImplementSt.hpp>
@@ -17,6 +17,7 @@
#include <Context/context.hpp> #include <Context/context.hpp>
#include <Utils/utils.hpp> #include <Utils/utils.hpp>
#include <Parser/parser.hpp> #include <Parser/parser.hpp>
#include <Core/executablePath.hpp>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
@@ -985,8 +986,8 @@ namespace Fig
} }
default: assert(false); default: assert(false);
return Object::getNullInstance(); // ignore warning
} }
return Object::getNullInstance(); // ignore warning
} }
StatementResult Evaluator::evalBlockStatement(Ast::BlockStatement block, ContextPtr ctx) StatementResult Evaluator::evalBlockStatement(Ast::BlockStatement block, ContextPtr ctx)
{ {
@@ -1481,6 +1482,14 @@ namespace Fig
static const std::vector<fs::path> defaultLibraryPath{"Library", "Library/fpm"}; static const std::vector<fs::path> defaultLibraryPath{"Library", "Library/fpm"};
std::vector<fs::path> pathToFind(defaultLibraryPath); std::vector<fs::path> pathToFind(defaultLibraryPath);
fs::path interpreterPath = getExecutablePath().parent_path();
for (fs::path &p : pathToFind)
{
p = interpreterPath / p; // 相对路径 -> 绝对路径
}
pathToFind.insert( pathToFind.insert(
pathToFind.begin(), pathToFind.begin(),
fs::path(this->sourcePath.toBasicString()).parent_path()); // first search module at the source file path fs::path(this->sourcePath.toBasicString()).parent_path()); // first search module at the source file path