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 | // CurrentObject.hpp -- |
---|
8 | // |
---|
9 | // Author : Rob Schluntz |
---|
10 | // Created On : Thu Jun 8 11:07:25 2017 |
---|
11 | // Last Modified By : Andrew Beach |
---|
12 | // Last Modified On : Thu Apr 6 16:14:00 2023 |
---|
13 | // Update Count : 4 |
---|
14 | // |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | #include <deque> |
---|
19 | #include <memory> // for unique_ptr |
---|
20 | #include <vector> |
---|
21 | |
---|
22 | #include "AST/Node.hpp" // for ptr |
---|
23 | #include "Common/CodeLocation.hpp" |
---|
24 | |
---|
25 | namespace ast { |
---|
26 | |
---|
27 | // AST class types: |
---|
28 | class Designation; |
---|
29 | class Type; |
---|
30 | struct InitAlternative; |
---|
31 | |
---|
32 | /// Iterates members of a type by initializer |
---|
33 | class MemberIterator; |
---|
34 | |
---|
35 | /// Builds initializer lists in resolution |
---|
36 | class CurrentObject final { |
---|
37 | std::vector<std::shared_ptr<MemberIterator>> objStack; |
---|
38 | |
---|
39 | public: |
---|
40 | CurrentObject() = default; |
---|
41 | CurrentObject( const CodeLocation & loc, const Type * type ); |
---|
42 | |
---|
43 | /// Resolves unresolved designation. |
---|
44 | const Designation * findNext( const Designation * designation ); |
---|
45 | /// Sets current position using the resolved designation. |
---|
46 | void setNext( const Designation * designation ); |
---|
47 | /// Steps to next sub-object of current object. |
---|
48 | void increment(); |
---|
49 | /// Sets new current object for the duration of this brace-enclosed intializer-list. |
---|
50 | void enterListInit( const CodeLocation & loc ); |
---|
51 | /// Restores previous current object. |
---|
52 | void exitListInit(); |
---|
53 | /// Produces a list of alternatives (Type *, Designation *) |
---|
54 | /// for the current sub-object's initializer. |
---|
55 | std::deque< InitAlternative > getOptions(); |
---|
56 | /// Produces the type of the current object but no subobjects. |
---|
57 | const Type * getCurrentType(); |
---|
58 | }; |
---|
59 | |
---|
60 | } // namespace ast |
---|
61 | |
---|
62 | // Local Variables: // |
---|
63 | // tab-width: 4 // |
---|
64 | // mode: c++ // |
---|
65 | // compile-command: "make install" // |
---|
66 | // End: // |
---|
67 | |
---|