00001 00002 #ifndef DECLARATION_CHAIN_HH 00003 #define DECLARATION_CHAIN_HH 00004 00005 // Copyright (c) 1995-2001 The University of Cincinnati. 00006 // All rights reserved. 00007 00008 // UC MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF 00009 // THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 00010 // TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 00011 // PARTICULAR PURPOSE, OR NON-INFRINGEMENT. UC SHALL NOT BE LIABLE 00012 // FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, 00013 // RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS 00014 // DERIVATIVES. 00015 00016 // By using or copying this Software, Licensee agrees to abide by the 00017 // intellectual property laws, and all other applicable laws of the 00018 // U.S., and the terms of this license. 00019 00020 // You may modify, distribute, and use the software contained in this package 00021 // under the terms of the "GNU LIBRARY GENERAL PUBLIC LICENSE" version 2, 00022 // June 1991. A copy of this license agreement can be found in the file 00023 // "LGPL", distributed with this archive. 00024 00025 // Author: Dale E. Martin dmartin@cliftonlabs.com 00026 00027 //--------------------------------------------------------------------------- 00028 00029 #include "IIR_Declaration.hh" 00030 #include "set.hh" 00031 #include "IIR_TextLiteral.hh" 00032 #include "IIRScram_Declaration.hh" 00033 00034 using namespace savant; 00035 00036 // This class encapsulates an entry of a single declaration in the symbol 00037 // table. If one symbol hides another when it's added, this information 00038 // necessarily needs to live in the symbol table and it's here that it's 00039 // kept. 00040 class hidden_symbol_entry{ 00041 public: 00042 hidden_symbol_entry( IIR_Declaration *init_declaration, 00043 savant::set<IIR_Declaration> *init_hidden ){ 00044 my_declaration = init_declaration; 00045 hidden_declarations = init_hidden; 00046 } 00047 00048 ~hidden_symbol_entry(){ delete hidden_declarations; } 00049 00050 IIR_Declaration *get_declaration(){ return my_declaration; } 00051 savant::set<IIR_Declaration> *get_hidden_declarations(){ return hidden_declarations; } 00052 00053 private: 00054 IIR_Declaration *my_declaration; 00055 savant::set<IIR_Declaration> *hidden_declarations; 00056 }; 00057 00058 class declaration_chain { 00059 00060 // This file holds the declaration of a class used in the symbol table 00061 // management for the savant project. This class encapsulates a string 00062 // with a list of pointers to declarations of "declarable things" of 00063 // VHDL. For instance, there might be a signal "x" and a variable "x" in 00064 // the same entity. In this case, the declaration_chain would have a 00065 // string "x" and a two elements. 00066 00067 // In addition, each declartion chain keeps a set of hidden declaration 00068 // information. The data in this set is somewhat redundant in that when 00069 // one declaration is hiding another there will be two pointers to a 00070 // single declaration in one chain. However, the most frequent operation 00071 // on the symbol lookup is to retrieve the set of declarations in a 00072 // chain, so we're going to live with a replicated pointer in order to 00073 // keep lookups speedy. 00074 00075 public: 00076 00077 IIR_TextLiteral *name; 00078 savant::set<IIR_Declaration> declarations; 00079 savant::set<hidden_symbol_entry> hidden_declaration_info; 00080 00081 declaration_chain() { 00082 // this is for safety's sake 00083 name = NULL; 00084 }; 00085 00086 ~declaration_chain() {}; 00087 00088 }; 00089 00090 inline ostream &operator<< (ostream &os, declaration_chain &dc) { 00091 00092 // os << "name: " << dc.name << " list_size: " 00093 // << dc.declaration_list.num_elements(); 00094 00095 os << "name: \"" << dc.name << "\""; 00096 00097 IIR_Declaration *current_declaration = dc.declarations.getElement(); 00098 00099 while( current_declaration != NULL ) { 00100 os << " " << *dynamic_cast<IIRScram_Declaration *>(current_declaration); 00101 current_declaration = dc.declarations.getNextElement(); 00102 } 00103 00104 return os; 00105 } 00106 #endif 00107
1.4.6