Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / clang / blink_gc_plugin / tests / finalize_after_dispatch.cpp
blob91244d12cada2c8dcd29cbf06ce9bf4a1a4bc53e
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "finalize_after_dispatch.h"
7 namespace blink {
9 static B* toB(A* a) { return static_cast<B*>(a); }
11 void A::trace(Visitor* visitor)
13 switch (m_type) {
14 case TB:
15 toB(this)->traceAfterDispatch(visitor);
16 break;
17 case TC:
18 static_cast<C*>(this)->traceAfterDispatch(visitor);
19 break;
20 case TD:
21 static_cast<D*>(this)->traceAfterDispatch(visitor);
22 break;
26 void A::traceAfterDispatch(Visitor* visitor)
30 void A::finalizeGarbageCollectedObject()
32 switch (m_type) {
33 case TB:
34 toB(this)->~B();
35 break;
36 case TC:
37 static_cast<C*>(this)->~C();
38 break;
39 case TD:
40 // Missing static_cast<D*>(this)->~D();
41 break;
45 void B::traceAfterDispatch(Visitor* visitor)
47 visitor->trace(m_a);
48 A::traceAfterDispatch(visitor);
51 void C::traceAfterDispatch(Visitor* visitor)
53 visitor->trace(m_a);
54 A::traceAfterDispatch(visitor);
57 void D::traceAfterDispatch(Visitor* visitor)
59 visitor->trace(m_a);
60 Abstract::traceAfterDispatch(visitor);