| 57 | } |
| 58 | |
| 59 | void StructBody::AddField(StructField* f) |
| 60 | { |
| 61 | if (f == nullptr) |
| 62 | yyerror("Struct field is null!"); |
| 63 | if (f->name->empty()) |
| 64 | yyerror("Struct field name is invalid!"); |
| 65 | if (f->type->empty()) |
| 66 | yyerror("Struct field type is invalid!"); |
| 67 | |
| 68 | // Check for duplicates |
| 69 | auto it = std::find_if(fields.begin(), fields.end(), [f](auto item)->bool { return *item->name.get() == *f->name.get(); }); |
| 70 | if (it != fields.end()) |
| 71 | yyerror("Duplicate struct field name " + *f->name.get()); |
| 72 | |
| 73 | fields.push_back(std::shared_ptr<StructField>(f)); |
| 74 | } |
| 75 | |
| 76 | void StructRejects::AddReject(std::string* r, bool g) |
| 77 | { |