| 1 |
/** |
| 2 |
* Implementation of invariant support routines. |
| 3 |
* |
| 4 |
* Copyright: Copyright Digital Mars 2007 - 2010. |
| 5 |
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). |
| 6 |
* Authors: Walter Bright |
| 7 |
* Source: $(DRUNTIMESRC rt/_invariant_.d) |
| 8 |
*/ |
| 9 |
|
| 10 |
module rt.invariant_; |
| 11 |
|
| 12 |
/** |
| 13 |
* |
| 14 |
*/ |
| 15 |
void _d_invariant(Object o) |
| 16 |
{ ClassInfo c; |
| 17 |
|
| 18 |
//printf("__d_invariant(%p)\n", o); |
| 19 |
|
| 20 |
// BUG: needs to be filename/line of caller, not library routine |
| 21 |
assert(o !is null); // just do null check, not invariant check |
| 22 |
|
| 23 |
c = typeid(o); |
| 24 |
do |
| 25 |
{ |
| 26 |
if (c.classInvariant) |
| 27 |
{ |
| 28 |
(*c.classInvariant)(o); |
| 29 |
} |
| 30 |
c = c.base; |
| 31 |
} while (c); |
| 32 |
} |