Changeset 69911c11
- Timestamp:
- Dec 17, 2015, 12:00:55 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:
- c23f807
- Parents:
- 7754cde
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r7754cde r69911c11 331 331 std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin(); 332 332 std::list< Expression* >::const_iterator fnArg = arg; 333 std::set< std::string > seenTypes; //< sizeofNamefor generic types we've seen333 std::set< std::string > seenTypes; //< names for generic types we've seen 334 334 for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) { 335 335 Type *parmType = (*fnParm)->get_type(); -
src/GenPoly/GenPoly.cc
r7754cde r69911c11 166 166 167 167 std::string sizeofName( Type *ty ) { 168 return std::string( "_sizeof_" ) + SymTab::Mangler::mangle ( ty, false, false);168 return std::string( "_sizeof_" ) + SymTab::Mangler::mangleType( ty ); 169 169 } 170 170 171 171 std::string alignofName( Type *ty ) { 172 return std::string( "_alignof_" ) + SymTab::Mangler::mangle ( ty, false, false);172 return std::string( "_alignof_" ) + SymTab::Mangler::mangleType( ty ); 173 173 } 174 174 } // namespace GenPoly -
src/SymTab/Mangler.cc
r7754cde r69911c11 30 30 31 31 namespace SymTab { 32 Mangler::Mangler( bool mangleOverridable, bool includeQualifiers ) 33 : nextVarNum( 0 ), isTopLevel( true ), mangleOverridable( mangleOverridable ), includeQualifiers(includeQualifiers) {} 32 std::string Mangler::mangleType( Type *ty ) { 33 Mangler mangler( false, true ); 34 maybeAccept( ty, mangler ); 35 return mangler.get_mangleName(); 36 } 37 38 Mangler::Mangler( bool mangleOverridable, bool typeMode ) 39 : nextVarNum( 0 ), isTopLevel( true ), mangleOverridable( mangleOverridable ), typeMode( typeMode ) {} 34 40 35 41 Mangler::Mangler( const Mangler &rhs ) : mangleName() { … … 38 44 isTopLevel = rhs.isTopLevel; 39 45 mangleOverridable = rhs.mangleOverridable; 40 includeQualifiers = rhs.includeQualifiers;46 typeMode = rhs.typeMode; 41 47 } 42 48 … … 164 170 if ( ! params.empty() ) { 165 171 mangleName << "_"; 166 std::list< Type* > paramTypes;167 172 for ( std::list< Expression* >::const_iterator param = params.begin(); param != params.end(); ++param ) { 168 173 TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param ); 169 174 assert(paramType && "Aggregate parameters should be type expressions"); 170 paramTypes.push_back( paramType->get_type());175 maybeAccept( paramType->get_type(), *this ); 171 176 } 172 acceptAll( paramTypes, *this );173 177 mangleName << "_"; 174 178 } … … 179 183 180 184 void Mangler::visit( StructInstType *aggregateUseType ) { 181 mangleGenericRef( aggregateUseType, "s" ); 185 if ( typeMode ) mangleGenericRef( aggregateUseType, "s" ); 186 else mangleRef( aggregateUseType, "s" ); 182 187 } 183 188 184 189 void Mangler::visit( UnionInstType *aggregateUseType ) { 185 mangleGenericRef( aggregateUseType, "u" ); 190 if ( typeMode ) mangleGenericRef( aggregateUseType, "u" ); 191 else mangleRef( aggregateUseType, "u" ); 186 192 } 187 193 … … 233 239 void Mangler::printQualifiers( Type *type ) { 234 240 // skip if not including qualifiers 235 if ( ! includeQualifiers) return;241 if ( typeMode ) return; 236 242 237 243 if ( ! type->get_forall().empty() ) { … … 253 259 varNums[ (*i )->get_name() ] = std::pair< int, int >( nextVarNum++, (int )(*i )->get_kind() ); 254 260 for ( std::list< DeclarationWithType* >::iterator assert = (*i )->get_assertions().begin(); assert != (*i )->get_assertions().end(); ++assert ) { 255 Mangler sub_mangler( mangleOverridable, includeQualifiers);261 Mangler sub_mangler( mangleOverridable, typeMode ); 256 262 sub_mangler.nextVarNum = nextVarNum; 257 263 sub_mangler.isTopLevel = false; -
src/SymTab/Mangler.h
r7754cde r69911c11 25 25 class Mangler : public Visitor { 26 26 public: 27 /// Mangle syntax tree object; primary interface to clients 27 28 template< typename SynTreeClass > 28 static std::string mangle( SynTreeClass *decl, bool mangleOverridable = true, bool includeQualifiers = true ); // interface to clients 29 static std::string mangle( SynTreeClass *decl, bool mangleOverridable = true ); 30 /// Mangle a type name; secondary interface 31 static std::string mangleType( Type* ty ); 29 32 30 33 virtual void visit( ObjectDecl *declaration ); … … 51 54 bool isTopLevel; ///< Is the Mangler at the top level 52 55 bool mangleOverridable; ///< Specially mangle overridable built-in methods 53 bool includeQualifiers; ///< Include type qualifiers in mangled name56 bool typeMode; ///< Produce a unique mangled name for a type 54 57 55 Mangler( bool mangleOverridable, bool includeQualifiers);58 Mangler( bool mangleOverridable, bool typeMode ); 56 59 Mangler( const Mangler & ); 57 60 … … 64 67 65 68 template< typename SynTreeClass > 66 std::string Mangler::mangle( SynTreeClass *decl, bool mangleOverridable , bool includeQualifiers) {67 Mangler mangler( mangleOverridable, includeQualifiers);69 std::string Mangler::mangle( SynTreeClass *decl, bool mangleOverridable ) { 70 Mangler mangler( mangleOverridable, false ); 68 71 maybeAccept( decl, mangler ); 69 72 return mangler.get_mangleName();
Note: See TracChangeset
for help on using the changeset viewer.