- Timestamp:
- Jul 13, 2024, 3:29:22 PM (5 months ago)
- Branches:
- master
- Children:
- 2e6b2a0
- Parents:
- 76b507d
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/SymbolTable.cpp
r76b507d r8315947 419 419 void SymbolTable::addWith( const std::vector< ptr<Expr> > & withExprs, const Decl * withStmt ) { 420 420 for ( const Expr * expr : withExprs ) { 421 if ( ! expr->result ) continue; 422 const Type * resTy = expr->result->stripReferences(); 423 auto aggrType = dynamic_cast< const BaseInstType * >( resTy ); 424 assertf( aggrType, "WithStmt expr has non-aggregate type: %s", 425 toString( expr->result ).c_str() ); 426 const AggregateDecl * aggr = aggrType->aggr(); 427 assertf( aggr, "WithStmt has null aggregate from type: %s", 428 toString( expr->result ).c_str() ); 429 430 addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) ); 421 if ( expr->result ) { 422 const Type * resTy = expr->result->stripReferences(); 423 auto aggrType = dynamic_cast< const BaseInstType * >( resTy ); 424 assertf( aggrType, "WithStmt expr has non-aggregate type: %s", 425 toString( expr->result ).c_str() ); 426 const AggregateDecl * aggr = aggrType->aggr(); 427 assertf( aggr, "WithStmt has null aggregate from type: %s", 428 toString( expr->result ).c_str() ); 429 430 addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) ); 431 } else { 432 auto typeExpr = dynamic_cast< const ast::TypeExpr *>( expr ); 433 if ( !typeExpr ) continue; 434 auto declEnumInst = typeExpr->type.as<ast::EnumInstType>(); 435 // assertf( declEnumInst, "WithStmt expr unsupprot type expression: %s", 436 // toString( typeExpr->type ).c_str()); 437 if ( !declEnumInst ) continue; 438 439 const EnumDecl * aggr = declEnumInst->aggr(); 440 // assertf( aggr, "WithStmt has null aggregate from type: %s", 441 // toString( typeExpr ).c_str() ); 442 // addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) ); 443 if ( !aggr ) { 444 aggr = lookupEnum( declEnumInst->name ); 445 assert( aggr ); 446 } 447 addMembers( aggr, expr, OnConflict::deleteWith( withStmt ) ); 448 } 431 449 } 432 450 } … … 800 818 if ( auto rty = dynamic_cast<const BaseInstType *>( t ) ) { 801 819 if ( ! dynamic_cast<const StructInstType *>(rty) 802 && ! dynamic_cast<const UnionInstType *>(rty) ) continue; 820 && ! dynamic_cast<const UnionInstType *>(rty) 821 && ! dynamic_cast<const EnumInstType *>(rty) ) continue; 803 822 ResolvExpr::Cost cost = ResolvExpr::Cost::zero; 804 823 ast::ptr<ast::TypeSubstitution> tmp = expr->env; -
src/ResolvExpr/Resolver.cpp
r76b507d r8315947 322 322 323 323 namespace { 324 bool structOrUnion ( const Candidate & i ) {324 bool structOrUnionOrEnum( const Candidate & i ) { 325 325 const ast::Type * t = i.expr->result->stripReferences(); 326 return dynamic_cast< const ast::StructInstType * >( t ) || dynamic_cast< const ast::UnionInstType * >( t ) ;326 return dynamic_cast< const ast::StructInstType * >( t ) || dynamic_cast< const ast::UnionInstType * >( t ) || dynamic_cast< const ast::EnumInstType * >( t ); 327 327 } 328 328 /// Predicate for "Candidate has integral type" … … 1140 1140 for (auto & expr : exprs) { 1141 1141 // only struct- and union-typed expressions are viable candidates 1142 expr = findKindExpression( expr, context, structOrUnion , "with expression" );1142 expr = findKindExpression( expr, context, structOrUnionOrEnum, "with expression" ); 1143 1143 1144 1144 // if with expression might be impure, create a temporary so that it is evaluated once -
src/Validate/GenericParameter.cpp
r76b507d r8315947 301 301 const ast::Expr * TranslateDimensionCore::postvisit( 302 302 const ast::TypeExpr * expr ) { 303 if ( auto instType = dynamic_cast<const ast::EnumInstType *>( expr->type.get() ) ) {304 const ast::EnumDecl * baseEnum = instType->base.get();305 return ast::ConstantExpr::from_int( expr->location, baseEnum->members.size() );306 }303 // if ( auto instType = dynamic_cast<const ast::EnumInstType *>( expr->type.get() ) ) { 304 // const ast::EnumDecl * baseEnum = instType->base.get(); 305 // return ast::ConstantExpr::from_int( expr->location, baseEnum->members.size() ); 306 // } 307 307 return expr; 308 308 }
Note: See TracChangeset
for help on using the changeset viewer.