- Timestamp:
- Nov 22, 2022, 10:18:04 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, stuck-waitfor-destruct
- Children:
- 20cf96d
- Parents:
- 1553a55 (diff), d41735a (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:
-
- 7 edited
-
Convert.cpp (modified) (4 diffs)
-
Decl.hpp (modified) (4 diffs)
-
Fwd.hpp (modified) (1 diff)
-
Pass.hpp (modified) (1 diff)
-
Pass.impl.hpp (modified) (2 diffs)
-
Print.cpp (modified) (1 diff)
-
Visitor.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r1553a55 r29702ad 236 236 } 237 237 238 // Inline ValueDecl vanish after EnumAndPointerDecay pass so no necessary to implement NewToOld239 const ast::DeclWithType * visit( const ast::Inline ValueDecl * node ) override final {238 // InlineMemberDecl vanish after EnumAndPointerDecay pass so no necessary to implement NewToOld 239 const ast::DeclWithType * visit( const ast::InlineMemberDecl * node ) override final { 240 240 assert( false ); 241 241 (void) node; … … 1764 1764 { old->linkage.val }, 1765 1765 GET_ACCEPT_1(base, Type), 1766 old->hide == EnumDecl::EnumHiding::Hide ? ast::EnumDecl::EnumHiding::Hide : ast::EnumDecl::EnumHiding::Visible, 1766 1767 old->enumValues 1767 1768 ); … … 1869 1870 } 1870 1871 1871 virtual void visit( const Inline ValueDecl * old ) override final {1872 virtual void visit( const InlineMemberDecl * old ) override final { 1872 1873 if ( inCache( old ) ) { 1873 1874 return; … … 1875 1876 auto&& type = GET_ACCEPT_1(type, Type); 1876 1877 auto&& attr = GET_ACCEPT_V(attributes, Attribute); 1877 1878 auto decl = new ast::Inline ValueDecl(1878 1879 auto decl = new ast::InlineMemberDecl( 1879 1880 old->location, 1880 1881 old->name, -
src/AST/Decl.hpp
r1553a55 r29702ad 315 315 // enum (type_optional) Name {...} 316 316 ptr<Type> base; // if isTyped == true && base.get() == nullptr, it is a "void" type enum 317 318 EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false, 317 enum class EnumHiding { Visible, Hide } hide; 318 319 EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false, 319 320 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, 320 Type const * base = nullptr, 321 Type const * base = nullptr, EnumHiding hide = EnumHiding::Hide, 321 322 std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() ) 322 : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), enumValues(enumValues) {}323 : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), hide(hide), enumValues(enumValues) {} 323 324 324 325 /// gets the integer value for this enumerator, returning true iff value found … … 397 398 }; 398 399 400 /// Static Assertion `_Static_assert( ... , ... );` 399 401 class StaticAssertDecl : public Decl { 400 402 public: … … 411 413 }; 412 414 413 class InlineValueDecl final : public DeclWithType { 415 /// Inline Member Declaration `inline TypeName;` 416 class InlineMemberDecl final : public DeclWithType { 414 417 public: 415 418 ptr<Type> type; 416 419 417 Inline ValueDecl( const CodeLocation & loc, const std::string & name, const Type * type,420 InlineMemberDecl( const CodeLocation & loc, const std::string & name, const Type * type, 418 421 Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::Cforall, 419 422 std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} ) … … 425 428 const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); } 426 429 private: 427 InlineValueDecl * clone() const override { return new InlineValueDecl{ *this }; } 428 MUTATE_FRIEND 429 }; 430 InlineMemberDecl * clone() const override { return new InlineMemberDecl{ *this }; } 431 MUTATE_FRIEND 432 }; 433 430 434 } 431 435 -
src/AST/Fwd.hpp
r1553a55 r29702ad 37 37 class DirectiveDecl; 38 38 class StaticAssertDecl; 39 class Inline ValueDecl;39 class InlineMemberDecl; 40 40 41 41 class Stmt; -
src/AST/Pass.hpp
r1553a55 r29702ad 141 141 const ast::DirectiveDecl * visit( const ast::DirectiveDecl * ) override final; 142 142 const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * ) override final; 143 const ast::DeclWithType * visit( const ast::Inline ValueDecl* ) override final;143 const ast::DeclWithType * visit( const ast::InlineMemberDecl * ) override final; 144 144 const ast::CompoundStmt * visit( const ast::CompoundStmt * ) override final; 145 145 const ast::Stmt * visit( const ast::ExprStmt * ) override final; -
src/AST/Pass.impl.hpp
r1553a55 r29702ad 686 686 687 687 if ( __visit_children() ) { 688 // unlike structs, traits, and unions, enums inject their members into the global scope 689 maybe_accept( node, &EnumDecl::base ); 690 maybe_accept( node, &EnumDecl::params ); 691 maybe_accept( node, &EnumDecl::members ); 692 maybe_accept( node, &EnumDecl::attributes ); 688 if ( node->hide == ast::EnumDecl::EnumHiding::Hide ) { 689 guard_symtab guard { *this }; 690 maybe_accept( node, &EnumDecl::base ); 691 maybe_accept( node, &EnumDecl::params ); 692 maybe_accept( node, &EnumDecl::members ); 693 maybe_accept( node, &EnumDecl::attributes ); 694 } else { 695 maybe_accept( node, &EnumDecl::base ); 696 maybe_accept( node, &EnumDecl::params ); 697 maybe_accept( node, &EnumDecl::members ); 698 maybe_accept( node, &EnumDecl::attributes ); 699 } 693 700 } 694 701 … … 803 810 804 811 //-------------------------------------------------------------------------- 805 // DeclWithType806 template< typename core_t > 807 const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::Inline ValueDecl * node ) {808 VISIT_START( node ); 809 810 if ( __visit_children() ) { 811 { 812 guard_symtab guard { *this }; 813 maybe_accept( node, &Inline ValueDecl::type );812 // InlineMemberDecl 813 template< typename core_t > 814 const ast::DeclWithType * ast::Pass< core_t >::visit( const ast::InlineMemberDecl * node ) { 815 VISIT_START( node ); 816 817 if ( __visit_children() ) { 818 { 819 guard_symtab guard { *this }; 820 maybe_accept( node, &InlineMemberDecl::type ); 814 821 } 815 822 } -
src/AST/Print.cpp
r1553a55 r29702ad 401 401 } 402 402 403 virtual const ast::DeclWithType * visit( const ast::Inline ValueDecl * node ) override final {403 virtual const ast::DeclWithType * visit( const ast::InlineMemberDecl * node ) override final { 404 404 os << "inline "; 405 405 if ( ! node->name.empty() ) os << node->name; -
src/AST/Visitor.hpp
r1553a55 r29702ad 33 33 virtual const ast::DirectiveDecl * visit( const ast::DirectiveDecl * ) = 0; 34 34 virtual const ast::StaticAssertDecl * visit( const ast::StaticAssertDecl * ) = 0; 35 virtual const ast::DeclWithType * visit( const ast::Inline ValueDecl* ) = 0;35 virtual const ast::DeclWithType * visit( const ast::InlineMemberDecl * ) = 0; 36 36 virtual const ast::CompoundStmt * visit( const ast::CompoundStmt * ) = 0; 37 37 virtual const ast::Stmt * visit( const ast::ExprStmt * ) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.