@@ -38,19 +38,14 @@ std::string Field::generateGetter(int fieldIndex) {
3838 return s.str ();
3939}
4040
41- StructOrUnion::StructOrUnion (std::string name, std::vector<Field *> fields,
41+ StructOrUnion::StructOrUnion (std::string name,
42+ std::vector<std::shared_ptr<Field>> fields,
4243 std::shared_ptr<Location> location)
4344 : name(std::move(name)), fields(std::move(fields)),
4445 location(std::move(location)) {}
4546
4647std::string StructOrUnion::getName () const { return name; }
4748
48- StructOrUnion::~StructOrUnion () {
49- for (const auto &field : fields) {
50- delete field;
51- }
52- }
53-
5449bool StructOrUnion::equals (const StructOrUnion &other) const {
5550 if (this == &other) {
5651 return true ;
@@ -77,8 +72,8 @@ std::shared_ptr<Location> StructOrUnion::getLocation() const {
7772 return location;
7873}
7974
80- Struct::Struct (std::string name, std::vector<Field *> fields, uint64_t typeSize ,
81- std::shared_ptr<Location> location)
75+ Struct::Struct (std::string name, std::vector<std::shared_ptr< Field>> fields,
76+ uint64_t typeSize, std::shared_ptr<Location> location)
8277 : StructOrUnion(std::move(name), std::move(fields), std::move(location)),
8378 typeSize(typeSize) {}
8479
@@ -163,8 +158,8 @@ bool Struct::operator==(const Type &other) const {
163158 return false ;
164159}
165160
166- Union::Union (std::string name, std::vector<Field *> fields, uint64_t maxSize ,
167- std::shared_ptr<Location> location)
161+ Union::Union (std::string name, std::vector<std::shared_ptr< Field>> fields,
162+ uint64_t maxSize, std::shared_ptr<Location> location)
168163 : StructOrUnion(std::move(name), std::move(fields), std::move(location)),
169164 ArrayType(std::make_shared<PrimitiveType>(" Byte" ), maxSize) {}
170165
0 commit comments