| 1 | //
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | //
 | 
|---|
| 7 | // TypedefTable.h --
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // Author           : Peter A. Buhr
 | 
|---|
| 10 | // Created On       : Sat May 16 15:24:36 2015
 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| 12 | // Last Modified On : Sat Feb 15 08:06:37 2020
 | 
|---|
| 13 | // Update Count     : 117
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #pragma once
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #include <string>                                                                               // for string
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "Common/ScopedMap.h"                                                   // for ScopedMap
 | 
|---|
| 21 | #include "ParserTypes.h"
 | 
|---|
| 22 | #include "parser.hh"                                                                    // for IDENTIFIER, TYPEDEFname, TYPEGENname
 | 
|---|
| 23 | 
 | 
|---|
| 24 | class TypedefTable {
 | 
|---|
| 25 |         struct Note { size_t level; bool forall; };
 | 
|---|
| 26 |         typedef ScopedMap< std::string, int, Note > KindTable;
 | 
|---|
| 27 |         KindTable kindTable;    
 | 
|---|
| 28 |         unsigned int level = 0;
 | 
|---|
| 29 |   public:
 | 
|---|
| 30 |         ~TypedefTable();
 | 
|---|
| 31 | 
 | 
|---|
| 32 |         bool exists( const std::string & identifier ) const;
 | 
|---|
| 33 |         bool existsCurr( const std::string & identifier ) const;
 | 
|---|
| 34 |         int isKind( const std::string & identifier ) const;
 | 
|---|
| 35 |         void makeTypedef( const std::string & name, int kind = TYPEDEFname );
 | 
|---|
| 36 |         void addToScope( const std::string & identifier, int kind, const char * );
 | 
|---|
| 37 |         void addToEnclosingScope( const std::string & identifier, int kind, const char * );
 | 
|---|
| 38 |         bool getEnclForall() { return kindTable.getNote( kindTable.currentScope() -  1 ).forall; }
 | 
|---|
| 39 | 
 | 
|---|
| 40 |         void enterScope();
 | 
|---|
| 41 |         void leaveScope();
 | 
|---|
| 42 | 
 | 
|---|
| 43 |         void up( bool );
 | 
|---|
| 44 |         void down();
 | 
|---|
| 45 | 
 | 
|---|
| 46 |         void print( void ) const;
 | 
|---|
| 47 | }; // TypedefTable
 | 
|---|
| 48 | 
 | 
|---|
| 49 | // Local Variables: //
 | 
|---|
| 50 | // tab-width: 4 //
 | 
|---|
| 51 | // mode: c++ //
 | 
|---|
| 52 | // compile-command: "make install" //
 | 
|---|
| 53 | // End: //
 | 
|---|