Changeset 7bb6bd8
- Timestamp:
- May 8, 2019, 1:38:55 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2ed1d50
- Parents:
- 3c1fa71 (diff), b1d3ee1 (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. - Location:
- src
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.h
r3c1fa71 r7bb6bd8 4 4 5 5 #include <stack> 6 #include <type_traits> 6 7 7 8 #include "Common/Stats.h" … … 301 302 302 303 303 TypeSubstitution ** get_env_ptr () { return env_impl( pass, 0); }304 auto get_env_ptr () -> decltype(env_impl( pass, 0)) { return env_impl( pass, 0); } 304 305 std::list< Statement* > * get_beforeStmts() { return stmtsToAddBefore_impl( pass, 0); } 305 306 std::list< Statement* > * get_afterStmts () { return stmtsToAddAfter_impl ( pass, 0); } … … 348 349 }; 349 350 351 class WithConstTypeSubstitution { 352 protected: 353 WithConstTypeSubstitution() = default; 354 ~WithConstTypeSubstitution() = default; 355 356 public: 357 const TypeSubstitution * env = nullptr; 358 }; 359 350 360 class WithStmtsToAdd { 351 361 protected: -
src/Common/PassVisitor.impl.h
r3c1fa71 r7bb6bd8 253 253 254 254 // don't want statements from outer CompoundStmts to be added to this CompoundStmt 255 ValueGuardPtr< TypeSubstitution * > oldEnv ( get_env_ptr() );255 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > 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< TypeSubstitution * > oldEnv( get_env_ptr() );1997 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > 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< TypeSubstitution * > oldEnv( get_env_ptr() );2014 ValueGuardPtr< typename std::remove_pointer<decltype(get_env_ptr())>::type > 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
r3c1fa71 r7bb6bd8 165 165 static inline type * name##_impl( __attribute__((unused)) pass_type& pass, __attribute__((unused)) long unused ) { return nullptr;} \ 166 166 167 FIELD_PTR( TypeSubstitution *, env )167 FIELD_PTR( const TypeSubstitution *, env ) 168 168 FIELD_PTR( std::list< Statement* >, stmtsToAddBefore ) 169 169 FIELD_PTR( std::list< Statement* >, stmtsToAddAfter ) -
src/GenPoly/Box.cc
r3c1fa71 r7bb6bd8 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 TypeSubstitution, public WithStmtsToAdd, public WithGuards, public WithVisitorRef<Pass1>, public WithShortCircuiting {78 class Pass1 final : public BoxPass, public WithConstTypeSubstitution, 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 TypeSubstitution {152 class PolyGenericCalculator final : public BoxPass, public WithGuards, public WithVisitorRef<PolyGenericCalculator>, public WithStmtsToAdd, public WithDeclsToAdd, public WithConstTypeSubstitution { 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
r3c1fa71 r7bb6bd8 440 440 } 441 441 442 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, TypeSubstitution * env ) {442 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, const 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, TypeSubstitution * env ) {452 bool needsBoxing( Type * param, Type * arg, ApplicationExpr * appExpr, const 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
r3c1fa71 r7bb6bd8 81 81 82 82 /// true if arg requires boxing given exprTyVars 83 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, TypeSubstitution * env );83 bool needsBoxing( Type * param, Type * arg, const TyVarMap &exprTyVars, const 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, TypeSubstitution * env );86 bool needsBoxing( Type * param, Type * arg, ApplicationExpr * appExpr, const TypeSubstitution * env ); 87 87 88 88 /// Adds the type variable `tyVar` to `tyVarMap` -
src/GenPoly/InstantiateGeneric.cc
r3c1fa71 r7bb6bd8 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 TypeSubstitution, public WithDeclsToAdd, public WithVisitorRef<GenericInstantiator>, public WithGuards {170 struct GenericInstantiator final : public WithConstTypeSubstitution, 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
r3c1fa71 r7bb6bd8 42 42 43 43 namespace GenPoly { 44 struct Specialize final : public With TypeSubstitution, public WithStmtsToAdd, public WithVisitorRef<Specialize> {44 struct Specialize final : public WithConstTypeSubstitution, 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, TypeSubstitution *env ) {56 bool needsPolySpecialization( Type *formalType, Type *actualType, const TypeSubstitution *env ) { 57 57 if ( env ) { 58 58 using namespace ResolvExpr; … … 145 145 } 146 146 147 bool needsSpecialization( Type *formalType, Type *actualType, TypeSubstitution *env ) {147 bool needsSpecialization( Type *formalType, Type *actualType, const TypeSubstitution *env ) { 148 148 return needsPolySpecialization( formalType, actualType, env ) || needsTupleSpecialization( formalType, actualType ); 149 149 } -
src/InitTweak/FixInit.cc
r3c1fa71 r7bb6bd8 72 72 }; 73 73 74 struct InsertImplicitCalls : public With TypeSubstitution {74 struct InsertImplicitCalls : public WithConstTypeSubstitution { 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 TypeSubstitution {189 class FixCopyCtors final : public WithStmtsToAdd, public WithShortCircuiting, public WithVisitorRef<FixCopyCtors>, public WithConstTypeSubstitution { 190 190 public: 191 191 FixCopyCtors( UnqCount & unqCount ) : unqCount( unqCount ){} -
src/SynTree/TypeSubstitution.cc
r3c1fa71 r7bb6bd8 108 108 namespace { 109 109 struct EnvTrimmer { 110 TypeSubstitution * env, * newEnv; 111 EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){} 110 const TypeSubstitution * env; 111 TypeSubstitution * newEnv; 112 EnvTrimmer( const TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){} 112 113 void previsit( TypeDecl * tyDecl ) { 113 114 // transfer known bindings for seen type variables … … 120 121 121 122 /// reduce environment to just the parts that are referenced in a given expression 122 TypeSubstitution * TypeSubstitution::newFromExpr( Expression * expr, TypeSubstitution * env ) {123 TypeSubstitution * TypeSubstitution::newFromExpr( Expression * expr, const TypeSubstitution * env ) { 123 124 if ( env ) { 124 125 TypeSubstitution * newEnv = new TypeSubstitution(); -
src/SynTree/TypeSubstitution.h
r3c1fa71 r7bb6bd8 39 39 TypeSubstitution &operator=( const TypeSubstitution &other ); 40 40 41 template< typename SynTreeClass > int apply( SynTreeClass *&input ) ;42 template< typename SynTreeClass > int applyFree( SynTreeClass *&input ) ;41 template< typename SynTreeClass > int apply( SynTreeClass *&input ) const; 42 template< typename SynTreeClass > int applyFree( SynTreeClass *&input ) const; 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, TypeSubstitution * env );58 static TypeSubstitution * newFromExpr( Expression * expr, const 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( TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}132 Substituter( const 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 TypeSubstitution & sub;145 const TypeSubstitution & sub; 146 146 int subCount = 0; 147 147 bool freeOnly; … … 151 151 152 152 template< typename SynTreeClass > 153 int TypeSubstitution::apply( SynTreeClass *&input ) {153 int TypeSubstitution::apply( SynTreeClass *&input ) const { 154 154 assert( input ); 155 155 PassVisitor<Substituter> sub( *this, false ); … … 163 163 164 164 template< typename SynTreeClass > 165 int TypeSubstitution::applyFree( SynTreeClass *&input ) {165 int TypeSubstitution::applyFree( SynTreeClass *&input ) const { 166 166 assert( input ); 167 167 PassVisitor<Substituter> sub( *this, true ); -
src/Tuples/TupleExpansion.cc
r3c1fa71 r7bb6bd8 58 58 }; 59 59 60 struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public With TypeSubstitution {60 struct TupleTypeReplacer : public WithDeclsToAdd, public WithGuards, public WithConstTypeSubstitution { 61 61 Type * postmutate( TupleType * tupleType ); 62 62 -
src/main.cc
r3c1fa71 r7bb6bd8 446 446 }; // description 447 447 448 static_assert( sizeof( long_opts ) / sizeof( long_opts[0] ) - 1 == sizeof( description ) / sizeof( description[0] ) );448 static_assert( sizeof( long_opts ) / sizeof( long_opts[0] ) - 1 == sizeof( description ) / sizeof( description[0] ), "Long opts and description must match" ); 449 449 450 450 static struct Printopts {
Note: See TracChangeset
for help on using the changeset viewer.