aboutsummaryrefslogtreecommitdiff
path: root/repl.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-02 18:47:39 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-02 18:47:39 -0400
commit61e482f6f36aee6f72392a6188f2ec5c858b88fd (patch)
treebea4123fcc62dd834405ae89ce9fe260e90a0023 /repl.c
parentf0f8f218703ebb4512b3cd3f9e06b86a7d9861b0 (diff)
Initial WIP first past
Diffstat (limited to 'repl.c')
-rw-r--r--repl.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/repl.c b/repl.c
index a2b77a81..85c1ec89 100644
--- a/repl.c
+++ b/repl.c
@@ -208,7 +208,7 @@ static double ast_to_num(env_t *env, ast_t *ast)
}
}
-static CORD obj_to_text(type_t *t, const void *obj, bool use_color)
+static Text_t obj_to_text(type_t *t, const void *obj, bool use_color)
{
const TypeInfo *info = type_to_type_info(t);
return generic_as_text(obj, use_color, info);
@@ -272,8 +272,8 @@ void run(env_t *env, ast_t *ast)
} else {
void *value = GC_MALLOC(size);
eval(env, doctest->expr, value);
- CORD c = obj_to_text(t, value, true);
- printf("= %s \x1b[2m: %T\x1b[m\n", CORD_to_const_char_star(c), t);
+ Text_t text = obj_to_text(t, value, true);
+ printf("= %k \x1b[2m: %T\x1b[m\n", &text, t);
fflush(stdout);
}
break;
@@ -353,11 +353,11 @@ void eval(env_t *env, ast_t *ast, void *dest)
case Int: {
if (!dest) return;
switch (Match(ast, Int)->bits) {
- case 0: *(Int_t*)dest = Int$from_text(Match(ast, Int)->str, NULL); break;
- case 64: *(int64_t*)dest = Int64$from_text(Match(ast, Int)->str, NULL); break;
- case 32: *(int32_t*)dest = Int32$from_text(Match(ast, Int)->str, NULL); break;
- case 16: *(int16_t*)dest = Int16$from_text(Match(ast, Int)->str, NULL); break;
- case 8: *(int8_t*)dest = Int8$from_text(Match(ast, Int)->str, NULL); break;
+ case 0: *(Int_t*)dest = Int$from_text(Text$from_str(Match(ast, Int)->str), NULL); break;
+ case 64: *(int64_t*)dest = Int64$from_text(Text$from_str(Match(ast, Int)->str), NULL); break;
+ case 32: *(int32_t*)dest = Int32$from_text(Text$from_str(Match(ast, Int)->str), NULL); break;
+ case 16: *(int16_t*)dest = Int16$from_text(Text$from_str(Match(ast, Int)->str), NULL); break;
+ case 8: *(int8_t*)dest = Int8$from_text(Text$from_str(Match(ast, Int)->str), NULL); break;
default: errx(1, "Invalid int bits: %ld", Match(ast, Int)->bits);
}
break;
@@ -386,7 +386,7 @@ void eval(env_t *env, ast_t *ast, void *dest)
size_t chunk_size = type_size(chunk_t);
char buf[chunk_size];
eval(env, chunk->ast, buf);
- ret = CORD_cat(ret, obj_to_text(chunk_t, buf, false));
+ ret = CORD_cat(ret, Text$as_c_string(obj_to_text(chunk_t, buf, false)));
}
}
if (dest) *(CORD*)dest = ret;