mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-05 22:48:42 +00:00
fixes, part of execute_visitor
This commit is contained in:
parent
802b736e15
commit
6e487c8fd9
6 changed files with 79 additions and 47 deletions
|
|
@ -42,10 +42,10 @@ public:
|
|||
|
||||
struct TupleValue {
|
||||
public:
|
||||
explicit TupleValue(ValueManager* value_manager) : value_manager_(value_manager) {}
|
||||
TupleValue() = default;
|
||||
|
||||
explicit TupleValue(std::vector<std::pair<std::optional<std::string>, utils::IdType>>&& fields,
|
||||
ValueManager* value_manager)
|
||||
TupleValue(std::vector<std::pair<std::optional<std::string>, utils::IdType>>&& fields,
|
||||
ValueManager* value_manager)
|
||||
: fields(std::move(fields)), value_manager_(value_manager) {}
|
||||
|
||||
std::optional<utils::IdType> GetFieldValue(const std::string& name);
|
||||
|
|
@ -53,29 +53,26 @@ public:
|
|||
std::vector<std::pair<std::optional<std::string>, utils::IdType>> fields;
|
||||
|
||||
private:
|
||||
ValueManager* value_manager_;
|
||||
ValueManager* value_manager_ = nullptr;
|
||||
};
|
||||
|
||||
struct VariantValue {
|
||||
public:
|
||||
explicit VariantValue(ValueManager* value_manager) : value_manager_(value_manager) {}
|
||||
explicit VariantValue() = default;
|
||||
|
||||
// TupleValue ?? // TODO: add type??
|
||||
VariantValue(utils::IdType value, size_t current_constructor, ValueManager* value_manager)
|
||||
: value(value), current_constructor(current_constructor), value_manager_(value_manager) {}
|
||||
VariantValue(TupleValue&& value, size_t current_constructor)
|
||||
: value(std::move(value)), current_constructor(current_constructor) {}
|
||||
|
||||
public:
|
||||
utils::IdType value;
|
||||
TupleValue value;
|
||||
size_t current_constructor;
|
||||
|
||||
std::optional<utils::IdType> GetFieldValue(const std::string& name);
|
||||
private:
|
||||
ValueManager* value_manager_;
|
||||
};
|
||||
|
||||
struct ReferenceToValue {
|
||||
public:
|
||||
explicit ReferenceToValue(ValueManager* value_manager) : value_manager_(value_manager) {}
|
||||
ReferenceToValue() = default;
|
||||
|
||||
ReferenceToValue(const std::vector<utils::ReferenceModifier>& references,
|
||||
utils::IdType value,
|
||||
|
|
@ -88,12 +85,12 @@ public:
|
|||
|
||||
std::optional<utils::IdType> GetFieldValue(const std::string& name);
|
||||
private:
|
||||
ValueManager* value_manager_;
|
||||
ValueManager* value_manager_ = nullptr;
|
||||
};
|
||||
|
||||
struct FunctionValue {
|
||||
public:
|
||||
explicit FunctionValue(ValueManager* value_manager) : value_manager_(value_manager) {}
|
||||
FunctionValue() = default;
|
||||
|
||||
template<typename T>
|
||||
FunctionValue(const T& function, ValueManager* value_manager)
|
||||
|
|
@ -105,17 +102,17 @@ public:
|
|||
|
||||
std::optional<utils::IdType> GetFieldValue(const std::string& name);
|
||||
private:
|
||||
ValueManager* value_manager_;
|
||||
ValueManager* value_manager_ = nullptr;
|
||||
};
|
||||
|
||||
|
||||
struct ArrayValue {
|
||||
public:
|
||||
explicit ArrayValue(ValueManager* value_manager) : value_manager_(value_manager) {}
|
||||
ArrayValue() = default;
|
||||
|
||||
explicit ArrayValue(std::vector<utils::IdType>&& elements,
|
||||
bool is_constant_size,
|
||||
ValueManager* value_manager)
|
||||
ArrayValue(std::vector<utils::IdType>&& elements,
|
||||
bool is_constant_size,
|
||||
ValueManager* value_manager)
|
||||
: elements(std::move(elements)), is_constant_size(is_constant_size), value_manager_(value_manager) {}
|
||||
|
||||
public:
|
||||
|
|
@ -124,14 +121,14 @@ public:
|
|||
|
||||
std::optional<utils::IdType> GetFieldValue(const std::string& name);
|
||||
private:
|
||||
ValueManager* value_manager_;
|
||||
ValueManager* value_manager_ = nullptr;
|
||||
};
|
||||
|
||||
struct OptionalValue {
|
||||
public:
|
||||
explicit OptionalValue(ValueManager* value_manager) : value_manager_(value_manager) {}
|
||||
OptionalValue() = default;
|
||||
|
||||
explicit OptionalValue(utils::IdType value, ValueManager* value_manager)
|
||||
OptionalValue(std::optional<utils::IdType> value, ValueManager* value_manager)
|
||||
: value(value), value_manager_(value_manager) {}
|
||||
|
||||
std::optional<utils::IdType> GetFieldValue(const std::string& name);
|
||||
|
|
@ -139,7 +136,7 @@ public:
|
|||
std::optional<utils::IdType> value;
|
||||
|
||||
private:
|
||||
ValueManager* value_manager_;
|
||||
ValueManager* value_manager_ = nullptr;
|
||||
};
|
||||
|
||||
struct Value { // DefinedValue ??
|
||||
|
|
@ -189,9 +186,9 @@ public:
|
|||
return values_.at(value_id).second;
|
||||
}
|
||||
|
||||
bool EqualTypes(utils::IdType first_type, utils::IdType second_type) = delete; // TODO
|
||||
bool EqualValues(utils::IdType first_value, utils::IdType second_value) = delete; // TODO
|
||||
|
||||
bool AddTypeRequirement(utils::IdType type, utils::IdType requrement) = delete;
|
||||
bool AddValueRequirement(utils::IdType value, utils::IdType requrement) = delete;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<Value, utils::ValueType>> values_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue