stage1 修复bug
This commit is contained in:
@@ -182,8 +182,7 @@ spl_expr_result_t spl_parse_block_expr(spl_comp_t *ctx) {
|
||||
skip_nl(ctx);
|
||||
if (peek(ctx)->type == TOK_SEMICOLON || peek(ctx)->type == TOK_ENDLINE) {
|
||||
/* Expression statement: drop value, consume ; */
|
||||
if (!is_assign && expr.type && expr.type->kind == TYPE_BASIC &&
|
||||
expr.type->basic_type != SPL_VOID)
|
||||
if (!is_assign && expr.type && spl_type_emit_type(expr.type) != SPL_VOID)
|
||||
spl_emit(ctx, SPL_DROP, SPL_VOID, 0);
|
||||
while (peek(ctx)->type == TOK_SEMICOLON || peek(ctx)->type == TOK_ENDLINE)
|
||||
advance(ctx);
|
||||
@@ -545,8 +544,8 @@ static void parse_defer_stmt(spl_comp_t *ctx) {
|
||||
* Delegates comparison to expr layer (spl_emit_match_enum_cmp).
|
||||
* Returns the variant for binding parsing, or NULL on error. */
|
||||
static spl_enum_variant_t *parse_match_enum_variant(spl_comp_t *ctx, spl_type_info_t *enum_type,
|
||||
int val_offset) {
|
||||
return spl_emit_match_enum_cmp(ctx, enum_type, val_offset);
|
||||
int val_offset, int by_value) {
|
||||
return spl_emit_match_enum_cmp(ctx, enum_type, val_offset, by_value);
|
||||
}
|
||||
|
||||
/* Parse a value pattern in a match arm (non-enum).
|
||||
@@ -642,6 +641,9 @@ static void parse_match_stmt(spl_comp_t *ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Scalar enums store the raw tag directly; others store a pointer */
|
||||
int match_by_value = (t && t->kind == TYPE_ENUM && spl_type_is_scalar(t));
|
||||
|
||||
/* Save match value to temp slot */
|
||||
int val_offset = ctx->current_local_bytes;
|
||||
ctx->current_local_bytes += (int)sizeof(spl_val_t);
|
||||
@@ -649,7 +651,7 @@ static void parse_match_stmt(spl_comp_t *ctx) {
|
||||
ctx->peak_local_bytes = ctx->current_local_bytes;
|
||||
spl_emit(ctx, SPL_LADDR, SPL_PTR, val_offset);
|
||||
spl_emit(ctx, SPL_SWAP, SPL_VOID, 0);
|
||||
spl_emit(ctx, SPL_STORE, SPL_PTR, 0);
|
||||
spl_emit(ctx, SPL_STORE, spl_type_emit_type(t), 0);
|
||||
|
||||
skip_nl(ctx);
|
||||
if (peek(ctx)->type == TOK_L_BRACE)
|
||||
@@ -684,7 +686,8 @@ static void parse_match_stmt(spl_comp_t *ctx) {
|
||||
} else {
|
||||
for (;;) {
|
||||
if (is_enum_match) {
|
||||
arm_variant = parse_match_enum_variant(ctx, enum_type, val_offset);
|
||||
arm_variant =
|
||||
parse_match_enum_variant(ctx, enum_type, val_offset, match_by_value);
|
||||
if (ctx->has_error)
|
||||
break;
|
||||
skip_nl(ctx);
|
||||
@@ -887,8 +890,7 @@ static void parse_expr_stmt(spl_comp_t *ctx) {
|
||||
if (is_assign)
|
||||
ctx->addr_of_mode = 0;
|
||||
|
||||
if (!is_assign && expr.type && expr.type->kind == TYPE_BASIC &&
|
||||
expr.type->basic_type != SPL_VOID)
|
||||
if (!is_assign && expr.type && spl_type_emit_type(expr.type) != SPL_VOID)
|
||||
spl_emit(ctx, SPL_DROP, SPL_VOID, 0);
|
||||
if (peek(ctx)->type == TOK_SEMICOLON)
|
||||
advance(ctx);
|
||||
|
||||
Reference in New Issue
Block a user