Changeset 67cf18c for src/SynTree
- Timestamp:
- May 26, 2017, 6:37:49 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 01b9928
- Parents:
- ff03f5c
- git-author:
- Rob Schluntz <rschlunt@…> (05/26/17 18:34:50)
- git-committer:
- Rob Schluntz <rschlunt@…> (05/26/17 18:37:49)
- Location:
- src/SynTree
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
rff03f5c r67cf18c 194 194 }; 195 195 196 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind );196 TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr ); 197 197 TypeDecl( const TypeDecl &other ); 198 virtual ~TypeDecl(); 198 199 199 200 Kind get_kind() const { return kind; } 201 202 Type * get_init() const { return init; } 203 TypeDecl * set_init( Type * newValue ) { init = newValue; return this; } 200 204 201 205 bool isComplete() const { return kind == Any || sized; } … … 209 213 virtual void accept( Visitor &v ) { v.visit( this ); } 210 214 virtual TypeDecl *acceptMutator( Mutator &m ) { return m.mutate( this ); } 215 virtual void print( std::ostream &os, int indent = 0 ) const; 216 211 217 private: 212 218 Kind kind; 219 Type * init; 213 220 bool sized; 214 221 }; -
src/SynTree/Mutator.cc
rff03f5c r67cf18c 77 77 TypeDecl *Mutator::mutate( TypeDecl *typeDecl ) { 78 78 handleNamedTypeDecl( typeDecl ); 79 typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) ); 79 80 return typeDecl; 80 81 } -
src/SynTree/TypeDecl.cc
rff03f5c r67cf18c 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind), sized( kind == Any || kind == Ttype ) {20 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), kind( kind ), init( init ), sized( kind == Any || kind == Ttype ) { 21 21 } 22 22 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), sized( other.sized ) { 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), init( maybeClone( other.init ) ), sized( other.sized ) { 24 } 25 26 TypeDecl::~TypeDecl() { 27 delete init; 24 28 } 25 29 … … 34 38 } 35 39 40 void TypeDecl::print( std::ostream &os, int indent ) const { 41 NamedTypeDecl::print( os, indent ); 42 if ( init ) { 43 os << std::endl << std::string( indent, ' ' ) << "with type initializer: "; 44 init->print( os, indent + 2 ); 45 } 46 } 47 48 36 49 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 37 50 return os << data.kind << ", " << data.isComplete; -
src/SynTree/Visitor.cc
rff03f5c r67cf18c 67 67 void Visitor::visit( TypeDecl *typeDecl ) { 68 68 handleNamedTypeDecl( static_cast< NamedTypeDecl* >( typeDecl ) ); 69 maybeAccept( typeDecl->get_init(), *this ); 69 70 } 70 71
Note: See TracChangeset
for help on using the changeset viewer.