diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-07-11 16:05:54 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-07-11 16:05:54 -0400 |
| commit | 4153c0af9d4dcc43c0a67cc446a313c46ee5ac33 (patch) | |
| tree | 246154cdf41f487f6d2da2c6b6df5aba50531ab6 /src | |
| parent | a51d48201b5245dc2cc2bfb00e0ac8e7b52203d9 (diff) | |
| parent | 46b0dbc5a448249ddc9a6ce20465f0fa41de6d64 (diff) | |
Merge branch 'main' into decimalsdecimals
Diffstat (limited to 'src')
| -rw-r--r-- | src/compile.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compile.c b/src/compile.c index 5aa1ab33..3bc2fa4a 100644 --- a/src/compile.c +++ b/src/compile.c @@ -113,8 +113,10 @@ static bool promote(env_t *env, ast_t *ast, CORD *code, type_t *actual, type_t * // Automatic optional checking for nums: if (needed->tag == NumType && actual->tag == OptionalType && Match(actual, OptionalType)->type->tag == NumType) { + int64_t line = get_line_number(ast->file, ast->start); *code = CORD_all("({ ", compile_declaration(actual, "opt"), " = ", *code, "; ", "if unlikely (", check_none(actual, "opt"), ")\n", + "#line ", String(line), "\n", "fail_source(", CORD_quoted(ast->file->filename), ", ", String((int64_t)(ast->start - ast->file->text)), ", ", String((int64_t)(ast->end - ast->file->text)), ", ", @@ -1308,10 +1310,14 @@ static CORD _compile_statement(env_t *env, ast_t *ast) ast_t *rhs_var = FakeAST(InlineCCode, .chunks=new(ast_list_t, .ast=FakeAST(TextLiteral, "_rhs")), .type=operand_t); ast_t *var_comparison = new(ast_t, .file=expr->file, .start=expr->start, .end=expr->end, .tag=expr->tag, .__data.Equals={.lhs=lhs_var, .rhs=rhs_var}); + int64_t line = get_line_number(ast->file, ast->start); return CORD_all("{ // assertion\n", compile_declaration(operand_t, "_lhs"), " = ", compile_to_type(env, cmp.lhs, operand_t), ";\n", + "\n#line ", String(line), "\n", compile_declaration(operand_t, "_rhs"), " = ", compile_to_type(env, cmp.rhs, operand_t), ";\n", + "\n#line ", String(line), "\n", "if (!(", compile_condition(env, var_comparison), "))\n", + "#line ", String(line), "\n", CORD_all( "fail_source(", CORD_quoted(ast->file->filename), ", ", String((int64_t)(expr->start - expr->file->text)), ", ", @@ -1324,8 +1330,10 @@ static CORD _compile_statement(env_t *env, ast_t *ast) } default: { + int64_t line = get_line_number(ast->file, ast->start); return CORD_all( "if (!(", compile_condition(env, expr), "))\n", + "#line ", String(line), "\n", "fail_source(", CORD_quoted(ast->file->filename), ", ", String((int64_t)(expr->start - expr->file->text)), ", ", String((int64_t)(expr->end - expr->file->text)), ", ", @@ -2826,8 +2834,10 @@ CORD compile(env_t *env, ast_t *ast) ast_t *value = Match(ast, NonOptional)->value; type_t *t = get_type(env, value); CORD value_code = compile(env, value); + int64_t line = get_line_number(ast->file, ast->start); return CORD_all("({ ", compile_declaration(t, "opt"), " = ", value_code, "; ", "if unlikely (", check_none(t, "opt"), ")\n", + "#line ", String(line), "\n", "fail_source(", CORD_quoted(ast->file->filename), ", ", String((int64_t)(value->start - value->file->text)), ", ", String((int64_t)(value->end - value->file->text)), ", ", |
