You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 line
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>Virtual Base Classes (STABS)</title>
  16. <meta name="description" content="Virtual Base Classes (STABS)">
  17. <meta name="keywords" content="Virtual Base 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="Static-Members.html#Static-Members" rel="next" title="Static Members">
  26. <link href="Inheritance.html#Inheritance" rel="prev" title="Inheritance">
  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="Virtual-Base-Classes"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="Static-Members.html#Static-Members" accesskey="n" rel="next">Static Members</a>, Previous: <a href="Inheritance.html#Inheritance" accesskey="p" rel="prev">Inheritance</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="Virtual-Base-Classes-1"></a>
  63. <h3 class="section">8.13 Virtual Base Classes</h3>
  64. <p>A derived class object consists of a concatenation in memory of the data
  65. areas defined by each base class, starting with the leftmost and ending
  66. with the rightmost in the list of base classes. The exception to this
  67. rule is for virtual inheritance. In the example above, class <code>D</code>
  68. inherits virtually from base class <code>B</code>. This means that an
  69. instance of a <code>D</code> object will not contain its own <code>B</code> part but
  70. merely a pointer to a <code>B</code> part, known as a virtual base pointer.
  71. </p>
  72. <p>In a derived class stab, the base offset part of the derivation
  73. information, described above, shows how the base class parts are
  74. ordered. The base offset for a virtual base class is always given as 0.
  75. Notice that the base offset for <code>B</code> is given as 0 even though
  76. <code>B</code> is not the first base class. The first base class <code>A</code>
  77. starts at offset 0.
  78. </p>
  79. <p>The field information part of the stab for class <code>D</code> describes the field
  80. which is the pointer to the virtual base class <code>B</code>. The vbase pointer
  81. name is &lsquo;<samp>$vb</samp>&rsquo; followed by a type reference to the virtual base class.
  82. Since the type id for <code>B</code> in this example is 25, the vbase pointer name
  83. is &lsquo;<samp>$vb25</samp>&rsquo;.
  84. </p>
  85. <div class="smallexample">
  86. <pre class="smallexample">.stabs &quot;D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,
  87. 160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;
  88. 2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt:
  89. :32:i;2A*-2147483646;31;;;~%20;&quot;,128,0,0,0
  90. </pre></div>
  91. <p>Following the name and a semicolon is a type reference describing the
  92. type of the virtual base class pointer, in this case 24. Type 24 was
  93. defined earlier as the type of the <code>B</code> class <code>this</code> pointer. The
  94. <code>this</code> pointer for a class is a pointer to the class type.
  95. </p>
  96. <div class="example">
  97. <pre class="example">.stabs &quot;this:P24=*25=xsB:&quot;,64,0,0,8
  98. </pre></div>
  99. <p>Finally the field offset part of the vbase pointer field description
  100. shows that the vbase pointer is the first field in the <code>D</code> object,
  101. before any data fields defined by the class. The layout of a <code>D</code>
  102. class object is a follows, <code>Adat</code> at 0, the vtable pointer for
  103. <code>A</code> at 32, <code>Cdat</code> at 64, the vtable pointer for C at 96, the
  104. virtual base pointer for <code>B</code> at 128, and <code>Ddat</code> at 160.
  105. </p>
  106. <hr>
  107. <div class="header">
  108. <p>
  109. Next: <a href="Static-Members.html#Static-Members" accesskey="n" rel="next">Static Members</a>, Previous: <a href="Inheritance.html#Inheritance" accesskey="p" rel="prev">Inheritance</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>
  110. </div>
  111. </body>
  112. </html>