Changeset 2908f08 for src/ResolvExpr/CurrentObject.h
- Timestamp:
- Nov 17, 2023, 3:03:51 PM (8 months ago)
- Branches:
- master
- Children:
- f7f997a
- Parents:
- 41606df1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CurrentObject.h
r41606df1 r2908f08 17 17 18 18 #include <deque> 19 #include <list> // for list20 19 #include <memory> // for unique_ptr 21 #include <stack> // for stack22 20 #include <vector> 23 21 … … 25 23 #include "Common/CodeLocation.h" 26 24 25 namespace ast { 26 27 // AST class types: 27 28 class Designation; 28 29 class Type; 29 30 struct InitAlternative; 30 31 31 namespace ResolvExpr { 32 32 /// Iterates members of a type by initializer 33 class MemberIterator; 33 34 34 // TODO: memory management of MemberIterators 35 class CurrentObject { 36 public: 37 CurrentObject(); 38 CurrentObject( Type * type ); 35 /// Builds initializer lists in resolution 36 class CurrentObject final { 37 std::vector<std::shared_ptr<MemberIterator>> objStack; 39 38 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(); 52 /// produces the type of the current object but no subobjects 53 Type * getCurrentType(); 39 public: 40 CurrentObject() = default; 41 CurrentObject( const CodeLocation & loc, const Type * type ); 54 42 55 private: 56 std::stack< MemberIterator * > objStack; 57 }; 58 } // namespace ResolvExpr 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 59 60 namespace ast {61 // AST class types62 class Designation;63 struct InitAlternative;64 class Type;65 66 /// Iterates members of a type by initializer67 class MemberIterator;68 69 /// Builds initializer lists in resolution70 class CurrentObject final {71 std::vector< std::shared_ptr<MemberIterator> > objStack;72 73 public:74 CurrentObject() = default;75 CurrentObject( const CodeLocation & loc, const Type * type );76 77 /// resolves unresolved designation78 const Designation * findNext( const Designation * designation );79 /// sets current position using the resolved designation80 void setNext( const ast::Designation * designation );81 /// steps to next sub-object of current object82 void increment();83 /// sets new current object for the duration of this brace-enclosed intializer-list84 void enterListInit( const CodeLocation & loc );85 /// restores previous current object86 void exitListInit();87 /// produces a list of alternatives (Type *, Designation *) for the current sub-object's88 /// initializer.89 std::deque< InitAlternative > getOptions();90 /// produces the type of the current object but no subobjects91 const Type * getCurrentType();92 };93 60 } // namespace ast 94 61
Note: See TracChangeset
for help on using the changeset viewer.