Changeset 057608a


Ignore:
Timestamp:
Mar 18, 2024, 5:44:22 PM (8 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
5b25c49
Parents:
8f650f0
Message:

Parser clean-up: Removed an unused field, added a comment, fixed a memory leak and reformated a function.

Location:
src/Parser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r8f650f0 r057608a  
    185185        newnode->type->aggregate.fields = fields;
    186186        newnode->type->aggregate.body = body;
    187         newnode->type->aggregate.tagged = false;
    188187        newnode->type->aggregate.parent = nullptr;
    189188        return newnode;
     
    199198        newnode->type->enumeration.typed = typed;
    200199        newnode->type->enumeration.hiding = hiding;
    201         if ( base && base->type )  {
     200        if ( base ) {
     201                assert( typed );
     202                assert( base->type );
    202203                newnode->type->base = base->type;
     204                base->type = nullptr;
     205                delete base;
    203206        } // if
    204207
     
    220223
    221224DeclarationNode * DeclarationNode::newEnumValueGeneric( const string * name, InitializerNode * init ) {
    222         if ( init ) {
    223                 if ( init->get_expression() ) {
    224                         return newEnumConstant( name, init->get_expression() );
    225                 } else {
    226                         DeclarationNode * newnode = newName( name );
    227                         newnode->initializer = init;
    228                         return newnode;
    229                 } // if
     225        if ( nullptr == init ) {
     226                return newName( name );
     227        } else if ( init->get_expression() ) {
     228                return newEnumConstant( name, init->get_expression() );
    230229        } else {
    231                 return newName( name );
     230                DeclarationNode * newnode = newName( name );
     231                newnode->initializer = init;
     232                return newnode;
    232233        } // if
    233234} // DeclarationNode::newEnumValueGeneric
     
    549550        newaggr->aggregate.body = false;
    550551        newaggr->aggregate.anon = oldaggr->aggregate.anon;
    551         newaggr->aggregate.tagged = oldaggr->aggregate.tagged;
    552552        swap( newaggr, oldaggr );
    553553
     
    596596}
    597597
     598// Wrap the declaration in a typedef. It actually does that by modifying the
     599// existing declaration, and may split it into two declarations.
     600// This only happens if the wrapped type is actually a declaration of a SUE
     601// type. If it does, the DeclarationNode for the SUE declaration is the node
     602// returned, make sure later transformations are applied to the right node.
    598603DeclarationNode * DeclarationNode::addTypedef() {
    599604        TypeData * newtype = new TypeData( TypeData::Symbolic );
  • src/Parser/TypeData.cc

    r8f650f0 r057608a  
    8888                aggregate.fields = nullptr;
    8989                aggregate.body = false;
    90                 aggregate.tagged = false;
    9190                aggregate.parent = nullptr;
    9291                aggregate.anon = false;
     
    228227                newtype->aggregate.body = aggregate.body;
    229228                newtype->aggregate.anon = aggregate.anon;
    230                 newtype->aggregate.tagged = aggregate.tagged;
    231229                break;
    232230        case AggregateInst:
  • src/Parser/TypeData.h

    r8f650f0 r057608a  
    5555                bool body;
    5656                bool anon;
    57                 bool tagged;
    5857        };
    5958
Note: See TracChangeset for help on using the changeset viewer.