- Timestamp:
- May 25, 2023, 1:01:00 PM (15 months ago)
- Branches:
- ast-experimental, master
- Children:
- a5294af
- Parents:
- 382467f
- Location:
- src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Pass.impl.hpp
r382467f rbccd70a 20 20 #include <unordered_map> 21 21 22 #include "AST/Copy.hpp" 22 23 #include "AST/TranslationUnit.hpp" 23 24 #include "AST/TypeSubstitution.hpp" -
src/AST/Print.cpp
r382467f rbccd70a 16 16 #include "Print.hpp" 17 17 18 #include "Attribute.hpp" 18 19 #include "Decl.hpp" 19 20 #include "Expr.hpp" 21 #include "Init.hpp" 20 22 #include "Stmt.hpp" 21 23 #include "Type.hpp" 22 24 #include "TypeSubstitution.hpp" 23 25 #include "CompilationState.h" 24 25 #include "Common/utility.h" // for group_iterate 26 #include "Common/Iterate.hpp" 26 27 27 28 using namespace std; -
src/AST/SymbolTable.cpp
r382467f rbccd70a 18 18 #include <cassert> 19 19 20 #include "Copy.hpp" 20 21 #include "Decl.hpp" 21 22 #include "Expr.hpp" -
src/AST/TypeSubstitution.cpp
r382467f rbccd70a 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jun 3 13:26:00 2017 13 // Update Count : 5 14 // 12 // Last Modified On : Thr May 25 11:24:00 2023 13 // Update Count : 6 14 // 15 16 #include "TypeSubstitution.hpp" 15 17 16 18 #include "Type.hpp" // for TypeInstType, Type, StructInstType, UnionInstType 17 #include " TypeSubstitution.hpp"19 #include "Pass.hpp" // for Pass, PureVisitor, WithGuards, WithVisitorRef 18 20 19 21 namespace ast { 20 21 22 // size_t TypeSubstitution::Substituter::traceId = Stats::Heap::new_stacktrace_id("TypeSubstitution");23 22 24 23 TypeSubstitution::TypeSubstitution() { … … 119 118 } 120 119 120 // definitition must happen after PassVisitor is included so that WithGuards can be used 121 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter>, public PureVisitor { 122 //static size_t traceId; 123 124 Substituter( const TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {} 125 126 const Type * postvisit( const TypeInstType * aggregateUseType ); 127 128 /// Records type variable bindings from forall-statements 129 void previsit( const FunctionType * type ); 130 /// Records type variable bindings from forall-statements and instantiations of generic types 131 // void handleAggregateType( const BaseInstType * type ); 132 133 // void previsit( const StructInstType * aggregateUseType ); 134 // void previsit( const UnionInstType * aggregateUseType ); 135 136 const TypeSubstitution & sub; 137 int subCount = 0; 138 bool freeOnly; 139 typedef std::unordered_set< TypeEnvKey > BoundVarsType; 140 BoundVarsType boundVars; 141 }; 142 143 // size_t TypeSubstitution::Substituter::traceId = Stats::Heap::new_stacktrace_id("TypeSubstitution"); 144 121 145 void TypeSubstitution::normalize() { 122 146 Pass<Substituter> sub( *this, true ); … … 128 152 } 129 153 } while ( sub.core.subCount ); 154 } 155 156 TypeSubstitution::ApplyResult<Node> TypeSubstitution::applyBase( 157 const Node * input, bool isFree ) const { 158 assert( input ); 159 Pass<Substituter> sub( *this, isFree ); 160 const Node * output = input->accept( sub ); 161 return { output, sub.core.subCount }; 130 162 } 131 163 -
src/AST/TypeSubstitution.hpp
r382467f rbccd70a 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T ue Apr 30 22:52:47 201913 // Update Count : 911 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 25 12:31:00 2023 13 // Update Count : 10 14 14 // 15 15 … … 46 46 TypeSubstitution &operator=( const TypeSubstitution &other ); 47 47 48 template< typename SynTreeClass>48 template< typename node_t > 49 49 struct ApplyResult { 50 ast::ptr< SynTreeClass> node;50 ast::ptr<node_t> node; 51 51 int count; 52 52 }; 53 53 54 template< typename SynTreeClass > ApplyResult<SynTreeClass> apply( const SynTreeClass * input ) const; 55 template< typename SynTreeClass > ApplyResult<SynTreeClass> applyFree( const SynTreeClass * input ) const; 54 template< typename node_t > 55 ApplyResult<node_t> apply( const node_t * input ) const { 56 ApplyResult<Node> ret = applyBase( input, false ); 57 return { ret.node.strict_as<node_t>(), ret.count }; 58 } 56 59 57 60 template< typename node_t, enum Node::ref_type ref_t > 58 61 int apply( ptr_base< node_t, ref_t > & input ) const { 59 const node_t * p = input.get(); 60 auto ret = apply(p); 61 input = ret.node; 62 ApplyResult<Node> ret = applyBase( input.get(), false ); 63 input = ret.node.strict_as<node_t>(); 62 64 return ret.count; 65 } 66 67 template< typename node_t > 68 ApplyResult<node_t> applyFree( const node_t * input ) const { 69 ApplyResult<Node> ret = applyBase( input, true ); 70 return { ret.node.strict_as<node_t>(), ret.count }; 63 71 } 64 72 65 73 template< typename node_t, enum Node::ref_type ref_t > 66 74 int applyFree( ptr_base< node_t, ref_t > & input ) const { 67 const node_t * p = input.get(); 68 auto ret = applyFree(p); 69 input = ret.node; 75 ApplyResult<Node> ret = applyBase( input.get(), true ); 76 input = ret.node.strict_as<node_t>(); 70 77 return ret.count; 71 78 } … … 97 104 // Mutator that performs the substitution 98 105 struct Substituter; 106 ApplyResult<Node> applyBase( const Node * input, bool isFree ) const; 99 107 100 108 // TODO: worry about traversing into a forall-qualified function type or type decl with assertions … … 158 166 } // namespace ast 159 167 160 // include needs to happen after TypeSubstitution is defined so that both TypeSubstitution and161 // PassVisitor are defined before PassVisitor implementation accesses TypeSubstitution internals.162 #include "Pass.hpp"163 #include "Copy.hpp"164 165 namespace ast {166 167 // definitition must happen after PassVisitor is included so that WithGuards can be used168 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter>, public PureVisitor {169 static size_t traceId;170 171 Substituter( const TypeSubstitution & sub, bool freeOnly ) : sub( sub ), freeOnly( freeOnly ) {}172 173 const Type * postvisit( const TypeInstType * aggregateUseType );174 175 /// Records type variable bindings from forall-statements176 void previsit( const FunctionType * type );177 /// Records type variable bindings from forall-statements and instantiations of generic types178 // void handleAggregateType( const BaseInstType * type );179 180 // void previsit( const StructInstType * aggregateUseType );181 // void previsit( const UnionInstType * aggregateUseType );182 183 const TypeSubstitution & sub;184 int subCount = 0;185 bool freeOnly;186 typedef std::unordered_set< TypeEnvKey > BoundVarsType;187 BoundVarsType boundVars;188 189 };190 191 template< typename SynTreeClass >192 TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::apply( const SynTreeClass * input ) const {193 assert( input );194 Pass<Substituter> sub( *this, false );195 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );196 return { input, sub.core.subCount };197 }198 199 template< typename SynTreeClass >200 TypeSubstitution::ApplyResult<SynTreeClass> TypeSubstitution::applyFree( const SynTreeClass * input ) const {201 assert( input );202 Pass<Substituter> sub( *this, true );203 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) );204 return { input, sub.core.subCount };205 }206 207 } // namespace ast208 209 168 // Local Variables: // 210 169 // tab-width: 4 // -
src/Concurrency/Waituntil.cpp
r382467f rbccd70a 14 14 // 15 15 16 #include "Waituntil.hpp" 17 16 18 #include <string> 17 19 18 #include " Waituntil.hpp"20 #include "AST/Copy.hpp" 19 21 #include "AST/Expr.hpp" 20 22 #include "AST/Pass.hpp" -
src/ControlStruct/ExceptDeclNew.cpp
r382467f rbccd70a 18 18 #include <sstream> 19 19 20 #include "AST/Copy.hpp" 20 21 #include "AST/Decl.hpp" 21 22 #include "AST/Pass.hpp" -
src/GenPoly/SpecializeNew.cpp
r382467f rbccd70a 16 16 #include "Specialize.h" 17 17 18 #include "AST/Copy.hpp" // for deepCopy 18 19 #include "AST/Inspect.hpp" // for isIntrinsicCallExpr 19 20 #include "AST/Pass.hpp" // for Pass -
src/MakeLibCfaNew.cpp
r382467f rbccd70a 16 16 #include "MakeLibCfa.h" 17 17 18 #include "AST/Copy.hpp" 18 19 #include "AST/Fwd.hpp" 19 20 #include "AST/Pass.hpp" -
src/ResolvExpr/CommonType.cc
r382467f rbccd70a 21 21 22 22 #include "AST/Decl.hpp" 23 #include "AST/Pass.hpp" 23 24 #include "AST/Type.hpp" 24 25 #include "Common/PassVisitor.h" -
src/ResolvExpr/PolyCost.cc
r382467f rbccd70a 15 15 16 16 #include "AST/SymbolTable.hpp" 17 #include "AST/Pass.hpp" 17 18 #include "AST/Type.hpp" 18 19 #include "AST/TypeEnvironment.hpp" -
src/Tuples/Explode.cc
r382467f rbccd70a 17 17 #include <list> // for list 18 18 19 #include "AST/Pass.hpp" // for Pass 19 20 #include "SynTree/Mutator.h" // for Mutator 20 21 #include "Common/PassVisitor.h" // for PassVisitor -
src/Validate/Autogen.cpp
r382467f rbccd70a 25 25 26 26 #include "AST/Attribute.hpp" 27 #include "AST/Copy.hpp" 27 28 #include "AST/Create.hpp" 28 29 #include "AST/Decl.hpp" -
src/Validate/FixQualifiedTypes.cpp
r382467f rbccd70a 16 16 #include "Validate/FixQualifiedTypes.hpp" 17 17 18 #include "AST/Copy.hpp" 18 19 #include "AST/LinkageSpec.hpp" // for Linkage 19 20 #include "AST/Pass.hpp" -
src/Validate/GenericParameter.cpp
r382467f rbccd70a 16 16 #include "GenericParameter.hpp" 17 17 18 #include "AST/Copy.hpp" 18 19 #include "AST/Decl.hpp" 19 20 #include "AST/Expr.hpp" -
src/Validate/ReplaceTypedef.cpp
r382467f rbccd70a 16 16 #include "ReplaceTypedef.hpp" 17 17 18 #include "AST/Copy.hpp" 18 19 #include "AST/Pass.hpp" 19 20 #include "Common/ScopedMap.h" -
src/Virtual/ExpandCasts.cc
r382467f rbccd70a 20 20 #include <string> // for string, allocator, operator==, ope... 21 21 22 #include "AST/Copy.hpp" 22 23 #include "AST/Decl.hpp" 23 24 #include "AST/Expr.hpp" -
src/main.cc
r382467f rbccd70a 32 32 33 33 #include "AST/Convert.hpp" 34 #include "AST/Pass.hpp" // for pass_visitor_stats 35 #include "AST/TranslationUnit.hpp" // for TranslationUnit 34 36 #include "AST/Util.hpp" // for checkInvariants 35 37 #include "CompilationState.h"
Note: See TracChangeset
for help on using the changeset viewer.