Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

141 lines
6.1KB

  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>Methods (STABS)</title>
  16. <meta name="description" content="Methods (STABS)">
  17. <meta name="keywords" content="Methods (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="Method-Type-Descriptor.html#Method-Type-Descriptor" rel="next" title="Method Type Descriptor">
  26. <link href="Class-Instance.html#Class-Instance" rel="prev" title="Class Instance">
  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="Methods"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="Method-Type-Descriptor.html#Method-Type-Descriptor" accesskey="n" rel="next">Method Type Descriptor</a>, Previous: <a href="Class-Instance.html#Class-Instance" accesskey="p" rel="prev">Class Instance</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="Method-Definition"></a>
  63. <h3 class="section">8.6 Method Definition</h3>
  64. <p>The class definition shown above declares Ameth. The C<tt>++</tt> source below
  65. defines Ameth:
  66. </p>
  67. <div class="example">
  68. <pre class="example">int
  69. baseA::Ameth(int in, char other)
  70. {
  71. return in;
  72. };
  73. </pre></div>
  74. <p>This method definition yields three stabs following the code of the
  75. method. One stab describes the method itself and following two describe
  76. its parameters. Although there is only one formal argument all methods
  77. have an implicit argument which is the <code>this</code> pointer. The <code>this</code>
  78. pointer is a pointer to the object on which the method was called. Note
  79. that the method name is mangled to encode the class name and argument
  80. types. Name mangling is described in the <small>ARM</small> (<cite>The Annotated
  81. C++ Reference Manual</cite>, by Ellis and Stroustrup, <small>ISBN</small>
  82. 0-201-51459-1); <samp>gpcompare.texi</samp> in Cygnus GCC distributions
  83. describes the differences between GNU mangling and <small>ARM</small>
  84. mangling.
  85. </p>
  86. <div class="example">
  87. <pre class="example">.stabs &quot;name:symbol_descriptor(global function)return_type(int)&quot;,
  88. N_FUN, NIL, NIL, code_addr_of_method_start
  89. .stabs &quot;Ameth__5baseAic:F1&quot;,36,0,0,_Ameth__5baseAic
  90. </pre></div>
  91. <p>Here is the stab for the <code>this</code> pointer implicit argument. The
  92. name of the <code>this</code> pointer is always <code>this</code>. Type 19, the
  93. <code>this</code> pointer is defined as a pointer to type 20, <code>baseA</code>,
  94. but a stab defining <code>baseA</code> has not yet been emitted. Since the
  95. compiler knows it will be emitted shortly, here it just outputs a cross
  96. reference to the undefined symbol, by prefixing the symbol name with
  97. &lsquo;<samp>xs</samp>&rsquo;.
  98. </p>
  99. <div class="example">
  100. <pre class="example">.stabs &quot;name:sym_desc(register param)type_def(19)=
  101. type_desc(ptr to)type_ref(baseA)=
  102. type_desc(cross-reference to)baseA:&quot;,N_RSYM,NIL,NIL,register_number
  103. .stabs &quot;this:P19=*20=xsbaseA:&quot;,64,0,0,8
  104. </pre></div>
  105. <p>The stab for the explicit integer argument looks just like a parameter
  106. to a C function. The last field of the stab is the offset from the
  107. argument pointer, which in most systems is the same as the frame
  108. pointer.
  109. </p>
  110. <div class="example">
  111. <pre class="example">.stabs &quot;name:sym_desc(value parameter)type_ref(int)&quot;,
  112. N_PSYM,NIL,NIL,offset_from_arg_ptr
  113. .stabs &quot;in:p1&quot;,160,0,0,72
  114. </pre></div>
  115. <p>&lt;&lt; The examples that follow are based on A1.C &gt;&gt;
  116. </p>
  117. <hr>
  118. <div class="header">
  119. <p>
  120. Next: <a href="Method-Type-Descriptor.html#Method-Type-Descriptor" accesskey="n" rel="next">Method Type Descriptor</a>, Previous: <a href="Class-Instance.html#Class-Instance" accesskey="p" rel="prev">Class Instance</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>
  121. </div>
  122. </body>
  123. </html>