Changes in / [7bb6bd8:3c1fa71]
- Location:
- src
- Files:
-
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r7bb6bd8 r3c1fa71 4 4 5 5 #include <stack> 6 #include <type_traits>7 6 8 7 #include "Common/Stats.h" … … 302 301 303 302 304 auto get_env_ptr () -> decltype(env_impl( pass, 0)) { return env_impl( pass, 0); }303 TypeSubstitution ** get_env_ptr () { return env_impl ( pass, 0); } 305 304 std::list< Statement* > * get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); } 306 305 std::list< Statement* > * get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); } … … 349 348 }; 350 349 351 class WithConstTypeSubstitution {352 protected:353 WithConstTypeSubstitution() = default;354 ~WithConstTypeSubstitution() = default;355 356 public:357 const TypeSubstitution * env = nullptr;358 };359 360 350 class WithStmtsToAdd { 361 351 protected: -
src/Common/PassVisitor.impl.h
r7bb6bd8 r3c1fa71 253 253 254 254 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 255 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );255 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr () ); 256 256 ValueGuardPtr< DeclList_t > oldBeforeDecls( get_beforeDecls() ); 257 257 ValueGuardPtr< DeclList_t > oldAfterDecls ( get_afterDecls () ); … … 1995 1995 1996 1996 // don't want statements from outer CompoundStmts to be added to this StmtExpr 1997 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );1997 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 1998 1998 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 1999 1999 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); … … 2012 2012 2013 2013 // don't want statements from outer CompoundStmts to be added to this StmtExpr 2014 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > oldEnv( get_env_ptr() );2014 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() ); 2015 2015 ValueGuardPtr< std::list< Statement* > > oldBeforeStmts( get_beforeStmts() ); 2016 2016 ValueGuardPtr< std::list< Statement* > > oldAfterStmts ( get_afterStmts () ); -
src/Common/PassVisitor.proto.h
r7bb6bd8 r3c1fa71 165 165 static inline type * name##_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) long unused ) { return nullptr;} \ 166 166 167 FIELD_PTR( constTypeSubstitution *, env )167 FIELD_PTR( TypeSubstitution *, env ) 168 168 FIELD_PTR( std::list< Statement* >, stmtsToAddBefore ) 169 169 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) -
src/GenPoly/Box.cc
r7bb6bd8 r3c1fa71 76 76 77 77 /// 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 78 class Pass1 final : public BoxPass, public With ConstTypeSubstitution, public WithStmtsToAdd, public WithGuards, public WithVisitorRef<Pass1>, public WithShortCircuiting {78 class Pass1 final : public BoxPass, public WithTypeSubstitution, public WithStmtsToAdd, public WithGuards, public WithVisitorRef<Pass1>, public WithShortCircuiting { 79 79 public: 80 80 Pass1(); … … 150 150 /// * Calculates polymorphic offsetof expressions from offset array 151 151 /// * Inserts dynamic calculation of polymorphic type layouts where needed 152 class PolyGenericCalculator final : public BoxPass, public WithGuards, public WithVisitorRef<PolyGenericCalculator>, public WithStmtsToAdd, public WithDeclsToAdd, public With ConstTypeSubstitution {152 class PolyGenericCalculator final : public BoxPass, public WithGuards, public WithVisitorRef<PolyGenericCalculator>, public WithStmtsToAdd, public WithDeclsToAdd, public WithTypeSubstitution { 153 153 public: 154 154 PolyGenericCalculator(); … … 1764 1764 1765 1765 Expression *PolyGenericCalculator::postmutate( SizeofExpr *sizeofExpr ) { 1766 Type *ty = sizeofExpr->get_isType() ? 1766 Type *ty = sizeofExpr->get_isType() ? 1767 1767 sizeofExpr->get_type() : sizeofExpr->get_expr()->get_result(); 1768 1768 1769 1769 Expression * gen = genSizeof( ty ); 1770 1770 if ( gen ) { -
src/GenPoly/GenPoly.cc
r7bb6bd8 r3c1fa71 440 440 } 441 441 442 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, constTypeSubstitution * env ) {442 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, TypeSubstitution * env ) { 443 443 // is parameter is not polymorphic, don't need to box 444 444 if ( ! isPolyType( param, exprTyVars ) ) return false; … … 450 450 } 451 451 452 bool needsBoxing( Type * param, Type * arg, ApplicationExpr * appExpr, constTypeSubstitution * env ) {452 bool needsBoxing( Type * param, Type * arg, ApplicationExpr * appExpr, TypeSubstitution * env ) { 453 453 FunctionType * function = getFunctionType( appExpr->function->result ); 454 454 assertf( function, "ApplicationExpr has non-function type: %s", toString( appExpr->function->result ).c_str() ); -
src/GenPoly/GenPoly.h
r7bb6bd8 r3c1fa71 81 81 82 82 /// true if arg requires boxing given exprTyVars 83 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, constTypeSubstitution * env );83 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, TypeSubstitution * env ); 84 84 85 85 /// true if arg requires boxing in the call to appExpr 86 bool needsBoxing( Type * param, Type * arg, ApplicationExpr * appExpr, constTypeSubstitution * env );86 bool needsBoxing( Type * param, Type * arg, ApplicationExpr * appExpr, TypeSubstitution * env ); 87 87 88 88 /// Adds the type variable `tyVar` to `tyVarMap` -
src/GenPoly/InstantiateGeneric.cc
r7bb6bd8 r3c1fa71 168 168 169 169 /// Mutator pass that replaces concrete instantiations of generic types with actual struct declarations, scoped appropriately 170 struct GenericInstantiator final : public With ConstTypeSubstitution, public WithDeclsToAdd, public WithVisitorRef<GenericInstantiator>, public WithGuards {170 struct GenericInstantiator final : public WithTypeSubstitution, public WithDeclsToAdd, public WithVisitorRef<GenericInstantiator>, public WithGuards { 171 171 /// Map of (generic type, parameter list) pairs to concrete type instantiations 172 172 InstantiationMap< AggregateDecl, AggregateDecl > instantiations; -
src/GenPoly/Specialize.cc
r7bb6bd8 r3c1fa71 42 42 43 43 namespace GenPoly { 44 struct Specialize final : public With ConstTypeSubstitution, public WithStmtsToAdd, public WithVisitorRef<Specialize> {44 struct Specialize final : public WithTypeSubstitution, public WithStmtsToAdd, public WithVisitorRef<Specialize> { 45 45 Expression * postmutate( ApplicationExpr *applicationExpr ); 46 46 Expression * postmutate( CastExpr *castExpr ); … … 54 54 55 55 /// Looks up open variables in actual type, returning true if any of them are bound in the environment or formal type. 56 bool needsPolySpecialization( Type *formalType, Type *actualType, constTypeSubstitution *env ) {56 bool needsPolySpecialization( Type *formalType, Type *actualType, TypeSubstitution *env ) { 57 57 if ( env ) { 58 58 using namespace ResolvExpr; … … 145 145 } 146 146 147 bool needsSpecialization( Type *formalType, Type *actualType, constTypeSubstitution *env ) {147 bool needsSpecialization( Type *formalType, Type *actualType, TypeSubstitution *env ) { 148 148 return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType ); 149 149 } -
src/InitTweak/FixInit.cc
r7bb6bd8 r3c1fa71 72 72 }; 73 73 74 struct InsertImplicitCalls : public With ConstTypeSubstitution {74 struct InsertImplicitCalls : public WithTypeSubstitution { 75 75 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which 76 76 /// function calls need their parameters to be copy constructed … … 187 187 }; 188 188 189 class FixCopyCtors final : public WithStmtsToAdd, public WithShortCircuiting, public WithVisitorRef<FixCopyCtors>, public With ConstTypeSubstitution {189 class FixCopyCtors final : public WithStmtsToAdd, public WithShortCircuiting, public WithVisitorRef<FixCopyCtors>, public WithTypeSubstitution { 190 190 public: 191 191 FixCopyCtors( UnqCount & unqCount ) : unqCount( unqCount ){} -
src/SynTree/TypeSubstitution.cc
r7bb6bd8 r3c1fa71 108 108 namespace { 109 109 struct EnvTrimmer { 110 const TypeSubstitution * env; 111 TypeSubstitution * newEnv; 112 EnvTrimmer( const TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){} 110 TypeSubstitution * env, * newEnv; 111 EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){} 113 112 void previsit( TypeDecl * tyDecl ) { 114 113 // transfer known bindings for seen type variables … … 121 120 122 121 /// reduce environment to just the parts that are referenced in a given expression 123 TypeSubstitution * TypeSubstitution::newFromExpr( Expression * expr, constTypeSubstitution * env ) {122 TypeSubstitution * TypeSubstitution::newFromExpr( Expression * expr, TypeSubstitution * env ) { 124 123 if ( env ) { 125 124 TypeSubstitution * newEnv = new TypeSubstitution(); -
src/SynTree/TypeSubstitution.h
r7bb6bd8 r3c1fa71 39 39 TypeSubstitution &operator=( const TypeSubstitution &other ); 40 40 41 template< typename SynTreeClass > int apply( SynTreeClass *&input ) const;42 template< typename SynTreeClass > int applyFree( SynTreeClass *&input ) const;41 template< typename SynTreeClass > int apply( SynTreeClass *&input ); 42 template< typename SynTreeClass > int applyFree( SynTreeClass *&input ); 43 43 44 44 void add( std::string formalType, Type *actualType ); … … 56 56 57 57 /// create a new TypeSubstitution using bindings from env containing all of the type variables in expr 58 static TypeSubstitution * newFromExpr( Expression * expr, constTypeSubstitution * env );58 static TypeSubstitution * newFromExpr( Expression * expr, TypeSubstitution * env ); 59 59 60 60 void normalize(); … … 130 130 // definitition must happen after PassVisitor is included so that WithGuards can be used 131 131 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter> { 132 Substituter( constTypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}132 Substituter( TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {} 133 133 134 134 Type * postmutate( TypeInstType * aggregateUseType ); … … 143 143 void premutate( UnionInstType * aggregateUseType ); 144 144 145 constTypeSubstitution & sub;145 TypeSubstitution & sub; 146 146 int subCount = 0; 147 147 bool freeOnly; … … 151 151 152 152 template< typename SynTreeClass > 153 int TypeSubstitution::apply( SynTreeClass *&input ) const{153 int TypeSubstitution::apply( SynTreeClass *&input ) { 154 154 assert( input ); 155 155 PassVisitor<Substituter> sub( *this, false ); … … 163 163 164 164 template< typename SynTreeClass > 165 int TypeSubstitution::applyFree( SynTreeClass *&input ) const{165 int TypeSubstitution::applyFree( SynTreeClass *&input ) { 166 166 assert( input ); 167 167 PassVisitor<Substituter> sub( *this, true ); -
src/Tuples/TupleExpansion.cc
r7bb6bd8 r3c1fa71 58 58 }; 59 59 60 struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public With ConstTypeSubstitution {60 struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public WithTypeSubstitution { 61 61 Type * postmutate( TupleType * tupleType ); 62 62 -
src/main.cc
r7bb6bd8 r3c1fa71 446 446 }; // description 447 447 448 static_assert( sizeof( long_opts ) / sizeof( long_opts[0] ) - 1 == sizeof( description ) / sizeof( description[0] ) , "Long opts and description must match");448 static_assert( sizeof( long_opts ) / sizeof( long_opts[0] ) - 1 == sizeof( description ) / sizeof( description[0] ) ); 449 449 450 450 static struct Printopts {
Note: See TracChangeset
for help on using the changeset viewer.