Changeset e0115286 for src/AST/Init.hpp


Ignore:
Timestamp:
May 10, 2019, 3:00:41 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2a5e8a6
Parents:
1f93c2c
Message:

Fix a cyclic dependency with ptr and nodes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Init.hpp

    r1f93c2c re0115286  
    2828class Stmt;
    2929
    30 /// List of designator (NameExpr, VariableExpr, and ConstantExpr) expressions that specify an 
     30/// List of designator (NameExpr, VariableExpr, and ConstantExpr) expressions that specify an
    3131/// object being initialized
    3232class Designation final : public ParseNode {
     
    3434        std::vector<ptr<Expr>> designators;
    3535
    36         Designation( const CodeLocation& loc, std::vector<ptr<Expr>>&& ds = {} ) 
     36        Designation( const CodeLocation& loc, std::vector<ptr<Expr>>&& ds = {} )
    3737        : ParseNode( loc ), designators( std::move(ds) ) {}
    3838
     
    6060        ptr<Expr> value;
    6161
    62         SingleInit( const CodeLocation& loc, Expr* val, bool mc = false ) 
     62        SingleInit( const CodeLocation& loc, Expr* val, bool mc = false )
    6363        : Init( loc, mc ), value( val ) {}
    6464
     
    7777        std::vector<ptr<Designation>> designations;
    7878
    79         ListInit( const CodeLocation& loc, std::vector<ptr<Init>>&& is, 
     79        ListInit( const CodeLocation& loc, std::vector<ptr<Init>>&& is,
    8080                std::vector<ptr<Designation>>&& ds = {}, bool mc = false );
    81        
     81
    8282        using iterator = std::vector<ptr<Init>>::iterator;
    8383        using const_iterator = std::vector<ptr<Init>>::const_iterator;
     
    9393
    9494/// Either a constructor expression or a C-style initializer.
    95 /// Should not be necessary to create manually; instead set `maybeConstructed` true on `SingleInit` 
     95/// Should not be necessary to create manually; instead set `maybeConstructed` true on `SingleInit`
    9696/// or `ListInit` if the object should be constructed.
    9797class ConstructorInit final : public Init {
     
    9999        ptr<Stmt> ctor;
    100100        ptr<Stmt> dtor;
    101         /// C-style initializer made up of SingleInit/ListInit nodes to use as a fallback if an 
     101        /// C-style initializer made up of SingleInit/ListInit nodes to use as a fallback if an
    102102        /// appropriate constructor definition is not found by the resolver.
    103103        ptr<Init> init;
     
    111111};
    112112
     113
     114//=================================================================================================
     115/// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
     116/// remove only if there is a better solution
     117/// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
     118/// forward declarations
     119inline void increment( const class Init * node, Node::ref_type ref ) { node->increment( ref ); }
     120inline void decrement( const class Init * node, Node::ref_type ref ) { node->decrement( ref ); }
     121inline void increment( const class SingleInit * node, Node::ref_type ref ) { node->increment( ref ); }
     122inline void decrement( const class SingleInit * node, Node::ref_type ref ) { node->decrement( ref ); }
     123inline void increment( const class ListInit * node, Node::ref_type ref ) { node->increment( ref ); }
     124inline void decrement( const class ListInit * node, Node::ref_type ref ) { node->decrement( ref ); }
     125inline void increment( const class ConstructorInit * node, Node::ref_type ref ) { node->increment( ref ); }
     126inline void decrement( const class ConstructorInit * node, Node::ref_type ref ) { node->decrement( ref ); }
    113127}
    114128
Note: See TracChangeset for help on using the changeset viewer.