Changes in / [896737b:10a1225]
- Location:
- src/AST
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r896737b r10a1225 10 10 // Created On : Thu May 09 15::37::05 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri May 17 11:14:00 201913 // Update Count : 212 // Last Modified On : Thu May 16 17:21:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 54 54 //================================================================================================ 55 55 56 #define ACCEPT_1(name, child, type) \ 57 old->child->accept(*this); \ 58 auto name = strict_dynamic_cast< ast::type * >( node ); 59 60 #define ACCEPT_N(name, child, type) \ 61 std::vector< ast::ptr<ast::type> > name; \ 62 name.reserve( old->child.size() ); \ 63 for( auto a : old->child ) { \ 64 a->accept( *this ); \ 65 name.emplace_back( strict_dynamic_cast< ast::type * >(node) ); \ 66 } 67 56 68 class ConverterOldToNew : public Visitor { 57 69 public: … … 110 122 111 123 virtual void visit( ObjectDecl * old ) override final { 124 ACCEPT_1(type, type, Type) 125 ACCEPT_1(init, init, Init) 126 ACCEPT_1(bitWd, bitfieldWidth, Expr) 127 ACCEPT_N(attr, attributes, Attribute) 128 112 129 auto decl = new ast::ObjectDecl( 113 130 old->location, 114 131 old->name, 115 GET_ACCEPT_1(type, Type),116 GET_ACCEPT_1(init, Init),132 type, 133 init, 117 134 { old->get_storageClasses().val }, 118 135 { old->linkage.val }, 119 GET_ACCEPT_1(bitfieldWidth, Expr),120 GET_ACCEPT_V(attributes, Attribute),136 bitWd, 137 std::move( attr ), 121 138 { old->get_funcSpec().val } 122 139 ); … … 135 152 136 153 virtual void visit( StructDecl * old ) override final { 154 ACCEPT_N(members, members, Decl) 155 ACCEPT_N(params, parameters, TypeDecl) 156 ACCEPT_1(parent, parent, AggregateDecl) 157 ACCEPT_N(attr, attributes, Attribute) 158 137 159 auto decl = new ast::StructDecl( 138 160 old->location, 139 161 old->name, 140 162 old->kind, 141 GET_ACCEPT_V(attributes, Attribute),163 std::move( attr ), 142 164 { old->linkage.val } 143 165 ); 144 decl->parent = GET_ACCEPT_1(parent, AggregateDecl);166 decl->parent = parent; 145 167 decl->body = old->body; 146 decl->params = GET_ACCEPT_V(parameters, TypeDecl);147 decl->members = GET_ACCEPT_V(members, Decl);168 decl->params = params; 169 decl->members = members; 148 170 decl->extension = old->extension; 149 171 decl->uniqueId = old->uniqueId; … … 154 176 155 177 virtual void visit( UnionDecl * old ) override final { 178 ACCEPT_N(members, members, Decl) 179 ACCEPT_N(params, parameters, TypeDecl) 180 ACCEPT_1(parent, parent, AggregateDecl) 181 ACCEPT_N(attr, attributes, Attribute) 182 156 183 auto decl = new ast::UnionDecl( 157 184 old->location, 158 185 old->name, 159 GET_ACCEPT_V(attributes, Attribute),186 std::move( attr ), 160 187 { old->linkage.val } 161 188 ); 162 decl->parent = GET_ACCEPT_1(parent, AggregateDecl);189 decl->parent = parent; 163 190 decl->body = old->body; 164 decl->params = GET_ACCEPT_V(parameters, TypeDecl);165 decl->members = GET_ACCEPT_V(members, Decl);191 decl->params = params; 192 decl->members = members; 166 193 decl->extension = old->extension; 167 194 decl->uniqueId = old->uniqueId; … … 172 199 173 200 virtual void visit( EnumDecl * old ) override final { 201 ACCEPT_N(members, members, Decl) 202 ACCEPT_N(params, parameters, TypeDecl) 203 ACCEPT_1(parent, parent, AggregateDecl) 204 ACCEPT_N(attr, attributes, Attribute) 205 174 206 auto decl = new ast::UnionDecl( 175 207 old->location, 176 208 old->name, 177 GET_ACCEPT_V(attributes, Attribute),209 std::move( attr ), 178 210 { old->linkage.val } 179 211 ); 180 decl->parent = GET_ACCEPT_1(parent, AggregateDecl);212 decl->parent = parent; 181 213 decl->body = old->body; 182 decl->params = GET_ACCEPT_V(parameters, TypeDecl);183 decl->members = GET_ACCEPT_V(members, Decl);214 decl->params = params; 215 decl->members = members; 184 216 decl->extension = old->extension; 185 217 decl->uniqueId = old->uniqueId; … … 190 222 191 223 virtual void visit( TraitDecl * old ) override final { 224 ACCEPT_N(members, members, Decl) 225 ACCEPT_N(params, parameters, TypeDecl) 226 ACCEPT_1(parent, parent, AggregateDecl) 227 ACCEPT_N(attr, attributes, Attribute) 228 192 229 auto decl = new ast::UnionDecl( 193 230 old->location, 194 231 old->name, 195 GET_ACCEPT_V(attributes, Attribute),232 std::move( attr ), 196 233 { old->linkage.val } 197 234 ); 198 decl->parent = GET_ACCEPT_1(parent, AggregateDecl);235 decl->parent = parent; 199 236 decl->body = old->body; 200 decl->params = GET_ACCEPT_V(parameters, TypeDecl);201 decl->members = GET_ACCEPT_V(members, Decl);237 decl->params = params; 238 decl->members = members; 202 239 decl->extension = old->extension; 203 240 decl->uniqueId = old->uniqueId; … … 212 249 213 250 virtual void visit( TypedefDecl * old ) override final { 251 ACCEPT_1(type, base, Type) 252 ACCEPT_N(params, parameters, TypeDecl) 253 ACCEPT_N(asserts, assertions, DeclWithType) 214 254 auto decl = new ast::TypedefDecl( 215 255 old->location, 216 256 old->name, 217 257 { old->storageClasses.val }, 218 GET_ACCEPT_1(base, Type),258 type, 219 259 { old->linkage.val } 220 260 ); 221 decl->assertions = GET_ACCEPT_V(assertions, DeclWithType); 222 decl->params = GET_ACCEPT_V(parameters, TypeDecl); 261 262 decl->assertions = asserts; 263 decl->params = params; 223 264 decl->extension = old->extension; 224 265 decl->uniqueId = old->uniqueId; … … 237 278 238 279 virtual void visit( CompoundStmt * old ) override final { 280 ACCEPT_N(kids, kids, Stmt) 239 281 auto stmt = new ast::CompoundStmt( 240 282 old->location, 241 to<std::list>::from( GET_ACCEPT_V(kids, Stmt) ),242 GET_LABELS_V(old->labels)243 );283 to<std::list>::from( std::move(kids) ) 284 ); 285 stmt->labels = to<std::vector>::from( make_labels( std::move( old->labels ) ) ); 244 286 245 287 this->node = stmt; … … 346 388 CASE(FallThroughDefault); 347 389 #undef CASE 348 default:349 assertf(false, "Invalid BranchStmt::Type %d\n", old->type);350 390 } 351 391 … … 379 419 kind = ast::ThrowStmt::Resume; 380 420 break; 381 default:382 assertf(false, "Invalid ThrowStmt::Kind %d\n", old->kind);383 421 } 384 422 … … 411 449 kind = ast::CatchStmt::Resume; 412 450 break; 413 default:414 assertf(false, "Invalid CatchStmt::Kind %d\n", old->kind);415 451 } 416 452 … … 753 789 #undef GET_ACCEPT_1 754 790 791 #undef ACCEPT_N 792 #undef ACCEPT_1 793 755 794 std::list< ast::ptr< ast::Decl > > convert( const std::list< Declaration * > & translationUnit ) { 756 795 ConverterOldToNew c; -
src/AST/Stmt.hpp
r896737b r10a1225 10 10 // Created On : Wed May 8 13:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri May 17 10:03:00 201913 // Update Count : 412 // Last Modified On : Wed May 16 12:20:00 2019 13 // Update Count : 3 14 14 // 15 15 … … 54 54 std::list<ptr<Stmt>> kids; 55 55 56 CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {}, 57 std::vector<Label>&& labels = {} ) 58 : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} 56 CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {} ) 57 : Stmt(loc), kids(std::move(ks)) {} 59 58 60 59 CompoundStmt( const CompoundStmt& o );
Note: See TracChangeset
for help on using the changeset viewer.