Changeset 2f42718 for src/SymTab
- Timestamp:
- Feb 22, 2019, 10:43:29 AM (7 years ago)
- Branches:
- no_list
- Parents:
- 43e0949
- Location:
- src/SymTab
- Files:
-
- 6 edited
-
Autogen.cc (modified) (5 diffs)
-
Demangle.cc (modified) (2 diffs)
-
Indexer.cc (modified) (2 diffs)
-
Indexer.h (modified) (1 diff)
-
Mangler.cc (modified) (8 diffs)
-
Validate.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r43e0949 r2f42718 410 410 } 411 411 412 assert( ! func->get_functionType()-> get_parameters().empty() );413 ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( func->get_functionType()-> get_parameters().front() );412 assert( ! func->get_functionType()->parameters.empty() ); 413 ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->parameters.front() ); 414 414 ObjectDecl * srcParam = nullptr; 415 if ( func->get_functionType()-> get_parameters().size() == 2 ) {416 srcParam = dynamic_cast<ObjectDecl*>( func->get_functionType()-> get_parameters().back() );415 if ( func->get_functionType()->parameters.size() == 2 ) { 416 srcParam = dynamic_cast<ObjectDecl*>( func->get_functionType()->parameters.back() ); 417 417 } 418 418 … … 429 429 void StructFuncGenerator::makeFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func ) { 430 430 FunctionType * ftype = func->type; 431 std::list<DeclarationWithType*>& params = ftype->parameters;431 auto & params = ftype->parameters; 432 432 assert( params.size() >= 2 ); // should not call this function for default ctor, etc. 433 433 … … 435 435 ObjectDecl * dstParam = dynamic_cast<ObjectDecl*>( params.front() ); 436 436 assert( dstParam ); 437 std::list<DeclarationWithType*>::iteratorparameter = params.begin()+1;437 auto parameter = params.begin()+1; 438 438 for ( ; member != end; ++member ) { 439 439 if ( DeclarationWithType * field = dynamic_cast<DeclarationWithType*>( *member ) ) { … … 656 656 void makeTupleFunctionBody( FunctionDecl * function ) { 657 657 FunctionType * ftype = function->get_functionType(); 658 assertf( ftype-> get_parameters().size() == 1 || ftype->get_parameters().size() == 2, "too many parameters in generated tuple function" );658 assertf( ftype->parameters.size() == 1 || ftype->parameters.size() == 2, "too many parameters in generated tuple function" ); 659 659 660 660 UntypedExpr * untyped = new UntypedExpr( new NameExpr( function->get_name() ) ); 661 661 662 662 /// xxx - &* is used to make this easier for later passes to handle 663 untyped->get_args().push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( ftype-> get_parameters().front() ) ) ) );664 if ( ftype-> get_parameters().size() == 2 ) {665 untyped->get_args().push_back( new VariableExpr( ftype-> get_parameters().back() ) );666 } 667 function-> get_statements()->get_kids().push_back( new ExprStmt( untyped ) );668 function-> get_statements()->get_kids().push_back( new ReturnStmt( UntypedExpr::createDeref( new VariableExpr( ftype->get_parameters().front() ) ) ) );663 untyped->get_args().push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( ftype->parameters.front() ) ) ) ); 664 if ( ftype->parameters.size() == 2 ) { 665 untyped->get_args().push_back( new VariableExpr( ftype->parameters.back() ) ); 666 } 667 function->statements->get_kids().push_back( new ExprStmt( untyped ) ); 668 function->statements->get_kids().push_back( new ReturnStmt( UntypedExpr::createDeref( new VariableExpr( ftype->parameters.front() ) ) ) ); 669 669 } 670 670 … … 691 691 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), Type::StorageClasses(), nullptr, TypeDecl::Dtype, true ); 692 692 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 693 newDecl-> get_assertions().push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,693 newDecl->assertions.push_back( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr, 694 694 std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 695 newDecl-> get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,695 newDecl->assertions.push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 696 696 std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 697 newDecl-> get_assertions().push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,697 newDecl->assertions.push_back( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr, 698 698 std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 699 newDecl-> get_assertions().push_back( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,699 newDecl->assertions.push_back( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr, 700 700 std::vector< Attribute * >(), Type::FuncSpecifiers( Type::Inline ) ) ); 701 701 typeParams.push_back( newDecl ); -
src/SymTab/Demangle.cc
r43e0949 r2f42718 173 173 174 174 /************* parameters ***************/ 175 const std:: list<DeclarationWithType *> &pars = funcType->parameters;175 const std::vector<DeclarationWithType *> &pars = funcType->parameters; 176 176 177 177 if ( pars.empty() ) { … … 476 476 Type * StringView::parseTuple(Type::Qualifiers tq) { 477 477 PRINT( std::cerr << "tuple..." << std::endl; ) 478 std:: list< Type * > types;478 std::vector< Type * > types; 479 479 size_t ncomponents; 480 480 if (! extractNumber(ncomponents)) return nullptr; -
src/SymTab/Indexer.cc
r43e0949 r2f42718 142 142 for ( auto decl : copy ) { 143 143 if ( FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl.id ) ) { 144 std::list< DeclarationWithType * >& params = function->type->parameters;144 auto & params = function->type->parameters; 145 145 assert( ! params.empty() ); 146 146 // use base type of pointer, so that qualifiers on the pointer type aren't considered. … … 668 668 } 669 669 670 void Indexer::addIds( const std:: list< DeclarationWithType * > & decls ) {670 void Indexer::addIds( const std::vector< DeclarationWithType * > & decls ) { 671 671 for ( auto d : decls ) { 672 672 addId( d ); -
src/SymTab/Indexer.h
r43e0949 r2f42718 117 117 118 118 /// convenience function for adding a list of Ids to the indexer 119 void addIds( const std:: list< DeclarationWithType * > & decls );119 void addIds( const std::vector< DeclarationWithType * > & decls ); 120 120 121 121 /// convenience function for adding a list of forall parameters to the indexer -
src/SymTab/Mangler.cc
r43e0949 r2f42718 79 79 80 80 public: 81 Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 82 int nextVarNum, const ResolvExpr::TypeEnvironment* env, 81 Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 82 int nextVarNum, const ResolvExpr::TypeEnvironment* env, 83 83 const VarMapType& varNums ); 84 84 … … 109 109 } 110 110 111 std::string mangleAssnKey( DeclarationWithType* decl, 111 std::string mangleAssnKey( DeclarationWithType* decl, 112 112 const ResolvExpr::TypeEnvironment& env ) { 113 113 PassVisitor<Mangler> mangler( env ); … … 118 118 namespace { 119 119 Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams ) 120 : nextVarNum( 0 ), env(nullptr), isTopLevel( true ), 121 mangleOverridable( mangleOverridable ), typeMode( typeMode ), 120 : nextVarNum( 0 ), env(nullptr), isTopLevel( true ), 121 mangleOverridable( mangleOverridable ), typeMode( typeMode ), 122 122 mangleGenericParams( mangleGenericParams ) {} 123 123 124 124 Mangler::Mangler( const ResolvExpr::TypeEnvironment& env ) 125 125 : nextVarNum( 0 ), env( &env ), isTopLevel( true ), mangleOverridable( false ), 126 126 typeMode( false ), mangleGenericParams( true ) {} 127 128 Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 129 int nextVarNum, const ResolvExpr::TypeEnvironment* env, 127 128 Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 129 int nextVarNum, const ResolvExpr::TypeEnvironment* env, 130 130 const VarMapType& varNums ) 131 : varNums( varNums ), nextVarNum( nextVarNum ), env( env ), isTopLevel( false ), 132 mangleOverridable( mangleOverridable ), typeMode( typeMode ), 131 : varNums( varNums ), nextVarNum( nextVarNum ), env( env ), isTopLevel( false ), 132 mangleOverridable( mangleOverridable ), typeMode( typeMode ), 133 133 mangleGenericParams( mangleGenericParams ) {} 134 134 … … 207 207 208 208 namespace { 209 inline std:: list< Type* > getTypes( const std::list< DeclarationWithType* > decls ) {210 std:: list< Type* > ret;209 inline std::vector< Type* > getTypes( const std::vector< DeclarationWithType* > decls ) { 210 std::vector< Type* > ret; 211 211 std::transform( decls.begin(), decls.end(), std::back_inserter( ret ), 212 212 std::mem_fun( &DeclarationWithType::get_type ) ); … … 223 223 GuardValue( inFunctionType ); 224 224 inFunctionType = true; 225 std:: list< Type* > returnTypes = getTypes( functionType->returnVals );225 std::vector< Type* > returnTypes = getTypes( functionType->returnVals ); 226 226 if (returnTypes.empty()) mangleName << Encoding::void_t; 227 227 else acceptAll( returnTypes, *visitor ); 228 228 mangleName << "_"; 229 std:: list< Type* > paramTypes = getTypes( functionType->parameters );229 std::vector< Type* > paramTypes = getTypes( functionType->parameters ); 230 230 acceptAll( paramTypes, *visitor ); 231 231 mangleName << "_"; … … 238 238 239 239 if ( mangleGenericParams ) { 240 std::list< Expression* > & params = refType->parameters;240 std::list< Expression* > & params = refType->parameters; 241 241 if ( ! params.empty() ) { 242 242 mangleName << "_"; 243 for ( std::list< Expression* >::const_iterator param = params.begin(); param != params.end(); ++param) {244 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param );245 assertf(paramType, "Aggregate parameters should be type expressions: %s", toCString( *param));243 for ( auto param : params ) { 244 TypeExpr *paramType = dynamic_cast< TypeExpr* >( param ); 245 assertf(paramType, "Aggregate parameters should be type expressions: %s", toCString(param)); 246 246 maybeAccept( paramType->type, *visitor ); 247 247 } … … 364 364 if ( varClass && varClass->type ) { 365 365 PassVisitor<Mangler> sub_mangler( 366 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, 366 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, 367 367 env, varNums ); 368 368 varClass->type->accept( sub_mangler ); … … 375 375 } 376 376 varNums[ (*i)->name ] = std::make_pair( varName, (int)(*i)->get_kind() ); 377 for ( std::list< DeclarationWithType* >::iterator assert = (*i)->assertions.begin(); assert != (*i)->assertions.end(); ++assert) {378 PassVisitor<Mangler> sub_mangler( 379 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, env, 377 for ( auto assert : (*i)->assertions ) { 378 PassVisitor<Mangler> sub_mangler( 379 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, env, 380 380 varNums ); 381 (*assert)->accept( sub_mangler );381 assert->accept( sub_mangler ); 382 382 assertionNames.push_back( sub_mangler.pass.get_mangleName() ); 383 383 acount++; -
src/SymTab/Validate.cc
r43e0949 r2f42718 179 179 void previsit( ReturnStmt * returnStmt ); 180 180 181 typedef std::list< DeclarationWithType * > ReturnVals; 182 ReturnVals returnVals; 181 std::vector< DeclarationWithType * > returnVals; 183 182 }; 184 183 … … 866 865 void ReturnChecker::previsit( FunctionDecl * functionDecl ) { 867 866 GuardValue( returnVals ); 868 returnVals = functionDecl->get_functionType()-> get_returnVals();867 returnVals = functionDecl->get_functionType()->returnVals; 869 868 } 870 869 … … 1121 1120 void VerifyCtorDtorAssign::previsit( FunctionDecl * funcDecl ) { 1122 1121 FunctionType * funcType = funcDecl->get_functionType(); 1123 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals();1124 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters();1122 auto & returnVals = funcType->returnVals; 1123 auto & params = funcType->parameters; 1125 1124 1126 1125 if ( CodeGen::isCtorDtorAssign( funcDecl->get_name() ) ) { // TODO: also check /=, etc. … … 1205 1204 void ReturnTypeFixer::postvisit( FunctionDecl * functionDecl ) { 1206 1205 FunctionType * ftype = functionDecl->get_functionType(); 1207 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();1206 auto & retVals = ftype->returnVals; 1208 1207 assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: %zu", functionDecl->get_name().c_str(), retVals.size() ); 1209 1208 if ( retVals.size() == 1 ) { … … 1223 1222 // Note that this pass needs to happen early so that other passes which look for tuple types 1224 1223 // find them in all of the right places, including function return types. 1225 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();1224 auto & retVals = ftype->returnVals; 1226 1225 if ( retVals.size() > 1 ) { 1227 1226 // generate a single return parameter which is the tuple of all of the return values … … 1320 1319 if ( funcDecl->get_name() == "*?" && funcDecl->get_linkage() == LinkageSpec::Intrinsic ) { 1321 1320 FunctionType * ftype = funcDecl->get_functionType(); 1322 if ( ftype-> get_parameters().size() == 1 && ftype->get_parameters().front()->get_type()->get_qualifiers() == Type::Qualifiers() ) {1321 if ( ftype->parameters.size() == 1 && ftype->parameters.front()->get_type()->get_qualifiers() == Type::Qualifiers() ) { 1323 1322 dereferenceOperator = funcDecl; 1324 1323 }
Note:
See TracChangeset
for help on using the changeset viewer.