- Timestamp:
- Apr 19, 2018, 3:40:22 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- b03eed6
- Parents:
- f38e7d7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rf38e7d7 re16294d 184 184 /// change the type of generic aggregate members to char[] 185 185 void mutateMembers( AggregateDecl * aggrDecl ); 186 /// returns the calculated sizeof expression for ty, or nullptr for use C sizeof() 187 Expression* genSizeof( Type* ty ); 186 188 187 189 /// Enters a new scope for type-variables, adding the type variables from ty … … 382 384 unsigned long n_members = 0; 383 385 bool firstMember = true; 384 for ( std::list< Declaration* >::const_iterator member = structDecl->get_members().begin(); member != structDecl->get_members().end(); ++member) {385 DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( *member );386 for ( Declaration* member : structDecl->get_members() ) { 387 DeclarationWithType *dwt = dynamic_cast< DeclarationWithType * >( member ); 386 388 assert( dwt ); 387 389 Type *memberType = dwt->get_type(); … … 1747 1749 } 1748 1750 1751 Expression * PolyGenericCalculator::genSizeof( Type* ty ) { 1752 if ( ArrayType * aty = dynamic_cast<ArrayType *>(ty) ) { 1753 // generate calculated size for possibly generic array 1754 Expression * sizeofBase = genSizeof( aty->get_base() ); 1755 if ( ! sizeofBase ) return nullptr; 1756 Expression * dim = aty->get_dimension(); 1757 aty->set_dimension( nullptr ); 1758 return makeOp( "?*?", sizeofBase, dim ); 1759 } else if ( findGeneric( ty ) ) { 1760 // generate calculated size for generic type 1761 return new NameExpr( sizeofName( mangleType( ty ) ) ); 1762 } else return nullptr; 1763 } 1764 1749 1765 Expression *PolyGenericCalculator::postmutate( SizeofExpr *sizeofExpr ) { 1750 Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result(); 1751 if ( findGeneric( ty ) ) { 1752 Expression *ret = new NameExpr( sizeofName( mangleType( ty ) ) ); 1766 Type *ty = sizeofExpr->get_isType() ? 1767 sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result(); 1768 1769 Expression * gen = genSizeof( ty ); 1770 if ( gen ) { 1753 1771 delete sizeofExpr; 1754 return ret; 1755 } 1756 return sizeofExpr; 1772 return gen; 1773 } else return sizeofExpr; 1757 1774 } 1758 1775
Note: See TracChangeset
for help on using the changeset viewer.