[Feat] 模块系统支持,使用 import x.x.x导入

[Fix] Context内部辅助函数修改, getStructName ....
[Feat] 增加字符串下标获取操作,和修改字符操作,实现使用了第四点的函数
[Impl] FString添加新方法 getRealChar, realReplace
[Fun] 在utf8_iterator中辱骂了C++
This commit is contained in:
2025-12-26 20:47:57 +08:00
parent 6e1df63507
commit 00240f1ed1
21 changed files with 578 additions and 140 deletions

View File

@@ -4,6 +4,7 @@
#include <Value/structInstance.hpp>
#include <Value/Type.hpp>
#include <Value/valueError.hpp>
#include <Value/module.hpp>
#include <variant>
#include <cmath>
@@ -58,7 +59,8 @@ namespace Fig
StructType,
StructInstance,
List,
Map>;
Map,
Module>;
std::unordered_map<TypeInfo,
std::unordered_map<FString,
@@ -134,6 +136,7 @@ namespace Fig
map.contains(index));
}},
}},
{ValueType::Module, {}}
};
std::unordered_map<TypeInfo, std::unordered_map<FString, int>, TypeInfoHash> memberTypeFunctionsParas{
{ValueType::Null, {}},
@@ -151,6 +154,7 @@ namespace Fig
{u8"get", 1},
{u8"contains", 1},
}},
{ValueType::Module, {}}
};
bool hasMemberFunction(const FString &name) const
@@ -190,6 +194,8 @@ namespace Fig
data(l) {}
Object(const Map &m) :
data(m) {}
Object(const Module &m) :
data(m) {}
Object(const Object &) = default;
Object(Object &&) noexcept = default;
@@ -283,6 +289,9 @@ namespace Fig
else if constexpr (std::is_same_v<T, Map>)
return ValueType::Map;
else if constexpr (std::is_same_v<T, Module>)
return ValueType::Module;
else
return ValueType::Any;
},
@@ -357,6 +366,12 @@ namespace Fig
output += u8"}";
return output;
}
if (is<Module>())
{
return FString(std::format(
"<Module at {:p}>",
static_cast<const void *>(&as<Module>())));
}
return FString(u8"<error>");
}
@@ -576,7 +591,6 @@ namespace Fig
using ObjectPtr = std::shared_ptr<Object>;
using RvObject = ObjectPtr;
inline bool operator==(const ValueKey &l, const ValueKey &r)
{
return *l.value == *r.value;