/* =====================================
 * Generated by Mod-c 0.26.5
 * HEADER codegen MODULE
 * ===================================== */

#ifndef MODC_MODULE_codegen_H
#define MODC_MODULE_codegen_H

#include <stdint.h>
#include <stdbool.h>
#include <assert.h>

#define nil ((void *)0)
#define NIL nil
typedef uint8_t byte;
typedef const char* string;
typedef int integer;
typedef unsigned int cardinal;
typedef float real;

/**
 * Mod-c
 * By M. Scott Reynolds
 * Date 18 April 2026
 * 
 * Main codegen dispacthcer and
 * Initial Context definition.
 *
 * Initial context passed into codegen_generate to setup environment
 * and other options. Target is defined in codegen_common.h
 *  .out = out                          // REQUIRED: Predefined output buffer. 
 *  .ast = ast                          // REQUIRED: Top of the Abstract Syntax Tree
 *  .debug_enabled = true               // REQUIRED: Set to true/false for debug statement generation.
 *  .target = TARGET_C/TARGET_HEADER    // REQUIRED: Output code target. 
 *                                      // Currently only TARGET_C and TARGET_HEADER supported.
 */

/* === IMPORT === */
#include "dynbuf.h"

/* === IMPORT === */
#include "codegen_mh.h"

/* === IMPORT === */
#include "stddef.h"

/* === IMPORT === */
#include "stdio.h"

/* === IMPORT === */
#include "stdlib.h"

/* === IMPORT === */
#include "node.h"

/* === IMPORT === */
#include "codegen_common.h"

/* === IMPORT === */
#include "codegen_c.h"

/* === IMPORT === */
#include "codegen_header.h"

/* === TYPE EXPORT === */
typedef struct InitialContext InitialContext;
typedef struct InitialContext {
    DynBuf* out;
    const Node* ast;
    bool debug_enabled;
    bool assert_off;
    bool dbc_off;
    CodegenTarget target;
} InitialContext;

/**
 * Codegen main dispatcher from the given AST using the selected target.
 * The output is written into the provided DynBuf (which must be initialized).
 * Exits program on fatal error. 
 */

/* === PROC/FUNC EXPORT === */
void codegen_generate(InitialContext initial);

void codegen(void);

#endif /* MODC_MODULE_codegen_H */
