source: src/Parser/TypedefTable.h @ 03321e4

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 03321e4 was 6b0b624, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

change #ifndef to #pragma once

  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[b87a5ed]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           : Rodolfo G. Esteves
10// Created On       : Sat May 16 15:24:36 2015
11// Last Modified By : Peter A. Buhr
[6b0b624]12// Last Modified On : Sat Jul 22 09:33:14 2017
13// Update Count     : 34
[b87a5ed]14//
15
[6b0b624]16#pragma once
[51b7345]17
18#include <map>
19#include <list>
20#include <string>
21#include <stack>
22
[44f44617]23#include "ParserTypes.h"
[a67b60e]24#include "parser.hh"
[984dce6]25
[c8ffe20b]26class TypedefTable {
[51b7345]27  public:
[984dce6]28        enum kind_t { ID = IDENTIFIER, TD = TYPEDEFname, TG = TYPEGENname };
[51b7345]29  private:
[b87a5ed]30        struct Entry {
31                int scope;
32                kind_t kind;
33        };
34       
35        struct DeferredEntry {
36                std::string identifier;
37                kind_t kind;
38        };
[51b7345]39
[7880579]40        typedef std::map< std::string, std::list< Entry > > tableType;
[b87a5ed]41        tableType table;
[51b7345]42
[b87a5ed]43        int currentScope;
[4040425]44        std::string currentTrait;
[b87a5ed]45        int contextScope;
46       
47        typedef std::list< DeferredEntry > deferListType;
48        std::stack< deferListType > deferListStack;
49        std::map< std::string, deferListType > contexts;
50       
51        std::stack< std::string > nextIdentifiers;
[51b7345]52
[b87a5ed]53        void addToScope( const std::string &identifier, kind_t kind, int scope );
[51b7345]54  public:
[b87a5ed]55        TypedefTable();
[51b7345]56
[984dce6]57        bool exists( const std::string &identifier );
58        int isKind( const std::string &identifier ) const;
[721f17a]59        void changeKind( const std::string &identifier, kind_t kind );
[45161b4d]60
61        void makeTypedef( const std::string &name );
62
[de62360d]63        // "addToCurrentScope" adds the identifier/type pair to the current scope. This does less than you think it does,
[b87a5ed]64        // since each declaration is within its own scope.  Mostly useful for type parameters.
65        void addToCurrentScope( const std::string &identifier, kind_t kind );
[721f17a]66        void addToCurrentScope( kind_t kind );                  // use nextIdentifiers.top()
[51b7345]67
[b87a5ed]68        // "addToEnclosingScope" adds the identifier/type pair to the scope that encloses the current one.  This is the
69        // right way to handle type and typedef names
70        void addToEnclosingScope( const std::string &identifier, kind_t kind );
71        void addToEnclosingScope( kind_t kind );                // use nextIdentifiers.top()
72       
73        // "addToEnclosingScope2" adds the identifier/type pair to the scope that encloses the scope enclosing the the
74        // current one.  This is the right way to handle assertion names
75        void addToEnclosingScope2( const std::string &identifier, kind_t kind );
76        void addToEnclosingScope2( kind_t kind );               // use nextIdentifiers.top()
77       
78        // set the next identifier to be used by an "add" operation without an identifier parameter within the current scope
79        void setNextIdentifier( const std::string &identifier );
80       
81        // dump the definitions from a pre-defined context into the current scope
[4040425]82        void openTrait( const std::string &contextName );
[b87a5ed]83       
84        void enterScope();
85        void leaveScope();
[4040425]86        void enterTrait( const std::string &contextName );
87        void leaveTrait();
[51b7345]88
[b87a5ed]89        void print() const;
[51b7345]90};
91
[b87a5ed]92// Local Variables: //
93// tab-width: 4 //
94// mode: c++ //
95// compile-command: "make install" //
96// End: //
Note: See TracBrowser for help on using the repository browser.