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.
17 lines
395 B
C
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
|