api improvements, part of expression type checks

This commit is contained in:
ProgramSnail 2024-01-04 14:30:57 +03:00
parent a2abb598ac
commit 512d011f72
4 changed files with 96 additions and 9 deletions

View file

@ -473,6 +473,8 @@ public:
const Type *get_type() const { return constructor_type_.get(); }
TypeProxy get_type_proxy() const { return constructor_type_; }
size_t arguments_size() const { return arguments_.size(); }
Expression *get_argument_value(size_t id) {

View file

@ -86,6 +86,8 @@ public:
void set_modifier(Modifier modifier) { modifier_ = modifier; }
bool is_modifier(Modifier modifier) const { return modifier_ == modifier; }
//
std::optional<std::string *> get_annotation() {
@ -102,6 +104,12 @@ public:
return std::nullopt;
}
bool is_no_annotation() const { return !annotation_.has_value(); }
bool is_annotation(const std::string &annotation) const {
return annotation_.has_value() && annotation_.value() == annotation;
}
void set_annotation(std::string &&annotation) {
annotation_ = std::move(annotation);
}
@ -176,7 +184,7 @@ public:
bool operator>=(const Type &other) const { return !operator<(other); }
// is parameters count check necessary ??
builtin::types::Type to_builtin() {
builtin::types::Type to_builtin() const {
auto builtin_type = builtin::types::to_type(*name_.get());
auto builtin_type_parameters_count =
@ -191,7 +199,9 @@ public:
return builtin_type;
}
bool is_builtin(builtin::types::Type type) { return to_builtin() == type; }
bool is_builtin(builtin::types::Type type) const {
return to_builtin() == type;
}
private:
Identifier name_;