Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r361bf01 r09867ec  
    271271        };
    272272
    273         struct ArrayLength : public WithIndexer {
     273        struct InitializerLength {
    274274                /// for array types without an explicit length, compute the length and store it so that it
    275275                /// is known to the rest of the phases. For example,
     
    282282
    283283                void previsit( ObjectDecl * objDecl );
     284        };
     285
     286        struct ArrayLength : public WithIndexer {
     287                static void computeLength( std::list< Declaration * > & translationUnit );
     288
    284289                void previsit( ArrayType * arrayType );
    285290        };
     
    382387                                        FixObjectType::fix, translationUnit);
    383388                        }
    384                         Stats::Time::TimeCall("Array Length",
    385                                 ArrayLength::computeLength, translationUnit);
     389                        Stats::Time::TimeCall("Initializer Length",
     390                                InitializerLength::computeLength, translationUnit);
     391                        if (!useNewAST) {
     392                                Stats::Time::TimeCall("Array Length",
     393                                        ArrayLength::computeLength, translationUnit);
     394                        }
    386395                        Stats::Time::TimeCall("Find Special Declarations",
    387396                                Validate::findSpecialDecls, translationUnit);
     
    13321341        }
    13331342
     1343        void InitializerLength::computeLength( std::list< Declaration * > & translationUnit ) {
     1344                PassVisitor<InitializerLength> len;
     1345                acceptAll( translationUnit, len );
     1346        }
     1347
    13341348        void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) {
    13351349                PassVisitor<ArrayLength> len;
     
    13371351        }
    13381352
    1339         void ArrayLength::previsit( ObjectDecl * objDecl ) {
     1353        void InitializerLength::previsit( ObjectDecl * objDecl ) {
    13401354                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) {
    13411355                        if ( at->dimension ) return;
     
    13471361
    13481362        void ArrayLength::previsit( ArrayType * type ) {
    1349                 if (!useNewAST) {
    1350                         if ( type->dimension ) {
    1351                                 // need to resolve array dimensions early so that constructor code can correctly determine
    1352                                 // if a type is a VLA (and hence whether its elements need to be constructed)
    1353                                 ResolvExpr::findSingleExpression( type->dimension, Validate::SizeType->clone(), indexer );
    1354 
    1355                                 // must re-evaluate whether a type is a VLA, now that more information is available
    1356                                 // (e.g. the dimension may have been an enumerator, which was unknown prior to this step)
    1357                                 type->isVarLen = ! InitTweak::isConstExpr( type->dimension );
    1358                         }
     1363                if ( type->dimension ) {
     1364                        // need to resolve array dimensions early so that constructor code can correctly determine
     1365                        // if a type is a VLA (and hence whether its elements need to be constructed)
     1366                        ResolvExpr::findSingleExpression( type->dimension, Validate::SizeType->clone(), indexer );
     1367
     1368                        // must re-evaluate whether a type is a VLA, now that more information is available
     1369                        // (e.g. the dimension may have been an enumerator, which was unknown prior to this step)
     1370                        type->isVarLen = ! InitTweak::isConstExpr( type->dimension );
    13591371                }
    13601372        }
     
    14621474                }
    14631475        }
     1476
     1477        /*
    14641478
    14651479        /// Associates forward declarations of aggregates with their definitions
     
    18441858                }
    18451859        };
     1860        */
    18461861} // anonymous namespace
    18471862
     1863/*
    18481864const ast::Type * validateType(
    18491865                const CodeLocation & loc, const ast::Type * type, const ast::SymbolTable & symtab ) {
     
    18541870        return type->accept( lrt )->accept( fpd );
    18551871}
     1872*/
    18561873
    18571874} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.