Changeset 052cd71 for src/SymTab
- Timestamp:
- Apr 26, 2019, 4:15:00 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 9795142
- Parents:
- bd405fa
- git-author:
- Aaron Moss <a3moss@…> (04/26/19 15:44:58)
- git-committer:
- Aaron Moss <a3moss@…> (04/26/19 16:15:00)
- Location:
- src/SymTab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SymTab/Mangler.cc ¶
rbd405fa r052cd71 38 38 struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler>, public WithGuards { 39 39 Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams ); 40 Mangler( const ResolvExpr::TypeEnvironment& env );41 40 Mangler( const Mangler & ) = delete; 42 41 … … 67 66 private: 68 67 std::ostringstream mangleName; ///< Mangled name being constructed 69 typedef std::map< std::string, std::pair< std::string, int > > VarMapType;68 typedef std::map< std::string, std::pair< int, int > > VarMapType; 70 69 VarMapType varNums; ///< Map of type variables to indices 71 70 int nextVarNum; ///< Next type variable index 72 const ResolvExpr::TypeEnvironment* env; ///< optional environment for substitutions73 71 bool isTopLevel; ///< Is the Mangler at the top level 74 72 bool mangleOverridable; ///< Specially mangle overridable built-in methods … … 80 78 public: 81 79 Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 82 int nextVarNum, const ResolvExpr::TypeEnvironment* env, 83 const VarMapType& varNums ); 80 int nextVarNum, const VarMapType& varNums ); 84 81 85 82 private: … … 109 106 } 110 107 111 std::string mangleAssnKey( DeclarationWithType* decl,112 const ResolvExpr::TypeEnvironment& env ) {113 PassVisitor<Mangler> mangler( env );114 maybeAccept( decl, mangler );115 return mangler.pass.get_mangleName();116 }117 118 108 namespace { 119 109 Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams ) 120 : nextVarNum( 0 ), env(nullptr),isTopLevel( true ),110 : nextVarNum( 0 ), isTopLevel( true ), 121 111 mangleOverridable( mangleOverridable ), typeMode( typeMode ), 122 112 mangleGenericParams( mangleGenericParams ) {} 123 113 124 Mangler::Mangler( const ResolvExpr::TypeEnvironment& env )125 : nextVarNum( 0 ), env( &env ), isTopLevel( true ), mangleOverridable( false ),126 typeMode( false ), mangleGenericParams( true ) {}127 128 114 Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams, 129 int nextVarNum, const ResolvExpr::TypeEnvironment* env, 130 const VarMapType& varNums ) 131 : varNums( varNums ), nextVarNum( nextVarNum ), env( env ), isTopLevel( false ), 115 int nextVarNum, const VarMapType& varNums ) 116 : varNums( varNums ), nextVarNum( nextVarNum ), isTopLevel( false ), 132 117 mangleOverridable( mangleOverridable ), typeMode( typeMode ), 133 118 mangleGenericParams( mangleGenericParams ) {} … … 358 343 assert( false ); 359 344 } // switch 360 std::string varName; 361 // replace type with substitution name if environment is available and bound 362 if ( env ) { 363 const ResolvExpr::EqvClass* varClass = env->lookup( (*i)->name ); 364 if ( varClass && varClass->type ) { 365 PassVisitor<Mangler> sub_mangler( 366 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, 367 env, varNums ); 368 varClass->type->accept( sub_mangler ); 369 varName = std::string{"%"} + sub_mangler.pass.get_mangleName(); 370 } 371 } 372 // otherwise just give type numeric name 373 if ( varName.empty() ) { 374 varName = std::to_string( nextVarNum++ ); 375 } 376 varNums[ (*i)->name ] = std::make_pair( varName, (int)(*i)->get_kind() ); 345 varNums[ (*i)->name ] = std::make_pair( nextVarNum, (int)(*i)->get_kind() ); 377 346 for ( std::list< DeclarationWithType* >::iterator assert = (*i)->assertions.begin(); assert != (*i)->assertions.end(); ++assert ) { 378 347 PassVisitor<Mangler> sub_mangler( 379 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, env, 380 varNums ); 348 mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ); 381 349 (*assert)->accept( sub_mangler ); 382 350 assertionNames.push_back( sub_mangler.pass.get_mangleName() ); -
TabularUnified src/SymTab/Mangler.h ¶
rbd405fa r052cd71 44 44 /// Mangle ignoring generic type parameters 45 45 std::string mangleConcrete( Type* ty ); 46 /// Mangle for assertion key47 std::string mangleAssnKey( DeclarationWithType* decl,48 const ResolvExpr::TypeEnvironment& env );49 46 50 47 namespace Encoding {
Note: See TracChangeset
for help on using the changeset viewer.