]> www.ginac.de Git - ginac.git/blobdiff - ginac/wildcard.cpp
* Added output-support for Python bindings and LaTeX printing for
[ginac.git] / ginac / wildcard.cpp
index 528df593f0bbb5528499a28715fc4f669b053aa9..10aa7e40ac8c9007e0916615e74118720c2650d2 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <iostream>
+
 #include "wildcard.h"
 #include "print.h"
 #include "archive.h"
 #include "utils.h"
-#include "debugmsg.h"
 
 namespace GiNaC {
 
 GINAC_IMPLEMENT_REGISTERED_CLASS(wildcard, basic)
 
 //////////
-// default constructor, destructor, copy constructor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
 //////////
 
 wildcard::wildcard() : label(0)
 {
-       debugmsg("wildcard default constructor", LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_wildcard;
 }
 
@@ -54,7 +54,6 @@ DEFAULT_DESTROY(wildcard)
 
 wildcard::wildcard(unsigned l) : label(l)
 {
-       debugmsg("wildcard constructor from unsigned", LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_wildcard;
 }
 
@@ -64,7 +63,6 @@ wildcard::wildcard(unsigned l) : label(l)
 
 wildcard::wildcard(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
-       debugmsg("wildcard constructor from archive_node", LOGLEVEL_CONSTRUCT);
        n.find_unsigned("label", label);
 }
 
@@ -77,12 +75,12 @@ void wildcard::archive(archive_node &n) const
 DEFAULT_UNARCHIVE(wildcard)
 
 //////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
 //////////
 
 int wildcard::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, wildcard));
+       GINAC_ASSERT(is_a<wildcard>(other));
        const wildcard &o = static_cast<const wildcard &>(other);
 
        if (label == o.label)
@@ -91,14 +89,14 @@ int wildcard::compare_same_type(const basic & other) const
                return label < o.label ? -1 : 1;
 }
 
-void wildcard::print(const print_context & c, unsigned level = 0) const
+void wildcard::print(const print_context & c, unsigned level) const
 {
-       debugmsg("wildcard print", LOGLEVEL_PRINT);
-
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
                c.s << std::string(level, ' ') << class_name() << " (" << label << ")"
                    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
                    << std::endl;
+       } else if (is_a<print_python_repr>(c)) {
+               c.s << class_name() << '(' << label << ')';
        } else
                c.s << "$" << label;
 }
@@ -115,10 +113,10 @@ unsigned wildcard::calchash(void) const
 
 bool wildcard::match(const ex & pattern, lst & repl_lst) const
 {
-       // Wildcards must match exactly (this is required for subs() to work
-       // properly because in the final step it substitutes all wildcards by
-       // their matching expressions)
-       return is_equal(*pattern.bp);
+       // Wildcards must match each other exactly (this is required for
+       // subs() to work properly because in the final step it substitutes
+       // all wildcards by their matching expressions)
+       return is_equal(ex_to<basic>(pattern));
 }
 
 } // namespace GiNaC