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.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Code-Centric Code Generation

  • Daniel Busch,
  • Steven Smyth,
  • Tim Tegeler,
  • Bernhard Steffen

摘要

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.