vrq
cattr.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (C) 1997-2007, Mark Hummel
3  * This file is part of Vrq.
4  *
5  * Vrq is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * Vrq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301 USA
19  *****************************************************************************
20  */
21 /******************************************************************************
22  *
23  *
24  * cattr.hpp
25  * - class definition of attribute
26  * definition nodes
27  *
28  ******************************************************************************
29  */
30 
31 #ifndef CATTR_HPP
32 #define CATTR_HPP
33 
34 #include <stdio.h>
35 #include <string>
36 #include <map>
37 #include "glue.h"
38 #include "cdecl.h"
39 
40 using namespace std;
41 
42 
43 class CNode;
44 
45 
50 class CAttr: public CDecl
51 {
52 private:
53  struct Entry {
54  string s;
55  CNode* exp;
56  };
57  vector<Entry> table;
58 public:
62  CAttr( Coord_t* aLoc );
68  virtual CDecl* Clone( CObstack* heap );
74  void AddAttribute( const char* name, CNode* aExp ) {
75  Entry entry;
76  entry.s = name;
77  entry.exp = aExp;
78  table.push_back( entry );
79  }
84  int GetAttributeCount() { return table.size(); }
90  const char* GetAttributeName( int index )
91  { return table[index].s.c_str(); }
97  CNode* GetAttributeExpression( int index ) { return table[index].exp; }
103  CNode* GetAttributeExpression( const char* name );
109  int HasAttribute( const char* name );
114  virtual void Dump( FILE* f );
115 private:
121  void Copy( CObstack* heap, CAttr& d );
122 private:
123  /*
124  * Disable copy constructor.
125  */
126  CAttr( const CAttr& );
127 };
128 
129 #endif // CATTR_HPP
const char * GetAttributeName(int index)
Get an attribute by index.
Definition: cattr.h:90
void AddAttribute(const char *name, CNode *aExp)
Add an attribute to list.
Definition: cattr.h:74
CNode * GetAttributeExpression(int index)
Get expression for attribute by index.
Definition: cattr.h:97
Structure to hold file coordinates.
Definition: cdecl.h:47
Bulk object allocation object.
Definition: cobstack.h:46
Primary data structure representing parse tree nodes.
Definition: cnode.h:188
int GetAttributeCount()
Get the number of attributes in list.
Definition: cattr.h:84
Base class for describing declaration objects.
Definition: cdecl.h:164
Declaration object for holding lists of verilog attributes and their corresponding expressions...
Definition: cattr.h:50