Changeset 71f4e4f for src/ResolvExpr
- Timestamp:
- Jan 13, 2016, 5:19:47 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- f1e012b
- Parents:
- 02c7d04
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r02c7d04 r71f4e4f 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Resolver.cc -- 7 // Resolver.cc -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 12:17:01 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jul 24 17:33:54 201513 // Update Count : 1 7811 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Jan 13 16:23:51 2016 13 // Update Count : 186 14 14 // 15 15 … … 33 33 public: 34 34 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {} 35 35 36 36 virtual void visit( FunctionDecl *functionDecl ); 37 37 virtual void visit( ObjectDecl *functionDecl ); … … 54 54 virtual void visit( SingleInit *singleInit ); 55 55 virtual void visit( ListInit *listInit ); 56 virtual void visit( ConstructorInit *ctorInit ); 56 57 private: 57 58 typedef std::list< Initializer * >::iterator InitIterator; … … 95 96 return newExpr; 96 97 } 97 98 98 99 Expression *findSingleExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 99 100 TypeEnvironment env; … … 126 127 } // if 127 128 } 128 129 129 130 Expression *findIntegralExpression( Expression *untyped, const SymTab::Indexer &indexer ) { 130 131 TypeEnvironment env; … … 159 160 return newExpr; 160 161 } 161 162 } 163 162 163 } 164 164 165 void Resolver::visit( ObjectDecl *objectDecl ) { 165 166 Type *new_type = resolveTypeof( objectDecl->get_type(), *this ); … … 251 252 forStmt->set_condition( newExpr ); 252 253 } // if 253 254 254 255 if ( forStmt->get_increment() ) { 255 256 Expression * newExpr = findVoidExpression( forStmt->get_increment(), *this ); … … 265 266 delete switchStmt->get_condition(); 266 267 switchStmt->set_condition( newExpr ); 267 268 268 269 visitor.Visitor::visit( switchStmt ); 269 270 } … … 307 308 bool isCharType( T t ) { 308 309 if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) { 309 return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 310 return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || 310 311 bt->get_kind() == BasicType::UnsignedChar; 311 312 } … … 319 320 string n = ne->get_name(); 320 321 if (n == "0") { 321 initContext = new BasicType(Type::Qualifiers(), 322 initContext = new BasicType(Type::Qualifiers(), 322 323 BasicType::SignedInt); 323 324 } else { … … 325 326 initContext = decl->get_type(); 326 327 } 327 } else if (ConstantExpr * e = 328 } else if (ConstantExpr * e = 328 329 dynamic_cast<ConstantExpr*>(singleInit->get_value())) { 329 330 Constant *c = e->get_constant(); … … 349 350 singleInit->set_value( ce->get_arg() ); 350 351 ce->set_arg( NULL ); 351 delete ce; 352 delete ce; 352 353 } 353 354 } … … 465 466 #endif 466 467 } 468 469 void Resolver::visit( ConstructorInit *ctorInit ) { 470 TypeEnvironment env; 471 AlternativeFinder finder( *this, env ); 472 finder.find( ctorInit->get_ctor() ); 473 if ( finder.get_alternatives().size() == 0 ) { 474 // could not find valid constructor 475 delete ctorInit->get_ctor(); 476 ctorInit->set_ctor( NULL ); 477 478 maybeAccept( ctorInit->get_init(), *this ); 479 } else if ( finder.get_alternatives().size() == 1 ) { 480 // found a constructor - can get rid of C-style initializer 481 Alternative &choice = finder.get_alternatives().front(); 482 Expression *newExpr = choice.expr->clone(); 483 finishExpr( newExpr, choice.env ); 484 ctorInit->set_ctor( newExpr ); 485 delete ctorInit->get_init(); 486 ctorInit->set_init( NULL ); 487 } else { 488 // too many constructors found 489 assert(false); 490 } 491 } 467 492 } // namespace ResolvExpr 468 493
Note: See TracChangeset
for help on using the changeset viewer.