aboutsummaryrefslogtreecommitdiff
path: root/src/compile/assertions.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-23 15:28:53 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-23 15:28:53 -0500
commit4771d6394d84eefaa45b661c1af8e20ac092a225 (patch)
tree6c0f08c7a6386eb454ef5b3a9059b84883a9ecdb /src/compile/assertions.c
parent0ea6cdf216ca765039f3c01f5b32dc1103265b58 (diff)
parent1a62de25c448d2661864ba25a98686ed506e66af (diff)
Merge branch 'dev'
Diffstat (limited to 'src/compile/assertions.c')
-rw-r--r--src/compile/assertions.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/compile/assertions.c b/src/compile/assertions.c
index 34055998..18531fd9 100644
--- a/src/compile/assertions.c
+++ b/src/compile/assertions.c
@@ -60,13 +60,10 @@ Text_t compile_assertion(env_t *env, ast_t *ast) {
compile_declaration(operand_t, Text("_rhs")), " = ", compile_to_type(env, cmp.rhs, operand_t), ";\n",
"\n#line ", line, "\n", "if (!(", compile_condition(env, var_comparison), "))\n", "#line ", line, "\n",
Texts("fail_source(", quoted_str(ast->file->filename), ", ", (int64_t)(expr->start - expr->file->text),
- ", ", (int64_t)(expr->end - expr->file->text), ", ",
- message ? Texts("Text$as_c_string(", compile_to_type(env, message, Type(TextType)), ")")
- : Text("\"This assertion failed!\""),
- ", ", "\" (\", ", expr_as_text(Text("_lhs"), operand_t, Text("no")),
- ", "
- "\" ",
- failure, " \", ", expr_as_text(Text("_rhs"), operand_t, Text("no")), ", \")\");\n"),
+ ", ", (int64_t)(expr->end - expr->file->text), ", Text$concat(",
+ message ? compile_to_type(env, message, Type(TextType)) : Text("Text(\"This assertion failed!\")"),
+ ", Text(\" (\"), ", expr_as_text(Text("_lhs"), operand_t, Text("no")), ", Text(\" ", failure,
+ " \"), ", expr_as_text(Text("_rhs"), operand_t, Text("no")), ", Text(\")\")));\n"),
"}\n");
}
default: {
@@ -74,8 +71,7 @@ Text_t compile_assertion(env_t *env, ast_t *ast) {
return Texts("if (!(", compile_condition(env, expr), "))\n", "#line ", line, "\n", "fail_source(",
quoted_str(ast->file->filename), ", ", (int64_t)(expr->start - expr->file->text), ", ",
(int64_t)(expr->end - expr->file->text), ", ",
- message ? Texts("Text$as_c_string(", compile_to_type(env, message, Type(TextType)), ")")
- : Text("\"This assertion failed!\""),
+ message ? compile_to_type(env, message, Type(TextType)) : Text("Text(\"This assertion failed!\")"),
");\n");
}
}