Changeset 1e30df7
- Timestamp:
- Oct 18, 2022, 5:48:13 PM (19 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 5408b59
- Parents:
- a55472cc
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
ra55472cc r1e30df7 1615 1615 { old->get_funcSpec().val } 1616 1616 ); 1617 decl->enumInLine = old->enumInLine; 1617 1618 cache.emplace(old, decl); 1618 1619 assert(cache.find( old ) != cache.end()); -
src/AST/Decl.hpp
ra55472cc r1e30df7 105 105 ptr<Init> init; 106 106 ptr<Expr> bitfieldWidth; 107 bool enumInLine = false; // A flag vairable to tell the compile: 108 // this is not a real object declaration. It is a place holder for 109 // a set of enum value (ObjectDecl). 107 110 108 111 ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, -
src/Parser/DeclarationNode.cc
ra55472cc r1e30df7 297 297 } // if 298 298 } // DeclarationNode::newEnumValueGeneric 299 300 DeclarationNode * DeclarationNode::newEnumInLine( const string name ) { 301 DeclarationNode * newnode = newName( new std::string(name) ); 302 newnode->enumInLine = true; 303 return newnode; 304 } 299 305 300 306 DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) { -
src/Parser/ParseNode.h
ra55472cc r1e30df7 240 240 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 241 241 static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init ); 242 static DeclarationNode * newEnumInLine( const std::string name ); 242 243 static DeclarationNode * newName( const std::string * ); 243 244 static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params ); … … 339 340 340 341 bool inLine = false; 342 bool enumInLine = false; 341 343 Type::FuncSpecifiers funcSpecs; 342 344 Type::StorageClasses storageClasses; -
src/Parser/TypeData.cc
ra55472cc r1e30df7 924 924 list< Declaration * >::iterator members = ret->get_members().begin(); 925 925 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 926 if ( cur->enumInLine ) { 927 // Tell the compiler this is a inline value placeholder 928 ObjectDecl * member = dynamic_cast< ObjectDecl* >(* members); 929 member->enumInLine = true; 930 } 926 931 if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) { 927 932 SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." ); -
src/Parser/parser.yy
ra55472cc r1e30df7 2601 2601 { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); } 2602 2602 | INLINE type_name 2603 { $$ = DeclarationNode::newEnum ValueGeneric( new string("inline"), nullptr); }2603 { $$ = DeclarationNode::newEnumInLine( *$2->type->symbolic.name ); } 2604 2604 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2605 2605 { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); } -
src/SynTree/Declaration.h
ra55472cc r1e30df7 121 121 Initializer * init; 122 122 Expression * bitfieldWidth; 123 bool enumInLine = false; 123 124 124 125 ObjectDecl( const std::string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression * bitfieldWidth, Type * type, Initializer * init, -
src/Validate/LinkReferenceToTypes.cpp
ra55472cc r1e30df7 203 203 } 204 204 205 // The following section 206 auto mut = ast::mutate( decl ); 207 std::vector<ast::ptr<ast::Decl>> buffer; 208 for ( auto it = decl->members.begin(); it != decl->members.end(); ++it) { 209 auto member = (*it).as<ast::ObjectDecl>(); 210 if ( member->enumInLine ) { 211 auto targetEnum = symtab.lookupEnum( member->name ); 212 if (targetEnum) { 213 for (auto singleMamber : targetEnum->members) { 214 auto tm = singleMamber.as<ast::ObjectDecl>(); 215 auto t = new ast::ObjectDecl( 216 member->location, // use the "inline" location 217 tm->name, 218 new ast::EnumInstType( decl, ast::CV::Const ), 219 // Construct a new EnumInstType as the type 220 tm->init, 221 tm->storage, 222 tm->linkage, 223 tm->bitfieldWidth, 224 {}, // enum member doesn't have attribute 225 tm->funcSpec 226 ); 227 buffer.push_back(t); 228 } 229 } 230 } else { 231 buffer.push_back( *it ); 232 } 233 } 234 mut->members = buffer; 235 decl = mut; 236 205 237 ForwardEnumsType::iterator fwds = forwardEnums.find( decl->name ); 206 238 if ( fwds != forwardEnums.end() ) {
Note: See TracChangeset
for help on using the changeset viewer.