Changeset 7030dab for src/SynTree/TypeDecl.cc
- Timestamp:
- Apr 6, 2020, 4:46:28 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- e3bc51c
- Parents:
- 71d6bd8 (diff), 057298e (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
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/TypeDecl.cc
r71d6bd8 r7030dab 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 9 14:35:00 201713 // Update Count : 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 15:26:14 2019 13 // Update Count : 21 14 14 // 15 15 … … 21 21 #include "Type.h" // for Type, Type::StorageClasses 22 22 23 TypeDecl::TypeDecl( const std::string & name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind) {23 TypeDecl::TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), kind( kind ), sized( kind == Ttype || sized ), init( init ) { 24 24 } 25 25 26 TypeDecl::TypeDecl( const TypeDecl & other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind) {26 TypeDecl::TypeDecl( const TypeDecl & other ) : Parent( other ), kind( other.kind ), sized( other.sized ), init( maybeClone( other.init ) ) { 27 27 } 28 28 29 29 TypeDecl::~TypeDecl() { 30 30 delete init; 31 31 } 32 32 33 std::stringTypeDecl::typeString() const {34 static const std::string kindNames[] = { "object type", "function type", "tuple type" };35 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );36 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl'skind is out of bounds." );37 return (isComplete() ? "sized " : "") + kindNames[ kind ];33 const char * TypeDecl::typeString() const { 34 static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" }; 35 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." ); 36 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." ); 37 return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0' 38 38 } 39 39 40 std::stringTypeDecl::genTypeString() const {41 static const std::string kindNames[] = { "dtype", "ftype", "ttype" };42 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );43 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl'skind is out of bounds." );40 const char * TypeDecl::genTypeString() const { 41 static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" }; 42 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." ); 43 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." ); 44 44 return kindNames[ kind ]; 45 45 } 46 46 47 47 void TypeDecl::print( std::ostream &os, Indenter indent ) const { 48 49 50 51 52 } 48 NamedTypeDecl::print( os, indent ); 49 if ( init ) { 50 os << std::endl << indent << "with type initializer: "; 51 init->print( os, indent + 1 ); 52 } // if 53 53 } 54 54 55 56 55 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 57 56 return os << data.kind << ", " << data.isComplete; 58 57 } 59 58
Note:
See TracChangeset
for help on using the changeset viewer.