Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

174 linhas
8.4KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1992-2020 Free Software Foundation, Inc.
  4. Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
  5. and David MacKenzie.
  6. Permission is granted to copy, distribute and/or modify this document
  7. under the terms of the GNU Free Documentation License, Version 1.3 or
  8. any later version published by the Free Software Foundation; with no
  9. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  10. Texts. A copy of the license is included in the section entitled "GNU
  11. Free Documentation License". -->
  12. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>Simple Classes (STABS)</title>
  16. <meta name="description" content="Simple Classes (STABS)">
  17. <meta name="keywords" content="Simple Classes (STABS)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="Cplusplus.html#Cplusplus" rel="up" title="Cplusplus">
  25. <link href="Class-Instance.html#Class-Instance" rel="next" title="Class Instance">
  26. <link href="Basic-Cplusplus-Types.html#Basic-Cplusplus-Types" rel="prev" title="Basic Cplusplus Types">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="Simple-Classes"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="Class-Instance.html#Class-Instance" accesskey="n" rel="next">Class Instance</a>, Previous: <a href="Basic-Cplusplus-Types.html#Basic-Cplusplus-Types" accesskey="p" rel="prev">Basic Cplusplus Types</a>, Up: <a href="Cplusplus.html#Cplusplus" accesskey="u" rel="up">Cplusplus</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  60. </div>
  61. <hr>
  62. <a name="Simple-Class-Definition"></a>
  63. <h3 class="section">8.4 Simple Class Definition</h3>
  64. <p>The stabs describing C<tt>++</tt> language features are an extension of the
  65. stabs describing C. Stabs representing C<tt>++</tt> class types elaborate
  66. extensively on the stab format used to describe structure types in C.
  67. Stabs representing class type variables look just like stabs
  68. representing C language variables.
  69. </p>
  70. <p>Consider the following very simple class definition.
  71. </p>
  72. <div class="example">
  73. <pre class="example">class baseA {
  74. public:
  75. int Adat;
  76. int Ameth(int in, char other);
  77. };
  78. </pre></div>
  79. <p>The class <code>baseA</code> is represented by two stabs. The first stab describes
  80. the class as a structure type. The second stab describes a structure
  81. tag of the class type. Both stabs are of stab type <code>N_LSYM</code>. Since the
  82. stab is not located between an <code>N_FUN</code> and an <code>N_LBRAC</code> stab this indicates
  83. that the class is defined at file scope. If it were, then the <code>N_LSYM</code>
  84. would signify a local variable.
  85. </p>
  86. <p>A stab describing a C<tt>++</tt> class type is similar in format to a stab
  87. describing a C struct, with each class member shown as a field in the
  88. structure. The part of the struct format describing fields is
  89. expanded to include extra information relevant to C<tt>++</tt> class members.
  90. In addition, if the class has multiple base classes or virtual
  91. functions the struct format outside of the field parts is also
  92. augmented.
  93. </p>
  94. <p>In this simple example the field part of the C<tt>++</tt> class stab
  95. representing member data looks just like the field part of a C struct
  96. stab. The section on protections describes how its format is
  97. sometimes extended for member data.
  98. </p>
  99. <p>The field part of a C<tt>++</tt> class stab representing a member function
  100. differs substantially from the field part of a C struct stab. It
  101. still begins with &lsquo;<samp>name:</samp>&rsquo; but then goes on to define a new type number
  102. for the member function, describe its return type, its argument types,
  103. its protection level, any qualifiers applied to the method definition,
  104. and whether the method is virtual or not. If the method is virtual
  105. then the method description goes on to give the vtable index of the
  106. method, and the type number of the first base class defining the
  107. method.
  108. </p>
  109. <p>When the field name is a method name it is followed by two colons rather
  110. than one. This is followed by a new type definition for the method.
  111. This is a number followed by an equal sign and the type of the method.
  112. Normally this will be a type declared using the &lsquo;<samp>#</samp>&rsquo; type
  113. descriptor; see <a href="Method-Type-Descriptor.html#Method-Type-Descriptor">Method Type Descriptor</a>; static member functions
  114. are declared using the &lsquo;<samp>f</samp>&rsquo; type descriptor instead; see
  115. <a href="Function-Types.html#Function-Types">Function Types</a>.
  116. </p>
  117. <p>The format of an overloaded operator method name differs from that of
  118. other methods. It is &lsquo;<samp>op$::<var>operator-name</var>.</samp>&rsquo; where
  119. <var>operator-name</var> is the operator name such as &lsquo;<samp>+</samp>&rsquo; or &lsquo;<samp>+=</samp>&rsquo;.
  120. The name ends with a period, and any characters except the period can
  121. occur in the <var>operator-name</var> string.
  122. </p>
  123. <p>The next part of the method description represents the arguments to the
  124. method, preceded by a colon and ending with a semi-colon. The types of
  125. the arguments are expressed in the same way argument types are expressed
  126. in C<tt>++</tt> name mangling. In this example an <code>int</code> and a <code>char</code>
  127. map to &lsquo;<samp>ic</samp>&rsquo;.
  128. </p>
  129. <p>This is followed by a number, a letter, and an asterisk or period,
  130. followed by another semicolon. The number indicates the protections
  131. that apply to the member function. Here the 2 means public. The
  132. letter encodes any qualifier applied to the method definition. In
  133. this case, &lsquo;<samp>A</samp>&rsquo; means that it is a normal function definition. The dot
  134. shows that the method is not virtual. The sections that follow
  135. elaborate further on these fields and describe the additional
  136. information present for virtual methods.
  137. </p>
  138. <div class="display">
  139. <pre class="display">.stabs &quot;class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4)
  140. field_name(Adat):type(int),bit_offset(0),field_bits(32);
  141. method_name(Ameth)::type_def(21)=type_desc(method)return_type(int);
  142. :arg_types(int char);
  143. protection(public)qualifier(normal)virtual(no);;&quot;
  144. N_LSYM,NIL,NIL,NIL
  145. </pre></div>
  146. <div class="smallexample">
  147. <pre class="smallexample">.stabs &quot;baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;&quot;,128,0,0,0
  148. .stabs &quot;class_name:sym_desc(struct tag)&quot;,N_LSYM,NIL,NIL,NIL
  149. .stabs &quot;baseA:T20&quot;,128,0,0,0
  150. </pre></div>
  151. <hr>
  152. <div class="header">
  153. <p>
  154. Next: <a href="Class-Instance.html#Class-Instance" accesskey="n" rel="next">Class Instance</a>, Previous: <a href="Basic-Cplusplus-Types.html#Basic-Cplusplus-Types" accesskey="p" rel="prev">Basic Cplusplus Types</a>, Up: <a href="Cplusplus.html#Cplusplus" accesskey="u" rel="up">Cplusplus</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  155. </div>
  156. </body>
  157. </html>