Changeset 9236060 for src/GenPoly/Box.cc
- Timestamp:
- Aug 14, 2017, 2:03:39 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, resolv-new, with_gc
- Children:
- 74b007ba
- Parents:
- fd344aa (diff), 54cd58b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
rfd344aa r9236060 27 27 #include "Box.h" 28 28 #include "DeclMutator.h" 29 #include "Lvalue.h" 30 #include "FindFunction.h" 29 31 #include "PolyMutator.h" 30 #include "FindFunction.h"31 32 #include "ScopedSet.h" 32 33 #include "ScrubTyVars.h" … … 204 205 }; 205 206 206 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable207 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, sizeof expressions of polymorphic types with the proper variable, and strips fields from generic struct declarations. 207 208 class Pass3 final : public PolyMutator { 208 209 public: … … 212 213 using PolyMutator::mutate; 213 214 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 215 virtual Declaration *mutate( StructDecl *structDecl ) override; 216 virtual Declaration *mutate( UnionDecl *unionDecl ) override; 214 217 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 215 218 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override; … … 757 760 assertf( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() ); 758 761 if ( isPolyType( param, exprTyVars ) ) { 759 if ( isPolyType( arg->get_result() ) ) { 762 Type * newType = arg->get_result()->clone(); 763 if ( env ) env->apply( newType ); 764 std::auto_ptr<Type> manager( newType ); 765 if ( isPolyType( newType ) ) { 760 766 // if the argument's type is polymorphic, we don't need to box again! 761 767 return; 762 } else if ( arg->get_result()->get_lvalue() ) { // xxx - is this still right?? 763 // xxx - dynamic_cast<ReferenceType *>( arg->get_result() )?? 764 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 765 // xxx - need to test that this code is still reachable 766 if ( CommaExpr *commaArg = dynamic_cast< CommaExpr* >( arg ) ) { 767 commaArg->set_arg2( new AddressExpr( commaArg->get_arg2() ) ); 768 } else { 769 arg = new AddressExpr( arg ); 770 } 768 } else if ( arg->get_result()->get_lvalue() ) { 769 // argument expression may be CFA lvalue, but not C lvalue -- apply generalizedLvalue transformations. 770 arg = generalizedLvalue( new AddressExpr( arg ) ); 771 771 if ( ! ResolvExpr::typesCompatible( param, arg->get_result(), SymTab::Indexer() ) ) { 772 772 // silence warnings by casting boxed parameters when the actual type does not match up with the formal type. … … 1760 1760 1761 1761 Expression *PolyGenericCalculator::mutate( SizeofExpr *sizeofExpr ) { 1762 Type *ty = sizeofExpr->get_ type();1762 Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result(); 1763 1763 if ( findGeneric( ty ) ) { 1764 1764 Expression *ret = new NameExpr( sizeofName( mangleType( ty ) ) ); … … 1770 1770 1771 1771 Expression *PolyGenericCalculator::mutate( AlignofExpr *alignofExpr ) { 1772 Type *ty = alignofExpr->get_ type();1772 Type *ty = alignofExpr->get_isType() ? alignofExpr->get_type() : alignofExpr->get_expr()->get_result(); 1773 1773 if ( findGeneric( ty ) ) { 1774 1774 Expression *ret = new NameExpr( alignofName( mangleType( ty ) ) ); … … 1880 1880 } 1881 1881 1882 /// Strips the members from a generic aggregate 1883 void stripGenericMembers(AggregateDecl* decl) { 1884 if ( ! decl->get_parameters().empty() ) decl->get_members().clear(); 1885 } 1886 1887 Declaration *Pass3::mutate( StructDecl *structDecl ) { 1888 stripGenericMembers( structDecl ); 1889 return structDecl; 1890 } 1891 1892 Declaration *Pass3::mutate( UnionDecl *unionDecl ) { 1893 stripGenericMembers( unionDecl ); 1894 return unionDecl; 1895 } 1896 1882 1897 TypeDecl * Pass3::mutate( TypeDecl *typeDecl ) { 1883 1898 // Initializer *init = 0;
Note: See TracChangeset
for help on using the changeset viewer.