Ignore:
Timestamp:
Aug 14, 2017, 2:05:42 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
36a5a77
Parents:
9236060
Message:

Remove unused isDynamicLayout parameter from autogen, add some more debug information

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r9236060 r74b007ba  
    156156        }
    157157
    158         /// true if the aggregate's layout is dynamic
    159         template< typename AggrDecl >
    160         bool hasDynamicLayout( AggrDecl * aggregateDecl ) {
    161                 for ( TypeDecl * param : aggregateDecl->get_parameters() ) {
    162                         if ( param->isComplete() ) return true;
    163                 }
    164                 return false;
    165         }
    166 
    167158        /// generate a function decl from a name and type. Nesting depth determines whether
    168159        /// the declaration is static or not; optional paramter determines if declaration is intrinsic
     
    310301
    311302        /// generates a single struct member operation (constructor call, destructor call, assignment call)
    312         void makeStructMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool isDynamicLayout, bool forward = true ) {
     303        void makeStructMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool forward = true ) {
    313304                InitTweak::InitExpander srcParam( src );
    314305
     
    320311        /// generates the body of a struct function by iterating the struct members (via parameters) - generates default ctor, copy ctor, assignment, and dtor bodies, but NOT field ctor bodies
    321312        template<typename Iterator>
    322         void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, bool isDynamicLayout, bool forward = true ) {
     313        void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, bool forward = true ) {
    323314                for ( ; member != end; ++member ) {
    324315                        if ( DeclarationWithType *field = dynamic_cast< DeclarationWithType * >( *member ) ) { // otherwise some form of type declaration, e.g. Aggregate
     
    356347
    357348                                Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : NULL;
    358                                 makeStructMemberOp( dstParam, srcselect, field, func, isDynamicLayout, forward );
     349                                makeStructMemberOp( dstParam, srcselect, field, func, forward );
    359350                        } // if
    360351                } // for
     
    364355        /// void ?{}(A *, int) and void?{}(A *, int, int) for a struct A which has two int fields.
    365356        template<typename Iterator>
    366         void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func, bool isDynamicLayout ) {
     357        void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func ) {
    367358                FunctionType * ftype = func->get_functionType();
    368359                std::list<DeclarationWithType*> & params = ftype->get_parameters();
     
    390381                                        // matching parameter, initialize field with copy ctor
    391382                                        Expression *srcselect = new VariableExpr(*parameter);
    392                                         makeStructMemberOp( dstParam, srcselect, field, func, isDynamicLayout );
     383                                        makeStructMemberOp( dstParam, srcselect, field, func );
    393384                                        ++parameter;
    394385                                } else {
    395386                                        // no matching parameter, initialize field with default ctor
    396                                         makeStructMemberOp( dstParam, NULL, field, func, isDynamicLayout );
     387                                        makeStructMemberOp( dstParam, NULL, field, func );
    397388                                }
    398389                        }
     
    410401                // Make function polymorphic in same parameters as generic struct, if applicable
    411402                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
    412                 bool isDynamicLayout = hasDynamicLayout( aggregateDecl );  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union)
    413403
    414404                // generate each of the functions based on the supplied FuncData objects
     
    436426                        // destructor needs to do everything in reverse, so pass "forward" based on whether the function is a destructor
    437427                        if ( ! CodeGen::isDestructor( dcl->get_name() ) ) {
    438                                 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), dcl, isDynamicLayout );
     428                                makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), dcl );
    439429                        } else {
    440                                 makeStructFunctionBody( aggregateDecl->get_members().rbegin(), aggregateDecl->get_members().rend(), dcl, isDynamicLayout, false );
     430                                makeStructFunctionBody( aggregateDecl->get_members().rbegin(), aggregateDecl->get_members().rend(), dcl, false );
    441431                        }
    442432                        if ( CodeGen::isAssignment( dcl->get_name() ) ) {
     
    474464                                memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), Type::StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );
    475465                                FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    476                                 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout );
     466                                makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor );
    477467                                declsToAdd.push_back( ctor );
    478468                        }
Note: See TracChangeset for help on using the changeset viewer.