Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Virtual-Base-Classes.html
blob4bfc13acacfbaef3e650c96d2de259f502cfb5c9
1 <html lang="en">
2 <head>
3 <title>STABS</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="STABS">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Virtual%20Base%20Classes">Virtual Base Classes</a>,
13 Next:<a rel="next" accesskey="n" href="Static-Members.html#Static%20Members">Static Members</a>,
14 Previous:<a rel="previous" accesskey="p" href="Inheritance.html#Inheritance">Inheritance</a>,
15 Up:<a rel="up" accesskey="u" href="Cplusplus.html#Cplusplus">Cplusplus</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Virtual Base Classes</h3>
21 <p>A derived class object consists of a concatenation in memory of the data
22 areas defined by each base class, starting with the leftmost and ending
23 with the rightmost in the list of base classes. The exception to this
24 rule is for virtual inheritance. In the example above, class <code>D</code>
25 inherits virtually from base class <code>B</code>. This means that an
26 instance of a <code>D</code> object will not contain its own <code>B</code> part but
27 merely a pointer to a <code>B</code> part, known as a virtual base pointer.
29 <p>In a derived class stab, the base offset part of the derivation
30 information, described above, shows how the base class parts are
31 ordered. The base offset for a virtual base class is always given as 0.
32 Notice that the base offset for <code>B</code> is given as 0 even though
33 <code>B</code> is not the first base class. The first base class <code>A</code>
34 starts at offset 0.
36 <p>The field information part of the stab for class <code>D</code> describes the field
37 which is the pointer to the virtual base class <code>B</code>. The vbase pointer
38 name is <code>$vb</code> followed by a type reference to the virtual base class.
39 Since the type id for <code>B</code> in this example is 25, the vbase pointer name
40 is <code>$vb25</code>.
42 <pre class="smallexample"> .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,
43 160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;
44 2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt:
45 :32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
46 </pre>
48 <p>Following the name and a semicolon is a type reference describing the
49 type of the virtual base class pointer, in this case 24. Type 24 was
50 defined earlier as the type of the <code>B</code> class <code>this</code> pointer. The
51 <code>this</code> pointer for a class is a pointer to the class type.
53 <pre class="example"> .stabs "this:P24=*25=xsB:",64,0,0,8
54 </pre>
56 <p>Finally the field offset part of the vbase pointer field description
57 shows that the vbase pointer is the first field in the <code>D</code> object,
58 before any data fields defined by the class. The layout of a <code>D</code>
59 class object is a follows, <code>Adat</code> at 0, the vtable pointer for
60 <code>A</code> at 32, <code>Cdat</code> at 64, the vtable pointer for C at 96, the
61 virtual base pointer for <code>B</code> at 128, and <code>Ddat</code> at 160.
63 </body></html>