1 /** @file structure.cpp
3 * Implementation of 'abstract' class structure. */
6 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "structure.h"
31 // default constructor, destructor, copy constructor assignment operator and helpers
36 structure::structure()
38 debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT);
39 tinfo_key = TINFO_structure;
42 structure::~structure()
44 debugmsg("structure destructor",LOGLEVEL_DESTRUCT);
48 structure::structure(structure const & other)
50 debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT);
54 structure const & structure::operator=(structure const & other)
56 debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT);
66 void structure::copy(structure const & other)
71 void structure::destroy(bool call_parent)
73 if (call_parent) basic::destroy(call_parent);
83 // structures overriding virtual structures from bases classes
88 basic * structure::duplicate() const
90 debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
91 return new structure(*this);
94 void structure::printraw(ostream & os) const
96 debugmsg("structure printraw",LOGLEVEL_PRINT);
98 os << "structure(hash=" << hashvalue << ",flags=" << flags << ")";
101 void structure::print(ostream & os, unsigned upper_precedence) const
103 debugmsg("structure print",LOGLEVEL_PRINT);
108 void structure::printtree(ostream & os, unsigned indent) const
110 debugmsg("structure printtree",LOGLEVEL_PRINT);
112 os << string(indent,' ') << "structure "
113 << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
114 << ", flags=" << flags << endl;
117 void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
119 debugmsg("structure print csrc",LOGLEVEL_PRINT);
126 int structure::compare_same_type(basic const & other) const
128 ASSERT(is_of_type(other, structure));
129 return 0; // all structures are the same
132 bool structure::is_equal_same_type(basic const & other) const
134 ASSERT(is_of_type(other, structure));
135 return true; // all structures are the same
139 // new virtual structures which can be overridden by derived classes
145 // non-virtual structures in this class
150 vector<registered_structure_info> & structure::registered_structures(void)
152 static vector<registered_structure_info> * rs=new vector<registered_structure_info>;
158 unsigned structure::register_new(char const * nm)
160 registered_structure_info rsi={nm};
161 registered_structures().push_back(rsi);
162 return registered_structures().size()-1;
166 // static member variables
175 const structure some_structure;
176 type_info const & typeid_structure=typeid(some_structure);