]> www.ginac.de Git - ginac.git/blobdiff - ginac/basic.cpp
Removed debugging code.
[ginac.git] / ginac / basic.cpp
index 483844c0ee0a81bd66b2e5bb03a2d29b23620179..01a29011152a9c9ff7b58620e7a0da71c7561d75 100644 (file)
@@ -55,7 +55,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(basic, void,
 /** basic copy constructor: implicitly assumes that the other class is of
  *  the exact same type (as it's used by duplicate()), so it can copy the
  *  tinfo_key and the hash value. */
-basic::basic(const basic & other) : tinfo_key(other.tinfo_key), flags(other.flags & ~status_flags::dynallocated), hashvalue(other.hashvalue), refcount(0)
+basic::basic(const basic & other) : tinfo_key(other.tinfo_key), flags(other.flags & ~status_flags::dynallocated), hashvalue(other.hashvalue)
 {
        GINAC_ASSERT(typeid(*this) == typeid(other));
 }
@@ -68,13 +68,13 @@ const basic & basic::operator=(const basic & other)
                // The other object is of a derived class, so clear the flags as they
                // might no longer apply (especially hash_calculated). Oh, and don't
                // copy the tinfo_key: it is already set correctly for this object.
-               flags = 0;
+               fl &= ~(status_flags::evaluated | status_flags::expanded | status_flags::hash_calculated);
        } else {
                // The objects are of the exact same class, so copy the hash value.
                hashvalue = other.hashvalue;
        }
        flags = fl;
-       refcount = 0;
+       set_refcount(0);
        return *this;
 }
 
@@ -93,7 +93,7 @@ const basic & basic::operator=(const basic & other)
 //////////
 
 /** Construct object from archive_node. */
-basic::basic(const archive_node &n, lst &sym_lst) : flags(0), refcount(0)
+basic::basic(const archive_node &n, lst &sym_lst) : flags(0)
 {
        // Reconstruct tinfo_key from class name
        std::string class_name;
@@ -184,10 +184,11 @@ void basic::do_print(const print_context & c, unsigned level) const
 /** Tree output to stream. */
 void basic::do_print_tree(const print_tree & c, unsigned level) const
 {
-       c.s << std::string(level, ' ') << class_name()
-           << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
-           << ", nops=" << nops()
-           << std::endl;
+       c.s << std::string(level, ' ') << class_name() << " @" << this
+           << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec;
+       if (nops())
+               c.s << ", nops=" << nops();
+       c.s << std::endl;
        for (size_t i=0; i<nops(); ++i)
                op(i).print(c, level + c.delta_indent);
 }
@@ -865,7 +866,7 @@ const basic & basic::hold() const
  *  is not the case. */
 void basic::ensure_if_modifiable() const
 {
-       if (refcount > 1)
+       if (get_refcount() > 1)
                throw(std::runtime_error("cannot modify multiply referenced object"));
        clearflag(status_flags::hash_calculated | status_flags::evaluated);
 }