Changeset 1d2b64f for src/ResolvExpr
- Timestamp:
- Dec 13, 2016, 5:20:54 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- d5556a3
- Parents:
- 722617d
- git-author:
- Rob Schluntz <rschlunt@…> (12/13/16 17:16:27)
- git-committer:
- Rob Schluntz <rschlunt@…> (12/13/16 17:20:54)
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Resolver.cc
r722617d r1d2b64f 36 36 public: 37 37 Resolver() : SymTab::Indexer( false ) {} 38 39 using SymTab::Indexer::visit; 38 Resolver( const SymTab:: Indexer & other ) : SymTab::Indexer( other ) { 39 if ( const Resolver * res = dynamic_cast< const Resolver * >( &other ) ) { 40 functionReturn = res->functionReturn; 41 initContext = res->initContext; 42 inEnumDecl = res->inEnumDecl; 43 } 44 } 45 46 typedef SymTab::Indexer Parent; 47 using Parent::visit; 40 48 virtual void visit( FunctionDecl *functionDecl ) override; 41 49 virtual void visit( ObjectDecl *functionDecl ) override; … … 192 200 initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt ); 193 201 } 194 SymTab::Indexer::visit( objectDecl );202 Parent::visit( objectDecl ); 195 203 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) { 196 204 // delete newly created signed int type … … 212 220 void Resolver::visit( ArrayType * at ) { 213 221 handlePtrType( at ); 214 Visitor::visit( at );222 Parent::visit( at ); 215 223 } 216 224 217 225 void Resolver::visit( PointerType * pt ) { 218 226 handlePtrType( pt ); 219 Visitor::visit( pt );227 Parent::visit( pt ); 220 228 } 221 229 … … 225 233 typeDecl->set_base( new_type ); 226 234 } // if 227 SymTab::Indexer::visit( typeDecl );235 Parent::visit( typeDecl ); 228 236 } 229 237 … … 238 246 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 239 247 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 240 SymTab::Indexer::visit( functionDecl );248 Parent::visit( functionDecl ); 241 249 } 242 250 243 251 void Resolver::visit( EnumDecl * enumDecl ) { 244 252 // in case we decide to allow nested enums 245 bool oldInEnumDecl = inEnumDecl;253 ValueGuard< bool > oldInEnumDecl( inEnumDecl ); 246 254 inEnumDecl = true; 247 SymTab::Indexer::visit( enumDecl ); 248 inEnumDecl = oldInEnumDecl; 255 Parent::visit( enumDecl ); 249 256 } 250 257 251 258 void Resolver::visit( ExprStmt *exprStmt ) { 252 if ( exprStmt->get_expr() ) { 253 Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this ); 254 delete exprStmt->get_expr(); 255 exprStmt->set_expr( newExpr ); 256 } // if 259 assertf( exprStmt->get_expr(), "ExprStmt has null Expression in resolver" ); 260 Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this ); 261 delete exprStmt->get_expr(); 262 exprStmt->set_expr( newExpr ); 257 263 } 258 264 … … 277 283 delete ifStmt->get_condition(); 278 284 ifStmt->set_condition( newExpr ); 279 Visitor::visit( ifStmt );285 Parent::visit( ifStmt ); 280 286 } 281 287 … … 284 290 delete whileStmt->get_condition(); 285 291 whileStmt->set_condition( newExpr ); 286 Visitor::visit( whileStmt );292 Parent::visit( whileStmt ); 287 293 } 288 294 289 295 void Resolver::visit( ForStmt *forStmt ) { 290 SymTab::Indexer::visit( forStmt );296 Parent::visit( forStmt ); 291 297 292 298 if ( forStmt->get_condition() ) { … … 318 324 319 325 void Resolver::visit( CaseStmt *caseStmt ) { 320 Visitor::visit( caseStmt );326 Parent::visit( caseStmt ); 321 327 } 322 328 … … 482 488 } else { 483 489 // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context 484 Visitor::visit( listInit );490 Parent::visit( listInit ); 485 491 } 486 492 } else { 487 493 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) 488 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );494 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) || dynamic_cast < EnumInstType * > ( initContext ) ); 489 495 // basic types are handled here 490 Visitor::visit( listInit );496 Parent::visit( listInit ); 491 497 } 492 498 … … 554 560 } 555 561 562 // needs to be callable from outside the resolver, so this is a standalone function 563 void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer ) { 564 assert( ctorInit ); 565 Resolver resolver( indexer ); 566 ctorInit->accept( resolver ); 567 } 568 569 void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer ) { 570 assert( stmtExpr ); 571 Resolver resolver( indexer ); 572 stmtExpr->accept( resolver ); 573 } 574 556 575 void Resolver::visit( ConstructorInit *ctorInit ) { 557 576 // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit -
src/ResolvExpr/Resolver.h
r722617d r1d2b64f 25 25 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ); 26 26 Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ); 27 void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer ); 28 void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer ); 27 29 } // namespace ResolvExpr 28 30
Note: See TracChangeset
for help on using the changeset viewer.