X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;ds=sidebyside;f=ginac%2Fsymbol.cpp;h=4d73c9eb4328b1ed232a3c95e5f3bf6c9aaa37a3;hb=0289100f425e420da988a709cd52616b6d69d348;hp=a736088903872dd854dfe55c34020a08a6aed1ea;hpb=ee1ec9db30b446d2d6348df2ce758ed2ff62a310;p=ginac.git diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index a7360889..4d73c9eb 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symbolic objects. */ /* - * GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -109,6 +109,15 @@ void symbol::read_archive(const archive_node &n, lst &sym_lst) for (lst::const_iterator it = sym_lst.begin(); it != sym_lst.end(); ++it) { if (is_a(*it) && (ex_to(*it).name == tmp_name)) { *this = ex_to(*it); + // XXX: This method is responsible for reading realsymbol + // and possymbol objects too. But + // basic::operator=(const basic& other) + // resets status_flags::evaluated if other and *this are + // of different types. Usually this is a good idea, but + // doing this for symbols is wrong (for one, nothing is + // going to set status_flags::evaluated, evaluation will + // loop forever). Therefore we need to restore flags. + setflag(status_flags::evaluated | status_flags::expanded); return; } } @@ -141,12 +150,21 @@ static const std::string& get_default_TeX_name(const std::string& name); // public +std::string symbol::get_name() const +{ + if (name.empty()) { + std::ostringstream s; + s << "symbol" << serial; + name = s.str(); + } + return name; +} + +// protected + void symbol::do_print(const print_context & c, unsigned level) const { - if (!name.empty()) - c.s << name; - else - c.s << "symbol" << serial; + c.s << get_name(); } void symbol::do_print_latex(const print_latex & c, unsigned level) const