Level 1 of the cross-language linking roadmap entry: produce an object file with a renamed entry point so a BASIC program can be linked into a larger C or Fortran build. - src/compiler_main.c: --emit-obj runs gcc -c (compile-only, produces prog.o) and skips the runtime link. --main-name NAME (or --main-name=NAME) is plumbed through codegen_opts_t. - src/codegen.c: emit `int <name>(int argc, char **argv)` instead of always emitting `main`. Default unchanged when --main-name isn't specified. - include/codegen.h: add main_name to codegen_opts_t. - docs/getting-started.md: new "Cross-Language Linking" section with C and Fortran (iso_c_binding) driver examples. - docs/roadmap.md: three levels of cross-language linking, with Level 1 marked done, Level 2 (BASIC-side EXTERN declarations) as the next concrete step, Level 3 (BASIC SUBs as C functions) deferred. Also added: FORTRAN-style WRITE / C-style PRINTF formatted I/O extensions, and a NumPy / DataFrame / Matplotlib- style standard library section as a separate sub-project track. Verified end-to-end: a BASIC program compiled with --emit-obj --main-name=run_basic_greet links cleanly with both a C driver (gcc) and a Fortran driver (gfortran with iso_c_binding), and prints the BASIC output before returning to the host. All 72 interpreter / 68 compat / 63 compiler tests still pass.
23 lines
796 B
C
23 lines
796 B
C
#ifndef CODEGEN_H
|
|
#define CODEGEN_H
|
|
|
|
#include "analysis.h"
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
|
|
typedef struct {
|
|
bool safe_mode; /* --safe: emit runtime safety checks */
|
|
bool warn_mode; /* --warn: static analysis warnings */
|
|
bool no_gc_check; /* --no-gc-check: skip gwrt_check_line per line
|
|
* (no string-pool GC, no Ctrl+Break check) */
|
|
bool fast_math; /* --fast-math: skip / by-zero checks */
|
|
const char *main_name; /* --main-name: rename entry point from
|
|
* "main" to NAME (for cross-language link;
|
|
* NULL keeps "main") */
|
|
} codegen_opts_t;
|
|
|
|
/* Generate C source from the analyzed program */
|
|
void codegen_emit(FILE *out, analysis_t *a, const codegen_opts_t *opts);
|
|
|
|
#endif
|