Ignore:
Timestamp:
Dec 16, 2019, 2:30:41 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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)
Message:

remove file TypeVar?.h* and put TypeVar::Kind into TypeDecl?, move LinkageSpec?.* from directory Parse to SynTree?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/TypeDecl.cc

    rab5c0008 r07de76b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec 11 17:56:30 2019
    13 // Update Count     : 10
     12// Last Modified On : Fri Dec 13 15:26:14 2019
     13// Update Count     : 21
    1414//
    1515
     
    1818
    1919#include "Common/utility.h"  // for maybeClone
    20 #include "Parser/ParseNode.h"
    2120#include "Declaration.h"     // for TypeDecl, TypeDecl::Data, TypeDecl::Kind...
    2221#include "Type.h"            // for Type, Type::StorageClasses
    2322
    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 ) {
     23TypeDecl::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 ) {
    2524}
    2625
    27 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), init( maybeClone( other.init ) ), sized( other.sized ), kind( other.kind ) {
     26TypeDecl::TypeDecl( const TypeDecl & other ) : Parent( other ), kind( other.kind ), sized( other.sized ), init( maybeClone( other.init ) ) {
    2827}
    2928
    3029TypeDecl::~TypeDecl() {
    31   delete init;
     30        delete init;
    3231}
    3332
    3433const 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's kind 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." );
    3837        return isComplete() ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'
    3938}
    4039
    4140const 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's kind 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." );
    4544        return kindNames[ kind ];
    4645}
    4746
    4847void TypeDecl::print( std::ostream &os, Indenter indent ) const {
    49   NamedTypeDecl::print( os, indent );
    50   if ( init ) {
    51     os << std::endl << indent << "with type initializer: ";
    52     init->print( os, indent + 1 );
    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
    5453}
    5554
    56 
    5755std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) {
    58   return os << data.kind << ", " << data.isComplete;
     56        return os << data.kind << ", " << data.isComplete;
    5957}
    6058
Note: See TracChangeset for help on using the changeset viewer.