Changeset f80e0218 for src/SynTree/Initializer.h
- Timestamp:
- Jun 30, 2016, 4:32:56 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ea29e73
- Parents:
- 1b5c81ed (diff), 84d4d6f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/SynTree/Initializer.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Initializer.h
r1b5c81ed rf80e0218 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 : Peter A. Buhr12 // Last Modified On : Mon May 18 09:03:48 201513 // Update Count : 1 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Apr 12 13:49:13 2016 13 // Update Count : 19 14 14 // 15 15 … … 20 20 #include "Visitor.h" 21 21 #include "Mutator.h" 22 #include "Type.h" 22 23 23 24 #include <cassert> … … 27 28 public: 28 29 // Initializer( std::string _name = std::string(""), int _pos = 0 ); 29 Initializer( ); 30 Initializer( bool maybeConstructed ); 31 Initializer( const Initializer & other ); 30 32 virtual ~Initializer(); 31 33 … … 43 45 } 44 46 47 bool get_maybeConstructed() { return maybeConstructed; } 48 45 49 virtual Initializer *clone() const = 0; 46 50 virtual void accept( Visitor &v ) = 0; … … 50 54 // std::string name; 51 55 // int pos; 56 bool maybeConstructed; 52 57 }; 53 58 … … 55 60 class SingleInit : public Initializer { 56 61 public: 57 SingleInit( Expression *value, std::list< Expression *> &designators = *(new std::list<Expression *>()));62 SingleInit( Expression *value, const std::list< Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false ); 58 63 SingleInit( const SingleInit &other ); 59 64 virtual ~SingleInit(); 60 65 61 66 Expression *get_value() { return value; } 62 67 void set_value( Expression *newValue ) { value = newValue; } … … 65 70 std::list<Expression *> &get_designators() { return designators; } 66 71 67 virtual SingleInit *clone() const ;72 virtual SingleInit *clone() const { return new SingleInit( *this); } 68 73 virtual void accept( Visitor &v ) { v.visit( this ); } 69 74 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 79 84 class ListInit : public Initializer { 80 85 public: 81 ListInit( std::list<Initializer*> &,82 std::list<Expression *> &designators = *(new std::list<Expression *>()));86 ListInit( const std::list<Initializer*> &initializers, 87 const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false ); 83 88 virtual ~ListInit(); 84 89 … … 91 96 std::list<Initializer*>::iterator end_initializers() { return initializers.end(); } 92 97 93 virtual ListInit *clone() const ;98 virtual ListInit *clone() const { return new ListInit( *this ); } 94 99 virtual void accept( Visitor &v ) { v.visit( this ); } 95 100 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } … … 100 105 }; 101 106 107 // ConstructorInit represents an initializer that is either a constructor expression or 108 // 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 fallback 131 // if an appropriate constructor definition is not found by the resolver 132 Initializer * init; 133 }; 134 135 std::ostream & operator<<( std::ostream & out, Initializer * init ); 136 102 137 #endif // INITIALIZER_H 103 138
Note:
See TracChangeset
for help on using the changeset viewer.