mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-07 07:28:45 +00:00
statement builders finished
This commit is contained in:
parent
64a91299ff
commit
4470454838
19 changed files with 682 additions and 255 deletions
|
|
@ -111,7 +111,7 @@ public:
|
|||
fields_.reserve(fields.size());
|
||||
for (auto &field : fields) {
|
||||
if (field.first.has_value()) {
|
||||
annotation_ids_[field.first.value()] = fields_.size();
|
||||
annotation_fields_[field.first.value()] = fields_.size();
|
||||
}
|
||||
fields_.push_back(field.second);
|
||||
}
|
||||
|
|
@ -124,15 +124,26 @@ public:
|
|||
const Type *get(size_t id) const { return fields_.at(id).get(); }
|
||||
|
||||
Type *get(const std::string &annotation) {
|
||||
return fields_.at(annotation_ids_.at(annotation)).get();
|
||||
return fields_.at(annotation_fields_.at(annotation)).get();
|
||||
}
|
||||
|
||||
const Type *get(const std::string &annotation) const {
|
||||
return fields_.at(annotation_ids_.at(annotation)).get();
|
||||
return fields_.at(annotation_fields_.at(annotation)).get();
|
||||
}
|
||||
|
||||
std::vector<std::string> get_all_annotations() {
|
||||
std::vector<std::string> annotations;
|
||||
|
||||
annotations.reserve(annotation_fields_.size());
|
||||
for (auto &annotation_with_field : annotation_fields_) {
|
||||
annotations.push_back(annotation_with_field.first);
|
||||
}
|
||||
|
||||
return annotations;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, size_t> annotation_ids_; // Annotations
|
||||
std::unordered_map<std::string, size_t> annotation_fields_;
|
||||
std::vector<TypeProxy> fields_;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue