Changes in src/SynTree/Initializer.h [f1b1e4c:05d47278]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Initializer.h
rf1b1e4c r05d47278 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Initializer.h -- 7 // Initializer.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Apr 12 13:49:13 201613 // Update Count : 1 911 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 18 09:03:48 2015 13 // Update Count : 1 14 14 // 15 15 … … 20 20 #include "Visitor.h" 21 21 #include "Mutator.h" 22 #include "Type.h"23 22 24 23 #include <cassert> … … 28 27 public: 29 28 // Initializer( std::string _name = std::string(""), int _pos = 0 ); 30 Initializer( bool maybeConstructed ); 31 Initializer( const Initializer & other ); 29 Initializer( ); 32 30 virtual ~Initializer(); 33 31 … … 45 43 } 46 44 47 bool get_maybeConstructed() { return maybeConstructed; }48 49 45 virtual Initializer *clone() const = 0; 50 46 virtual void accept( Visitor &v ) = 0; … … 54 50 // std::string name; 55 51 // int pos; 56 bool maybeConstructed;57 52 }; 58 53 … … 60 55 class SingleInit : public Initializer { 61 56 public: 62 SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false);57 SingleInit( Expression *value, std::list< Expression *> &designators = *(new std::list<Expression *>()) ); 63 58 SingleInit( const SingleInit &other ); 64 59 virtual ~SingleInit(); 65 60 66 61 Expression *get_value() { return value; } 67 62 void set_value( Expression *newValue ) { value = newValue; } … … 70 65 std::list<Expression *> &get_designators() { return designators; } 71 66 72 virtual SingleInit *clone() const { return new SingleInit( *this); }67 virtual SingleInit *clone() const; 73 68 virtual void accept( Visitor &v ) { v.visit( this ); } 74 69 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 84 79 class ListInit : public Initializer { 85 80 public: 86 ListInit( const std::list<Initializer*> &initializers,87 const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false);81 ListInit( std::list<Initializer*> &, 82 std::list<Expression *> &designators = *(new std::list<Expression *>()) ); 88 83 virtual ~ListInit(); 89 84 … … 96 91 std::list<Initializer*>::iterator end_initializers() { return initializers.end(); } 97 92 98 virtual ListInit *clone() const { return new ListInit( *this ); }93 virtual ListInit *clone() const; 99 94 virtual void accept( Visitor &v ) { v.visit( this ); } 100 95 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 105 100 }; 106 101 107 // ConstructorInit represents an initializer that is either a constructor expression or108 // a C-style initializer.109 class ConstructorInit : public Initializer {110 public:111 ConstructorInit( Statement * ctor, Statement * dtor, Initializer * init );112 ConstructorInit( const ConstructorInit &other );113 virtual ~ConstructorInit();114 115 void set_ctor( Statement * newValue ) { ctor = newValue; }116 Statement * get_ctor() const { return ctor; }117 void set_dtor( Statement * newValue ) { dtor = newValue; }118 Statement * get_dtor() const { return dtor; }119 void set_init( Initializer * newValue ) { init = newValue; }120 Initializer * get_init() const { return init; }121 122 ConstructorInit *clone() const { return new ConstructorInit( *this ); }123 virtual void accept( Visitor &v ) { v.visit( this ); }124 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); }125 virtual void print( std::ostream &os, int indent = 0 );126 127 private:128 Statement * ctor;129 Statement * dtor;130 // C-style initializer made up of SingleInit and ListInit nodes to use as a fallback131 // if an appropriate constructor definition is not found by the resolver132 Initializer * init;133 };134 135 std::ostream & operator<<( std::ostream & out, Initializer * init );136 137 102 #endif // INITIALIZER_H 138 103
Note:
See TracChangeset
for help on using the changeset viewer.