Changes in src/ResolvExpr/CurrentObject.h [2d11663:ea6332d]
- File:
-
- 1 edited
-
src/ResolvExpr/CurrentObject.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CurrentObject.h
r2d11663 rea6332d 16 16 #pragma once 17 17 18 #include <deque>19 18 #include <list> // for list 20 #include <memory> // for unique_ptr21 19 #include <stack> // for stack 22 #include <vector>23 24 #include "AST/Node.hpp" // for ptr25 #include "Common/CodeLocation.h"26 20 27 21 class Designation; … … 58 52 } // namespace ResolvExpr 59 53 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 public:69 virtual ~MemberIterator() {}70 71 /// Internal set position based on iterator ranges72 virtual void setPosition(73 std::deque< ptr< Expr > >::const_iterator it,74 std::deque< ptr< Expr > >::const_iterator end ) = 0;75 76 /// walks the current object using the given designators as a guide77 void setPosition( const std::deque< ptr< Expr > > & designators ) {78 setPosition( designators.begin(), designators.end() );79 }80 81 /// retrieve the list of possible (Type,Designation) pairs for the current position in the82 /// current object83 virtual std::deque< InitAlternative > operator* () const = 0;84 85 /// true if the iterator is not currently at the end86 virtual operator bool() const = 0;87 88 /// moves the iterator by one member in the current object89 virtual MemberIterator & bigStep() = 0;90 91 /// moves the iterator by one member in the current subobject92 virtual MemberIterator & smallStep() = 0;93 94 /// the type of the current object95 virtual const Type * getType() = 0;96 97 /// the type of the current subobject98 virtual const Type * getNext() = 0;99 100 /// helper for operator*; aggregates must add designator to each init alternative, but101 /// adding designators in operator* creates duplicates102 virtual std::deque< InitAlternative > first() const = 0;103 };104 105 /// Builds initializer lists in resolution106 class CurrentObject final {107 std::vector< std::shared_ptr<MemberIterator> > objStack;108 109 public:110 CurrentObject() = default;111 CurrentObject( const CodeLocation & loc, const Type * type );112 113 /// resolves unresolved designation114 const Designation * findNext( const Designation * designation );115 /// sets current position using the resolved designation116 void setNext( const ast::Designation * designation );117 /// steps to next sub-object of current object118 void increment();119 /// sets new current object for the duration of this brace-enclosed intializer-list120 void enterListInit( const CodeLocation & loc );121 /// restores previous current object122 void exitListInit();123 /// produces a list of alternatives (Type *, Designation *) for the current sub-object's124 /// initializer.125 std::deque< InitAlternative > getOptions();126 /// produces the type of the current object but no subobjects127 const Type * getCurrentType();128 };129 } // namespace ast130 131 54 // Local Variables: // 132 55 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.