Changes in src/ResolvExpr/CurrentObject.cc [2b59f55:ba4a1d8]
- File:
-
- 1 edited
-
src/ResolvExpr/CurrentObject.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CurrentObject.cc
r2b59f55 rba4a1d8 20 20 #include <string> // for string, operator<<, allocator 21 21 22 #include "AST/Expr.hpp" // for InitAlternative23 #include "AST/Init.hpp" // for Designation24 #include "AST/Node.hpp" // for readonly25 22 #include "Common/Indenter.h" // for Indenter, operator<< 26 23 #include "Common/SemanticError.h" // for SemanticError … … 582 579 } // namespace ResolvExpr 583 580 584 namespace ast {585 586 /// Iterates members of a type by initializer587 class MemberIterator {588 public:589 virtual ~MemberIterator() {}590 591 /// retrieve the list of possible (Type,Designation) pairs for the current position in the592 /// current object593 virtual std::vector< InitAlternative > operator* () const = 0;594 595 protected:596 /// helper for operator*; aggregates must add designator to each init alternative, but597 /// adding designators in operator* creates duplicates598 virtual std::vector< InitAlternative > first() const = 0;599 };600 601 /// Iterates "other" types (e.g. basic, pointer) which do not change at list initializer entry602 class SimpleIterator final : public MemberIterator {603 CodeLocation location;604 readonly< Type > type = nullptr;605 public:606 SimpleIterator( const CodeLocation & loc, const Type * t ) : location( loc ), type( t ) {}607 608 std::vector< InitAlternative > operator* () const override { return first(); }609 610 protected:611 std::vector< InitAlternative > first() const override {612 if ( type ) return { InitAlternative{ type, new Designation{ location } } };613 return {};614 }615 };616 617 CurrentObject::CurrentObject( const CodeLocation & loc, const Type * type ) : objStack() {618 objStack.emplace_back( new SimpleIterator{ loc, type } );619 }620 621 std::vector< InitAlternative > CurrentObject::getOptions() {622 PRINT( std::cerr << "____getting current options" << std::endl; )623 assertf( ! objStack.empty(), "objstack empty in getOptions" );624 return **objStack.back();625 }626 }627 628 581 // Local Variables: // 629 582 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.