stage1 完成15测试
This commit is contained in:
@@ -47,6 +47,13 @@ typedef struct {
|
||||
} spl_enum_variant_t;
|
||||
typedef VEC(spl_enum_variant_t) spl_enum_variant_vec_t;
|
||||
|
||||
/* Method info (struct/enum methods) */
|
||||
typedef struct {
|
||||
char *name;
|
||||
int func_idx; /* index in ctx->funcs */
|
||||
} spl_method_info_t;
|
||||
typedef VEC(spl_method_info_t) spl_method_info_vec_t;
|
||||
|
||||
struct spl_type_info {
|
||||
spl_type_kind_t kind;
|
||||
spl_type_t basic_type; /* for TYPE_BASIC */
|
||||
@@ -55,6 +62,7 @@ struct spl_type_info {
|
||||
char *name; /* type name for TYPE_NAME/STRUCT/ENUM */
|
||||
spl_field_vec_t fields; /* for TYPE_STRUCT */
|
||||
spl_enum_variant_vec_t variants; /* for TYPE_ENUM */
|
||||
spl_method_info_vec_t methods; /* methods */
|
||||
usize byte_size; /* total byte size (cached) */
|
||||
usize slot_count; /* stack slot count */
|
||||
int is_pub; /* public visibility */
|
||||
@@ -118,6 +126,13 @@ typedef VEC(spl_func_info_t) spl_func_info_vec_t;
|
||||
#define COMP_ERROR_MAX 256
|
||||
#define DEFER_MAX 64
|
||||
|
||||
typedef struct {
|
||||
usize body_start; /* IP where defer body starts (after skip-JMP) */
|
||||
usize jmp_exit; /* IP of the JMP after the body (to patch at scope exit) */
|
||||
int depth; /* scope depth */
|
||||
int count_at_decl; /* defer_count when declared */
|
||||
} spl_defer_entry_t;
|
||||
|
||||
typedef struct {
|
||||
/* Lexer output */
|
||||
spl_tok_vec_t toks;
|
||||
@@ -155,7 +170,7 @@ typedef struct {
|
||||
usize continue_target; /* ip to jump to for continue */
|
||||
|
||||
/* Defer stack */
|
||||
usize defer_addrs[DEFER_MAX];
|
||||
spl_defer_entry_t defer_stack[DEFER_MAX];
|
||||
int defer_count;
|
||||
|
||||
/* Global data index for string literals */
|
||||
@@ -247,7 +262,7 @@ void spl_comp_register(spl_prog_t *prog);
|
||||
|
||||
/* Defer */
|
||||
void spl_emit_defer(spl_comp_t *ctx);
|
||||
void spl_emit_defer_epilogue(spl_comp_t *ctx);
|
||||
void spl_emit_defer_epilogue(spl_comp_t *ctx, int depth);
|
||||
|
||||
/* Type lookup and parsing */
|
||||
spl_type_info_t *spl_resolve_type(spl_comp_t *ctx, const char *name);
|
||||
|
||||
Reference in New Issue
Block a user