Changeset 10c1770


Ignore:
Timestamp:
Mar 26, 2025, 5:30:13 PM (4 days ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
185cd94
Parents:
30bf6bf
Message:

Refactoring in the resolver. Removed unneeded variable and used the ast::Pass<>::read helper.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/ResolvExpr/Resolver.cpp

    r30bf6bf r10c1770  
    703703        } else {
    704704                if ( !objectDecl->isTypeFixed ) {
    705                         auto newDecl = fixObjectType(objectDecl, context);
    706                         auto mutDecl = mutate(newDecl);
     705                        objectDecl = fixObjectType(objectDecl, context);
    707706
    708707                        // generate CtorInit wrapper when necessary.
     
    710709                        // this object in visitor pass, thus disabling CtorInit codegen.
    711710                        // this happens on aggregate members and function parameters.
    712                         if ( shouldGenCtorInit( mutDecl ) ) {
     711                        if ( shouldGenCtorInit( objectDecl ) ) {
    713712                                // constructed objects cannot be designated
    714                                 if ( InitTweak::isDesignated( mutDecl->init ) ) {
    715                                         ast::Pass<ResolveDesignators> res( context );
    716                                         maybe_accept( mutDecl->init.get(), res );
    717                                         if ( !res.core.result ) {
    718                                                 SemanticError( mutDecl, "Cannot include designations in the initializer for a managed Object.\n"
    719                                                                            "If this is really what you want, initialize with @=." );
    720                                         }
     713                                if ( InitTweak::isDesignated( objectDecl->init )
     714                                                && !ast::Pass<ResolveDesignators>::read(
     715                                                        objectDecl->init.get(), context ) ) {
     716                                        SemanticError( objectDecl, "Cannot include designations in the initializer for a managed Object.\n"
     717                                                        "If this is really what you want, initialize with @=." );
    721718                                }
    722719                                // constructed objects should not have initializers nested too deeply
    723                                 if ( ! InitTweak::checkInitDepth( mutDecl ) ) SemanticError( mutDecl, "Managed object's initializer is too deep " );
    724 
    725                                 mutDecl->init = InitTweak::genCtorInit( mutDecl->location, mutDecl );
     720                                if ( !InitTweak::checkInitDepth( objectDecl ) ) SemanticError( objectDecl, "Managed object's initializer is too deep " );
     721
     722                                objectDecl = ast::mutate_field( objectDecl, &ast::ObjectDecl::init,
     723                                        InitTweak::genCtorInit( objectDecl->location, objectDecl ) );
    726724                        }
    727 
    728                         objectDecl = mutDecl;
    729725                }
    730726                currentObject = ast::CurrentObject{ objectDecl->location, objectDecl->get_type() };
Note: See TracChangeset for help on using the changeset viewer.