- Timestamp:
- Sep 1, 2020, 1:18:10 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 86c1f1c3, a77496cb
- Parents:
- 8d8ac3b (diff), d3aa64f1 (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/AST
- Files:
-
- 9 edited
-
Convert.cpp (modified) (2 diffs)
-
Copy.hpp (modified) (1 diff)
-
Expr.hpp (modified) (1 diff)
-
Pass.hpp (modified) (1 diff)
-
Pass.impl.hpp (modified) (10 diffs)
-
Pass.proto.hpp (modified) (1 diff)
-
Print.cpp (modified) (2 diffs)
-
TypeSubstitution.hpp (modified) (3 diffs)
-
module.mk (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r8d8ac3b r25a1cb0 705 705 new KeywordCastExpr( 706 706 get<Expression>().accept1(node->arg), 707 castTarget 707 castTarget, 708 {node->concrete_target.field, node->concrete_target.getter} 708 709 ) 709 710 ); … … 2087 2088 old->location, 2088 2089 GET_ACCEPT_1(arg, Expr), 2089 castTarget 2090 castTarget, 2091 {old->concrete_target.field, old->concrete_target.getter} 2090 2092 ) 2091 2093 ); -
src/AST/Copy.hpp
r8d8ac3b r25a1cb0 21 21 #include "Stmt.hpp" 22 22 #include "Type.hpp" 23 #include <unordered_set> 24 #include <unordered_map> 23 25 24 26 namespace ast { -
src/AST/Expr.hpp
r8d8ac3b r25a1cb0 312 312 public: 313 313 ptr<Expr> arg; 314 struct Concrete { 315 std::string field; 316 std::string getter; 317 318 Concrete() = default; 319 Concrete(const Concrete &) = default; 320 }; 314 321 ast::AggregateDecl::Aggregate target; 322 Concrete concrete_target; 323 315 324 316 325 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t ) 317 326 : Expr( loc ), arg( a ), target( t ) {} 327 328 KeywordCastExpr( const CodeLocation & loc, const Expr * a, ast::AggregateDecl::Aggregate t, const Concrete & ct ) 329 : Expr( loc ), arg( a ), target( t ), concrete_target( ct ) {} 318 330 319 331 /// Get a name for the target type -
src/AST/Pass.hpp
r8d8ac3b r25a1cb0 266 266 267 267 /// Keep track of the polymorphic const TypeSubstitution * env for the current expression 268 269 /// marker to force shallow copies in pass visit 270 struct PureVisitor {}; 271 268 272 struct WithConstTypeSubstitution { 269 273 const TypeSubstitution * env = nullptr; -
src/AST/Pass.impl.hpp
r8d8ac3b r25a1cb0 21 21 22 22 #include "AST/TypeSubstitution.hpp" 23 // #include "AST/Copy.hpp" 23 24 24 25 #define VISIT_START( node ) \ … … 57 58 58 59 namespace ast { 60 template<typename node_t> 61 node_t * shallowCopy( const node_t * node ); 62 59 63 namespace __pass { 60 64 // Check if this is either a null pointer or a pointer to an empty container … … 62 66 static inline bool empty( T * ptr ) { 63 67 return !ptr || ptr->empty(); 68 } 69 70 template< typename core_t, typename node_t > 71 static inline node_t* mutate(const node_t *node) { 72 return std::is_base_of<PureVisitor, core_t>::value ? ::ast::shallowCopy(node) : ::ast::mutate(node); 64 73 } 65 74 … … 320 329 321 330 if( __pass::differs(old_val, new_val) ) { 322 auto new_parent = mutate(parent); 331 // auto new_parent = mutate(parent); 332 auto new_parent = __pass::mutate<core_t>(parent); 323 333 new_parent->*child = new_val; 324 334 parent = new_parent; … … 334 344 if ( node->forall.empty() ) return; 335 345 336 node_t * mut = mutate( node );346 node_t * mut = __pass::mutate<core_t>( node ); 337 347 mut->forall = subs->clone( node->forall, *this ); 338 348 node = mut; … … 894 904 895 905 if(mutated) { 896 auto n = mutate(node);906 auto n = __pass::mutate<core_t>(node); 897 907 n->clauses = std::move( new_clauses ); 898 908 node = n; … … 904 914 auto nval = call_accept( node->field ); \ 905 915 if(nval != node->field ) { \ 906 auto nparent = mutate(node); \916 auto nparent = __pass::mutate<core_t>(node); \ 907 917 nparent->field = nval; \ 908 918 node = nparent; \ … … 1610 1620 1611 1621 if(mutated) { 1612 auto n = mutate(node);1622 auto n = __pass::mutate<core_t>(node); 1613 1623 n->associations = std::move( new_kids ); 1614 1624 node = n; … … 1940 1950 } 1941 1951 if (mutated) { 1942 auto new_node = mutate( node );1952 auto new_node = __pass::mutate<core_t>( node ); 1943 1953 new_node->typeEnv.swap( new_map ); 1944 1954 node = new_node; … … 1956 1966 } 1957 1967 if (mutated) { 1958 auto new_node = mutate( node );1968 auto new_node = __pass::mutate<core_t>( node ); 1959 1969 new_node->varEnv.swap( new_map ); 1960 1970 node = new_node; -
src/AST/Pass.proto.hpp
r8d8ac3b r25a1cb0 22 22 template<typename core_t> 23 23 class Pass; 24 25 struct PureVisitor; 24 26 25 27 namespace __pass { -
src/AST/Print.cpp
r8d8ac3b r25a1cb0 21 21 #include "Type.hpp" 22 22 #include "TypeSubstitution.hpp" 23 #include "CompilationState.h" 23 24 24 25 #include "Common/utility.h" // for group_iterate … … 239 240 240 241 if ( node->result ) { 241 os << endl << indent << "... with resolved type:" << endl; 242 ++indent; 243 os << indent; 244 node->result->accept( *this ); 245 --indent; 242 if (!deterministic_output) { 243 os << endl << indent << "... with resolved type:" << endl; 244 ++indent; 245 os << indent; 246 node->result->accept( *this ); 247 --indent; 248 } 246 249 } 247 250 -
src/AST/TypeSubstitution.hpp
r8d8ac3b r25a1cb0 159 159 160 160 // definitition must happen after PassVisitor is included so that WithGuards can be used 161 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter> {161 struct TypeSubstitution::Substituter : public WithGuards, public WithVisitorRef<Substituter>, public PureVisitor { 162 162 static size_t traceId; 163 163 … … 187 187 assert( input ); 188 188 Pass<Substituter> sub( *this, false ); 189 input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) ); 189 // input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) ); 190 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) ); 190 191 return { input, sub.core.subCount }; 191 192 } … … 195 196 assert( input ); 196 197 Pass<Substituter> sub( *this, true ); 197 input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) ); 198 // input = strict_dynamic_cast< const SynTreeClass * >( deepCopy(input)->accept( sub ) ); 199 input = strict_dynamic_cast< const SynTreeClass * >( input->accept( sub ) ); 198 200 return { input, sub.core.subCount }; 199 201 } -
src/AST/module.mk
r8d8ac3b r25a1cb0 17 17 SRC_AST = \ 18 18 AST/AssertAcyclic.cpp \ 19 AST/AssertAcyclic.hpp \ 19 20 AST/Attribute.cpp \ 21 AST/Attribute.hpp \ 22 AST/Bitfield.hpp \ 23 AST/Chain.hpp \ 20 24 AST/Convert.cpp \ 25 AST/Convert.hpp \ 26 AST/Copy.hpp \ 27 AST/CVQualifiers.hpp \ 21 28 AST/Decl.cpp \ 29 AST/Decl.hpp \ 22 30 AST/DeclReplacer.cpp \ 31 AST/DeclReplacer.hpp \ 32 AST/Eval.hpp \ 23 33 AST/Expr.cpp \ 34 AST/Expr.hpp \ 24 35 AST/ForallSubstitutionTable.cpp \ 36 AST/ForallSubstitutionTable.hpp \ 37 AST/ForallSubstitutor.hpp \ 38 AST/FunctionSpec.hpp \ 39 AST/Fwd.hpp \ 25 40 AST/GenericSubstitution.cpp \ 41 AST/GenericSubstitution.hpp \ 26 42 AST/Init.cpp \ 43 AST/Init.hpp \ 44 AST/Label.hpp \ 27 45 AST/LinkageSpec.cpp \ 46 AST/LinkageSpec.hpp \ 28 47 AST/Node.cpp \ 48 AST/Node.hpp \ 49 AST/ParseNode.hpp \ 29 50 AST/Pass.cpp \ 51 AST/Pass.hpp \ 52 AST/Pass.impl.hpp \ 53 AST/Pass.proto.hpp \ 30 54 AST/Print.cpp \ 55 AST/Print.hpp \ 31 56 AST/Stmt.cpp \ 57 AST/Stmt.hpp \ 58 AST/StorageClasses.hpp \ 32 59 AST/SymbolTable.cpp \ 60 AST/SymbolTable.hpp \ 33 61 AST/Type.cpp \ 62 AST/Type.hpp \ 34 63 AST/TypeEnvironment.cpp \ 35 AST/TypeSubstitution.cpp 64 AST/TypeEnvironment.hpp \ 65 AST/TypeSubstitution.cpp \ 66 AST/TypeSubstitution.hpp \ 67 AST/Visitor.hpp 36 68 37 69 SRC += $(SRC_AST)
Note:
See TracChangeset
for help on using the changeset viewer.