1#include "include/pw.h"
2
3void _pw_print_indent(FILE* fp, int indent)
4{
5 for (int i = 0; i < indent; i++ ) {
6 fputc(' ', fp);
7 }
8}
9
10void _pw_print_type(FILE* fp, PwValuePtr value)
11{
12 char* type_name = pw_typeof(value)->name;
13
14 fprintf(fp, "%p", (void*) value);
15 if (type_name == nullptr) {
16 fprintf(fp, " BAD TYPE %d", value->type_id);
17 } else {
18 fprintf(fp, " %s (type id: %d)", type_name, value->type_id);
19 }
20}
21
22void _pw_dump(FILE* fp, PwValuePtr value, int indent, _PwCompoundChain* tail)
23{
24 if (value == nullptr) {
25 _pw_print_indent(fp, indent);
26 fprintf(fp, "nullptr\n");
27 return;
28 }
29 pw_call(Basic, dump, value, fp, indent, tail);
30}
31
32void pw_dump(FILE* fp, PwValuePtr value)
33{
34 _pw_dump(fp, value, 0, nullptr);
35}