Changeset bdd516a for translator/ResolvExpr
- Timestamp:
- Apr 28, 2015, 4:21:36 PM (9 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, string, with_gc
- Children:
- 42e2ad7
- Parents:
- ad17ba6a
- Location:
- translator/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/ResolvExpr/AlternativeFinder.cc
rad17ba6a rbdd516a 756 756 alternatives.push_back( Alternative( sizeofExpr->clone(), env, Cost::zero ) ); 757 757 } else { 758 // find all alternatives for the argument to sizeof 758 759 AlternativeFinder finder( indexer, env ); 759 760 finder.find( sizeofExpr->get_expr() ); 760 if ( finder.alternatives.size() != 1 ) { 761 // find the lowest cost alternative among the alternatives, otherwise ambiguous 762 AltList winners; 763 findMinCost( finder.alternatives.begin(), finder.alternatives.end(), back_inserter( winners ) ); 764 if ( winners.size() != 1 ) { 761 765 throw SemanticError( "Ambiguous expression in sizeof operand: ", sizeofExpr->get_expr() ); 762 766 } 763 Alternative &choice = finder.alternatives.front(); 767 // return the lowest cost alternative for the argument 768 Alternative &choice = winners.front(); 764 769 alternatives.push_back( Alternative( new SizeofExpr( choice.expr->clone() ), choice.env, Cost::zero ) ); 765 770 } -
translator/ResolvExpr/Resolver.cc
rad17ba6a rbdd516a 44 44 acceptAll( translationUnit, resolver ); 45 45 #if 0 46 resolver.print( cerr ); 46 47 for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) { 47 48 (*i)->print( std::cerr ); … … 241 242 void Resolver::visit( SingleInit *singleInit ) { 242 243 if ( singleInit->get_value() ) { 244 #if 0 245 if (NameExpr * ne = dynamic_cast<NameExpr*>(singleInit->get_value())) { 246 string n = ne->get_name(); 247 if (n == "0") { 248 initContext = new BasicType(Type::Qualifiers(), 249 BasicType::SignedInt); 250 } else { 251 DeclarationWithType * decl = lookupId(n); 252 initContext = decl->get_type(); 253 } 254 } else if (ConstantExpr * e = 255 dynamic_cast<ConstantExpr*>(singleInit->get_value())) { 256 Constant *c = e->get_constant(); 257 initContext = c->get_type(); 258 } else { 259 assert(0); 260 } 261 #endif 243 262 CastExpr *castExpr = new CastExpr( singleInit->get_value(), initContext->clone() ); 244 263 Expression *newExpr = findSingleExpression( castExpr, *this ); … … 250 269 251 270 void Resolver::visit( ListInit *listInit ) { 271 Visitor::visit(listInit); 272 #if 0 252 273 if ( ArrayType *at = dynamic_cast<ArrayType*>(initContext) ) { 253 initContext = at->get_base(); 254 Visitor::visit( listInit ); 274 std::list<Initializer *>::iterator iter( listInit->begin_initializers() ); 275 for ( ; iter != listInit->end_initializers(); ++iter ) { 276 initContext = at->get_base(); 277 (*iter)->accept( *this ); 278 } // for 255 279 } else if ( StructInstType *st = dynamic_cast<StructInstType*>(initContext) ) { 256 280 StructDecl *baseStruct = st->get_baseStruct(); … … 295 319 (*listInit->begin_initializers())->accept( *this ); 296 320 } // if 321 #endif 297 322 } 298 323 } // namespace ResolvExpr
Note: See TracChangeset
for help on using the changeset viewer.