Changes in / [24cde55:ead8c7e]


Ignore:
Location:
src/Parser
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r24cde55 read8c7e  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 15:45:02 2017
    13 // Update Count     : 759
     12// Last Modified On : Thu Feb 16 13:06:50 2017
     13// Update Count     : 753
    1414//
    1515
     
    174174        } // if
    175175
     176        if ( body ) {
     177                newnode->type->function.hasBody = true;
     178        } // if
     179
    176180        if ( ret ) {
    177181                newnode->type->base = ret->type;
     
    255259} // DeclarationNode::newAggregate
    256260
    257 DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants, bool body ) {
     261DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants ) {
    258262        DeclarationNode * newnode = new DeclarationNode;
    259263        newnode->type = new TypeData( TypeData::Enum );
     
    264268        } // if
    265269        newnode->type->enumeration.constants = constants;
    266         newnode->type->enumeration.body = body;
    267270        return newnode;
    268271} // DeclarationNode::newEnum
     
    695698        assert( ! type->function.body );
    696699        type->function.body = body;
     700        type->function.hasBody = true;
    697701        return this;
    698702}
     
    10361040        switch ( type->kind ) {
    10371041          case TypeData::Enum: {
    1038                   if ( type->enumeration.body ) {
    1039                           EnumDecl * typedecl = buildEnum( type, attributes );
    1040                           return new EnumInstType( buildQualifiers( type ), typedecl );
    1041                   } else {
    1042                           return new EnumInstType( buildQualifiers( type ), *type->enumeration.name );
    1043                   }
     1042                  EnumDecl * typedecl = buildEnum( type, attributes );
     1043                  return new EnumInstType( buildQualifiers( type ), typedecl );
    10441044          }
    10451045          case TypeData::Aggregate: {
     1046                  AggregateDecl * typedecl = buildAggregate( type, attributes );
    10461047                  ReferenceToType * ret;
    1047                   if ( type->aggregate.body ) {
    1048                           AggregateDecl * typedecl = buildAggregate( type, attributes );
    1049                           switch ( type->aggregate.kind ) {
    1050                                 case DeclarationNode::Struct:
    1051                                   ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl );
    1052                                   break;
    1053                                 case DeclarationNode::Union:
    1054                                   ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl );
    1055                                   break;
    1056                                 case DeclarationNode::Trait:
    1057                                   assert( false );
    1058                                   //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl );
    1059                                   break;
    1060                                 default:
    1061                                   assert( false );
    1062                           } // switch
    1063                   } else {
    1064                           switch ( type->aggregate.kind ) {
    1065                                 case DeclarationNode::Struct:
    1066                                   ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name );
    1067                                   break;
    1068                                 case DeclarationNode::Union:
    1069                                   ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name );
    1070                                   break;
    1071                                 case DeclarationNode::Trait:
    1072                                   assert( false );
    1073                                   //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl );
    1074                                   break;
    1075                                 default:
    1076                                   assert( false );
    1077                           } // switch
    1078                   } // if
     1048                  switch ( type->aggregate.kind ) {
     1049                        case DeclarationNode::Struct:
     1050                          ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl );
     1051                          break;
     1052                        case DeclarationNode::Union:
     1053                          ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl );
     1054                          break;
     1055                        case DeclarationNode::Trait:
     1056                          assert( false );
     1057                          //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl );
     1058                          break;
     1059                        default:
     1060                          assert( false );
     1061                  } // switch
    10791062                  buildList( type->aggregate.actuals, ret->get_parameters() );
    10801063                  return ret;
  • src/Parser/ParseNode.h

    r24cde55 read8c7e  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 15:22:10 2017
    13 // Update Count     : 662
     12// Last Modified On : Thu Feb 16 13:15:55 2017
     13// Update Count     : 661
    1414//
    1515
     
    238238        static DeclarationNode * newFromTypedef( std::string * );
    239239        static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    240         static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body );
     240        static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants );
    241241        static DeclarationNode * newEnumConstant( std::string * name, ExpressionNode * constant );
    242242        static DeclarationNode * newName( std::string * );
  • src/Parser/TypeData.cc

    r24cde55 read8c7e  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 16:26:39 2017
    13 // Update Count     : 477
     12// Last Modified On : Sun Feb 19 09:49:33 2017
     13// Update Count     : 467
    1414//
    1515
     
    4848                function.oldDeclList = nullptr;
    4949                function.body = nullptr;
     50                function.hasBody = false;
    5051                function.newStyle = false;
    5152                break;
     
    6768                enumeration.name = nullptr;
    6869                enumeration.constants = nullptr;
    69                 enumeration.body = false;
    7070                break;
    7171          case Symbolic:
     
    182182                newtype->function.oldDeclList = maybeClone( function.oldDeclList );
    183183                newtype->function.body = maybeClone( function.body );
     184                newtype->function.hasBody = function.hasBody;
    184185                newtype->function.newStyle = function.newStyle;
    185186                break;
     
    199200                newtype->enumeration.name = enumeration.name ? new string( *enumeration.name ) : nullptr;
    200201                newtype->enumeration.constants = maybeClone( enumeration.constants );
    201                 newtype->enumeration.body = enumeration.body;
    202202                break;
    203203          case Symbolic:
     
    293293                } // if
    294294                os << endl;
     295                if ( function.hasBody ) {
     296                        os << string( indent + 2, ' ' ) << "with body " << endl;
     297                } // if
    295298                if ( function.body ) {
    296                         os << string( indent + 2, ' ' ) << "with body " << endl;
    297299                        function.body->printList( os, indent + 2 );
    298300                } // if
     
    333335                        os << "with constants" << endl;
    334336                        enumeration.constants->printList( os, indent + 2 );
    335                 } // if
    336                 if ( enumeration.body ) {
    337                         os << string( indent + 2, ' ' ) << " with body " << endl;
    338337                } // if
    339338                break;
     
    697696                } // if
    698697        } // for
    699         ret->set_body( td->enumeration.body );
    700698        return ret;
    701699} // buildEnum
     
    726724Declaration * 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 ) {
    727725        if ( td->kind == TypeData::Function ) {
    728                 if ( td->function.idList ) {                                    // KR function ?
    729                         buildKRFunction( td->function );                        // transform into C11 function
     726                if ( td->function.idList ) {
     727                        buildKRFunction( td->function );
    730728                } // if
    731729
    732730                FunctionDecl * decl;
    733                 Statement * stmt = maybeBuild<Statement>( td->function.body );
    734                 CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt );
    735                 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn, attributes );
     731                if ( td->function.hasBody ) {
     732                        if ( td->function.body ) {
     733                                Statement * stmt = td->function.body->build();
     734                                CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt );
     735                                assert( body );
     736                                decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn, attributes );
     737                        } else {
     738                                // list< Label > ls;
     739                                decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), new CompoundStmt( list< Label >() ), isInline, isNoreturn, attributes );
     740                        } // if
     741                } else {
     742                        decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), nullptr, isInline, isNoreturn, attributes );
     743                } // if
    736744                return decl->set_asmName( asmName );
    737745        } else if ( td->kind == TypeData::Aggregate ) {
     
    808816
    809817        for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) {
    810                 if ( ! param->type ) {                                                  // generate type int for empty parameter type
     818                if ( ! param->type ) {                                                  // generate type int for empty parameters
    811819                        param->type = new TypeData( TypeData::Basic );
    812820                        param->type->basictype = DeclarationNode::Int;
  • src/Parser/TypeData.h

    r24cde55 read8c7e  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 15:16:18 2017
    13 // Update Count     : 155
     12// Last Modified On : Thu Feb 16 14:30:05 2017
     13// Update Count     : 153
    1414//
    1515
     
    4949                const std::string * name;
    5050                DeclarationNode * constants;
    51                 bool body;
    5251        };
    5352
     
    5756                mutable DeclarationNode * oldDeclList;
    5857                StatementNode * body;
     58                bool hasBody;
    5959                bool newStyle;
    6060        };
  • src/Parser/parser.cc

    r24cde55 read8c7e  
    72927292/* Line 1806 of yacc.c  */
    72937293#line 1651 "parser.yy"
    7294     { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(4) - (6)].decl), true )->addQualifiers( (yyvsp[(2) - (6)].decl) ); }
     7294    { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(4) - (6)].decl) )->addQualifiers( (yyvsp[(2) - (6)].decl) ); }
    72957295    break;
    72967296
     
    73017301    {
    73027302                        typedefTable.makeTypedef( *(yyvsp[(3) - (3)].tok) );
    7303                         (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (3)].tok), 0, false )->addQualifiers( (yyvsp[(2) - (3)].decl) );
     7303                        (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (3)].tok), 0 )->addQualifiers( (yyvsp[(2) - (3)].decl) );
    73047304                }
    73057305    break;
     
    73167316/* Line 1806 of yacc.c  */
    73177317#line 1660 "parser.yy"
    7318     { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (8)].tok), (yyvsp[(6) - (8)].decl), true )->addQualifiers( (yyvsp[(2) - (8)].decl) ); }
     7318    { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (8)].tok), (yyvsp[(6) - (8)].decl) )->addQualifiers( (yyvsp[(2) - (8)].decl) ); }
    73197319    break;
    73207320
  • src/Parser/parser.yy

    r24cde55 read8c7e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 15:23:49 2017
    13 // Update Count     : 2187
     12// Last Modified On : Thu Feb 16 15:56:33 2017
     13// Update Count     : 2186
    1414//
    1515
     
    16491649enum_type:
    16501650        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    1651                 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
     1651                { $$ = DeclarationNode::newEnum( nullptr, $4 )->addQualifiers( $2 ); }
    16521652        | ENUM attribute_list_opt no_attr_identifier_or_type_name
    16531653                {
    16541654                        typedefTable.makeTypedef( *$3 );
    1655                         $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 );
     1655                        $$ = DeclarationNode::newEnum( $3, 0 )->addQualifiers( $2 );
    16561656                }
    16571657        | ENUM attribute_list_opt no_attr_identifier_or_type_name
    16581658                { typedefTable.makeTypedef( *$3 ); }
    16591659          '{' enumerator_list comma_opt '}'
    1660                 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); }
     1660                { $$ = DeclarationNode::newEnum( $3, $6 )->addQualifiers( $2 ); }
    16611661        ;
    16621662
Note: See TracChangeset for help on using the changeset viewer.