Class CodeGenerator

java.lang.Object
icyllis.arc3d.compiler.CodeGenerator
Direct Known Subclasses:
GLSLCodeGenerator, SPIRVCodeGenerator

public abstract class CodeGenerator extends Object
Abstract superclass of all code generators, which take a TranslationUnit as input and produce code as output.
  • Field Details

  • Constructor Details

  • Method Details

    • generateCode

      @Nullable public abstract ByteBuffer generateCode()
      Generates the code and returns the pointer value. The code size in bytes is Buffer.remaining(). Check errors via Context.getErrorHandler().

      The return value is a direct buffer, see ByteBuffer.allocateDirect(int). A direct buffer wraps an address that points to off-heap memory, i.e. a native pointer. The byte order is ByteOrder.nativeOrder() and it's safe to pass the result to OpenGL and Vulkan API. There is no way to free this buffer explicitly, as it is subject to GC.

      Returns:
      the generated code, or null if there's an error
    • getContext

      protected Context getContext()