aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-03 23:35:42 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-03 23:35:42 -0400
commit805082d2990c780328bef7d0d8ebc5601ef02eb1 (patch)
tree8488d9fbbb58f276b0bc277b79bd13bd2a2bdf57
parentf60edfbe7f7fe4a3f62228aeafc18a1819de5319 (diff)
Minor codegen cleanup Texts(...)
-rw-r--r--builtins/text.h1
-rw-r--r--compile.c6
2 files changed, 4 insertions, 3 deletions
diff --git a/builtins/text.h b/builtins/text.h
index b343798d..3aa51872 100644
--- a/builtins/text.h
+++ b/builtins/text.h
@@ -20,6 +20,7 @@ int Text$print(FILE *stream, Text_t t);
void Text$visualize(Text_t t);
Text_t Text$_concat(int n, Text_t items[n]);
#define Text$concat(...) Text$_concat(sizeof((Text_t[]){__VA_ARGS__})/sizeof(Text_t), (Text_t[]){__VA_ARGS__})
+#define Texts(...) Text$concat(__VA_ARGS__)
Text_t Text$slice(Text_t text, Int_t first_int, Int_t last_int);
Text_t Text$from_str(const char *str);
uint64_t Text$hash(Text_t *text);
diff --git a/compile.c b/compile.c
index 6c1bee4c..edad2f12 100644
--- a/compile.c
+++ b/compile.c
@@ -593,7 +593,7 @@ CORD compile_statement(env_t *env, ast_t *ast)
return CORD_all(lhs, " ^= ", rhs, ";");
case BINOP_CONCAT: {
if (lhs_t->tag == TextType) {
- return CORD_all(lhs, " = Text$concat(", lhs, ", ", rhs, ");");
+ return CORD_all(lhs, " = Texts(", lhs, ", ", rhs, ");");
} else if (lhs_t->tag == ArrayType) {
CORD padded_item_size = CORD_asprintf("%ld", padded_type_size(Match(lhs_t, ArrayType)->item_type));
if (promote(env, &rhs, rhs_t, Match(lhs_t, ArrayType)->item_type)) {
@@ -822,7 +822,7 @@ CORD compile_statement(env_t *env, ast_t *ast)
if (!to_print)
return CORD_EMPTY;
- CORD code = "say(Text$concat(";
+ CORD code = "say(Texts(";
for (ast_list_t *chunk = to_print; chunk; chunk = chunk->next) {
if (chunk->ast->tag == TextLiteral) {
code = CORD_cat(code, compile(env, chunk->ast));
@@ -1845,7 +1845,7 @@ CORD compile(env_t *env, ast_t *ast)
if (chunk->next) code = CORD_cat(code, ", ");
}
if (chunks->next)
- return CORD_all("Text$concat(", code, ")");
+ return CORD_all("Texts(", code, ")");
else
return code;
}