X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;ds=sidebyside;f=ginac%2Fbasic.cpp;h=725f28a2e6b0ea40965ebbc45d50e6ca9d5e7a98;hb=1c5f50be3b99721e70d51cb3c18f556d71f99861;hp=66e6c90182cdfef57bc2ccec12ec55c3caa0b43d;hpb=052d42fd9eb8b7e59eff497da98e1f58cde413a4;p=ginac.git diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 66e6c901..725f28a2 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -124,15 +124,27 @@ void basic::archive(archive_node &n) const * @param level value that is used to identify the precedence or indentation * level for placing parentheses and formatting */ void basic::print(const print_context & c, unsigned level) const +{ + print_dispatch(get_class_info(), c, level); +} + +/** Like print(), but dispatch to the specified class. Can be used by + * implementations of print methods to dispatch to the method of the + * superclass. + * + * @see basic::print */ +void basic::print_dispatch(const registered_class_info & ri, const print_context & c, unsigned level) const { // Double dispatch on object type and print_context type - const registered_class_info * reg_info = &get_class_info(); + const registered_class_info * reg_info = &ri; const print_context_class_info * pc_info = &c.get_class_info(); next_class: +std::clog << "searching class " << reg_info->options.get_name() << std::endl; const std::vector & pdt = reg_info->options.get_print_dispatch_table(); next_context: +std::clog << "searching context " << pc_info->options.get_name() << ", ID " << pc_info->options.get_id() << std::endl; unsigned id = pc_info->options.get_id(); if (id >= pdt.size() || !(pdt[id].is_valid())) { @@ -161,6 +173,8 @@ next_context: } else { // Call method +std::clog << "method found, calling" << std::endl; +std::clog << " this = " << class_name() << ", context = " << c.class_name() << std::endl; pdt[id](*this, c, level); } }