Changeset 0720e049 for src/GenPoly/Box.cc
- Timestamp:
- Aug 11, 2017, 10:33:37 AM (8 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:
- 54cd58b0
- Parents:
- 3d4b23fa (diff), 59a75cb (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
r3d4b23fa r0720e049 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" … … 202 203 }; 203 204 204 /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable205 /// 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. 205 206 class Pass3 final : public PolyMutator { 206 207 public: … … 210 211 using PolyMutator::mutate; 211 212 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 213 virtual Declaration *mutate( StructDecl *structDecl ) override; 214 virtual Declaration *mutate( UnionDecl *unionDecl ) override; 212 215 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 213 216 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override; … … 753 756 754 757 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 755 assert ( arg->has_result() );758 assertf( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() ); 756 759 if ( isPolyType( param, exprTyVars ) ) { 757 if ( isPolyType( arg->get_result() ) ) { 760 Type * newType = arg->get_result()->clone(); 761 if ( env ) env->apply( newType ); 762 std::auto_ptr<Type> manager( newType ); 763 if ( isPolyType( newType ) ) { 758 764 // if the argument's type is polymorphic, we don't need to box again! 759 765 return; 760 766 } else if ( arg->get_result()->get_lvalue() ) { 761 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 762 // xxx - need to test that this code is still reachable 763 if ( CommaExpr *commaArg = dynamic_cast< CommaExpr* >( arg ) ) { 764 commaArg->set_arg2( new AddressExpr( commaArg->get_arg2() ) ); 765 } else { 766 arg = new AddressExpr( arg ); 767 } 767 // argument expression may be CFA lvalue, but not C lvalue -- apply generalizedLvalue transformations. 768 arg = generalizedLvalue( new AddressExpr( arg ) ); 768 769 if ( ! ResolvExpr::typesCompatible( param, arg->get_result(), SymTab::Indexer() ) ) { 769 770 // silence warnings by casting boxed parameters when the actual type does not match up with the formal type. … … 1748 1749 1749 1750 Expression *PolyGenericCalculator::mutate( SizeofExpr *sizeofExpr ) { 1750 Type *ty = sizeofExpr->get_ type();1751 Type *ty = sizeofExpr->get_isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result(); 1751 1752 if ( findGeneric( ty ) ) { 1752 1753 Expression *ret = new NameExpr( sizeofName( mangleType( ty ) ) ); … … 1758 1759 1759 1760 Expression *PolyGenericCalculator::mutate( AlignofExpr *alignofExpr ) { 1760 Type *ty = alignofExpr->get_ type();1761 Type *ty = alignofExpr->get_isType() ? alignofExpr->get_type() : alignofExpr->get_expr()->get_result(); 1761 1762 if ( findGeneric( ty ) ) { 1762 1763 Expression *ret = new NameExpr( alignofName( mangleType( ty ) ) ); … … 1868 1869 } 1869 1870 1871 /// Strips the members from a generic aggregate 1872 void stripGenericMembers(AggregateDecl* decl) { 1873 if ( ! decl->get_parameters().empty() ) decl->get_members().clear(); 1874 } 1875 1876 Declaration *Pass3::mutate( StructDecl *structDecl ) { 1877 stripGenericMembers( structDecl ); 1878 return structDecl; 1879 } 1880 1881 Declaration *Pass3::mutate( UnionDecl *unionDecl ) { 1882 stripGenericMembers( unionDecl ); 1883 return unionDecl; 1884 } 1885 1870 1886 TypeDecl * Pass3::mutate( TypeDecl *typeDecl ) { 1871 1887 // Initializer *init = 0;
Note:
See TracChangeset
for help on using the changeset viewer.