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