From cb8ec6419e76899d91c068c4835a477c01063450 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 14 Aug 2024 18:59:45 +0300 Subject: print whole type list --- src/debug.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/debug.c b/src/debug.c index 92d85d2..2db23a9 100644 --- a/src/debug.c +++ b/src/debug.c @@ -234,6 +234,22 @@ static void _type_list_str(FILE *fp, struct type *types) } } +static void _param_str(FILE *fp, struct ast *params) +{ + if (!params) + return; + + assert(params->k == AST_VAR_DEF); + _type_str(fp, var_type(params)); + + params = params->n; + foreach_node(n, params) { + assert(n->k == AST_VAR_DEF); + fprintf(fp, ", "); + _type_str(fp, var_type(n)); + } +} + /** * Workhorse for type_str(). * @@ -266,16 +282,26 @@ static void _type_str(FILE *fp, struct type *type) if (trait_id(def)) { fprintf(fp, "%s ", trait_id(def)); } - fprintf(fp, "(trait)"); + + if (struct_params(def)) { + fprintf(fp, "!["); + _param_str(fp, trait_params(def)); + fprintf(fp, "]"); + } break; } case TYPE_STRUCT: { struct ast *def = type->d; if (struct_id(def)) { - fprintf(fp, "%s ", struct_id(def)); + fprintf(fp, "%s", struct_id(def)); + } + + if (struct_params(def)) { + fprintf(fp, "!["); + _param_str(fp, struct_params(def)); + fprintf(fp, "]"); } - fprintf(fp, "(struct)"); break; } -- cgit v1.3