From 82849ba783e2b8f8e3a040751cd964313470e7f2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 3 Sep 2024 15:00:28 -0400 Subject: Use Text("...") literal constructor instead of Text$from_str("...") function call. --- structs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'structs.c') diff --git a/structs.c b/structs.c index 44285871..ebd4f7a3 100644 --- a/structs.c +++ b/structs.c @@ -19,19 +19,19 @@ static CORD compile_str_method(env_t *env, ast_t *ast) const char *dollar = strrchr(name, '$'); if (dollar) name = dollar + 1; CORD str_func = CORD_asprintf("static Text_t %r$as_text(%r_t *obj, bool use_color) {\n" - "\tif (!obj) return Text$from_str(\"%s\");\n", full_name, full_name, name); + "\tif (!obj) return Text(\"%s\");\n", full_name, full_name, name); if (def->secret) { - CORD_appendf(&str_func, "\treturn Text$from_str(use_color ? \"\\x1b[0;1m%s\\x1b[m(\\x1b[2m...\\x1b[m)\" : \"%s(...)\");\n}", + CORD_appendf(&str_func, "\treturn use_color ? Text(\"\\x1b[0;1m%s\\x1b[m(\\x1b[2m...\\x1b[m)\") : Text(\"%s(...)\");\n}", name, name); } else { - CORD_appendf(&str_func, "\treturn Text$concat(Text$from_str(use_color ? \"\\x1b[0;1m%s\\x1b[m(\" : \"%s(\")", name, name); + CORD_appendf(&str_func, "\treturn Text$concat(use_color ? Text(\"\\x1b[0;1m%s\\x1b[m(\") : Text(\"%s(\")", name, name); for (arg_ast_t *field = def->fields; field; field = field->next) { type_t *field_type = get_arg_ast_type(env, field); CORD field_str = expr_as_text(env, CORD_cat("obj->$", field->name), field_type, "use_color"); - CORD_appendf(&str_func, ", Text$from_str(\"%s=\"), %r", field->name, field_str); - if (field->next) CORD_appendf(&str_func, ", Text$from_str(\", \")"); + CORD_appendf(&str_func, ", Text(\"%s=\"), %r", field->name, field_str); + if (field->next) CORD_appendf(&str_func, ", Text(\", \")"); } - CORD_appendf(&str_func, ", Text$from_str(\")\"));\n}\n"); + CORD_appendf(&str_func, ", Text(\")\"));\n}\n"); } return str_func; } -- cgit v1.2.3