aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtins/array.c8
-rw-r--r--builtins/bool.c22
-rw-r--r--builtins/c_string.c4
-rw-r--r--builtins/channel.c8
-rw-r--r--builtins/functions.c10
-rw-r--r--builtins/integers.c20
-rw-r--r--builtins/memory.c2
-rw-r--r--builtins/nums.c4
-rw-r--r--builtins/pointer.c20
-rw-r--r--builtins/range.c2
-rw-r--r--builtins/table.c20
-rw-r--r--builtins/text.c4
-rw-r--r--builtins/thread.c2
-rw-r--r--builtins/types.c8
-rw-r--r--enums.c18
-rw-r--r--structs.c12
16 files changed, 82 insertions, 82 deletions
diff --git a/builtins/array.c b/builtins/array.c
index 63539559..68f581c8 100644
--- a/builtins/array.c
+++ b/builtins/array.c
@@ -537,17 +537,17 @@ public bool Array$equal(const array_t *x, const array_t *y, const TypeInfo *type
public Text_t Array$as_text(const array_t *arr, bool colorize, const TypeInfo *type)
{
if (!arr)
- return Text$concat(Text$from_str("["), generic_as_text(NULL, false, type->ArrayInfo.item), Text$from_str("]"));
+ return Text$concat(Text("["), generic_as_text(NULL, false, type->ArrayInfo.item), Text("]"));
const TypeInfo *item_type = type->ArrayInfo.item;
- Text_t text = Text$from_str("[");
+ Text_t text = Text("[");
for (int64_t i = 0; i < arr->length; i++) {
if (i > 0)
- text = Text$concat(text, Text$from_str(", "));
+ text = Text$concat(text, Text(", "));
Text_t item_text = generic_as_text(arr->data + i*arr->stride, colorize, item_type);
text = Text$concat(text, item_text);
}
- text = Text$concat(text, Text$from_str("]"));
+ text = Text$concat(text, Text("]"));
return text;
}
diff --git a/builtins/bool.c b/builtins/bool.c
index 488c6ddc..b3ba0bd7 100644
--- a/builtins/bool.c
+++ b/builtins/bool.c
@@ -16,25 +16,25 @@
public Text_t Bool$as_text(const bool *b, bool colorize, const TypeInfo *type)
{
(void)type;
- if (!b) return Text$from_str("Bool");
+ if (!b) return Text("Bool");
if (colorize)
- return *b ? Text$from_str("\x1b[35myes\x1b[m") : Text$from_str("\x1b[35mno\x1b[m");
+ return *b ? Text("\x1b[35myes\x1b[m") : Text("\x1b[35mno\x1b[m");
else
- return *b ? Text$from_str("yes") : Text$from_str("no");
+ return *b ? Text("yes") : Text("no");
}
public Bool_t Bool$from_text(Text_t text, bool *success)
{
- if (Text$equal_ignoring_case(text, Text$from_str("yes"))
- || Text$equal_ignoring_case(text, Text$from_str("on"))
- || Text$equal_ignoring_case(text, Text$from_str("true"))
- || Text$equal_ignoring_case(text, Text$from_str("1"))) {
+ if (Text$equal_ignoring_case(text, Text("yes"))
+ || Text$equal_ignoring_case(text, Text("on"))
+ || Text$equal_ignoring_case(text, Text("true"))
+ || Text$equal_ignoring_case(text, Text("1"))) {
if (success) *success = yes;
return yes;
- } else if (Text$equal_ignoring_case(text, Text$from_str("no"))
- || Text$equal_ignoring_case(text, Text$from_str("off"))
- || Text$equal_ignoring_case(text, Text$from_str("false"))
- || Text$equal_ignoring_case(text, Text$from_str("0"))) {
+ } else if (Text$equal_ignoring_case(text, Text("no"))
+ || Text$equal_ignoring_case(text, Text("off"))
+ || Text$equal_ignoring_case(text, Text("false"))
+ || Text$equal_ignoring_case(text, Text("0"))) {
if (success) *success = yes;
return no;
} else {
diff --git a/builtins/c_string.c b/builtins/c_string.c
index 8abb2b9f..bd35b549 100644
--- a/builtins/c_string.c
+++ b/builtins/c_string.c
@@ -16,9 +16,9 @@
public Text_t CString$as_text(const void *c_string, bool colorize, const TypeInfo *info)
{
(void)info;
- if (!c_string) return Text$from_str("CString");
+ if (!c_string) return Text("CString");
Text_t text = Text$from_str(*(char**)c_string);
- return Text$concat(Text$from_str(colorize ? "\x1b[34mCString\x1b[m(" : "CString("), Text$quoted(text, colorize), Text$from_str(")"));
+ return Text$concat(colorize ? Text("\x1b[34mCString\x1b[m(") : Text("CString("), Text$quoted(text, colorize), Text(")"));
}
public int CString$compare(const char **x, const char **y)
diff --git a/builtins/channel.c b/builtins/channel.c
index 08d6424f..4647f33f 100644
--- a/builtins/channel.c
+++ b/builtins/channel.c
@@ -125,15 +125,15 @@ Text_t Channel$as_text(const channel_t **channel, bool colorize, const TypeInfo
const TypeInfo *item_type = type->ChannelInfo.item;
if (!channel) {
Text_t typename = generic_as_text(NULL, false, item_type);
- return Text$concat(Text$from_str(colorize ? "\x1b[34;1m|:" : "|:"), typename, Text$from_str(colorize ? "|\x1b[m" : "|"));
+ return Text$concat(colorize ? Text("\x1b[34;1m|:") : Text("|:"), typename, colorize ? Text("|\x1b[m") : Text("|"));
}
Text_t typename = generic_as_text(NULL, false, item_type);
return Text$concat(
- Text$from_str(colorize ? "\x1b[34;1m|:" : "|:"),
+ colorize ? Text("\x1b[34;1m|:") : Text("|:"),
typename,
- Text$from_str("|<"),
+ Text("|<"),
Int64$hex((int64_t)(void*)*channel, I_small(0), true, true),
- Text$from_str(colorize ? ">\x1b[m" : ">")
+ colorize ? Text(">\x1b[m") : Text(">")
);
}
diff --git a/builtins/functions.c b/builtins/functions.c
index 4aa699a5..3fbccf84 100644
--- a/builtins/functions.c
+++ b/builtins/functions.c
@@ -169,8 +169,8 @@ public Text_t generic_as_text(const void *obj, bool colorize, const TypeInfo *ty
case TableInfo: return Table$as_text(obj, colorize, type);
case TypeInfoInfo: return Type$as_text(obj, colorize, type);
case EmptyStruct: return colorize ?
- Text$concat(Text$from_str("\x1b[0;1m"), Text$from_str(type->EmptyStruct.name), Text$from_str("\x1b[m()"))
- : Text$concat(Text$from_str(type->EmptyStruct.name), Text$from_str("()"));
+ Text$concat(Text("\x1b[0;1m"), Text$from_str(type->EmptyStruct.name), Text("\x1b[m()"))
+ : Text$concat(Text$from_str(type->EmptyStruct.name), Text("()"));
case CustomInfo:
if (!type->CustomInfo.as_text)
fail("No text function provided for type!\n");
@@ -218,9 +218,9 @@ public void end_test(void *expr, const TypeInfo *type, const char *expected, con
Text_t expr_plain = USE_COLOR ? generic_as_text(expr, false, type) : expr_text;
bool success = Text$equal(&expr_plain, &expected_text);
if (!success) {
- Int_t colon = Text$find(expected_text, Text$from_str(":"), I_small(1), NULL);
+ Int_t colon = Text$find(expected_text, Text(":"), I_small(1), NULL);
if (colon.small != I_small(0).small) {
- Text_t with_type = Text$concat(expr_plain, Text$from_str(" : "), type_name);
+ Text_t with_type = Text$concat(expr_plain, Text(" : "), type_name);
success = Text$equal(&with_type, &expected_text);
}
}
@@ -256,7 +256,7 @@ public bool pop_flag(char **argv, int *i, const char *flag, Text_t *result)
*i += 1;
return true;
} else if (strncmp(argv[*i] + 2, "no-", 3) == 0 && streq(argv[*i] + 5, flag)) {
- *result = Text$from_str("no");
+ *result = Text("no");
argv[*i] = NULL;
*i += 1;
return true;
diff --git a/builtins/integers.c b/builtins/integers.c
index 44ecaf91..8e17ca24 100644
--- a/builtins/integers.c
+++ b/builtins/integers.c
@@ -25,14 +25,14 @@ public void Int$init_random(long seed)
public Text_t Int$as_text(const Int_t *i, bool colorize, const TypeInfo *type) {
(void)type;
- if (!i) return Text$from_str("Int");
+ if (!i) return Text("Int");
if (__builtin_expect(i->small & 1, 1)) {
return Text$format(colorize ? "\x1b[35m%ld\x1b[m" : "%ld", (i->small)>>2);
} else {
char *str = mpz_get_str(NULL, 10, *i->big);
Text_t text = Text$from_str(str);
- if (colorize) text = Text$concat(Text$from_str("\x1b[35m"), text, Text$from_str("\x1b[m"));
+ if (colorize) text = Text$concat(Text("\x1b[35m"), text, Text("\x1b[m"));
return text;
}
}
@@ -85,7 +85,7 @@ public Text_t Int$format(Int_t i, Int_t digits_int)
char *zeroes = GC_MALLOC_ATOMIC(needed_zeroes);
memset(zeroes, '0', needed_zeroes);
if (negative)
- return Text$concat(Text$from_str("-"), Text$from_str(zeroes), Text$from_str(str + 1));
+ return Text$concat(Text("-"), Text$from_str(zeroes), Text$from_str(str + 1));
else
return Text$concat(Text$from_str(zeroes), Text$from_str(str));
}
@@ -93,7 +93,7 @@ public Text_t Int$format(Int_t i, Int_t digits_int)
public Text_t Int$hex(Int_t i, Int_t digits_int, bool uppercase, bool prefix) {
if (Int$compare(&i, (Int_t[1]){I_small(0)}, &$Int) < 0)
- return Text$concat(Text$from_str("-"), Int$hex(Int$negative(i), digits_int, uppercase, prefix));
+ return Text$concat(Text("-"), Int$hex(Int$negative(i), digits_int, uppercase, prefix));
int64_t digits = Int_to_Int64(digits_int, false);
if (__builtin_expect(i.small & 1, 1)) {
@@ -107,12 +107,12 @@ public Text_t Int$hex(Int_t i, Int_t digits_int, bool uppercase, bool prefix) {
}
int64_t needed_zeroes = digits - (int64_t)strlen(str);
if (needed_zeroes <= 0)
- return prefix ? Text$concat(Text$from_str("0x"), Text$from_str(str)) : Text$from_str(str);
+ return prefix ? Text$concat(Text("0x"), Text$from_str(str)) : Text$from_str(str);
char *zeroes = GC_MALLOC_ATOMIC(needed_zeroes);
memset(zeroes, '0', needed_zeroes);
if (prefix)
- return Text$concat(Text$from_str("0x"), Text$from_str(zeroes), Text$from_str(str));
+ return Text$concat(Text("0x"), Text$from_str(zeroes), Text$from_str(str));
else
return Text$concat(Text$from_str(zeroes), Text$from_str(str));
}
@@ -121,7 +121,7 @@ public Text_t Int$hex(Int_t i, Int_t digits_int, bool uppercase, bool prefix) {
public Text_t Int$octal(Int_t i, Int_t digits_int, bool prefix) {
Int_t zero = I_small(0);
if (Int$compare(&i, &zero, &$Int) < 0)
- return Text$concat(Text$from_str("-"), Int$octal(Int$negative(i), digits_int, prefix));
+ return Text$concat(Text("-"), Int$octal(Int$negative(i), digits_int, prefix));
int64_t digits = Int_to_Int64(digits_int, false);
if (__builtin_expect(i.small & 1, 1)) {
@@ -131,12 +131,12 @@ public Text_t Int$octal(Int_t i, Int_t digits_int, bool prefix) {
char *str = mpz_get_str(NULL, 8, *i.big);
int64_t needed_zeroes = digits - (int64_t)strlen(str);
if (needed_zeroes <= 0)
- return prefix ? Text$concat(Text$from_str("0o"), Text$from_str(str)) : Text$from_str(str);
+ return prefix ? Text$concat(Text("0o"), Text$from_str(str)) : Text$from_str(str);
char *zeroes = GC_MALLOC_ATOMIC(needed_zeroes);
memset(zeroes, '0', needed_zeroes);
if (prefix)
- return Text$concat(Text$from_str("0o"), Text$from_str(zeroes), Text$from_str(str));
+ return Text$concat(Text("0o"), Text$from_str(zeroes), Text$from_str(str));
else
return Text$concat(Text$from_str(zeroes), Text$from_str(str));
}
@@ -408,7 +408,7 @@ public const TypeInfo $Int = {
#define DEFINE_INT_TYPE(c_type, KindOfInt, fmt, min_val, max_val)\
public Text_t KindOfInt ## $as_text(const c_type *i, bool colorize, const TypeInfo *type) { \
(void)type; \
- if (!i) return Text$from_str(#KindOfInt); \
+ if (!i) return Text(#KindOfInt); \
return Text$format(colorize ? "\x1b[35m%" fmt "\x1b[m" : "%" fmt, *i); \
} \
public int32_t KindOfInt ## $compare(const c_type *x, const c_type *y, const TypeInfo *type) { \
diff --git a/builtins/memory.c b/builtins/memory.c
index 4e8e4c50..06fb7bb2 100644
--- a/builtins/memory.c
+++ b/builtins/memory.c
@@ -15,7 +15,7 @@
public Text_t Memory__as_text(const void *p, bool colorize, const TypeInfo *type) {
(void)type;
- if (!p) return Text$from_str("Memory");
+ if (!p) return Text("Memory");
return Text$format(colorize ? "\x1b[0;34;1mMemory<%p>\x1b[m" : "Memory<%p>", p);
}
diff --git a/builtins/nums.c b/builtins/nums.c
index 5848a589..94837281 100644
--- a/builtins/nums.c
+++ b/builtins/nums.c
@@ -16,7 +16,7 @@
public Text_t Num$as_text(const double *f, bool colorize, const TypeInfo *type) {
(void)type;
- if (!f) return Text$from_str("Num");
+ if (!f) return Text("Num");
return Text$format(colorize ? "\x1b[35m%.16g\x1b[33;2m\x1b[m" : "%.16g", *f);
}
@@ -95,7 +95,7 @@ public const TypeInfo $Num = {
public Text_t Num32$as_text(const float *f, bool colorize, const TypeInfo *type) {
(void)type;
- if (!f) return Text$from_str("Num32");
+ if (!f) return Text("Num32");
return Text$format(colorize ? "\x1b[35m%.8g_f32\x1b[33;2m\x1b[m" : "%.8g_f32", *f);
}
diff --git a/builtins/pointer.c b/builtins/pointer.c
index 41f4a2a1..5090edd9 100644
--- a/builtins/pointer.c
+++ b/builtins/pointer.c
@@ -25,12 +25,12 @@ public Text_t Pointer$as_text(const void *x, bool colorize, const TypeInfo *type
Text_t typename = generic_as_text(NULL, false, ptr_info.pointed);
Text_t text;
if (colorize)
- text = Text$concat(Text$from_str("\x1b[34;1m"), Text$from_str(ptr_info.sigil), typename, Text$from_str("\x1b[m"));
+ text = Text$concat(Text("\x1b[34;1m"), Text$from_str(ptr_info.sigil), typename, Text("\x1b[m"));
else
text = Text$concat(Text$from_str(ptr_info.sigil), typename);
if (ptr_info.is_optional)
- text = Text$concat(text, Text$from_str("?"));
+ text = Text$concat(text, Text("?"));
return text;
}
@@ -38,9 +38,9 @@ public Text_t Pointer$as_text(const void *x, bool colorize, const TypeInfo *type
if (!ptr) {
Text_t typename = generic_as_text(NULL, false, ptr_info.pointed);
if (colorize)
- return Text$concat(Text$from_str("\x1b[34;1m!"), typename, Text$from_str("\x1b[m"));
+ return Text$concat(Text("\x1b[34;1m!"), typename, Text("\x1b[m"));
else
- return Text$concat(Text$from_str("!"), typename);
+ return Text$concat(Text("!"), typename);
}
// Check for recursive references, so if `x.foo = x`, then it prints as
@@ -51,13 +51,13 @@ public Text_t Pointer$as_text(const void *x, bool colorize, const TypeInfo *type
++depth;
if (r->ptr == ptr) {
Text_t text = Text$concat(
- Text$from_str(colorize ? "\x1b[34;1m" : ""),
+ colorize ? Text("\x1b[34;1m") : Text(""),
Text$from_str(ptr_info.sigil),
- Text$from_str(".."),
+ Text(".."),
Int32$as_text(&depth, false, &$Int32),
- Text$from_str(colorize ? "\x1b[m" : ""));
+ colorize ? Text("\x1b[m") : Text(""));
if (ptr_info.is_optional)
- text = Text$concat(text, Text$from_str(colorize ? "\x1b[34;1m?\x1b[m" : "?"));
+ text = Text$concat(text, colorize ? Text("\x1b[34;1m?\x1b[m") : Text("?"));
return text;
}
}
@@ -71,12 +71,12 @@ public Text_t Pointer$as_text(const void *x, bool colorize, const TypeInfo *type
}
Text_t text;
if (colorize)
- text = Text$concat(Text$from_str("\x1b[34;1m"), Text$from_str(ptr_info.sigil), Text$from_str("\x1b[m"), pointed);
+ text = Text$concat(Text("\x1b[34;1m"), Text$from_str(ptr_info.sigil), Text("\x1b[m"), pointed);
else
text = Text$concat(Text$from_str(ptr_info.sigil), pointed);
if (ptr_info.is_optional)
- text = Text$concat(text, Text$from_str("?"));
+ text = Text$concat(text, Text("?"));
return text;
}
diff --git a/builtins/range.c b/builtins/range.c
index 9b5af8cd..362174b0 100644
--- a/builtins/range.c
+++ b/builtins/range.c
@@ -35,7 +35,7 @@ static bool Range$equal(const Range_t *x, const Range_t *y, const TypeInfo *type
static Text_t Range$as_text(const Range_t *r, bool use_color, const TypeInfo *type)
{
(void)type;
- if (!r) return Text$from_str("Range");
+ if (!r) return Text("Range");
return Text$format(use_color ? "\x1b[0;1mRange\x1b[m(first=%r, last=%r, step=%r)"
: "Range(first=%r, last=%r, step=%r)",
diff --git a/builtins/table.c b/builtins/table.c
index 9bc3ded1..22797775 100644
--- a/builtins/table.c
+++ b/builtins/table.c
@@ -459,34 +459,34 @@ public Text_t Table$as_text(const table_t *t, bool colorize, const TypeInfo *typ
if (!t) {
if (table.value != &$Void)
return Text$concat(
- Text$from_str("{"),
+ Text("{"),
generic_as_text(NULL, false, table.key),
- Text$from_str(":"),
+ Text(":"),
generic_as_text(NULL, false, table.value),
- Text$from_str("}"));
+ Text("}"));
else
return Text$concat(
- Text$from_str("{"),
+ Text("{"),
generic_as_text(NULL, false, table.key),
- Text$from_str("}"));
+ Text("}"));
}
int64_t val_off = value_offset(type);
- Text_t text = Text$from_str("{");
+ Text_t text = Text("{");
for (int64_t i = 0, length = Table$length(*t); i < length; i++) {
if (i > 0)
- text = Text$concat(text, Text$from_str(", "));
+ text = Text$concat(text, Text(", "));
void *entry = GET_ENTRY(*t, i);
text = Text$concat(text, generic_as_text(entry, colorize, table.key));
if (table.value != &$Void)
- text = Text$concat(text, Text$from_str(":"), generic_as_text(entry + val_off, colorize, table.value));
+ text = Text$concat(text, Text(":"), generic_as_text(entry + val_off, colorize, table.value));
}
if (t->fallback) {
- text = Text$concat(text, Text$from_str("; fallback="), Table$as_text(t->fallback, colorize, type));
+ text = Text$concat(text, Text("; fallback="), Table$as_text(t->fallback, colorize, type));
}
- text = Text$concat(text, Text$from_str("}"));
+ text = Text$concat(text, Text("}"));
return text;
}
diff --git a/builtins/text.c b/builtins/text.c
index 00958743..422f99a5 100644
--- a/builtins/text.c
+++ b/builtins/text.c
@@ -1440,10 +1440,10 @@ static inline Text_t _quoted(Text_t text, bool colorize, char quote_char)
public Text_t Text$as_text(const void *text, bool colorize, const TypeInfo *info)
{
(void)info;
- if (!text) return info && info->TextInfo.lang ? Text$from_str(info->TextInfo.lang) : Text$from_str("Text");
+ if (!text) return info && info->TextInfo.lang ? Text$from_str(info->TextInfo.lang) : Text("Text");
Text_t as_text = _quoted(*(Text_t*)text, colorize, info == &Pattern ? '/' : '"');
if (info && info->TextInfo.lang && info != &$Text && info != &Pattern)
- as_text = Text$concat(Text$from_str(colorize ? "\x1b[1m$" : "$"), Text$from_str(info->TextInfo.lang), as_text);
+ as_text = Text$concat(colorize ? Text("\x1b[1m$") : Text("$"), Text$from_str(info->TextInfo.lang), as_text);
return as_text;
}
diff --git a/builtins/thread.c b/builtins/thread.c
index 793a0101..4f422e5d 100644
--- a/builtins/thread.c
+++ b/builtins/thread.c
@@ -43,7 +43,7 @@ Text_t Thread$as_text(const pthread_t **thread, bool colorize, const TypeInfo *t
{
(void)type;
if (!thread) {
- return Text$from_str(colorize ? "\x1b[34;1mThread\x1b[m" : "Thread");
+ return colorize ? Text("\x1b[34;1mThread\x1b[m") : Text("Thread");
}
return Text$format(colorize ? "\x1b[34;1mThread(%p)\x1b[m" : "Thread(%p)", *thread);
}
diff --git a/builtins/types.c b/builtins/types.c
index ab1b8013..c34882f0 100644
--- a/builtins/types.c
+++ b/builtins/types.c
@@ -14,13 +14,13 @@
public Text_t Type$as_text(const void *typeinfo, bool colorize, const TypeInfo *type)
{
- if (!typeinfo) return Text$from_str("TypeInfo");
+ if (!typeinfo) return Text("TypeInfo");
if (colorize)
return Text$concat(
- Text$from_str("\x1b[36;1m"),
+ Text("\x1b[36;1m"),
Text$from_str(type->TypeInfoInfo.type_str),
- Text$from_str("\x1b[m"));
+ Text("\x1b[m"));
else
return Text$from_str(type->TypeInfoInfo.type_str);
}
@@ -40,7 +40,7 @@ public Text_t Func$as_text(const void *fn, bool colorize, const TypeInfo *type)
(void)fn;
Text_t text = Text$from_str(type->FunctionInfo.type_str);
if (fn && colorize)
- text = Text$concat(Text$from_str("\x1b[32;1m"), text, Text$from_str("\x1b[m"));
+ text = Text$concat(Text("\x1b[32;1m"), text, Text("\x1b[m"));
return text;
}
diff --git a/enums.c b/enums.c
index 1ad96280..0705f688 100644
--- a/enums.c
+++ b/enums.c
@@ -25,30 +25,30 @@ static CORD compile_str_method(env_t *env, ast_t *ast)
auto def = Match(ast, EnumDef);
CORD full_name = CORD_cat(namespace_prefix(env->libname, env->namespace), def->name);
CORD str_func = CORD_all("static Text_t ", full_name, "$as_text(", full_name, "_t *obj, bool use_color) {\n"
- "\tif (!obj) return Text$from_str(\"", def->name, "\");\n"
+ "\tif (!obj) return Text(\"", def->name, "\");\n"
"switch (obj->tag) {\n");
for (tag_ast_t *tag = def->tags; tag; tag = tag->next) {
if (!tag->fields) {
- str_func = CORD_all(str_func, "\tcase ", full_name, "$tag$", tag->name, ": return Text$from_str(use_color ? \"\\x1b[36;1m",
- def->name, ".", tag->name, "\\x1b[m\" : \"", def->name, ".", tag->name, "\");\n");
+ str_func = CORD_all(str_func, "\tcase ", full_name, "$tag$", tag->name, ": return use_color ? Text(\"\\x1b[36;1m",
+ def->name, ".", tag->name, "\\x1b[m\") : Text(\"", def->name, ".", tag->name, "\");\n");
continue;
}
- str_func = CORD_all(str_func, "\tcase ", full_name, "$tag$", tag->name, ": return Text$concat(Text$from_str(use_color ? \"\\x1b[36;1m",
- def->name, ".", tag->name, "\\x1b[m(\" : \"", def->name, ".", tag->name, "(\")");
+ str_func = CORD_all(str_func, "\tcase ", full_name, "$tag$", tag->name, ": return Text$concat(use_color ? Text(\"\\x1b[36;1m",
+ def->name, ".", tag->name, "\\x1b[m(\") : Text(\"", def->name, ".", tag->name, "(\")");
if (tag->secret) {
- str_func = CORD_cat(str_func, ", Text$from_str(use_color ? \"\\x1b[2m...\\x1b[m\" : \"...\", \")\"));\n");
+ str_func = CORD_cat(str_func, ", use_color ? Text(\"\\x1b[2m...\\x1b[m\") : Text(\"...\", \")\"));\n");
continue;
}
for (arg_ast_t *field = tag->fields; field; field = field->next) {
type_t *field_t = get_arg_ast_type(env, field);
CORD field_str = expr_as_text(env, CORD_all("obj->$", tag->name, ".$", field->name), field_t, "use_color");
- str_func = CORD_all(str_func, ", Text$from_str(\"", field->name, "=\"), ", field_str);
- if (field->next) str_func = CORD_cat(str_func, ", Text$from_str(\", \")");
+ str_func = CORD_all(str_func, ", Text(\"", field->name, "=\"), ", field_str);
+ if (field->next) str_func = CORD_cat(str_func, ", Text(\", \")");
}
- str_func = CORD_cat(str_func, ", Text$from_str(\")\"));\n");
+ str_func = CORD_cat(str_func, ", Text(\")\"));\n");
}
str_func = CORD_cat(str_func, "\tdefault: return (Text_t){.length=0};\n\t}\n}\n");
return str_func;
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;
}