Ignore:
Timestamp:
Mar 3, 2017, 10:12:02 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
8191203
Parents:
f37147b
Message:

first attempt to create function specifiers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cc

    rf37147b rdd020c0  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 21:48:55 2017
    13 // Update Count     : 485
     12// Last Modified On : Fri Mar  3 21:59:10 2017
     13// Update Count     : 516
    1414//
    1515
     
    157157TypeData * TypeData::clone() const {
    158158        TypeData * newtype = new TypeData( kind );
    159         newtype->qualifiers = qualifiers;
     159        newtype->typeQualifiers = typeQualifiers;
    160160        newtype->base = maybeClone( base );
    161161        newtype->forall = maybeClone( forall );
     
    226226
    227227void TypeData::print( ostream &os, int indent ) const {
    228         for ( int i = 0; i < DeclarationNode::NoQualifier; i += 1 ) {
    229                 if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' ';
     228        for ( int i = 0; i < DeclarationNode::NoTypeQualifier; i += 1 ) {
     229                if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' ';
    230230        } // for
    231231
     
    250250                break;
    251251          case Basic:
    252                 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessName[ signedness ] << " ";
    253                 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthName[ length ] << " ";
     252                if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " ";
     253                if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " ";
    254254                assert( basictype != DeclarationNode::NoBasicType );
    255                 os << DeclarationNode::basicTypeName[ basictype ] << " ";
    256                 if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeName[ complextype ] << " ";
     255                os << DeclarationNode::basicTypeNames[ basictype ] << " ";
     256                if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeNames[ complextype ] << " ";
    257257                break;
    258258          case Array:
     
    301301                break;
    302302          case Aggregate:
    303                 os << DeclarationNode::aggregateName[ aggregate.kind ] << ' ' << *aggregate.name << endl;
     303                os << DeclarationNode::aggregateNames[ aggregate.kind ] << ' ' << *aggregate.name << endl;
    304304                if ( aggregate.params ) {
    305305                        os << string( indent + 2, ' ' ) << "with type parameters " << endl;
     
    399399                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false );
    400400                        dtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    401                         td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr, false, false ) );
     401                        td->get_assertions().push_front( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, dtorType, nullptr ) );
    402402
    403403                        // add copy ctor:  void ?{}(T *, T)
     
    405405                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    406406                        copyCtorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    407                         td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr, false, false ) );
     407                        td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, copyCtorType, nullptr ) );
    408408
    409409                        // add default ctor:  void ?{}(T *)
    410410                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false );
    411411                        ctorType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    412                         td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr, false, false ) );
     412                        td->get_assertions().push_front( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, ctorType, nullptr ) );
    413413
    414414                        // add assignment operator:  T * ?=?(T *, T)
     
    417417                        assignType->get_parameters().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    418418                        assignType->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    419                         td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr, false, false ) );
     419                        td->get_assertions().push_front( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, assignType, nullptr ) );
    420420                } // if
    421421        } // for
     
    494494Type::Qualifiers buildQualifiers( const TypeData * td ) {
    495495        Type::Qualifiers q;
    496         q.isConst = td->qualifiers[ DeclarationNode::Const ];
    497         q.isVolatile = td->qualifiers[ DeclarationNode::Volatile ];
    498         q.isRestrict = td->qualifiers[ DeclarationNode::Restrict ];
    499         q.isLvalue = td->qualifiers[ DeclarationNode::Lvalue ];
    500         q.isAtomic = td->qualifiers[ DeclarationNode::Atomic ];;
     496        q.isConst = td->typeQualifiers[ DeclarationNode::Const ];
     497        q.isVolatile = td->typeQualifiers[ DeclarationNode::Volatile ];
     498        q.isRestrict = td->typeQualifiers[ DeclarationNode::Restrict ];
     499        q.isLvalue = td->typeQualifiers[ DeclarationNode::Lvalue ];
     500        q.isAtomic = td->typeQualifiers[ DeclarationNode::Atomic ];;
    501501        return q;
    502502} // buildQualifiers
     
    516516          case DeclarationNode::Bool:
    517517                if ( td->signedness != DeclarationNode::NoSignedness ) {
    518                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
     518                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td );
    519519                } // if
    520520                if ( td->length != DeclarationNode::NoLength ) {
    521                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     521                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
    522522                } // if
    523523
     
    532532
    533533                if ( td->length != DeclarationNode::NoLength ) {
    534                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     534                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
    535535                } // if
    536536
     
    562562          FloatingPoint: ;
    563563                if ( td->signedness != DeclarationNode::NoSignedness ) {
    564                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
     564                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td );
    565565                } // if
    566566                if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) {
    567                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
     567                        throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
    568568                } // if
    569569                if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) {
     
    784784} // buildTypeof
    785785
    786 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {
     786Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, DeclarationNode::FuncSpec funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {
    787787        if ( td->kind == TypeData::Function ) {
    788788                if ( td->function.idList ) {                                    // KR function ?
     
    793793                Statement * stmt = maybeBuild<Statement>( td->function.body );
    794794                CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt );
    795                 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn, attributes );
     795                decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, attributes, funcSpec );
    796796                return decl->set_asmName( asmName );
    797797        } else if ( td->kind == TypeData::Aggregate ) {
     
    802802                return buildSymbolic( td, name, sc );
    803803        } else {
    804                 return (new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, attributes, isInline, isNoreturn ))->set_asmName( asmName );
     804                return (new ObjectDecl( name, sc, linkage, bitfieldWidth, typebuild( td ), init, attributes ))->set_asmName( asmName );
    805805        } // if
    806806        return nullptr;
     
    820820                        break;
    821821                  default:
    822                         ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base,  "", DeclarationNode::NoStorageClass, nullptr, false, false, LinkageSpec::Cforall, nullptr ) ) );
     822                        ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType* >( buildDecl( td->base, "", DeclarationNode::NoStorageClass, nullptr, DeclarationNode::FuncSpecifier(), LinkageSpec::Cforall, nullptr ) ) );
    823823                } // switch
    824824        } else {
Note: See TracChangeset for help on using the changeset viewer.