forked from PuqiAR/Fig-TreeWalker
Compare commits
2 Commits
v0.3.7-alp
...
v0.3.8-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| ccf80536b3 | |||
| 13fdbec0c4 |
@@ -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"
|
||||||
|
|||||||
21
src/Core/executablePath.hpp
Normal file
21
src/Core/executablePath.hpp
Normal 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
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user