As C does not have any means of reflection (and even C++981 does not have enough reflective abilities), gengtype was introduced to support some GCC-specific type and variable annotations, which in turn support garbage collection inside the compiler and precompiled headers. As such, gengtype is a one big kludge of a rudimentary C lexer and parser.

gengtype output

On a long-term perspective, we could take inspiration from Qt moc machinery2 to systematically generate runtime accessible meta-data describing most important GCC datatypes. This could permit useful extensions, like generic dumpers for debugging the compiler, generic serialization of GCC data, generic or generated browser code for inspecting GCC internal data (i.e. a much improved replacement of tree-browser.c which is probably rotten, etc..). Such a powerful system is useful, since GCC is a huge code.

Improvement areas

Please contribute with your ideas here!

  1. One cannot code, even with complex templates, a rather generic serializer or debug-printer in C++. This would require accessing a description of fields inside classes, which C++ templates or RTTI does not provide. (1)

  2. Or even Smalltalk or Common Lisp meta-classes or object systems (2)

  3. Basile believes we cannot and should not get rid of gengtype or garbage collection even if all of GCC was in C++; other people apparently suggested we get rid of gengtype while C++-ifying GCC. (3)

None: gengtype (last edited 2013-08-05 14:18:41 by IanLanceTaylor)