Changes in / [db6cdc0:1fb09eff]
- Location:
- src
- Files:
-
- 9 edited
-
AST/Convert.cpp (modified) (1 diff)
-
AST/Decl.hpp (modified) (1 diff)
-
AST/Pass.impl.hpp (modified) (1 diff)
-
Parser/DeclarationNode.cc (modified) (2 diffs)
-
Parser/ParseNode.h (modified) (1 diff)
-
Parser/TypeData.cc (modified) (1 diff)
-
Parser/TypeData.h (modified) (1 diff)
-
Parser/parser.yy (modified) (2 diffs)
-
SynTree/Declaration.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
rdb6cdc0 r1fb09eff 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,1767 1766 old->enumValues 1768 1767 ); -
src/AST/Decl.hpp
rdb6cdc0 r1fb09eff 315 315 // enum (type_optional) Name {...} 316 316 ptr<Type> base; // if isTyped == true && base.get() == nullptr, it is a "void" type enum 317 enum class EnumHiding { Visible, Hide } hide; 318 319 EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false, 317 318 EnumDecl( const CodeLocation& loc, const std::string& name, bool isTyped = false, 320 319 std::vector<ptr<Attribute>>&& attrs = {}, Linkage::Spec linkage = Linkage::Cforall, 321 Type const * base = nullptr, EnumHiding hide = EnumHiding::Hide,320 Type const * base = nullptr, 322 321 std::unordered_map< std::string, long long > enumValues = std::unordered_map< std::string, long long >() ) 323 : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), hide(hide),enumValues(enumValues) {}322 : AggregateDecl( loc, name, std::move(attrs), linkage ), isTyped(isTyped), base(base), enumValues(enumValues) {} 324 323 325 324 /// gets the integer value for this enumerator, returning true iff value found -
src/AST/Pass.impl.hpp
rdb6cdc0 r1fb09eff 686 686 687 687 if ( __visit_children() ) { 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 } 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 ); 700 693 } 701 694 -
src/Parser/DeclarationNode.cc
rdb6cdc0 r1fb09eff 254 254 } // DeclarationNode::newAggregate 255 255 256 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base , EnumHiding hiding) {256 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base) { 257 257 DeclarationNode * newnode = new DeclarationNode; 258 258 newnode->type = new TypeData( TypeData::Enum ); … … 262 262 newnode->type->enumeration.anon = name == nullptr; 263 263 newnode->type->enumeration.typed = typed; 264 newnode->type->enumeration.hiding = hiding;265 264 if ( base && base->type) { 266 265 newnode->type->base = base->type; -
src/Parser/ParseNode.h
rdb6cdc0 r1fb09eff 239 239 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 240 240 static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 241 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base = nullptr , EnumHiding hiding = EnumHiding::Visible);241 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base = nullptr ); 242 242 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 243 243 static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init ); -
src/Parser/TypeData.cc
rdb6cdc0 r1fb09eff 923 923 buildList( td->enumeration.constants, ret->get_members() ); 924 924 list< Declaration * >::iterator members = ret->get_members().begin(); 925 ret->hide = td->enumeration.hiding == EnumHiding::Hide ? EnumDecl::EnumHiding::Hide : EnumDecl::EnumHiding::Visible;926 925 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 927 926 if ( cur->enumInLine ) { -
src/Parser/TypeData.h
rdb6cdc0 r1fb09eff 60 60 bool anon; 61 61 bool typed; 62 EnumHiding hiding;63 62 }; 64 63 -
src/Parser/parser.yy
rdb6cdc0 r1fb09eff 2558 2558 { typedefTable.makeTypedef( *$3 ); } 2559 2559 hide_opt '{' enumerator_list comma_opt '}' 2560 { $$ = DeclarationNode::newEnum( $3, $7, true, false , nullptr, $5)->addQualifiers( $2 ); }2560 { $$ = DeclarationNode::newEnum( $3, $7, true, false )->addQualifiers( $2 ); } 2561 2561 | ENUM attribute_list_opt typedef_name // unqualified type name 2562 2562 hide_opt '{' enumerator_list comma_opt '}' 2563 { $$ = DeclarationNode::newEnum( $3->name, $6, true, false , nullptr, $4)->addQualifiers( $2 ); }2563 { $$ = DeclarationNode::newEnum( $3->name, $6, true, false )->addQualifiers( $2 ); } 2564 2564 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}' 2565 2565 { … … 2580 2580 hide_opt '{' enumerator_list comma_opt '}' 2581 2581 { 2582 $$ = DeclarationNode::newEnum( $6, $11, true, true, $3 , $9)->addQualifiers( $5 )->addQualifiers( $7 );2582 $$ = DeclarationNode::newEnum( $6, $11, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 ); 2583 2583 } 2584 2584 | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt 2585 2585 hide_opt '{' enumerator_list comma_opt '}' 2586 2586 { 2587 $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr , $7)->addQualifiers( $4 )->addQualifiers( $6 );2587 $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 ); 2588 2588 } 2589 2589 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt 2590 2590 hide_opt '{' enumerator_list comma_opt '}' 2591 2591 { 2592 $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3 , $8)->addQualifiers( $5 )->addQualifiers( $7 );2592 $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 ); 2593 2593 } 2594 2594 | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt 2595 2595 hide_opt '{' enumerator_list comma_opt '}' 2596 2596 { 2597 $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr , $7)->addQualifiers( $4 )->addQualifiers( $6 );2597 $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 ); 2598 2598 } 2599 2599 | enum_type_nobody -
src/SynTree/Declaration.h
rdb6cdc0 r1fb09eff 340 340 bool isTyped; 341 341 Type * base; 342 enum EnumHiding { Visible, Hide } hide;343 342 344 343 EnumDecl( const std::string & name, … … 346 345 bool isTyped = false, LinkageSpec::Spec linkage = LinkageSpec::Cforall, 347 346 Type * baseType = nullptr ) 348 : Parent( name, attributes, linkage ), isTyped(isTyped), base( baseType ) {}347 : Parent( name, attributes, linkage ),isTyped(isTyped), base( baseType ) {} 349 348 EnumDecl( const EnumDecl & other ) 350 349 : Parent( other ), isTyped( other.isTyped), base( other.base ) {}
Note:
See TracChangeset
for help on using the changeset viewer.