1 /** @file structure.cpp
3 * Implementation of 'abstract' class structure.
5 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 // default constructor, destructor, copy constructor assignment operator and helpers
32 structure::structure()
34 debugmsg("structure default constructor",LOGLEVEL_CONSTRUCT);
35 tinfo_key = TINFO_STRUCTURE;
38 structure::~structure()
40 debugmsg("structure destructor",LOGLEVEL_DESTRUCT);
44 structure::structure(structure const & other)
46 debugmsg("structure copy constructor",LOGLEVEL_CONSTRUCT);
50 structure const & structure::operator=(structure const & other)
52 debugmsg("structure operator=",LOGLEVEL_ASSIGNMENT);
62 void structure::copy(structure const & other)
67 void structure::destroy(bool call_parent)
69 if (call_parent) basic::destroy(call_parent);
79 // structures overriding virtual structures from bases classes
84 basic * structure::duplicate() const
86 debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
87 return new structure(*this);
90 void structure::printraw(ostream & os) const
92 debugmsg("structure printraw",LOGLEVEL_PRINT);
94 os << "structure(hash=" << hashvalue << ",flags=" << flags << ")";
97 void structure::print(ostream & os, unsigned upper_precedence) const
99 debugmsg("structure print",LOGLEVEL_PRINT);
104 void structure::printtree(ostream & os, unsigned indent) const
106 debugmsg("structure printtree",LOGLEVEL_PRINT);
108 os << string(indent,' ') << "structure "
109 << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
110 << ", flags=" << flags << endl;
113 void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
115 debugmsg("structure print csrc",LOGLEVEL_PRINT);
122 int structure::compare_same_type(basic const & other) const
124 ASSERT(is_of_type(other, structure));
125 return 0; // all structures are the same
128 bool structure::is_equal_same_type(basic const & other) const
130 ASSERT(is_of_type(other, structure));
131 return true; // all structures are the same
135 // new virtual structures which can be overridden by derived classes
141 // non-virtual structures in this class
146 vector<registered_structure_info> & structure::registered_structures(void)
148 static vector<registered_structure_info> * rs=new vector<registered_structure_info>;
154 unsigned structure::register_new(char const * nm)
156 registered_structure_info rsi={nm};
157 registered_structures().push_back(rsi);
158 return registered_structures().size()-1;
162 // static member variables
171 const structure some_structure;
172 type_info const & typeid_structure=typeid(some_structure);