mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-28 17:58:45 +00:00
combine functions fixes
This commit is contained in:
parent
5e70f0015f
commit
4714a05467
5 changed files with 117 additions and 44 deletions
|
|
@ -115,6 +115,16 @@ public:
|
|||
value_ += name;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool operator==(const Identifier &other_identifier) const {
|
||||
return type_ == other_identifier.type_ && value_ == other_identifier.value_;
|
||||
}
|
||||
|
||||
bool operator!=(const Identifier &other_identifier) const {
|
||||
return !(*this == other_identifier);
|
||||
}
|
||||
|
||||
private:
|
||||
IdentifierType type_;
|
||||
std::string value_;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ enum class CombineResult {
|
|||
MORE_THEN_ONE_DOCS_ERROR,
|
||||
MORE_THEN_ONE_CONSTRAINTS_ERROR,
|
||||
MORE_THEN_ONE_DEFINITION_BODY_ERROR,
|
||||
TYPECLASSES_ERROR,
|
||||
ARGUMENTS_ERROR,
|
||||
DIFFERENT_STATEMENT_TYPES,
|
||||
STATEMENTS_CANT_BE_COMBINED_ERROR,
|
||||
|
|
|
|||
|
|
@ -56,10 +56,14 @@ public:
|
|||
: Node(node), name_(identifier), parameters_(std::move(parameters)),
|
||||
is_on_heap_(is_on_heap), modifier_(modifier) {}
|
||||
|
||||
//
|
||||
|
||||
Identifier *get_name() { return &name_; }
|
||||
|
||||
const Identifier *get_name() const { return &name_; }
|
||||
|
||||
//
|
||||
|
||||
size_t get_parametrs_size() const { return parameters_.size(); }
|
||||
|
||||
Type *get_parameter(size_t id) { return parameters_.at(id).get(); }
|
||||
|
|
@ -68,10 +72,34 @@ public:
|
|||
return parameters_.at(id).get();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
bool is_on_heap() const { return is_on_heap_; }
|
||||
|
||||
Modifier get_modifier() const { return modifier_; }
|
||||
|
||||
//
|
||||
|
||||
bool operator==(const Type &other_type) const {
|
||||
if (name_ != other_type.name_ || is_on_heap_ != other_type.is_on_heap_ ||
|
||||
modifier_ != other_type.modifier_ ||
|
||||
parameters_.size() != other_type.parameters_.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < parameters_.size(); ++i) {
|
||||
if (*parameters_[i].get() != *other_type.parameters_[i].get()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const Type &other_type) const {
|
||||
return !(*this == other_type);
|
||||
}
|
||||
|
||||
private:
|
||||
Identifier name_;
|
||||
std::vector<TypeProxy> parameters_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue