Changeset 07de76b for src/SynTree/TypeDecl.cc
- Timestamp:
- Dec 16, 2019, 2:30:41 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- bffcd66
- Parents:
- ab5c0008
- git-author:
- Peter A. Buhr <pabuhr@…> (12/16/19 14:23:00)
- git-committer:
- Peter A. Buhr <pabuhr@…> (12/16/19 14:30:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/TypeDecl.cc
rab5c0008 r07de76b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 17:56:30201913 // Update Count : 1012 // Last Modified On : Fri Dec 13 15:26:14 2019 13 // Update Count : 21 14 14 // 15 15 … … 18 18 19 19 #include "Common/utility.h" // for maybeClone 20 #include "Parser/ParseNode.h"21 20 #include "Declaration.h" // for TypeDecl, TypeDecl::Data, TypeDecl::Kind... 22 21 #include "Type.h" // for Type, Type::StorageClasses 23 22 24 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 ) { 25 24 } 26 25 27 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 ) ) { 28 27 } 29 28 30 29 TypeDecl::~TypeDecl() { 31 30 delete init; 32 31 } 33 32 34 33 const char * TypeDecl::typeString() const { 35 static const char * kindNames[] = { "sized object type", "sized function type", "sized tuple type" };36 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );37 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl'skind is out of bounds." );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." ); 38 37 return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0' 39 38 } 40 39 41 40 const char * TypeDecl::genTypeString() const { 42 static const char * kindNames[] = { "dtype", " ftype", "ttype" };43 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );44 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl'skind is out of bounds." );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." ); 45 44 return kindNames[ kind ]; 46 45 } 47 46 48 47 void TypeDecl::print( std::ostream &os, Indenter indent ) const { 49 50 51 52 53 } 48 NamedTypeDecl::print( os, indent ); 49 if ( init ) { 50 os << std::endl << indent << "with type initializer: "; 51 init->print( os, indent + 1 ); 52 } // if 54 53 } 55 54 56 57 55 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 58 56 return os << data.kind << ", " << data.isComplete; 59 57 } 60 58
Note: See TracChangeset
for help on using the changeset viewer.