Providing a code generator extender

If your custom node translator introduces new kinds of statements, or if you add a new expression type, you must provide the Java™ code to generate the corresponding IRL code.

About this task

To provide a code generator extender, you must create an implementation of IlrCodeGeneratorExtender.

Procedure

To provide a code generator extender:

  1. Create an implementation of IlrCodeGeneratorExtender.

    This interface declares methods that are automatically called when the IRL code generator main class inspects an expression or a statement that is not part of the predefined expressions or statements.

  2. In the implementation of IlrCodeGeneratorExtender, define a print method for each of the custom types that your languages introduces. To print the generated IRL, use the methods provided by the code generator, by casting it as an IlrIRLCodeGenerator.
  3. Register the code generator extender to the abstract syntax node in the concrete syntax properties, using the codeGeneratorExtender.irl property, and the fully qualified name of the code generator extender class.