Changeset 2f42718 for src/Parser


Ignore:
Timestamp:
Feb 22, 2019, 10:43:29 AM (7 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
no_list
Parents:
43e0949
Message:

Parameters and return value of functions are now vectors (and some related clean-up)

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r43e0949 r2f42718  
    10651065} // buildList
    10661066
    1067 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList ) {
     1067void buildTypeList( const DeclarationNode * firstNode, std::vector< Type * > & outputList ) {
    10681068        SemanticErrorException errors;
    1069         std::back_insert_iterator< std::list< Type * > > out( outputList );
     1069        std::back_insert_iterator< std::vector< Type * > > out( outputList );
    10701070        const DeclarationNode * cur = firstNode;
    10711071
     
    10971097                assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." );
    10981098                TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr );
    1099                 buildList( variable.assertions, ret->get_assertions() );
     1099                buildList( variable.assertions, ret->assertions );
    11001100                return ret;
    11011101        } // if
  • src/Parser/ParseNode.h

    r43e0949 r2f42718  
    467467void buildList( const DeclarationNode * firstNode, std::list< Declaration * > & outputList );
    468468void buildList( const DeclarationNode * firstNode, std::list< DeclarationWithType * > & outputList );
    469 void buildTypeList( const DeclarationNode * firstNode, std::list< Type * > & outputList );
     469void buildTypeList( const DeclarationNode * firstNode, std::vector< Type * > & outputList );
    470470
    471471template< typename SynTreeType, typename NodeType >
  • src/Parser/TypeData.cc

    r43e0949 r2f42718  
    493493                        // add dtor:  void ^?{}(T *)
    494494                        FunctionType * dtorType = new FunctionType( Type::Qualifiers(), false );
    495                         dtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    496                         td->get_assertions().push_front( new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) );
     495                        dtorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     496                        td->assertions.insert( td->assertions.begin(), new FunctionDecl( "^?{}", Type::StorageClasses(), LinkageSpec::Cforall, dtorType, nullptr ) );
    497497
    498498                        // add copy ctor:  void ?{}(T *, T)
    499499                        FunctionType * copyCtorType = new FunctionType( Type::Qualifiers(), false );
    500                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    501                         copyCtorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    502                         td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) );
     500                        copyCtorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     501                        copyCtorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     502                        td->assertions.insert( td->assertions.begin(), new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, copyCtorType, nullptr ) );
    503503
    504504                        // add default ctor:  void ?{}(T *)
    505505                        FunctionType * ctorType = new FunctionType( Type::Qualifiers(), false );
    506                         ctorType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    507                         td->get_assertions().push_front( new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) );
     506                        ctorType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     507                        td->assertions.insert( td->assertions.begin(), new FunctionDecl( "?{}", Type::StorageClasses(), LinkageSpec::Cforall, ctorType, nullptr ) );
    508508
    509509                        // add assignment operator:  T * ?=?(T *, T)
    510510                        FunctionType * assignType = new FunctionType( Type::Qualifiers(), false );
    511                         assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
    512                         assignType->get_parameters().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    513                         assignType->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
    514                         td->get_assertions().push_front( new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) );
     511                        assignType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), new TypeInstType( Type::Qualifiers(), td->get_name(), *i ) ), nullptr ) );
     512                        assignType->parameters.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     513                        assignType->returnVals.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new TypeInstType( Type::Qualifiers(), td->get_name(), *i ), nullptr ) );
     514                        td->assertions.insert( td->assertions.begin(), new FunctionDecl( "?=?", Type::StorageClasses(), LinkageSpec::Cforall, assignType, nullptr ) );
    515515                } // if
    516516        } // for
     
    897897        } // if
    898898        buildList( td->symbolic.params, ret->get_parameters() );
    899         buildList( td->symbolic.assertions, ret->get_assertions() );
     899        buildList( td->symbolic.assertions, ret->assertions );
    900900        ret->base->attributes.insert( ret->base->attributes.end(), attributes.begin(), attributes.end() );
    901901        return ret;
     
    930930TupleType * buildTuple( const TypeData * td ) {
    931931        assert( td->kind == TypeData::Tuple );
    932         std::list< Type * > types;
     932        std::vector< Type * > types;
    933933        buildTypeList( td->tuple, types );
    934934        TupleType * ret = new TupleType( buildQualifiers( td ), types );
     
    983983                        break;
    984984                  default:
    985                         ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );
     985                        ft->returnVals.push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );
    986986                } // switch
    987987        } else {
    988                 ft->get_returnVals().push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );
     988                ft->returnVals.push_back( new ObjectDecl( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), nullptr ) );
    989989        } // if
    990990        return ft;
Note: See TracChangeset for help on using the changeset viewer.