3 #include <AD/gc/gcobject.h>
4 #include <AD/strings/quark.h>
9 class base : public GCObject
13 virtual void trace(GC *) { traced++; }
16 datatype Exp<T> : collectable public base<T> :: collectable =
17 OP(Quark, Exp<T>, Exp<T>)
23 ostream& operator << (ostream& s, Exp<T> e)
25 OP(a,b,c): { return s << '(' << b << ' ' << a << ' ' << c << ')'; }
26 | OBJ x: { return s << x; }
27 | ID x: { return s << x; }
31 instantiate datatype Exp<int>;
35 GC::get_default_gc().set_initial_heap_size(1024*1024);
36 for (int i = 0; i < 100000; i++)
38 Exp<int> a = new classof ID<int>(#"a");
39 Exp<int> b = new classof ID<int>(#"b");
40 Exp<int> e1 = new classof OBJ<int>(0);
41 Exp<int> e = OP(#"+",a,OP(#"*",b,e1));
42 if (i % 10000 == 0) cout << i << ": " << e << '\n';
44 cout << "Finished: base class traced = " << traced << "\n";