- debugmsg("function printtree",LOGLEVEL_PRINT);
-
- GINAC_ASSERT(serial<registered_functions().size());
-
- os << string(indent,' ') << "function "
- << registered_functions()[serial].name
- << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
- << ", flags=" << flags
- << ", nops=" << nops() << endl;
- for (unsigned i=0; i<nops(); ++i) {
- seq[i].printtree(os,indent+delta_indent);
- }
- os << string(indent+delta_indent,' ') << "=====" << endl;
-}
-
-void function::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
-{
- debugmsg("function print csrc",LOGLEVEL_PRINT);
-
- GINAC_ASSERT(serial<registered_functions().size());
-
- // Print function name in lowercase
- string lname;
- lname=registered_functions()[serial].name;
- for (unsigned i=0; i<lname.size(); i++)
- lname[i] = tolower(lname[i]);
- os << lname << "(";
-
- // Print arguments, separated by commas
- exvector::const_iterator it = seq.begin();
- exvector::const_iterator itend = seq.end();
- while (it != itend) {
- it->bp->printcsrc(os, type, 0);
- it++;
- if (it != itend)
- os << ",";
- }
- os << ")";
+ GINAC_ASSERT(serial<registered_functions().size());
+
+ if (is_a<print_tree>(c)) {
+
+ c.s << std::string(level, ' ') << class_name() << " "
+ << registered_functions()[serial].name
+ << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
+ << ", nops=" << nops()
+ << std::endl;
+ unsigned delta_indent = static_cast<const print_tree &>(c).delta_indent;
+ for (size_t i=0; i<seq.size(); ++i)
+ seq[i].print(c, level + delta_indent);
+ c.s << std::string(level + delta_indent, ' ') << "=====" << std::endl;
+
+ } else if (is_a<print_csrc>(c)) {
+
+ // Print function name in lowercase
+ std::string lname = registered_functions()[serial].name;
+ size_t num = lname.size();
+ for (size_t i=0; i<num; i++)
+ lname[i] = tolower(lname[i]);
+ c.s << lname << "(";
+
+ // Print arguments, separated by commas
+ exvector::const_iterator it = seq.begin(), itend = seq.end();
+ while (it != itend) {
+ it->print(c);
+ ++it;
+ if (it != itend)
+ c.s << ",";
+ }
+ c.s << ")";
+
+ } else if (is_a<print_latex>(c)) {
+ c.s << registered_functions()[serial].TeX_name;
+ printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence());
+ } else {
+ c.s << registered_functions()[serial].name;
+ printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence());
+ }