[Fix] 修复struct内部函数无法访问内部成员的问题

[Feat] 拓展构建
This commit is contained in:
2025-12-23 01:37:46 +08:00
parent 6226059adc
commit 660cca2579
6 changed files with 83 additions and 71 deletions

View File

@@ -56,6 +56,11 @@ namespace Fig
structTypeNames.insert(c.structTypeNames.begin(), c.structTypeNames.end());
}
std::unordered_map<size_t, Function> getFunctions() const
{
return functions;
}
std::optional<ObjectPtr> get(const FString &name)
{
auto it = variables.find(name);
@@ -125,6 +130,21 @@ namespace Fig
throw RuntimeError(FStringView(std::format("Variable '{}' not defined", name.toBasicString())));
}
}
void _update(const FString &name, const Object &value)
{
if (variables.contains(name))
{
variables[name] = std::make_shared<Object>(value);
}
else if (parent != nullptr)
{
parent->set(name, value);
}
else
{
throw RuntimeError(FStringView(std::format("Variable '{}' not defined", name.toBasicString())));
}
}
void def(const FString &name, const TypeInfo &ti, AccessModifier am, const ObjectPtr &value = Object::getNullInstance())
{
if (containsInThisScope(name))