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"
28 // default constructor, destructor, copy constructor assignment operator and helpers
33 structure::structure()
35 debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT);
36 tinfo_key = TINFO_structure;
39 structure::~structure()
41 debugmsg("structure destructor",LOGLEVEL_DESTRUCT);
45 structure::structure(structure const & other)
47 debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT);
51 structure const & structure::operator=(structure const & other)
53 debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT);
63 void structure::copy(structure const & other)
68 void structure::destroy(bool call_parent)
70 if (call_parent) basic::destroy(call_parent);
80 // structures overriding virtual structures from bases classes
85 basic * structure::duplicate() const
87 debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
88 return new structure(*this);
91 void structure::printraw(ostream & os) const
93 debugmsg("structure printraw",LOGLEVEL_PRINT);
95 os << "structure(hash=" << hashvalue << ",flags=" << flags << ")";
98 void structure::print(ostream & os, unsigned upper_precedence) const
100 debugmsg("structure print",LOGLEVEL_PRINT);
105 void structure::printtree(ostream & os, unsigned indent) const
107 debugmsg("structure printtree",LOGLEVEL_PRINT);
109 os << string(indent,' ') << "structure "
110 << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
111 << ", flags=" << flags << endl;
114 void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
116 debugmsg("structure print csrc",LOGLEVEL_PRINT);
123 int structure::compare_same_type(basic const & other) const
125 ASSERT(is_of_type(other, structure));
126 return 0; // all structures are the same
129 bool structure::is_equal_same_type(basic const & other) const
131 ASSERT(is_of_type(other, structure));
132 return true; // all structures are the same
136 // new virtual structures which can be overridden by derived classes
142 // non-virtual structures in this class
147 vector<registered_structure_info> & structure::registered_structures(void)
149 static vector<registered_structure_info> * rs=new vector<registered_structure_info>;
155 unsigned structure::register_new(char const * nm)
157 registered_structure_info rsi={nm};
158 registered_structures().push_back(rsi);
159 return registered_structures().size()-1;
163 // static member variables
172 const structure some_structure;
173 type_info const & typeid_structure=typeid(some_structure);