void visit(TypeFunction *t) { /* * <function-type> ::= F [Y] <bare-function-type> E * <bare-function-type> ::= <signature type>+ * # types are possible return type, then parameter types */ /* ABI says: "The type of a non-static member function is considered to be different, for the purposes of substitution, from the type of a namespace-scope or static member function whose type appears similar. The types of two non-static member functions are considered to be different, for the purposes of substitution, if the functions are members of different classes. In other words, for the purposes of substitution, the class of which the function is a member is considered part of the type of function." BUG: Right now, types of functions are never merged, so our simplistic component matcher always finds them to be different. We should use Type::equals on these, and use different TypeFunctions for non-static member functions, and non-static member functions of different classes. */ if (substitute(t)) return; buf.writeByte('F'); if (t->linkage == LINKc) buf.writeByte('Y'); t->next->accept(this); argsCppMangle(t->parameters, t->varargs); buf.writeByte('E'); store(t); }
void mangle_function(FuncDeclaration *d) { /* * <mangled-name> ::= _Z <encoding> * <encoding> ::= <function name> <bare-function-type> * ::= <data name> * ::= <special-name> */ TypeFunction *tf = (TypeFunction *)d->type; buf.writestring(global.params.isOSX ? "__Z" : "_Z"); // "__Z" for OSX, "_Z" for other Dsymbol *p = d->toParent(); if (p && !p->isModule() && tf->linkage == LINKcpp) { buf.writeByte('N'); if (d->type->isConst()) buf.writeByte('K'); prefix_name(p); if (d->isDtorDeclaration()) { buf.writestring("D1"); } else { source_name(d); } buf.writeByte('E'); } else { source_name(d); } if (tf->linkage == LINKcpp) //Template args accept extern "C" symbols with special mangling { assert(tf->ty == Tfunction); argsCppMangle(tf->parameters, tf->varargs); } }