Ignore:
Timestamp:
Aug 20, 2018, 1:26:36 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
550e819
Parents:
d978ada
Message:

Change type variable name mangling to use combination of tyvar position/encoding prefix rather than type variable name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Mangler.cc

    rd978ada r0e761e40  
    240240                                } else {
    241241                                        printQualifiers( typeInst );
     242                                        // Note: Can't use name here, since type variable names do not actually disambiguate a function, e.g.
     243                                        //   forall(dtype T) void f(T);
     244                                        //   forall(dtype S) void f(S);
     245                                        // are equivalent and should mangle the same way. This is accomplished by numbering the type variables when they
     246                                        // are first found and prefixing with the appropriate encoding for the type class.
    242247                                        assertf( varNum->second.second < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", varNum->second.second );
    243                                         mangleName << Encoding::typeVariables[varNum->second.second] << typeInst->get_name().size() << typeInst->get_name(); // varNum->second.first;
     248                                        mangleName << Encoding::typeVariables[varNum->second.second] << varNum->second.first;
    244249                                } // if
    245250                        }
     
    287292
    288293                        void Mangler::postvisit( TypeDecl * decl ) {
     294                                // TODO: is there any case where mangling a TypeDecl makes sense? If so, this code needs to be
     295                                // fixed to ensure that two TypeDecls mangle to the same name when they are the same type and vice versa.
     296                                // Note: The current scheme may already work correctly for this case, I have not thought about this deeply
     297                                // and the case has not yet come up in practice. Alternatively, if not then this code can be removed
     298                                // aside from the assert false.
     299                                assertf(false, "Mangler should not visit typedecl: %s", toCString(decl));
    289300                                assertf( decl->get_kind() < TypeDecl::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->get_kind() );
    290301                                mangleName << Encoding::typeVariables[ decl->get_kind() ] << ( decl->name.length() ) << decl->name;
Note: See TracChangeset for help on using the changeset viewer.