⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gxxint.texi

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
GNU Java does the same.@subsection Primitive typesThe C++ types @code{int}, @code{long}, @code{short}, @code{char},and @code{long long} are mangled as @samp{i}, @samp{l},@samp{s}, @samp{c}, and @samp{x}, respectively.The corresponding unsigned types have @samp{U} prefixedto the mangling.  The type @code{signed char} is mangled @samp{Sc}.The C++ and Java floating-point types @code{float} and @code{double}are mangled as @samp{f} and @samp{d} respectively.The C++ @code{bool} type and the Java @code{boolean} type aremangled as @samp{b}.The C++ @code{wchar_t} and the Java @code{char} types aremangled as @samp{w}.The Java integral types @code{byte}, @code{short}, @code{int}and @code{long} are mangled as @samp{c}, @samp{s}, @samp{i},and @samp{x}, respectively.C++ code that has included @code{javatypes.h} will manglethe typedefs  @code{jbyte}, @code{jshort}, @code{jint}and @code{jlong} as respectively @samp{c}, @samp{s}, @samp{i},and @samp{x}.  (This has not been implemented yet.)@subsection Mangling of simple namesA simple class, package, template, or namespace name isencoded as the number of characters in the name, followed bythe actual characters.  Thus the class @code{Foo}is encoded as @samp{3Foo}.If any of the characters in the name are not alphanumeric(i.e not one of the standard ASCII letters, digits, or '_'),or the initial character is a digit, then the name ismangled as a sequence of encoded Unicode letters.A Unicode encoding starts with a @samp{U} to indicatethat Unicode escapes are used, followed by the number ofbytes used by the Unicode encoding, followed by the bytesrepresenting the encoding.  ASSCI letters andnon-initial digits are encoded without change.  However, allother characters (including underscore and initial digits) aretranslated into a sequence starting with an underscore,followed by the big-endian 4-hex-digit lower-case encoding of the character.If a method name contains Unicode-escaped characters, theentire mangled method name is followed by a @samp{U}.For example, the method @code{X\u0319::M\u002B(int)} is encoded as@samp{M_002b__U6X_0319iU}.@subsection Pointer and reference typesA C++ pointer type is mangled as @samp{P} followed by themangling of the type pointed to.A C++ reference type as mangled as @samp{R} followed by themangling of the type referenced.A Java object reference type is equivalentto a C++ pointer parameter, so we mangle such an parameter typeas @samp{P} followed by the mangling of the class name.@subsection Squangled type compressionSquangling (enabled with the @samp{-fsquangle} option), utilizes the@samp{B} code to indicate reuse of a previously seen type within anindentifier. Types are recognized in a left to right manner and givenincreasing values, which are appended to the code in the standardmanner. Ie, multiple digit numbers are delimited by @samp{_}characters. A type is considered to be any non primitive type,regardless of whether its a parameter, template parameter, or entiretemplate. Certain codes are considered modifiers of a type, and are notincluded as part of the type. These are the @samp{C}, @samp{V},@samp{P}, @samp{A}, @samp{R}, @samp{U} and @samp{u} codes, denotingconstant, volatile, pointer, array, reference, unsigned, and restrict.These codes may precede a @samp{B} type in order to make the requiredmodifications to the type.For example:@exampletemplate <class T> class class1 @{ @};template <class T> class class2 @{ @};class class3 @{ @};int f(class2<class1<class3> > a ,int b, const class1<class3>&c, class3 *d) @{ @}    B0 -> class2<class1<class3>    B1 -> class1<class3>    B2 -> class3@end exampleProduces the mangled name @samp{f__FGt6class21Zt6class11Z6class3iRCB1PB2}.The int parameter is a basic type, and does not receive a B encoding...@subsection Qualified namesBoth C++ and Java allow a class to be lexically nested inside anotherclass.  C++ also supports namespaces (not yet implemented by G++).Java also supports packages.These are all mangled the same way:  First the letter @samp{Q}indicates that we are emitting a qualified name.That is followed by the number of parts in the qualified name.If that number is 9 or less, it is emitted with no delimiters.Otherwise, an underscore is written before and after the count.Then follows each part of the qualified name, as described above.For example @code{Foo::\u0319::Bar} is encoded as@samp{Q33FooU5_03193Bar}.Squangling utilizes the the letter @samp{K} to indicate a remembered portion of a qualified name. As qualified names are processedfor an identifier, the names are numbered and remembered in a manner similar to the @samp{B} type compression code. Names are recognized left to right, and given increasing values, which areappended to the code in the standard manner. ie, multiple digit numbersare delimited by @samp{_} characters.For example @exampleclass Andrew @{  class WasHere   @{      class AndHereToo       @{      @};  @};@};f(Andrew&r1, Andrew::WasHere& r2, Andrew::WasHere::AndHereToo& r3) @{ @}   K0 ->  Andrew   K1 ->  Andrew::WasHere   K2 ->  Andrew::WasHere::AndHereToo@end exampleFunction @samp{f()} would be mangled as : @samp{f__FR6AndrewRQ2K07WasHereRQ2K110AndHereToo}There are some occasions when either a @samp{B} or @samp{K} code couldbe chosen, preference is always given to the @samp{B} code. Ie, the examplein the section on @samp{B} mangling could have used a @samp{K} code instead of @samp{B2}.@subsection TemplatesA class template instantiation is encoded as the letter @samp{t},followed by the encoding of the template name, followedthe number of template parameters, followed by encoding of the templateparameters.  If a template parameter is a type, it is writtenas a @samp{Z} followed by the encoding of the type.A function template specialization (either an instantiation or anexplicit specialization) is encoded by an @samp{H} followed by theencoding of the template parameters, as described above, followed by an@samp{_}, the encoding of the argument types to the template function(not the specialization), another @samp{_}, and the return type.  (Likethe argument types, the return type is the return type of the functiontemplate, not the specialization.)  Template parameters in the argumentand return types are encoded by an @samp{X} for type parameters, or a@samp{Y} for constant parameters, an index indicating their positionin the template parameter list declaration, and their template depth.@subsection ArraysC++ array types are mangled by emitting @samp{A}, followed bythe length of the array, followed by an @samp{_}, followed bythe mangling of the element type.  Of course, normallyarray parameter types decay into a pointer types, so youdon't see this.Java arrays are objects.  A Java type @code{T[]} is mangledas if it were the C++ type @code{JArray<T>}.For example @code{java.lang.String[]} is encoded as@samp{Pt6JArray1ZPQ34java4lang6String}.@subsection Static fieldsBoth C++ and Java classes can have static fields.These are allocated statically, and are shared among all instances.The mangling starts with a prefix (@samp{_} in most systems), which isfollowed by the manglingof the class name, followed by the "joiner" and finally the field name.The joiner (see @code{JOINER} in @code{cp-tree.h}) is a specialseparator character.  For historical reasons (and idiosyncraciesof assembler syntax) it can @samp{$} or @samp{.} (or even@samp{_} on a few systems).  If the joiner is @samp{_} then the prefixis @samp{__static_} instead of just @samp{_}.For example @code{Foo::Bar::var} (or @code{Foo.Bar.var} in Java syntax)would be encoded as @samp{_Q23Foo3Bar$var} or @samp{_Q23Foo3Bar.var}(or rarely @samp{__static_Q23Foo3Bar_var}).If the name of a static variable needs Unicode escapes,the Unicode indicator @samp{U} comes before the "joiner".This @code{\u1234Foo::var\u3445} becomes @code{_U8_1234FooU.var_3445}.@subsection Table of demangling code charactersThe following special characters are used in mangling:@table @samp@item AIndicates a C++ array type.@item bEncodes the C++ @code{bool} type,and the Java @code{boolean} type.@item BUsed for squangling. Similar in concept to the 'T' non-squangled code.@item cEncodes the C++ @code{char} type, and the Java @code{byte} type.@item CA modifier to indicate a @code{const} type.Also used to indicate a @code{const} member function(in which cases it precedes the encoding of the method's class).@item dEncodes the C++ and Java @code{double} types.@item eIndicates extra unknown arguments @code{...}.@item EIndicates the opening parenthesis of an expression.@item fEncodes the C++ and Java @code{float} types.@item FUsed to indicate a function type.@item HUsed to indicate a template function.@item iEncodes the C++ and Java @code{int} types.@item IEncodes typedef names of the form @code{int@var{n}_t}, where @var{n} is apositive decimal number.  The @samp{I} is followed by either twohexidecimal digits, which encode the value of @var{n}, or by anarbitrary number of hexidecimal digits between underscores.  Forexample, @samp{I40} encodes the type @code{int64_t}, and @samp{I_200_}encodes the type @code{int512_t}.@item JIndicates a complex type.@item KUsed by squangling to compress qualified names.@item lEncodes the C++ @code{long} type.@item nImmediate repeated type. Followed by the repeat count.@item N Repeated type. Followed by the repeat count of the repeated type,followed by the type index of the repeated type. Due to a bug ing++ 2.7.2, this is only generated if index is 0. Superceded by@samp{n} when squangling.@item PIndicates a pointer type.  Followed by the type pointed to.@item QUsed to mangle qualified names, which arise from nested classes.Also used for namespaces.In Java used to mangle package-qualified names, and inner classes.@item rEncodes the GNU C++ @code{long double} type.@item RIndicates a reference type.  Followed by the referenced type.@item sEncodes the C++ and java @code{short} types.@item SA modifier that indicates that the following integer type is signed.Only used with @code{char}.Also used as a modifier to indicate a static member function.@item tIndicates a template instantiation.@item TA back reference to a previously seen type.@item UA modifier that indicates that the following integer type is unsigned.Also used to indicate that the following class or namespace nameis encoded using Unicode-mangling.@item uThe @code{restrict} type qualifier.@item vEncodes the C++ and Java @code{void} types.@item VA modifier for a @code{volatile} type or method.@item wEncodes the C++ @code{wchar_t} type, and the Java @code{char} types.@item WIndicates the closing parenthesis of an expression.@item xEncodes the GNU C++ @code{long long} type, and the Java @code{long} type.@item XEncodes a template type parameter, when part of a function type.@item YEncodes a template constant parameter, when part of a function type.@item ZUsed for template type parameters. @end tableThe letters @samp{G}, @samp{M}, @samp{O}, and @samp{p}also seem to be used for obscure purposes ...@node Vtables, Concept Index, Mangling, Top@section Virtual TablesIn order to invoke virtual functions, GNU C++ uses virtual tables. Eachvirtual function gets an index, and the table entry points to theoverridden function to call. Sometimes, and adjustment to the thispointer has to be made before calling a virtual function:@examplestruct A@{  int i;  virtual void foo();@};struct B@{  int j;  virtual void bar();@};struct C:A,B@{  virtual void bar();@};void C::bar()@{  i++;@}int main()@{  C *c = new C;  B *b = c;  c->bar();@}@end exam

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -