- dir = "{dir}/cpp"
- dir.mkdir
- file = new OFStream.open("{dir}/{name}.cpp")
-
- write "#include <iostream>"
- write "#include <stdlib.h>"
- write "class Root\n\t\{ public: virtual int id() \{ return 0;\} \};"
- for c in classes do
- write "template<class E>"
- write "class {c} "
- if c.supers.is_empty then
- write "\t: public virtual Root"
- else for s in [c.supers.first] do
- write "\t: public virtual {s}<E>"
- end
- write "\{"
- write "\tpublic: virtual int id() \{ return {c.id}; \}"
- write "\};"
- end
-
- write "void test(Root *a, Root *b, int loops, int start) \{"
- write "\tint x = start;"
- write "\tfor(int i = 0; i < loops; i++) \{"
- write "\t\tfor(int j = 0; j < loops; j++) \{"
- var test
- if dry then test = "" else
- write "\t\t\t{classes[middle]}<Root> *to = dynamic_cast<{classes[middle]}<Root>*>(a);"
- test = "to != 0 &&"
- end
- write "\t\tif({test}x>=0) \{"
- if check then write "\t\t\tx += 1"
- write "\} else \{ x--; a = b;\}"
- write "\t\t}"
- write "\t\}"
- write "\tstd::cout << x << std::endl;"
- write "\}"