source: src/ResolvExpr/CurrentObject.h @ 45a091b

Last change on this file since 45a091b was 485393c, checked in by Andrew Beach <ajbeach@…>, 21 months ago

Moved code out of the CurrentObject? header.

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[e4d829b]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.h --
8//
9// Author           : Rob Schluntz
10// Created On       : Thu Jun  8 11:07:25 2017
[485393c]11// Last Modified By : Andrew Beach
12// Last Modified On : Thu Apr  6 16:14:00 2023
13// Update Count     : 4
[e4d829b]14//
15
[6b0b624]16#pragma once
[e4d829b]17
[60aaa51d]18#include <deque>
[ea6332d]19#include <list>   // for list
[b7d92b96]20#include <memory> // for unique_ptr
[ea6332d]21#include <stack>  // for stack
[b7d92b96]22#include <vector>
[e4d829b]23
[60aaa51d]24#include "AST/Node.hpp"  // for ptr
[2b59f55]25#include "Common/CodeLocation.h"
26
[ea6332d]27class Designation;
28class Type;
29struct InitAlternative;
[e4d829b]30
31namespace ResolvExpr {
32        class MemberIterator;
33
[f7cb0bc]34        // TODO: memory management of MemberIterators
[e4d829b]35        class CurrentObject {
36        public:
37                CurrentObject();
38                CurrentObject( Type * type );
39
40                /// resolves unresolved designation
41                Designation * findNext( Designation * designation );
42                /// sets current position using resolved designation
43                void setNext( Designation * designation );
44                /// steps to next sub-object of current-object
45                void increment();
46                /// sets new current-object for the duration of this brace-enclosed initializer-list
47                void enterListInit();
48                /// restores previous current-object
49                void exitListInit();
50                /// produces a list of alternatives (Type *, Designation *) for the current sub-object's initializer
51                std::list< InitAlternative > getOptions();
[62423350]52                /// produces the type of the current object but no subobjects
53                Type * getCurrentType();
[e4d829b]54
55        private:
56                std::stack< MemberIterator * > objStack;
57        };
58} // namespace ResolvExpr
59
[b7d92b96]60namespace ast {
61        // AST class types
62        class Designation;
[60aaa51d]63        struct InitAlternative;
[b7d92b96]64        class Type;
65
[60aaa51d]66        /// Iterates members of a type by initializer
[485393c]67        class MemberIterator;
[b7d92b96]68
69        /// Builds initializer lists in resolution
70        class CurrentObject final {
71                std::vector< std::shared_ptr<MemberIterator> > objStack;
72       
73        public:
74                CurrentObject() = default;
[2b59f55]75                CurrentObject( const CodeLocation & loc, const Type * type );
76
[2d11663]77                /// resolves unresolved designation
78                const Designation * findNext( const Designation * designation );
[60aaa51d]79                /// sets current position using the resolved designation
80                void setNext( const ast::Designation * designation );
81                /// steps to next sub-object of current object
82                void increment();
83                /// sets new current object for the duration of this brace-enclosed intializer-list
84                void enterListInit( const CodeLocation & loc );
85                /// restores previous current object
86                void exitListInit();
[2b59f55]87                /// produces a list of alternatives (Type *, Designation *) for the current sub-object's
88                /// initializer.
[60aaa51d]89                std::deque< InitAlternative > getOptions();
90                /// produces the type of the current object but no subobjects
91                const Type * getCurrentType();
[b7d92b96]92        };
93} // namespace ast
94
[e4d829b]95// Local Variables: //
96// tab-width: 4 //
97// mode: c++ //
98// compile-command: "make install" //
99// End: //
100
Note: See TracBrowser for help on using the repository browser.