Files
gw-basic-2026/include/codegen.h
Eremey Valetov 20ecdae938 Add --warn and --safe memory safety flags to the compiler
Three progressive levels for gwbasic-compile:

--warn: static analysis warnings (uninitialized variables, GOTO to
nonexistent line, unreachable code detection). Zero runtime cost.

--safe (implies --warn): runtime checked integer arithmetic via
gw_int_add/sub/mul/neg matching real GW-BASIC overflow semantics,
enhanced array bounds diagnostics with variable names and line numbers,
GOSUB stack overflow diagnostics with source line reporting.

--safe=sanitize (implies --safe): passes -fsanitize=address,undefined
to gcc for full memory error detection.

Also: fix pre-existing missing closing paren in array LET-to-integer
codegen, add strpool_pin/unpin infrastructure, add compiler optimization
flags and memory safety sections to roadmap.

72/72 interpreter tests pass. 64/64 eligible compiler tests pass in
--safe mode.
2026-04-09 13:14:26 -04:00

17 lines
395 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 */
} codegen_opts_t;
/* Generate C source from the analyzed program */
void codegen_emit(FILE *out, analysis_t *a, const codegen_opts_t *opts);
#endif