From ca8533334b43a73244c294bc878928115dac121d Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 24 May 2026 20:14:32 +0100 Subject: [PATCH] ast: implement to_string for int and double nodes --- bshell/ast/double.c | 10 ++++++++++ bshell/ast/int.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bshell/ast/double.c b/bshell/ast/double.c index 1f79e6b..d3a70bb 100644 --- a/bshell/ast/double.c +++ b/bshell/ast/double.c @@ -1,6 +1,16 @@ +#include "../parse/token.h" #include "ast.h" +#include + +static void to_string(const struct ast_node *node, fx_bstr *out) +{ + struct double_ast_node *i = (struct double_ast_node *)node; + fx_value_to_string(&i->n_value->tok_number, (fx_stream *)out, NULL); +} + struct ast_node_definition double_ast_node = { .def_id = AST_DOUBLE, .def_node_size = sizeof(struct double_ast_node), + .def_to_string = to_string, }; diff --git a/bshell/ast/int.c b/bshell/ast/int.c index 0cafd4c..60eeca3 100644 --- a/bshell/ast/int.c +++ b/bshell/ast/int.c @@ -1,10 +1,12 @@ #include "../parse/token.h" #include "ast.h" +#include + static void to_string(const struct ast_node *node, fx_bstr *out) { struct int_ast_node *i = (struct int_ast_node *)node; - fx_bstr_write_fmt(out, NULL, "%lld", i->n_value->tok_int); + fx_value_to_string(&i->n_value->tok_number, (fx_stream *)out, NULL); } struct ast_node_definition int_ast_node = {