- Timestamp:
- Nov 13, 2023, 3:43:43 AM (2 years ago)
- Branches:
- master
- Children:
- 25f2798
- Parents:
- 0030b508 (diff), 2174191 (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:
-
- 2 deleted
- 11 edited
-
Convert.cpp (deleted)
-
Convert.hpp (deleted)
-
Decl.hpp (modified) (6 diffs)
-
Fwd.hpp (modified) (1 diff)
-
Node.cpp (modified) (1 diff)
-
Pass.cpp (modified) (1 diff)
-
Pass.hpp (modified) (1 diff)
-
Pass.impl.hpp (modified) (1 diff)
-
Print.cpp (modified) (1 diff)
-
Stmt.hpp (modified) (7 diffs)
-
Type.hpp (modified) (1 diff)
-
Visitor.hpp (modified) (1 diff)
-
module.mk (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
r0030b508 rfc12f05 125 125 126 126 /// Object declaration `int foo()` 127 class FunctionDecl : public DeclWithType {127 class FunctionDecl final : public DeclWithType { 128 128 public: 129 129 std::vector<ptr<TypeDecl>> type_params; … … 314 314 class EnumDecl final : public AggregateDecl { 315 315 public: 316 bool isTyped;// isTyped indicated if the enum has a declaration like:316 // isTyped indicated if the enum has a declaration like: 317 317 // enum (type_optional) Name {...} 318 ptr<Type> base; // if isTyped == true && base.get() == nullptr, it is a "void" type enum 318 bool isTyped; 319 // if isTyped == true && base.get() == nullptr, it is a "void" type enum 320 ptr<Type> base; 319 321 enum class EnumHiding { Visible, Hide } hide; 320 322 … … 374 376 375 377 /// Assembly declaration: `asm ... ( "..." : ... )` 376 class AsmDecl : public Decl {378 class AsmDecl final : public Decl { 377 379 public: 378 380 ptr<AsmStmt> stmt; 379 381 380 382 AsmDecl( const CodeLocation & loc, AsmStmt * stmt ) 381 : Decl( loc, "", {}, {}), stmt(stmt) {}383 : Decl( loc, "", {}, Linkage::C ), stmt(stmt) {} 382 384 383 385 const AsmDecl * accept( Visitor & v ) const override { return v.visit( this ); } … … 388 390 389 391 /// C-preprocessor directive `#...` 390 class DirectiveDecl : public Decl {392 class DirectiveDecl final : public Decl { 391 393 public: 392 394 ptr<DirectiveStmt> stmt; 393 395 394 396 DirectiveDecl( const CodeLocation & loc, DirectiveStmt * stmt ) 395 : Decl( loc, "", {}, {}), stmt(stmt) {}397 : Decl( loc, "", {}, Linkage::C ), stmt(stmt) {} 396 398 397 399 const DirectiveDecl * accept( Visitor & v ) const override { return v.visit( this ); } … … 402 404 403 405 /// Static Assertion `_Static_assert( ... , ... );` 404 class StaticAssertDecl : public Decl {406 class StaticAssertDecl final : public Decl { 405 407 public: 406 408 ptr<Expr> cond; … … 408 410 409 411 StaticAssertDecl( const CodeLocation & loc, const Expr * condition, const ConstantExpr * msg ) 410 : Decl( loc, "", {}, {}), cond( condition ), msg( msg ) {}412 : Decl( loc, "", {}, Linkage::C ), cond( condition ), msg( msg ) {} 411 413 412 414 const StaticAssertDecl * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/Fwd.hpp
r0030b508 rfc12f05 68 68 class MutexStmt; 69 69 class CorunStmt; 70 class CoforStmt; 70 71 71 72 class Expr; -
src/AST/Node.cpp
r0030b508 rfc12f05 194 194 template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::weak >; 195 195 template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::strong >; 196 template class ast::ptr_base< ast::CoforStmt, ast::Node::ref_type::weak >; 197 template class ast::ptr_base< ast::CoforStmt, ast::Node::ref_type::strong >; 196 198 template class ast::ptr_base< ast::Expr, ast::Node::ref_type::weak >; 197 199 template class ast::ptr_base< ast::Expr, ast::Node::ref_type::strong >; -
src/AST/Pass.cpp
r0030b508 rfc12f05 19 19 20 20 PassVisitorStats pass_visitor_stats; 21 // TODO: There was a counter for every syntax node created. 22 // This has not been translated to the new ast. 21 23 // Stats::Counters::SimpleCounter * BaseSyntaxNode::new_nodes = nullptr; 22 24 -
src/AST/Pass.hpp
r0030b508 rfc12f05 172 172 const ast::Stmt * visit( const ast::MutexStmt * ) override final; 173 173 const ast::Stmt * visit( const ast::CorunStmt * ) override final; 174 const ast::Stmt * visit( const ast::CoforStmt * ) override final; 174 175 const ast::Expr * visit( const ast::ApplicationExpr * ) override final; 175 176 const ast::Expr * visit( const ast::UntypedExpr * ) override final; -
src/AST/Pass.impl.hpp
r0030b508 rfc12f05 1134 1134 1135 1135 //-------------------------------------------------------------------------- 1136 // CoforStmt 1137 template< typename core_t > 1138 const ast::Stmt * ast::Pass< core_t >::visit( const ast::CoforStmt * node ) { 1139 VISIT_START( node ); 1140 1141 if ( __visit_children() ) { 1142 // for statements introduce a level of scope (for the initialization) 1143 guard_symtab guard { *this }; 1144 maybe_accept( node, &CoforStmt::inits ); 1145 maybe_accept_top( node, &CoforStmt::cond ); 1146 maybe_accept_top( node, &CoforStmt::inc ); 1147 maybe_accept_as_compound( node, &CoforStmt::body ); 1148 } 1149 1150 VISIT_END( Stmt, node ); 1151 } 1152 1153 //-------------------------------------------------------------------------- 1136 1154 // ApplicationExpr 1137 1155 template< typename core_t > -
src/AST/Print.cpp
r0030b508 rfc12f05 934 934 } 935 935 936 virtual const ast::Stmt * visit( const ast::CoforStmt * node ) override final { 937 os << "Cofor Statement" << endl; 938 939 if ( ! node->inits.empty() ) { 940 os << indent << "... initialization:" << endl; 941 ++indent; 942 for ( const ast::Stmt * stmt : node->inits ) { 943 os << indent+1; 944 safe_print( stmt ); 945 } 946 --indent; 947 } 948 949 if ( node->cond ) { 950 os << indent << "... condition:" << endl; 951 ++indent; 952 os << indent; 953 node->cond->accept( *this ); 954 --indent; 955 } 956 957 if ( node->inc ) { 958 os << indent << "... increment:" << endl; 959 ++indent; 960 os << indent; 961 node->inc->accept( *this ); 962 --indent; 963 } 964 965 if ( node->body ) { 966 os << indent << "... with body:" << endl; 967 ++indent; 968 os << indent; 969 node->body->accept( *this ); 970 --indent; 971 } 972 os << endl; 973 print( node->labels ); 974 975 return node; 976 } 977 936 978 virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) override final { 937 979 ++indent; -
src/AST/Stmt.hpp
r0030b508 rfc12f05 28 28 // Must be included in *all* AST classes; should be #undef'd at the end of the file 29 29 #define MUTATE_FRIEND \ 30 template<typename node_t> friend node_t * mutate(const node_t * node); \30 template<typename node_t> friend node_t * mutate(const node_t * node); \ 31 31 template<typename node_t> friend node_t * shallowCopy(const node_t * node); 32 32 … … 340 340 341 341 CatchClause( const CodeLocation & loc, ExceptionKind kind, const Decl * decl, const Expr * cond, 342 const Stmt * body )342 const Stmt * body ) 343 343 : StmtClause(loc), decl(decl), cond(cond), body(body), kind(kind) {} 344 344 … … 380 380 // Base class of WaitFor/WaitUntil statements 381 381 // form: KEYWORD(...) ... timeout(...) ... else ... 382 class WaitStmt : public Stmt { 383 public: 384 ptr<Expr> timeout_time;382 class WaitStmt : public Stmt { 383 public: 384 ptr<Expr> timeout_time; 385 385 ptr<Stmt> timeout_stmt; 386 386 ptr<Expr> timeout_cond; … … 388 388 ptr<Expr> else_cond; 389 389 390 WaitStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} )390 WaitStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 391 391 : Stmt(loc, std::move(labels)) {} 392 392 393 393 private: 394 WaitStmt * clone() const override = 0;394 WaitStmt * clone() const override = 0; 395 395 MUTATE_FRIEND 396 396 }; … … 444 444 class WaitUntilStmt final : public WaitStmt { 445 445 public: 446 // Non-ast node used during compilation to store data needed to generate predicates447 // and set initial status values for clauses448 // Used to create a tree corresponding to the structure of the clauses in a WaitUntil449 struct ClauseNode { 450 enum Op { AND, OR, LEFT_OR, LEAF, ELSE, TIMEOUT } op; // operation/type tag451 // LEFT_OR used with TIMEOUT/ELSE to indicate that we ignore right hand side after parsing452 453 ClauseNode * left;454 ClauseNode * right;455 WhenClause * leaf; // only set if this node is a leaf (points into vector of clauses)456 457 bool ambiguousWhen; // used to paint nodes of predicate tree based on when() clauses458 bool whenState; // used to track if when_cond is toggled on or off for generating init values459 bool childOfAnd; // true on leaf nodes that are children of AND, false otherwise460 461 ClauseNode( Op op, ClauseNode * left, ClauseNode * right )462 : op(op), left(left), right(right), leaf(nullptr), 463 ambiguousWhen(false), whenState(true), childOfAnd(false) {}464 ClauseNode( Op op, WhenClause * leaf )465 : op(op), left(nullptr), right(nullptr), leaf(leaf),466 ambiguousWhen(false), whenState(true), childOfAnd(false) {}467 ClauseNode( WhenClause * leaf ) : ClauseNode(LEAF, leaf) {}468 469 ~ClauseNode() {470 if ( left ) delete left;471 if ( right ) delete right;472 }473 };446 // Non-ast node used during compilation to store data needed to generate predicates 447 // and set initial status values for clauses 448 // Used to create a tree corresponding to the structure of the clauses in a WaitUntil 449 struct ClauseNode { 450 enum Op { AND, OR, LEFT_OR, LEAF, ELSE, TIMEOUT } op; // operation/type tag 451 // LEFT_OR used with TIMEOUT/ELSE to indicate that we ignore right hand side after parsing 452 453 ClauseNode * left; 454 ClauseNode * right; 455 WhenClause * leaf; // only set if this node is a leaf (points into vector of clauses) 456 457 bool ambiguousWhen; // used to paint nodes of predicate tree based on when() clauses 458 bool whenState; // used to track if when_cond is toggled on or off for generating init values 459 bool childOfAnd; // true on leaf nodes that are children of AND, false otherwise 460 461 ClauseNode( Op op, ClauseNode * left, ClauseNode * right ) 462 : op(op), left(left), right(right), leaf(nullptr), 463 ambiguousWhen(false), whenState(true), childOfAnd(false) {} 464 ClauseNode( Op op, WhenClause * leaf ) 465 : op(op), left(nullptr), right(nullptr), leaf(leaf), 466 ambiguousWhen(false), whenState(true), childOfAnd(false) {} 467 ClauseNode( WhenClause * leaf ) : ClauseNode(LEAF, leaf) {} 468 469 ~ClauseNode() { 470 if ( left ) delete left; 471 if ( right ) delete right; 472 } 473 }; 474 474 475 475 std::vector<ptr<WhenClause>> clauses; 476 ClauseNode * predicateTree;476 ClauseNode * predicateTree; 477 477 478 478 WaitUntilStmt( const CodeLocation & loc, const std::vector<Label> && labels = {} ) 479 479 : WaitStmt(loc, std::move(labels)) {} 480 480 481 ~WaitUntilStmt() { delete predicateTree; }481 ~WaitUntilStmt() { delete predicateTree; } 482 482 483 483 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } … … 522 522 std::vector<ptr<Expr>> mutexObjs; 523 523 524 MutexStmt( const CodeLocation & loc, const Stmt * stmt, 524 MutexStmt( const CodeLocation & loc, const Stmt * stmt, 525 525 const std::vector<ptr<Expr>> && mutexes, const std::vector<Label> && labels = {} ) 526 526 : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {} … … 543 543 private: 544 544 CorunStmt * clone() const override { return new CorunStmt{ *this }; } 545 MUTATE_FRIEND 546 }; 547 548 // Corun Statement 549 class CoforStmt final : public Stmt { 550 public: 551 std::vector<ptr<Stmt>> inits; 552 ptr<Expr> cond; 553 ptr<Expr> inc; 554 ptr<Stmt> body; 555 556 CoforStmt( const CodeLocation & loc, const std::vector<ptr<Stmt>> && inits, const Expr * cond, 557 const Expr * inc, const Stmt * body, const std::vector<Label> && label = {} ) 558 : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body) {} 559 560 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 561 private: 562 CoforStmt * clone() const override { return new CoforStmt{ *this }; } 545 563 MUTATE_FRIEND 546 564 }; -
src/AST/Type.hpp
r0030b508 rfc12f05 34 34 35 35 namespace ast { 36 37 template< typename T > class Pass;38 36 39 37 class Type : public Node { -
src/AST/Visitor.hpp
r0030b508 rfc12f05 60 60 virtual const ast::Stmt * visit( const ast::MutexStmt * ) = 0; 61 61 virtual const ast::Stmt * visit( const ast::CorunStmt * ) = 0; 62 virtual const ast::Stmt * visit( const ast::CoforStmt * ) = 0; 62 63 virtual const ast::Expr * visit( const ast::ApplicationExpr * ) = 0; 63 64 virtual const ast::Expr * visit( const ast::UntypedExpr * ) = 0; -
src/AST/module.mk
r0030b508 rfc12f05 20 20 AST/Bitfield.hpp \ 21 21 AST/Chain.hpp \ 22 AST/Convert.cpp \23 AST/Convert.hpp \24 22 AST/Copy.cpp \ 25 23 AST/Copy.hpp \
Note:
See TracChangeset
for help on using the changeset viewer.