Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r982f95d r2efe4b8  
    3838#include "Lvalue.h"                      // for generalizedLvalue
    3939#include "Parser/LinkageSpec.h"          // for C, Spec, Cforall, Intrinsic
     40#include "ResolvExpr/TypeEnvironment.h"  // for EqvClass
    4041#include "ResolvExpr/typeops.h"          // for typesCompatible
    4142#include "ScopedSet.h"                   // for ScopedSet, ScopedSet<>::iter...
     
    183184                        /// change the type of generic aggregate members to char[]
    184185                        void mutateMembers( AggregateDecl * aggrDecl );
    185                         /// returns the calculated sizeof expression for ty, or nullptr for use C sizeof()
    186                         Expression* genSizeof( Type* ty );
    187186
    188187                        /// Enters a new scope for type-variables, adding the type variables from ty
     
    384383                unsigned long n_members = 0;
    385384                bool firstMember = true;
    386                 for ( Declaration* member : structDecl->get_members() ) {
    387                         DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( member );
     385                for ( std::list< Declaration* >::const_iterator member = structDecl->get_members().begin(); member != structDecl->get_members().end(); ++member ) {
     386                        DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );
    388387                        assert( dwt );
    389388                        Type *memberType = dwt->get_type();
     
    591590                        // pass size/align for type variables
    592591                        for ( TyVarMap::const_iterator tyParm = exprTyVars.begin(); tyParm != exprTyVars.end(); ++tyParm ) {
     592                                ResolvExpr::EqvClass eqvClass;
    593593                                assert( env );
    594594                                if ( tyParm->second.isComplete ) {
     
    17371737                }
    17381738
    1739                 Expression * PolyGenericCalculator::genSizeof( Type* ty ) {
    1740                         if ( ArrayType * aty = dynamic_cast<ArrayType *>(ty) ) {
    1741                                 // generate calculated size for possibly generic array
    1742                                 Expression * sizeofBase = genSizeof( aty->get_base() );
    1743                                 if ( ! sizeofBase ) return nullptr;
    1744                                 Expression * dim = aty->get_dimension();
    1745                                 aty->set_dimension( nullptr );
    1746                                 return makeOp( "?*?", sizeofBase, dim );
    1747                         } else if ( findGeneric( ty ) ) {
    1748                                 // generate calculated size for generic type
     1739                Expression *PolyGenericCalculator::postmutate( SizeofExpr *sizeofExpr ) {
     1740                        Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result();
     1741                        if ( findGeneric( ty ) ) {
    17491742                                return new NameExpr( sizeofName( mangleType( ty ) ) );
    1750                         } else return nullptr;
    1751                 }
    1752 
    1753                 Expression *PolyGenericCalculator::postmutate( SizeofExpr *sizeofExpr ) {
    1754                         Type *ty = sizeofExpr->get_isType() ?
    1755                                 sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result();
    1756                        
    1757                         Expression * gen = genSizeof( ty );
    1758                         return gen ? gen : sizeofExpr;
     1743                        }
     1744                        return sizeofExpr;
    17591745                }
    17601746
Note: See TracChangeset for help on using the changeset viewer.