Ignore:
Timestamp:
Nov 17, 2023, 3:03:51 PM (8 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
f7f997a
Parents:
41606df1
Message:

Most of ResolvExpr? was written before the new style standard. Some files updated, focus on headers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CurrentObject.h

    r41606df1 r2908f08  
    1717
    1818#include <deque>
    19 #include <list>   // for list
    2019#include <memory> // for unique_ptr
    21 #include <stack>  // for stack
    2220#include <vector>
    2321
     
    2523#include "Common/CodeLocation.h"
    2624
     25namespace ast {
     26
     27// AST class types:
    2728class Designation;
    2829class Type;
    2930struct InitAlternative;
    3031
    31 namespace ResolvExpr {
    32         class MemberIterator;
     32/// Iterates members of a type by initializer
     33class MemberIterator;
    3334
    34         // TODO: memory management of MemberIterators
    35         class CurrentObject {
    36         public:
    37                 CurrentObject();
    38                 CurrentObject( Type * type );
     35/// Builds initializer lists in resolution
     36class CurrentObject final {
     37        std::vector<std::shared_ptr<MemberIterator>> objStack;
    3938
    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();
     39public:
     40        CurrentObject() = default;
     41        CurrentObject( const CodeLocation & loc, const Type * type );
    5442
    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};
    5959
    60 namespace ast {
    61         // AST class types
    62         class Designation;
    63         struct InitAlternative;
    64         class Type;
    65 
    66         /// Iterates members of a type by initializer
    67         class MemberIterator;
    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;
    75                 CurrentObject( const CodeLocation & loc, const Type * type );
    76 
    77                 /// resolves unresolved designation
    78                 const Designation * findNext( const Designation * designation );
    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();
    87                 /// produces a list of alternatives (Type *, Designation *) for the current sub-object's
    88                 /// initializer.
    89                 std::deque< InitAlternative > getOptions();
    90                 /// produces the type of the current object but no subobjects
    91                 const Type * getCurrentType();
    92         };
    9360} // namespace ast
    9461
Note: See TracChangeset for help on using the changeset viewer.