2 Commits

Author SHA1 Message Date
ccf80536b3 [Fix] 蠢蛋clang!
All checks were successful
Release Build / build-windows-x64 (push) Successful in 47s
Release Build / build-linux-x64 (push) Successful in 58s
2026-01-14 21:35:48 +08:00
13fdbec0c4 [VER] v0.3.8-alpha
Some checks failed
Release Build / build-linux-x64 (push) Failing after 18s
Release Build / build-windows-x64 (push) Successful in 46s
[Impl][Fix] 更改resolveModulePath实现,使用绝对路径查找内置库
2026-01-14 21:31:11 +08:00
3 changed files with 34 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,21 @@
#pragma once
#include <filesystem>
#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>
@@ -68,7 +69,7 @@ namespace Fig
AccessModifier::PublicConst), AccessModifier::PublicConst),
ctx); // fake l-value ctx); // fake l-value
} }
if (ctx->hasMethodImplemented(baseVal->getTypeInfo(), member)) if (ctx->hasMethodImplemented(baseVal->getTypeInfo(), member))
{ {
// builtin type implementation! // builtin type implementation!
@@ -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