- 'guard cond' lowers to if(cond) { defers; return; } (legacy rule).
- '[N] T name' parameters emit C declarator order.
- Cross-module alias calls match the import's file-path target against
the module source stem too — inbe imports name file paths
('src/screens/settings/settings_theme'), not dotted module names.
- Global initializers pass through rewrite_body2 (nil -> NULL, local
function-name resolution) and KIR_TEXT_MAX grew to 4096 so joined
multi-element initializers stop truncating mid-list.
38 lines
1.4 KiB
C
38 lines
1.4 KiB
C
#ifndef K2C_LOWER_H
|
|
#define K2C_LOWER_H
|
|
|
|
#include "kir.h"
|
|
|
|
/* Cross-module symbol table: for each parsed module (by its slash-path),
|
|
* every function's .kry name -> full C name. Built by main after parsing all
|
|
* inputs; used to resolve alias-qualified calls (start.draw_start_page(...)
|
|
* -> ide_start_page_draw_start_page_kry_draw(...)). */
|
|
typedef struct K2cModuleSyms {
|
|
char module_stem[KIR_PATH_MAX]; /* source path minus .kry */
|
|
char module_slash[KIR_PATH_MAX];
|
|
struct {
|
|
char kry[KIR_NAME_MAX];
|
|
char c[KIR_NAME_MAX * 3];
|
|
} fns[256];
|
|
int fn_count;
|
|
} K2cModuleSyms;
|
|
|
|
/* Lower a KirProgram to C source (.c/.h). restab/restab_count resolve
|
|
* cross-module calls; pass NULL/0 to resolve same-module only. */
|
|
void k2c_lower(const KirProgram *program, const char *root,
|
|
const char *out_dir, const K2cModuleSyms *restab,
|
|
int restab_count);
|
|
|
|
/* Build the symbol table entry for one program into out. */
|
|
void k2c_build_syms(const KirProgram *program, K2cModuleSyms *out);
|
|
|
|
/* Full C name for a function (module prefix, colon naming, _kry_draw). */
|
|
void k2c_function_c_name(const KirModule *m, const KirFunction *fn,
|
|
char *dst, size_t dst_size);
|
|
|
|
/* k2c_project.c — kryon_project.h/.c (app-host ABI) after all files lower. */
|
|
void k2c_write_project(KirProgram *const *progs, int prog_count,
|
|
const char *root, const char *out_dir, int no_main);
|
|
|
|
#endif
|