stage1 - 全面重构 stage1 编译器架构:类型系统(arena + items)、IR 发射层(spl_emit.h/c)、统一所有 emit 调用点。

- 实现 as 类型转换运算符、修复 &&/|| 短路求值 bug。
- 在 splc1.spl 中实现 Vec/Map/Emit 基础库(~50 个方法)。
- 修复实例方法调用中 self 参数被错误丢弃的 bug。
This commit is contained in:
zzy
2026-07-20 20:53:41 +08:00
parent 21f35b30fa
commit 459b6188a9
17 changed files with 307 additions and 217 deletions

View File

@@ -10,8 +10,8 @@
#include <stdlib.h>
#include <string.h>
#include "spl_type.h"
#include "spl_emit.h"
#include "spl_type.h"
/* Forward declarations */
typedef struct spl_comp spl_comp_t;
@@ -162,8 +162,7 @@ spl_expr_result_t spl_parse_expr(spl_comp_t *ctx, int min_prec);
spl_expr_result_t spl_parse_struct_literal(spl_comp_t *ctx, int type_idx);
/* Match arm pattern comparison */
int spl_emit_match_enum_cmp(spl_comp_t *ctx, int enum_type_idx, int val_offset,
int by_value);
int spl_emit_match_enum_cmp(spl_comp_t *ctx, int enum_type_idx, int val_offset, int by_value);
void spl_emit_match_value_cmp(spl_comp_t *ctx, int val_offset);
/* ============================================================
@@ -178,9 +177,6 @@ spl_expr_result_t spl_parse_block_expr(spl_comp_t *ctx);
* Remaining helpers in spl_comp.c
* ============================================================ */
void spl_emit_ret(spl_comp_t *ctx, int ret_type_idx);
void spl_emit_store_init(spl_comp_t *ctx, int var_offset, int var_type_idx);
/* Variable management */
int spl_declare_var(spl_comp_t *ctx, const char *name, int type_idx, int is_const);
spl_var_info_t *spl_lookup_var(spl_comp_t *ctx, const char *name);
@@ -207,8 +203,4 @@ void spl_emit_defer_epilogue(spl_comp_t *ctx, int depth);
/* Register runtime natives (stub) */
void spl_comp_register(spl_prog_t *prog);
/* Shared token helpers (defined in spl_parser.c) */
spl_tok_t *peek(spl_comp_t *ctx);
spl_tok_t *advance(spl_comp_t *ctx);
#endif /* __SPL_COMP_H__ */