Changeset 27fefeb6 for src


Ignore:
Timestamp:
Aug 10, 2016, 11:31:24 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
82da9b8
Parents:
321f55d (diff), 72e2ea0 (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.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r321f55d r27fefeb6  
    104104                        Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true );
    105105                        /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value
    106                         Expression *addPolyRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg );
     106                        Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg );
    107107                        Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    108108                        void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars );
     
    661661                                // process polymorphic return value
    662662                                retval = 0;
    663                                 if ( isPolyRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
     663                                if ( isDynRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
    664664                                        retval = functionDecl->get_functionType()->get_returnVals().front();
    665665
     
    868868                }
    869869
    870                 Expression *Pass1::addPolyRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg ) {
     870                Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *dynType, std::list< Expression *>::iterator &arg ) {
    871871                        assert( env );
    872                         Type *concrete = replaceWithConcrete( appExpr, polyType );
     872                        Type *concrete = replaceWithConcrete( appExpr, dynType );
    873873                        // add out-parameter for return value
    874874                        return addRetParam( appExpr, function, concrete, arg );
     
    877877                Expression *Pass1::applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ) {
    878878                        Expression *ret = appExpr;
    879                         if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
     879//                      if ( ! function->get_returnVals().empty() && isPolyType( function->get_returnVals().front()->get_type(), tyVars ) ) {
     880                        if ( isDynRet( function, tyVars ) ) {
    880881                                ret = addRetParam( appExpr, function, function->get_returnVals().front()->get_type(), arg );
    881882                        } // if
     
    968969                        // actually make the adapter type
    969970                        FunctionType *adapter = adaptee->clone();
    970                         if ( ! adapter->get_returnVals().empty() && isPolyType( adapter->get_returnVals().front()->get_type(), tyVars ) ) {
     971//                      if ( ! adapter->get_returnVals().empty() && isPolyType( adapter->get_returnVals().front()->get_type(), tyVars ) ) {
     972                        if ( isDynRet( adapter, tyVars ) ) {
    971973                                makeRetParm( adapter );
    972974                        } // if
     
    10301032                                addAdapterParams( adapteeApp, arg, param, adapterType->get_parameters().end(), realParam, tyVars );
    10311033                                bodyStmt = new ExprStmt( noLabels, adapteeApp );
    1032                         } else if ( isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
     1034//                      } else if ( isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
     1035                        } else if ( isDynType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
    10331036                                // return type T
    10341037                                if ( (*param)->get_name() == "" ) {
     
    12771280                        TyVarMap exprTyVars( (TypeDecl::Kind)-1 );
    12781281                        makeTyVarMap( function, exprTyVars );
    1279                         ReferenceToType *polyRetType = isPolyRet( function );
    1280 
    1281                         if ( polyRetType ) {
    1282                                 ret = addPolyRetParam( appExpr, function, polyRetType, arg );
     1282                        ReferenceToType *dynRetType = isDynRet( function, exprTyVars );
     1283
     1284                        if ( dynRetType ) {
     1285                                ret = addDynRetParam( appExpr, function, dynRetType, arg );
    12831286                        } else if ( needsAdapter( function, scopeTyVars ) ) {
    12841287                                // std::cerr << "needs adapter: ";
     
    12901293                        arg = appExpr->get_args().begin();
    12911294
    1292                         passTypeVars( appExpr, polyRetType, arg, exprTyVars );
     1295                        passTypeVars( appExpr, dynRetType, arg, exprTyVars );
    12931296                        addInferredParams( appExpr, function, arg, exprTyVars );
    12941297
     
    15771580
    15781581                        // move polymorphic return type to parameter list
    1579                         if ( isPolyRet( funcType ) ) {
     1582                        if ( isDynRet( funcType ) ) {
    15801583                                DeclarationWithType *ret = funcType->get_returnVals().front();
    15811584                                ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) );
  • src/GenPoly/GenPoly.cc

    r321f55d r27fefeb6  
    2323
    2424namespace GenPoly {
    25         bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) {
    26                 if ( ! adaptee->get_returnVals().empty() && isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
    27                         return true;
    28                 } // if
    29                 for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) {
    30                         if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) {
    31                                 return true;
    32                         } // if
    33                 } // for
    34                 return false;
    35         }
    36 
    37         ReferenceToType *isPolyRet( FunctionType *function ) {
    38                 if ( ! function->get_returnVals().empty() ) {
    39                         TyVarMap forallTypes( (TypeDecl::Kind)-1 );
    40                         makeTyVarMap( function, forallTypes );
    41                         return (ReferenceToType*)isPolyType( function->get_returnVals().front()->get_type(), forallTypes );
    42                 } // if
    43                 return 0;
    44         }
    45 
    4625        namespace {
    4726                /// Checks a parameter list for polymorphic parameters; will substitute according to env if present
     
    6443                        return false;
    6544                }
     45
     46                /// Checks a parameter list for dynamic-layout parameters from tyVars; will substitute according to env if present
     47                bool hasDynParams( std::list< Expression* >& params, const TyVarMap &tyVars, const TypeSubstitution *env ) {
     48                        for ( std::list< Expression* >::iterator param = params.begin(); param != params.end(); ++param ) {
     49                                TypeExpr *paramType = dynamic_cast< TypeExpr* >( *param );
     50                                assert(paramType && "Aggregate parameters should be type expressions");
     51                                if ( isDynType( paramType->get_type(), tyVars, env ) ) return true;
     52                        }
     53                        return false;
     54                }
    6655        }
    6756
     
    10190                }
    10291                return 0;
     92        }
     93
     94        Type *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
     95                type = replaceTypeInst( type, env );
     96
     97                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
     98                        auto var = tyVars.find( typeInst->get_name() );
     99                        if ( var != tyVars.end() && var->second == TypeDecl::Any ) {
     100                                return type;
     101                        }
     102                } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {
     103                        if ( hasDynParams( structType->get_parameters(), tyVars, env ) ) return type;
     104                } else if ( UnionInstType *unionType = dynamic_cast< UnionInstType* >( type ) ) {
     105                        if ( hasDynParams( unionType->get_parameters(), tyVars, env ) ) return type;
     106                }
     107                return 0;
     108        }
     109
     110        ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &forallTypes ) {
     111                if ( function->get_returnVals().empty() ) return 0;
     112               
     113                return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
     114        }
     115
     116        ReferenceToType *isDynRet( FunctionType *function ) {
     117                if ( function->get_returnVals().empty() ) return 0;
     118
     119                TyVarMap forallTypes( (TypeDecl::Kind)-1 );
     120                makeTyVarMap( function, forallTypes );
     121                return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
     122        }
     123
     124        bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVars ) {
     125//              if ( ! adaptee->get_returnVals().empty() && isPolyType( adaptee->get_returnVals().front()->get_type(), tyVars ) ) {
     126//                      return true;
     127//              } // if
     128                if ( isDynRet( adaptee, tyVars ) ) return true;
     129               
     130                for ( std::list< DeclarationWithType* >::const_iterator innerArg = adaptee->get_parameters().begin(); innerArg != adaptee->get_parameters().end(); ++innerArg ) {
     131//                      if ( isPolyType( (*innerArg)->get_type(), tyVars ) ) {
     132                        if ( isDynType( (*innerArg)->get_type(), tyVars ) ) {
     133                                return true;
     134                        } // if
     135                } // for
     136                return false;
    103137        }
    104138
  • src/GenPoly/GenPoly.h

    r321f55d r27fefeb6  
    3131namespace GenPoly {
    3232        typedef ErasableScopedMap< std::string, TypeDecl::Kind > TyVarMap;
    33        
    34         /// A function needs an adapter if it returns a polymorphic value or if any of its
    35         /// parameters have polymorphic type
    36         bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
    37 
    38         /// true iff function has polymorphic return type
    39         ReferenceToType *isPolyRet( FunctionType *function );
    4033
    4134        /// Replaces a TypeInstType by its referrent in the environment, if applicable
     
    4740        /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
    4841        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
     42
     43        /// returns dynamic-layout type if is dynamic-layout type in tyVars, NULL otherwise; will look up substitution in env if provided
     44        Type *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
     45
     46        /// true iff function has dynamic-layout return type under the given type variable map
     47        ReferenceToType *isDynRet( FunctionType *function, const TyVarMap &tyVars );
     48
     49        /// true iff function has dynamic-layout return type under the type variable map generated from its forall-parameters
     50        ReferenceToType *isDynRet( FunctionType *function );
     51
     52        /// A function needs an adapter if it returns a dynamic-layout value or if any of its parameters have dynamic-layout type
     53        bool needsAdapter( FunctionType *adaptee, const TyVarMap &tyVarr );
    4954
    5055        /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided
  • src/GenPoly/InstantiateGeneric.cc

    r321f55d r27fefeb6  
    2424#include "GenPoly.h"
    2525#include "ScopedMap.h"
     26#include "ScopedSet.h"
    2627
    2728#include "ResolvExpr/typeops.h"
     
    122123                }
    123124        };
     125
     126        /// Possible options for a given specialization of a generic type
     127        enum class genericType {
     128                dtypeStatic,  ///< Concrete instantiation based solely on {d,f}type-to-void conversions
     129                concrete,     ///< Concrete instantiation requiring at least one parameter type
     130                dynamic       ///< No concrete instantiation
     131        };
     132
     133        genericType& operator |= ( genericType& gt, const genericType& ht ) {
     134                switch ( gt ) {
     135                case genericType::dtypeStatic:
     136                        gt = ht;
     137                        break;
     138                case genericType::concrete:
     139                        if ( ht == genericType::dynamic ) { gt = genericType::dynamic; }
     140                        break;
     141                case genericType::dynamic:
     142                        // nothing possible
     143                        break;
     144                }
     145                return gt;
     146        }
    124147       
    125148        /// Mutator pass that replaces concrete instantiations of generic types with actual struct declarations, scoped appropriately
     
    127150                /// Map of (generic type, parameter list) pairs to concrete type instantiations
    128151                InstantiationMap< AggregateDecl, AggregateDecl > instantiations;
     152                /// Set of types which are dtype-only generic (and therefore have static layout)
     153                ScopedSet< AggregateDecl* > dtypeStatics;
    129154                /// Namer for concrete types
    130155                UniqueName typeNamer;
    131156
    132157        public:
    133                 GenericInstantiator() : DeclMutator(), instantiations(), typeNamer("_conc_") {}
     158                GenericInstantiator() : DeclMutator(), instantiations(), dtypeStatics(), typeNamer("_conc_") {}
    134159
    135160                virtual Type* mutate( StructInstType *inst );
     
    147172                /// Wrap instantiation insertion for unions
    148173                void insert( UnionInstType *inst, const std::list< TypeExpr* > &typeSubs, UnionDecl *decl ) { instantiations.insert( inst->get_baseUnion(), typeSubs, decl ); }
     174
     175                /// Strips a dtype-static aggregate decl of its type parameters, marks it as stripped
     176                void stripDtypeParams( AggregateDecl *base, std::list< TypeDecl* >& baseParams, const std::list< TypeExpr* >& typeSubs );
    149177        };
    150178
     
    154182        }
    155183
    156         //////////////////////////////////////// GenericInstantiator //////////////////////////////////////////////////
    157 
    158         /// Possible options for a given specialization of a generic type
    159         enum class genericType {
    160                 dtypeStatic,  ///< Concrete instantiation based solely on {d,f}type-to-void conversions
    161                 concrete,     ///< Concrete instantiation requiring at least one parameter type
    162                 dynamic       ///< No concrete instantiation
    163         };
    164 
    165         genericType& operator |= ( genericType& gt, const genericType& ht ) {
    166                 switch ( gt ) {
    167                 case genericType::dtypeStatic:
    168                         gt = ht;
    169                         break;
    170                 case genericType::concrete:
    171                         if ( ht == genericType::dynamic ) { gt = genericType::dynamic; }
    172                         break;
    173                 case genericType::dynamic:
    174                         // nothing possible
    175                         break;
    176                 }
    177                 return gt;
    178         }
    179 
    180         /// Makes substitutions of params into baseParams; returns true if all parameters substituted for a concrete type
     184        /// Makes substitutions of params into baseParams; returns dtypeStatic if there is a concrete instantiation based only on {d,f}type-to-void conversions,
     185        /// concrete if there is a concrete instantiation requiring at least one parameter type, and dynamic if there is no concrete instantiation
    181186        genericType makeSubstitutions( const std::list< TypeDecl* >& baseParams, const std::list< Expression* >& params, std::list< TypeExpr* >& out ) {
    182187                genericType gt = genericType::dtypeStatic;
     
    223228        }
    224229
     230        /// Substitutes types of members according to baseParams => typeSubs, working in-place
     231        void substituteMembers( std::list< Declaration* >& members, const std::list< TypeDecl* >& baseParams, const std::list< TypeExpr* >& typeSubs ) {
     232                // substitute types into new members
     233                TypeSubstitution subs( baseParams.begin(), baseParams.end(), typeSubs.begin() );
     234                for ( std::list< Declaration* >::iterator member = members.begin(); member != members.end(); ++member ) {
     235                        subs.apply(*member);
     236                }
     237        }
     238
     239        /// Strips the instances's type parameters
     240        void stripInstParams( ReferenceToType *inst ) {
     241                deleteAll( inst->get_parameters() );
     242                inst->get_parameters().clear();
     243        }
     244       
     245        void GenericInstantiator::stripDtypeParams( AggregateDecl *base, std::list< TypeDecl* >& baseParams, const std::list< TypeExpr* >& typeSubs ) {
     246                substituteMembers( base->get_members(), baseParams, typeSubs );
     247
     248                deleteAll( baseParams );
     249                baseParams.clear();
     250               
     251                dtypeStatics.insert( base );
     252        }
     253
    225254        Type* GenericInstantiator::mutate( StructInstType *inst ) {
    226255                // mutate subtypes
     
    231260                // exit early if no need for further mutation
    232261                if ( inst->get_parameters().empty() ) return inst;
     262
     263                // check for an already-instantiatiated dtype-static type
     264                if ( dtypeStatics.find( inst->get_baseStruct() ) != dtypeStatics.end() ) {
     265                        stripInstParams( inst );
     266                        return inst;
     267                }
     268               
     269                // check if type can be concretely instantiated; put substitutions into typeSubs
    233270                assert( inst->get_baseParameters() && "Base struct has parameters" );
    234 
    235                 // check if type can be concretely instantiated; put substitutions into typeSubs
    236271                std::list< TypeExpr* > typeSubs;
    237272                genericType gt = makeSubstitutions( *inst->get_baseParameters(), inst->get_parameters(), typeSubs );
    238273                switch ( gt ) {
    239                 case genericType::dtypeStatic: // TODO strip params off original decl and reuse here
    240                 case genericType::concrete:
    241                 {
     274                case genericType::dtypeStatic:
     275                        stripDtypeParams( inst->get_baseStruct(), *inst->get_baseParameters(), typeSubs );
     276                        stripInstParams( inst );
     277                        break;
     278               
     279                case genericType::concrete: {
    242280                        // make concrete instantiation of generic type
    243281                        StructDecl *concDecl = lookup( inst, typeSubs );
     
    274312                // exit early if no need for further mutation
    275313                if ( inst->get_parameters().empty() ) return inst;
     314
     315                // check for an already-instantiatiated dtype-static type
     316                if ( dtypeStatics.find( inst->get_baseUnion() ) != dtypeStatics.end() ) {
     317                        stripInstParams( inst );
     318                        return inst;
     319                }
     320
     321                // check if type can be concretely instantiated; put substitutions into typeSubs
    276322                assert( inst->get_baseParameters() && "Base union has parameters" );
    277 
    278                 // check if type can be concretely instantiated; put substitutions into typeSubs
    279323                std::list< TypeExpr* > typeSubs;
    280324                genericType gt = makeSubstitutions( *inst->get_baseParameters(), inst->get_parameters(), typeSubs );
    281325                switch ( gt ) {
    282                 case genericType::dtypeStatic:  // TODO strip params off original decls and reuse here
     326                case genericType::dtypeStatic:
     327                        stripDtypeParams( inst->get_baseUnion(), *inst->get_baseParameters(), typeSubs );
     328                        stripInstParams( inst );
     329                        break;
     330                       
    283331                case genericType::concrete:
    284332                {
     
    311359                DeclMutator::doBeginScope();
    312360                instantiations.beginScope();
     361                dtypeStatics.beginScope();
    313362        }
    314363
     
    316365                DeclMutator::doEndScope();
    317366                instantiations.endScope();
     367                dtypeStatics.endScope();
    318368        }
    319369
  • src/GenPoly/ScrubTyVars.cc

    r321f55d r27fefeb6  
    4545
    4646        Type * ScrubTyVars::mutateAggregateType( Type *ty ) {
    47                 if ( isPolyType( ty, tyVars ) ) {
     47                if ( shouldScrub( ty ) ) {
    4848                        PointerType *ret = new PointerType( Type::Qualifiers(), new VoidType( ty->get_qualifiers() ) );
    4949                        delete ty;
     
    6363        Expression * ScrubTyVars::mutate( SizeofExpr *szeof ) {
    6464                // sizeof( T ) => _sizeof_T parameter, which is the size of T
    65                 if ( Type *polyType = isPolyType( szeof->get_type() ) ) {
    66                         Expression *expr = new NameExpr( sizeofName( mangleType( polyType ) ) );
     65                if ( Type *dynType = shouldScrub( szeof->get_type() ) ) {
     66                        Expression *expr = new NameExpr( sizeofName( mangleType( dynType ) ) );
    6767                        return expr;
    6868                } else {
     
    7373        Expression * ScrubTyVars::mutate( AlignofExpr *algnof ) {
    7474                // alignof( T ) => _alignof_T parameter, which is the alignment of T
    75                 if ( Type *polyType = isPolyType( algnof->get_type() ) ) {
    76                         Expression *expr = new NameExpr( alignofName( mangleType( polyType ) ) );
     75                if ( Type *dynType = shouldScrub( algnof->get_type() ) ) {
     76                        Expression *expr = new NameExpr( alignofName( mangleType( dynType ) ) );
    7777                        return expr;
    7878                } else {
     
    8282
    8383        Type * ScrubTyVars::mutate( PointerType *pointer ) {
    84                 if ( Type *polyType = isPolyType( pointer->get_base(), tyVars ) ) {
    85                         Type *ret = polyType->acceptMutator( *this );
     84//              // special case of shouldScrub that takes all TypeInstType pointer bases, even if they're not dynamic
     85//              Type *base = pointer->get_base();
     86//              Type *dynType = 0;
     87//              if ( dynamicOnly ) {
     88//                      if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( base ) ) {
     89//                              if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) { dynType = typeInst; }
     90//                      } else {
     91//                              dynType = isDynType( base, tyVars );
     92//                      }
     93//              } else {
     94//                      dynType = isPolyType( base, tyVars );
     95//              }
     96//              if ( dynType ) {
     97                if ( Type *dynType = shouldScrub( pointer->get_base() ) ) {
     98                        Type *ret = dynType->acceptMutator( *this );
    8699                        ret->get_qualifiers() += pointer->get_qualifiers();
    87100                        pointer->set_base( 0 );
  • src/GenPoly/ScrubTyVars.h

    r321f55d r27fefeb6  
    2727        class ScrubTyVars : public Mutator {
    2828          public:
    29                 ScrubTyVars( const TyVarMap &tyVars ): tyVars( tyVars ) {}
     29                ScrubTyVars( const TyVarMap &tyVars, bool dynamicOnly = false ): tyVars( tyVars ), dynamicOnly( dynamicOnly ) {}
    3030
    3131                /// For all polymorphic types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type,
     
    3333                template< typename SynTreeClass >
    3434                static SynTreeClass *scrub( SynTreeClass *target, const TyVarMap &tyVars );
     35
     36                /// For all dynamic-layout types with type variables in `tyVars`, replaces generic types, dtypes, and ftypes with the appropriate void type,
     37                /// and sizeof/alignof expressions with the proper variable
     38                template< typename SynTreeClass >
     39                static SynTreeClass *scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars );
    3540
    3641                virtual Type* mutate( TypeInstType *typeInst );
     
    4247
    4348          private:
     49                /// Returns the type if it should be scrubbed, NULL otherwise.
     50                Type* shouldScrub( Type *ty ) {
     51                        return dynamicOnly ? isDynType( ty, tyVars ) : isPolyType( ty, tyVars );
     52//                      if ( ! dynamicOnly ) return isPolyType( ty, tyVars );
     53//
     54//                      if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( ty ) ) {
     55//                              return tyVars.find( typeInst->get_name() ) != tyVars.end() ? ty : 0;
     56//                      }
     57//
     58//                      return isDynType( ty, tyVars );
     59                }
     60               
    4461                /// Mutates (possibly generic) aggregate types appropriately
    4562                Type* mutateAggregateType( Type *ty );
    4663               
    47                 const TyVarMap &tyVars;
     64                const TyVarMap &tyVars;  ///< Type variables to scrub
     65                bool dynamicOnly;        ///< only scrub the types with dynamic layout? [false]
    4866        };
    4967
    50         /* static class method */
    5168        template< typename SynTreeClass >
    5269        SynTreeClass * ScrubTyVars::scrub( SynTreeClass *target, const TyVarMap &tyVars ) {
    5370                ScrubTyVars scrubber( tyVars );
     71                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
     72        }
     73
     74        template< typename SynTreeClass >
     75        SynTreeClass * ScrubTyVars::scrubDynamic( SynTreeClass *target, const TyVarMap &tyVars ) {
     76                ScrubTyVars scrubber( tyVars, true );
    5477                return static_cast< SynTreeClass * >( target->acceptMutator( scrubber ) );
    5578        }
  • src/SymTab/Autogen.cc

    r321f55d r27fefeb6  
    174174
    175175        void makeStructMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, TypeSubstitution & genericSubs, bool isDynamicLayout, bool forward = true ) {
    176                 if ( isDynamicLayout && src ) {
    177                         genericSubs.apply( src );
    178                 }
     176//              if ( isDynamicLayout && src ) {
     177//                      genericSubs.apply( src );
     178//              }
    179179
    180180                ObjectDecl * returnVal = NULL;
  • src/examples/gc_no_raii/src/gc.h

    r321f55d r27fefeb6  
    77static inline gcpointer(T) gcmalloc()
    88{
    9     gcpointer(T) ptr;
    10     void* address = gc_allocate(sizeof(T));
    11     (&ptr){ address };
    12     ctor(&ptr, address);
     9    gcpointer(T) ptr = { gc_allocate(sizeof(T)) };
     10    ptr{};
    1311    gc_conditional_collect();
    1412    return ptr;
    1513}
     14
     15forall(otype T)
     16static inline void gcmalloc(gcpointer(T)* ptr)
     17{
     18        ptr{ gc_allocate(sizeof(T)) };
     19      (*ptr){};
     20      gc_conditional_collect();
     21}
  • src/examples/gc_no_raii/test/gctest.c

    r321f55d r27fefeb6  
    88        sout | "Bonjour au monde!\n";
    99
    10         gcpointer(int) anInt = gcmalloc();
     10        for(int i = 0; i < 1000000; i++) {
     11                gcpointer(int) anInt;
     12                gcmalloc(&anInt);
     13        }
    1114}
Note: See TracChangeset for help on using the changeset viewer.