Ignore:
Timestamp:
Nov 8, 2017, 5:43:33 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
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:
954908d
Parents:
78315272 (diff), e35f30a (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cc

    r78315272 r3f7e12cb  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep  1 23:13:38 2017
    13 // Update Count     : 569
     12// Last Modified On : Mon Sep 25 18:33:41 2017
     13// Update Count     : 587
    1414//
    1515
     
    9898} // TypeData::TypeData
    9999
     100
    100101TypeData::~TypeData() {
    101102        delete base;
     
    161162        } // switch
    162163} // TypeData::~TypeData
     164
    163165
    164166TypeData * TypeData::clone() const {
     
    235237} // TypeData::clone
    236238
     239
    237240void TypeData::print( ostream &os, int indent ) const {
    238241        for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) {
     
    399402} // TypeData::print
    400403
     404
    401405template< typename ForallList >
    402406void buildForall( const DeclarationNode * firstNode, ForallList &outputList ) {
    403407        buildList( firstNode, outputList );
    404         for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i ) {
     408        auto n = firstNode;
     409        for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) {
    405410                TypeDecl * td = static_cast<TypeDecl *>(*i);
    406                 if ( td->get_kind() == TypeDecl::Any ) {
     411                if ( n->variable.tyClass == DeclarationNode::Otype ) {
    407412                        // add assertion parameters to `type' tyvars in reverse order
    408413                        // add dtor:  void ^?{}(T *)
     
    430435                } // if
    431436        } // for
    432 }
     437} // buildForall
     438
    433439
    434440Type * typebuild( const TypeData * td ) {
     
    477483} // typebuild
    478484
     485
    479486TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) {
    480487        TypeData * ret = nullptr;
     
    504511} // typeextractAggregate
    505512
     513
    506514Type::Qualifiers buildQualifiers( const TypeData * td ) {
    507515        return td->qualifiers;
    508516} // buildQualifiers
    509517
     518
     519static string genTSError( string msg, DeclarationNode::BasicType basictype ) {
     520        throw SemanticError( string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
     521} // genTSError
     522
    510523Type * buildBasicType( const TypeData * td ) {
    511524        BasicType::Kind ret;
     
    513526        switch ( td->basictype ) {
    514527          case DeclarationNode::Void:
    515                 if ( td->signedness != DeclarationNode::NoSignedness && td->length != DeclarationNode::NoLength ) {
    516                         throw SemanticError( "invalid type specifier \"void\" in type: ", td );
    517                 } // if
    518 
     528                if ( td->signedness != DeclarationNode::NoSignedness ) {
     529                        genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype );
     530                } // if
     531                if ( td->length != DeclarationNode::NoLength ) {
     532                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
     533                } // if
    519534                return new VoidType( buildQualifiers( td ) );
    520535                break;
     
    522537          case DeclarationNode::Bool:
    523538                if ( td->signedness != DeclarationNode::NoSignedness ) {
    524                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td );
     539                        genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype );
    525540                } // if
    526541                if ( td->length != DeclarationNode::NoLength ) {
    527                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
     542                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    528543                } // if
    529544
     
    538553
    539554                if ( td->length != DeclarationNode::NoLength ) {
    540                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
     555                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    541556                } // if
    542557
     
    557572                break;
    558573
     574          case DeclarationNode::Int128:
     575                ret = td->signedness == 1 ? BasicType::UnsignedInt128 : BasicType::SignedInt128;
     576                if ( td->length != DeclarationNode::NoLength ) {
     577                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
     578                } // if
     579                break;
     580
    559581          case DeclarationNode::Float:
     582          case DeclarationNode::Float80:
     583          case DeclarationNode::Float128:
    560584          case DeclarationNode::Double:
    561585          case DeclarationNode::LongDouble:                                     // not set until below
     
    568592          FloatingPoint: ;
    569593                if ( td->signedness != DeclarationNode::NoSignedness ) {
    570                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td );
     594                        genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype );
    571595                } // if
    572596                if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) {
    573                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
     597                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    574598                } // if
    575599                if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) {
    576                         throw SemanticError( "invalid type specifier \"long\" in type: ", td );
     600                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    577601                } // if
    578602                if ( td->length == DeclarationNode::Long ) {
     
    593617                goto Integral;
    594618          default:
    595                 assert(false);
     619                assertf( false, "unknown basic type" );
    596620                return nullptr;
    597621        } // switch
     
    601625        return bt;
    602626} // buildBasicType
     627
    603628
    604629PointerType * buildPointer( const TypeData * td ) {
     
    612637        return pt;
    613638} // buildPointer
     639
    614640
    615641ArrayType * buildArray( const TypeData * td ) {
     
    626652} // buildArray
    627653
     654
    628655ReferenceType * buildReference( const TypeData * td ) {
    629656        ReferenceType * rt;
     
    637664} // buildReference
    638665
     666
    639667AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    640668        assert( td->kind == TypeData::Aggregate );
     
    665693        return at;
    666694} // buildAggregate
     695
    667696
    668697ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
     
    722751} // buildAggInst
    723752
     753
    724754ReferenceToType * buildAggInst( const TypeData * td ) {
    725755        assert( td->kind == TypeData::AggregateInst );
     
    761791} // buildAggInst
    762792
     793
    763794NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) {
    764795        assert( td->kind == TypeData::Symbolic );
     
    768799                ret = new TypedefDecl( name, scs, typebuild( td->base ), linkage );
    769800        } else {
    770                 ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Any );
     801                ret = new TypeDecl( name, scs, typebuild( td->base ), TypeDecl::Dtype, true );
    771802        } // if
    772803        buildList( td->symbolic.params, ret->get_parameters() );
     
    774805        return ret;
    775806} // buildSymbolic
     807
    776808
    777809EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
     
    790822} // buildEnum
    791823
     824
    792825TypeInstType * buildSymbolicInst( const TypeData * td ) {
    793826        assert( td->kind == TypeData::SymbolicInst );
     
    797830        return ret;
    798831} // buildSymbolicInst
     832
    799833
    800834TupleType * buildTuple( const TypeData * td ) {
     
    807841} // buildTuple
    808842
     843
    809844TypeofType * buildTypeof( const TypeData * td ) {
    810845        assert( td->kind == TypeData::Typeof );
     
    813848        return new TypeofType( buildQualifiers( td ), td->typeexpr->build() );
    814849} // buildTypeof
     850
    815851
    816852Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, Expression *asmName, Initializer * init, std::list< Attribute * > attributes ) {
     
    836872        return nullptr;
    837873} // buildDecl
     874
    838875
    839876FunctionType * buildFunction( const TypeData * td ) {
     
    857894        return ft;
    858895} // buildFunction
     896
    859897
    860898// Transform KR routine declarations into C99 routine declarations:
Note: See TracChangeset for help on using the changeset viewer.