阶段性保存,全面修改Value为Object
This commit is contained in:
@@ -7,56 +7,57 @@
|
||||
#include <Value/BaseValue.hpp>
|
||||
|
||||
#include <context_forward.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Fig
|
||||
{
|
||||
struct Field
|
||||
{
|
||||
bool isPublic() const
|
||||
{
|
||||
return am == AccessModifier::Public or am == AccessModifier::PublicConst or am == AccessModifier::PublicFinal;
|
||||
}
|
||||
bool isConst() const
|
||||
{
|
||||
return am == AccessModifier::Const or am == AccessModifier::PublicConst;
|
||||
}
|
||||
bool isFinal() const
|
||||
{
|
||||
return am == AccessModifier::Final or am == AccessModifier::PublicFinal;
|
||||
}
|
||||
|
||||
AccessModifier am;
|
||||
FString name;
|
||||
TypeInfo type;
|
||||
Ast::Expression defaultValue;
|
||||
|
||||
Field(AccessModifier _am, FString _name, TypeInfo _type, Ast::Expression _defaultValue) :
|
||||
am(std::move(_am)), name(std::move(_name)), type(std::move(_type)), defaultValue(std::move(_defaultValue)) {}
|
||||
am(_am), name(std::move(_name)), type(std::move(_type)), defaultValue(std::move(_defaultValue)) {}
|
||||
|
||||
bool isPublic() const
|
||||
{
|
||||
return am == AccessModifier::Public || am == AccessModifier::PublicConst || am == AccessModifier::PublicFinal;
|
||||
}
|
||||
bool isConst() const
|
||||
{
|
||||
return am == AccessModifier::Const || am == AccessModifier::PublicConst;
|
||||
}
|
||||
bool isFinal() const
|
||||
{
|
||||
return am == AccessModifier::Final || am == AccessModifier::PublicFinal;
|
||||
}
|
||||
};
|
||||
struct StructT final// = StructType 结构体定义
|
||||
|
||||
struct StructType
|
||||
{
|
||||
std::size_t id;
|
||||
ContextPtr defContext; // 定义时的上下文
|
||||
std::vector<Field> fields;
|
||||
StructT(ContextPtr _defContext, std::vector<Field> fieldsMap) :
|
||||
defContext(std::move(_defContext)),
|
||||
fields(std::move(fieldsMap))
|
||||
{
|
||||
id = nextId();
|
||||
}
|
||||
StructT(const StructT &other) :
|
||||
id(other.id), fields(other.fields) {}
|
||||
StructT &operator=(const StructT &other) = default;
|
||||
StructT(StructT &&) noexcept = default;
|
||||
StructT &operator=(StructT &&) noexcept = default;
|
||||
|
||||
bool operator==(const StructT &other) const noexcept
|
||||
// ===== Constructors =====
|
||||
StructType(ContextPtr _defContext, std::vector<Field> _fields) :
|
||||
id(nextId()), defContext(std::move(_defContext)), fields(std::move(_fields)) {}
|
||||
|
||||
StructType(const StructType &other) = default;
|
||||
StructType(StructType &&) noexcept = default;
|
||||
StructType &operator=(const StructType &) = default;
|
||||
StructType &operator=(StructType &&) noexcept = default;
|
||||
|
||||
// ===== Comparison =====
|
||||
bool operator==(const StructType &other) const noexcept
|
||||
{
|
||||
return id == other.id;
|
||||
}
|
||||
bool operator!=(const StructT &other) const noexcept
|
||||
bool operator!=(const StructType &other) const noexcept
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
@@ -68,28 +69,4 @@ namespace Fig
|
||||
return counter++;
|
||||
}
|
||||
};
|
||||
|
||||
class StructType final : public __ValueWrapper<StructT>
|
||||
{
|
||||
public:
|
||||
StructType(const StructT &x) :
|
||||
__ValueWrapper(ValueType::StructType)
|
||||
{
|
||||
data = std::make_unique<StructT>(x);
|
||||
}
|
||||
StructType(ContextPtr _defContext, std::vector<Field> fieldsMap) :
|
||||
__ValueWrapper(ValueType::StructType)
|
||||
{
|
||||
data = std::make_unique<StructT>(std::move(_defContext), std::move(fieldsMap));
|
||||
}
|
||||
bool operator==(const StructType &other) const noexcept
|
||||
{
|
||||
return data == other.data;
|
||||
}
|
||||
StructType(const StructType &) = default;
|
||||
StructType(StructType &&) noexcept = default;
|
||||
StructType &operator=(const StructType &) = default;
|
||||
StructType &operator=(StructType &&) noexcept = default;
|
||||
};
|
||||
|
||||
}; // namespace Fig
|
||||
} // namespace Fig
|
||||
|
||||
Reference in New Issue
Block a user