source: src/Parser/TypedefTable.h@ d180746

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new stuck-waitfor-destruct with_gc
Last change on this file since d180746 was d180746, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Big header cleaning pass - commit 2

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