Changeset d9a0e76 for translator/SynTree/Initializer.h
- Timestamp:
- Dec 16, 2014, 9:41:50 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, string, with_gc
- Children:
- 17cd4eb
- Parents:
- 3848e0e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/SynTree/Initializer.h
r3848e0e rd9a0e76 1 /*2 * This file is part of the Cforall project3 *4 * $Id: Initializer.h,v 1.14 2005/08/29 20:59:25 rcbilson Exp $5 *6 */7 8 1 #ifndef INITIALIZER_H 9 2 #define INITIALIZER_H … … 17 10 18 11 // Initializer: base class for object initializers (provide default values) 19 class Initializer 20 { 21 public: 12 class Initializer { 13 public: 22 14 // Initializer( std::string _name = std::string(""), int _pos = 0 ); 23 15 Initializer( ); … … 41 33 virtual Initializer *acceptMutator( Mutator &m ) = 0; 42 34 virtual void print( std::ostream &os, int indent = 0 ); 43 44 private: 35 private: 45 36 // std::string name; 46 37 // int pos; … … 48 39 49 40 // SingleInit represents an initializer for a common object (e.g., int x = 4) 50 class SingleInit : public Initializer 51 { 52 public: 41 class SingleInit : public Initializer { 42 public: 53 43 SingleInit( Expression *value, std::list< Expression *> &designators ); 54 44 SingleInit( const SingleInit &other ); … … 65 55 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 66 56 virtual void print( std::ostream &os, int indent = 0 ); 67 68 private: 57 private: 69 58 //Constant *value; 70 59 Expression *value; // has to be a compile-time constant … … 72 61 }; 73 62 74 // MemberInit represents an initializer for a member of an aggregate object 75 // (e.g., struct q { int a } x = { a: 4 } ) 76 class MemberInit : public Initializer 77 { 78 public: 63 // MemberInit represents an initializer for a member of an aggregate object (e.g., struct q { int a; } x = { a : 4 } ) 64 class MemberInit : public Initializer { 65 public: 79 66 MemberInit( Expression *value, std::string member = std::string("") ); 80 67 virtual ~MemberInit(); … … 89 76 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 90 77 virtual void print( std::ostream &os, int indent = 0 ); 91 92 private: 78 private: 93 79 std::string member; 94 80 Expression *value; 95 81 }; 96 82 97 // ElementInit represents an initializer of an element of an array 98 // (e.g., [10] int x = { [7]: 4 } 99 class ElementInit : public Initializer 100 { 101 public: 83 // ElementInit represents an initializer of an element of an array (e.g., [10] int x = { [7] : 4 } 84 class ElementInit : public Initializer { 85 public: 102 86 ElementInit( Expression *value ); 103 87 virtual ~ElementInit(); … … 112 96 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 113 97 virtual void print( std::ostream &os, int indent = 0 ); 114 115 private: 98 private: 116 99 int index; 117 100 Expression *value; 118 101 }; 119 102 120 // ListInit represents an initializer that is composed recursively of a list of initializers; this 121 // is used to initialize an array or aggregate 122 class ListInit : public Initializer 123 { 124 public: 103 // ListInit represents an initializer that is composed recursively of a list of initializers; this is used to initialize 104 // an array or aggregate 105 class ListInit : public Initializer { 106 public: 125 107 ListInit( std::list<Initializer*> &, 126 std::list<Expression *> &designators = *(new std::list<Expression *>()) );108 std::list<Expression *> &designators = *(new std::list<Expression *>()) ); 127 109 virtual ~ListInit(); 128 110 … … 139 121 virtual Initializer *acceptMutator( Mutator &m ) { return m.mutate( this ); } 140 122 virtual void print( std::ostream &os, int indent = 0 ); 141 142 private: 123 private: 143 124 std::list<Initializer*> initializers; // order *is* important 144 125 std::list<Expression *> designators; 145 126 }; 146 127 147 148 #endif /* #ifndef INITIALIZER_H */ 149 150 /* 151 Local Variables: 152 mode: c++ 153 End: 154 */ 128 #endif // INITIALIZER_H
Note: See TracChangeset
for help on using the changeset viewer.