Code-Centric Code Generation
摘要
We present Code-centric Code Generation (CCG), an approach designed to ease the development and evolution of template-based code generators. The key idea is to generate the required templates from appropriately annotated runnable prototypes written in the target language. In essence, this turns template definition into a two-step process: 1. writing a prototype (base configuration) in the target language, and 2. annotating the prototype’s AST with parameterized operations that, given the required parameters, allow one to transform this base configuration into the intended target code. The advantage of this approach is that prototypes, in contrast to templates, can be conveniently developed and evolved with the full tool support of common software development. We illustrate the ease of CCG-based code generator development by first specifying and then evolving the required templates in order to overcome a detected security vulnerability. A proof-of-concept implementation is publicly available for reproducibility.