Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rf2b2029 rf8b961b  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Dec 02 11:52:37 2015
    13 // Update Count     : 201
     12// Last Modified On : Thu Nov 26 17:01:55 2015
     13// Update Count     : 191
    1414//
    1515
     
    5050                FunctionType *makeAdapterType( FunctionType *adaptee, const TyVarMap &tyVars );
    5151
     52                /// Replaces polymorphic return types with out-parameters, replaces calls to polymorphic functions with adapter calls as needed, and adds appropriate type variables to the function call
    5253                class Pass1 : public PolyMutator {
    5354                  public:
     
    8889                };
    8990
     91                /// Moves polymorphic returns in function types to pointer-type parameters, adds type size and assertion parameters to parameter lists as well
    9092                class Pass2 : public PolyMutator {
    9193                  public:
     
    105107                };
    106108
     109                /// 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
    107110                class Pass3 : public PolyMutator {
    108111                  public:
     
    183186                }
    184187
    185                 // returns true if the given declaration is: (*?=?)(T *, T) for some T (return not checked, but maybe should be)
    186188                bool checkAssignment( DeclarationWithType *decl, std::string &name ) {
    187189                        if ( decl->get_name() == "?=?" ) {
     
    669671                                                TypeInstType *typeInst1 = isPolyPtr( appExpr->get_args().front()->get_results().front(), env, scopeTyVars );
    670672                                                TypeInstType *typeInst2 = isPolyPtr( appExpr->get_args().back()->get_results().front(), env, scopeTyVars );
    671                                                 assert( ! typeInst1 || ! typeInst2 );  // the arguments cannot both be polymorphic pointers
     673                                                assert( ! typeInst1 || ! typeInst2 );
    672674                                                UntypedExpr *ret = 0;
    673                                                 if ( typeInst1 || typeInst2 ) { // one of the arguments is a polymorphic pointer
     675                                                if ( typeInst1 || typeInst2 ) {
    674676                                                        ret = new UntypedExpr( new NameExpr( "?+?" ) );
    675677                                                } // if
     
    867869
    868870                Statement * Pass1::mutate(ReturnStmt *retStmt) {
    869                         // by this point, a cast expr on a polymorphic return value is redundant
     871                        // a cast expr on a polymorphic return value is either redundant or invalid
    870872                        while ( CastExpr *castExpr = dynamic_cast< CastExpr *>( retStmt->get_expr() ) ) {
    871873                                retStmt->set_expr( castExpr->get_arg() );
     
    10091011                        std::list< DeclarationWithType *> inferredParams;
    10101012                        ObjectDecl *newObj = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0 );
    1011 ///   ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 );
     1013//   ObjectDecl *newFunPtr = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) ), 0 );
    10121014                        for ( std::list< TypeDecl *>::const_iterator tyParm = funcType->get_forall().begin(); tyParm != funcType->get_forall().end(); ++tyParm ) {
    10131015                                ObjectDecl *thisParm;
     
    10211023                                // move all assertions into parameter list
    10221024                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyParm)->get_assertions().begin(); assert != (*tyParm)->get_assertions().end(); ++assert ) {
    1023 ///      *assert = (*assert)->acceptMutator( *this );
     1025//      *assert = (*assert)->acceptMutator( *this );
    10241026                                        inferredParams.push_back( *assert );
    10251027                                }
     
    10631065
    10641066                TypeDecl * Pass3::mutate( TypeDecl *typeDecl ) {
    1065 ///   Initializer *init = 0;
    1066 ///   std::list< Expression *> designators;
    1067 ///   scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    1068 ///   if ( typeDecl->get_base() ) {
    1069 ///     init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators );
    1070 ///   }
    1071 ///   return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init );
     1067//   Initializer *init = 0;
     1068//   std::list< Expression *> designators;
     1069//   scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
     1070//   if ( typeDecl->get_base() ) {
     1071//     init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators );
     1072//   }
     1073//   return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init );
    10721074
    10731075                        scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
Note: See TracChangeset for help on using the changeset viewer.