stage1 重制18测试用例替换成match 完成现有全部测试

This commit is contained in:
zzy
2026-07-11 21:24:52 +08:00
parent 147f26e063
commit 53ae30f1ca
9 changed files with 729 additions and 143 deletions

View File

@@ -28,8 +28,9 @@ typedef enum {
TYPE_INFER, /* _ (to be inferred) */
} spl_type_kind_t;
/* Forward declaration */
/* Forward declarations */
typedef struct spl_type_info spl_type_info_t;
typedef struct spl_comp spl_comp_t;
/* Struct field */
typedef struct {
@@ -89,6 +90,15 @@ const char *spl_type_str(spl_type_info_t *t);
int spl_type_is_integer(spl_type_t bt);
spl_type_info_t *spl_type_clone(spl_type_info_t *t);
/* Determine the uniform type for LOAD/STORE codegen (i32→SPL_I32, ptr→SPL_PTR, else→SPL_PTR) */
spl_type_t spl_type_emit_type(spl_type_info_t *type);
/* Emit LOAD from [saved_ptr + byte_offset] and STORE to local var at var_offset.
* Stack: [] → []
* The saved_ptr is loaded from the 1-slot temp at ptr_slot_offset. */
void spl_emit_load_to_var(spl_comp_t *ctx, int ptr_slot_offset, usize byte_offset,
spl_type_info_t *data_type, int var_offset);
/* ============================================================
* Scope / symbol table
* ============================================================ */
@@ -134,7 +144,7 @@ typedef struct {
int count_at_decl; /* defer_count when declared */
} spl_defer_entry_t;
typedef struct {
typedef struct spl_comp {
/* Lexer output */
spl_tok_vec_t toks;
usize tok_idx;
@@ -162,6 +172,7 @@ typedef struct {
int current_func_idx;
spl_type_info_t *current_ret_type;
int current_local_bytes; /* next free local byte offset */
int peak_local_bytes; /* peak current_local_bytes for ALLOC sizing */
const char *current_type_name; /* name of type whose body we're parsing (for method short-name
lookup) */