aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/io.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-29 21:25:03 +0900
committernsfisis <nsfisis@gmail.com>2025-08-29 21:49:56 +0900
commitb678465c11517a5342b1ec5aa4fe21570f13a3ed (patch)
tree6ef19e02b1cf18f5ac451e6104f6e20b475a6f52 /src/io.c
parent8f352553faec69a6f29854898b93be47604aff28 (diff)
downloadducc-b678465c11517a5342b1ec5aa4fe21570f13a3ed.tar.gz
ducc-b678465c11517a5342b1ec5aa4fe21570f13a3ed.tar.zst
ducc-b678465c11517a5342b1ec5aa4fe21570f13a3ed.zip
feat: add utility function to dump any internal object as JSON
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index 859e046..5530ab7 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1,5 +1,17 @@
#include "io.h"
#include "common.h"
+#include "json.h"
+
+void sourcelocation_build_json(JsonBuilder* builder, SourceLocation* loc) {
+ jsonbuilder_object_start(builder);
+ jsonbuilder_object_member_start(builder, "filename");
+ jsonbuilder_string(builder, loc->filename);
+ jsonbuilder_object_member_end(builder);
+ jsonbuilder_object_member_start(builder, "line");
+ jsonbuilder_integer(builder, loc->line);
+ jsonbuilder_object_member_end(builder);
+ jsonbuilder_object_end(builder);
+}
InFile* infile_open(const char* filename) {
FILE* in;