From 0b8a1a0de83ea21f7b48ba04cd53c22537105082 Mon Sep 17 00:00:00 2001 From: krangelov Date: Sat, 4 Dec 2021 18:09:08 +0100 Subject: [PATCH] fix the order in which HOAS variables are shown in pgf_graphviz_abstract_tree --- src/runtime/c/pgf/printer.cxx | 19 ++++++++----------- src/runtime/c/pgf/printer.h | 6 +++++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/runtime/c/pgf/printer.cxx b/src/runtime/c/pgf/printer.cxx index 014192b67..a75e4737a 100644 --- a/src/runtime/c/pgf/printer.cxx +++ b/src/runtime/c/pgf/printer.cxx @@ -447,18 +447,15 @@ void PgfPrinter::parg(ref ty, ref parg) puts(")"); } -void PgfPrinter::bindings(size_t n_vars) +void PgfPrinter::bindings(PgfPrintContext *context, size_t n_vars) { - bool first = true; - PgfPrintContext *context = ctxt; - while (context != NULL && n_vars > 0) { - if (!first) { - puts(","); - first = false; - } - efun(&context->name); - context = context->next; - } + if (context == NULL || n_vars == 0) + return; + + bindings(context->next, n_vars-1); + if (n_vars > 1) + puts(","); + efun(&context->name); } void PgfPrinter::lvar(size_t var) diff --git a/src/runtime/c/pgf/printer.h b/src/runtime/c/pgf/printer.h index 6e2978c70..019222810 100644 --- a/src/runtime/c/pgf/printer.h +++ b/src/runtime/c/pgf/printer.h @@ -27,6 +27,8 @@ class PGF_INTERNAL_DECL PgfPrinter : public PgfUnmarshaller { // The marshaller for pattern matching PgfMarshaller *m; + void bindings(PgfPrintContext *context, size_t n_vars); + public: PgfPrinter(PgfPrintContext *context, int priority, PgfMarshaller *marshaller); @@ -73,7 +75,9 @@ public: size_t n_exprs, PgfExpr *exprs); virtual void free_ref(object x); - void bindings(size_t n_vars); + void bindings(size_t n_vars) { + bindings(ctxt,n_vars); + } }; #endif