Changeset 78dd0da for src/GenPoly
- Timestamp:
- Dec 15, 2015, 2:56:43 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 4389966, ffad73a
- Parents:
- 5e92fee
- Location:
- src/GenPoly
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r5e92fee r78dd0da 640 640 } 641 641 642 Expression *makeIncrDecrExpr( ApplicationExpr *appExpr, std::string polyName, bool isIncr ) {642 Expression *makeIncrDecrExpr( ApplicationExpr *appExpr, Type *polyType, bool isIncr ) { 643 643 NameExpr *opExpr; 644 644 if ( isIncr ) { … … 653 653 addAssign->get_args().push_back( appExpr->get_args().front() ); 654 654 } // if 655 addAssign->get_args().push_back( new NameExpr( s td::string("_sizeof_") + polyName) );655 addAssign->get_args().push_back( new NameExpr( sizeofName( polyType ) ) ); 656 656 addAssign->get_results().front() = appExpr->get_results().front()->clone(); 657 657 if ( appExpr->get_env() ) { … … 680 680 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); 681 681 multiply->get_args().push_back( appExpr->get_args().back() ); 682 multiply->get_args().push_back( new NameExpr( s td::string("_sizeof_") + typeInst1->get_name() ) );682 multiply->get_args().push_back( new NameExpr( sizeofName( typeInst1 ) ) ); 683 683 ret->get_args().push_back( appExpr->get_args().front() ); 684 684 ret->get_args().push_back( multiply ); … … 686 686 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); 687 687 multiply->get_args().push_back( appExpr->get_args().front() ); 688 multiply->get_args().push_back( new NameExpr( s td::string("_sizeof_") + typeInst2->get_name() ) );688 multiply->get_args().push_back( new NameExpr( sizeofName( typeInst2 ) ) ); 689 689 ret->get_args().push_back( multiply ); 690 690 ret->get_args().push_back( appExpr->get_args().back() ); … … 732 732 assignExpr->get_args().push_back( appExpr->get_args().front()->clone() ); 733 733 } // if 734 CommaExpr *firstComma = new CommaExpr( assignExpr, makeIncrDecrExpr( appExpr, typeInst ->get_name(), varExpr->get_var()->get_name() == "?++" ) );734 CommaExpr *firstComma = new CommaExpr( assignExpr, makeIncrDecrExpr( appExpr, typeInst, varExpr->get_var()->get_name() == "?++" ) ); 735 735 return new CommaExpr( firstComma, tempExpr ); 736 736 } // if … … 739 739 assert( appExpr->get_args().size() == 1 ); 740 740 if ( TypeInstType *typeInst = isPolyPtr( appExpr->get_results().front(), env, scopeTyVars ) ) { 741 return makeIncrDecrExpr( appExpr, typeInst ->get_name(), varExpr->get_var()->get_name() == "++?" );741 return makeIncrDecrExpr( appExpr, typeInst, varExpr->get_var()->get_name() == "++?" ); 742 742 } // if 743 743 } else if ( varExpr->get_var()->get_name() == "?+?" || varExpr->get_var()->get_name() == "?-?" ) { … … 749 749 UntypedExpr *divide = new UntypedExpr( new NameExpr( "?/?" ) ); 750 750 divide->get_args().push_back( appExpr ); 751 divide->get_args().push_back( new NameExpr( s td::string("_sizeof_") + typeInst1->get_name() ) );751 divide->get_args().push_back( new NameExpr( sizeofName( typeInst1 ) ) ); 752 752 divide->get_results().push_front( appExpr->get_results().front()->clone() ); 753 753 if ( appExpr->get_env() ) { … … 759 759 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); 760 760 multiply->get_args().push_back( appExpr->get_args().back() ); 761 multiply->get_args().push_back( new NameExpr( s td::string("_sizeof_") + typeInst1->get_name() ) );761 multiply->get_args().push_back( new NameExpr( sizeofName( typeInst1 ) ) ); 762 762 appExpr->get_args().back() = multiply; 763 763 } else if ( typeInst2 ) { 764 764 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); 765 765 multiply->get_args().push_back( appExpr->get_args().front() ); 766 multiply->get_args().push_back( new NameExpr( s td::string("_sizeof_") + typeInst2->get_name() ) );766 multiply->get_args().push_back( new NameExpr( sizeofName( typeInst2 ) ) ); 767 767 appExpr->get_args().front() = multiply; 768 768 } // if … … 774 774 UntypedExpr *multiply = new UntypedExpr( new NameExpr( "?*?" ) ); 775 775 multiply->get_args().push_back( appExpr->get_args().back() ); 776 multiply->get_args().push_back( new NameExpr( s td::string("_sizeof_") + typeInst->get_name() ) );776 multiply->get_args().push_back( new NameExpr( sizeofName( typeInst ) ) ); 777 777 appExpr->get_args().back() = multiply; 778 778 } // if … … 1009 1009 std::list< DeclarationWithType *>::iterator last = funcType->get_parameters().begin(); 1010 1010 std::list< DeclarationWithType *> inferredParams; 1011 ObjectDecl *newObj = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );1011 ObjectDecl newObj( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 ); 1012 1012 // ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 ); 1013 1013 for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) { … … 1015 1015 // add all size and alignment parameters to parameter list 1016 1016 if ( (*tyParm)->get_kind() == TypeDecl::Any ) { 1017 sizeParm = newObj->clone(); 1018 sizeParm->set_name( std::string("_sizeof_") + (*tyParm)->get_name() ); 1017 TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm ); 1018 1019 sizeParm = newObj.clone(); 1020 sizeParm->set_name( sizeofName( &parmType ) ); 1019 1021 last = funcType->get_parameters().insert( last, sizeParm ); 1020 1022 ++last; 1021 alignParm = newObj->clone(); 1022 alignParm->set_name( std::string("_alignof_") + (*tyParm)->get_name() ); 1023 1024 alignParm = newObj.clone(); 1025 alignParm->set_name( alignofName( &parmType ) ); 1023 1026 last = funcType->get_parameters().insert( last, alignParm ); 1024 1027 ++last; … … 1031 1034 (*tyParm)->get_assertions().clear(); 1032 1035 } 1033 delete newObj;1034 1036 funcType->get_parameters().splice( last, inferredParams ); 1035 1037 addAdapters( funcType ); … … 1108 1110 assert( typeInst ); 1109 1111 UntypedExpr *alloc = new UntypedExpr( new NameExpr( "__builtin_alloca" ) ); 1110 alloc->get_args().push_back( new NameExpr( s td::string("_sizeof_") + typeInst->get_name() ) );1112 alloc->get_args().push_back( new NameExpr( sizeofName( typeInst ) ) ); 1111 1113 1112 1114 delete objectDecl->get_init(); -
src/GenPoly/ScrubTyVars.cc
r5e92fee r78dd0da 14 14 // 15 15 16 #include <sstream> 16 17 #include <string> 17 18 18 19 #include "GenPoly.h" 19 20 #include "ScrubTyVars.h" 21 22 #include "SymTab/Mangler.h" 20 23 21 24 #include "SynTree/Mutator.h" … … 46 49 // sizeof( T ) => _sizeof_T parameter, which is the size of T 47 50 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( szeof->get_type() ) ) { 48 Expression *expr = new NameExpr( s td::string("_sizeof_") + typeInst->get_name() );51 Expression *expr = new NameExpr( sizeofName( typeInst ) ); 49 52 return expr; 50 53 } else { … … 56 59 // alignof( T ) => _alignof_T parameter, which is the alignment of T 57 60 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( algnof->get_type() ) ) { 58 Expression *expr = new NameExpr( std::string("_alignof_") + typeInst->get_name() );61 Expression *expr = new NameExpr( alignofName( typeInst ) ); 59 62 return expr; 60 63 } else { … … 75 78 return Mutator::mutate( pointer ); 76 79 } 80 81 std::string sizeofName( Type *ty ) { 82 return std::string( "_sizeof_" ) + SymTab::Mangler::mangle( ty, false, false ); 83 } 84 85 std::string alignofName( Type *ty ) { 86 return std::string( "_alignof_" ) + SymTab::Mangler::mangle( ty, false, false ); 87 } 77 88 } // namespace GenPoly 78 89 -
src/GenPoly/ScrubTyVars.h
r5e92fee r78dd0da 16 16 #ifndef _SCRUBTYVARS_H 17 17 #define _SCRUBTYVARS_H 18 19 #include <string> 18 20 19 21 #include "GenPoly.h" … … 57 59 return static_cast< SynTreeClass* >( target->acceptMutator( scrubber ) ); 58 60 } 61 62 /// Gets the name of the sizeof parameter for the type 63 std::string sizeofName( Type *ty ); 64 65 /// Gets the name of the alignof parameter for the type 66 std::string alignofName( Type *ty ); 59 67 } // namespace GenPoly 60 68
Note: See TracChangeset
for help on using the changeset viewer.