Changes in src/GenPoly/Box.cc [acd7c5dd:2a7b3ca]
- File:
-
- 1 edited
-
src/GenPoly/Box.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
racd7c5dd r2a7b3ca 27 27 #include "Box.h" 28 28 #include "DeclMutator.h" 29 #include " Lvalue.h"29 #include "PolyMutator.h" 30 30 #include "FindFunction.h" 31 #include "PolyMutator.h"32 31 #include "ScopedSet.h" 33 32 #include "ScrubTyVars.h" … … 203 202 }; 204 203 205 /// 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.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 variable 206 205 class Pass3 final : public PolyMutator { 207 206 public: … … 211 210 using PolyMutator::mutate; 212 211 virtual DeclarationWithType *mutate( FunctionDecl *functionDecl ) override; 213 virtual Declaration *mutate( StructDecl *structDecl ) override;214 virtual Declaration *mutate( UnionDecl *unionDecl ) override;215 212 virtual ObjectDecl *mutate( ObjectDecl *objectDecl ) override; 216 213 virtual TypedefDecl *mutate( TypedefDecl *objectDecl ) override; … … 756 753 757 754 void Pass1::boxParam( Type *param, Expression *&arg, const TyVarMap &exprTyVars ) { 758 assert f( arg->has_result(), "arg does not have result: %s", toString( arg ).c_str() );755 assert( arg->has_result() ); 759 756 if ( isPolyType( param, exprTyVars ) ) { 760 Type * newType = arg->get_result()->clone(); 761 if ( env ) env->apply( newType ); 762 std::auto_ptr<Type> manager( newType ); 763 if ( isPolyType( newType ) ) { 757 if ( isPolyType( arg->get_result() ) ) { 764 758 // if the argument's type is polymorphic, we don't need to box again! 765 759 return; 766 760 } else if ( arg->get_result()->get_lvalue() ) { 767 // argument expression may be CFA lvalue, but not C lvalue -- apply generalizedLvalue transformations. 768 arg = generalizedLvalue( new AddressExpr( arg ) ); 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 } 769 768 if ( ! ResolvExpr::typesCompatible( param, arg->get_result(), SymTab::Indexer() ) ) { 770 769 // silence warnings by casting boxed parameters when the actual type does not match up with the formal type. … … 1749 1748 1750 1749 Expression *PolyGenericCalculator::mutate( SizeofExpr *sizeofExpr ) { 1751 Type *ty = sizeofExpr->get_ isType() ? sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result();1750 Type *ty = sizeofExpr->get_type(); 1752 1751 if ( findGeneric( ty ) ) { 1753 1752 Expression *ret = new NameExpr( sizeofName( mangleType( ty ) ) ); … … 1759 1758 1760 1759 Expression *PolyGenericCalculator::mutate( AlignofExpr *alignofExpr ) { 1761 Type *ty = alignofExpr->get_ isType() ? alignofExpr->get_type() : alignofExpr->get_expr()->get_result();1760 Type *ty = alignofExpr->get_type(); 1762 1761 if ( findGeneric( ty ) ) { 1763 1762 Expression *ret = new NameExpr( alignofName( mangleType( ty ) ) ); … … 1869 1868 } 1870 1869 1871 /// Strips the members from a generic aggregate1872 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 1886 1870 TypeDecl * Pass3::mutate( TypeDecl *typeDecl ) { 1887 1871 // Initializer *init = 0;
Note:
See TracChangeset
for help on using the changeset viewer.