Changeset f135b50 for src/Parser
- Timestamp:
- Feb 28, 2022, 3:41:44 AM (2 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 786c438
- Parents:
- a8ef59e
- Location:
- src/Parser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
ra8ef59e rf135b50 78 78 delete variable.initializer; 79 79 80 delete type;80 // delete type; 81 81 delete bitfieldWidth; 82 82 … … 253 253 } // DeclarationNode::newAggregate 254 254 255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool ) {255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool typed) { 256 256 DeclarationNode * newnode = new DeclarationNode; 257 257 newnode->type = new TypeData( TypeData::Enum ); … … 272 272 } // DeclarationNode::newName 273 273 274 DeclarationNode * DeclarationNode::newEnumConstant( const string * name, ExpressionNode * constant ) { 274 DeclarationNode * DeclarationNode::newEnumConstant( const string * name, ExpressionNode * constant ) { // Marker 275 275 DeclarationNode * newnode = newName( name ); 276 276 newnode->enumeratorValue.reset( constant ); … … 667 667 } 668 668 669 DeclarationNode * DeclarationNode::addEnumBase( DeclarationNode * o ) { 670 if ( o && o -> type) { 671 type->base= o->type; 672 } 673 delete o; 674 return this; 675 } 676 669 677 DeclarationNode * DeclarationNode::addTypedef() { 670 678 TypeData * newtype = new TypeData( TypeData::Symbolic ); -
src/Parser/ParseNode.h
ra8ef59e rf135b50 265 265 DeclarationNode * addType( DeclarationNode * ); 266 266 DeclarationNode * addTypedef(); 267 DeclarationNode * addEnumBase( DeclarationNode * ); 267 268 DeclarationNode * addAssertions( DeclarationNode * ); 268 269 DeclarationNode * addName( std::string * ); -
src/Parser/StatementNode.cc
ra8ef59e rf135b50 366 366 } // maybe_build_compound 367 367 368 // Question 368 369 Statement * build_asm( bool voltile, Expression * instruction, ExpressionNode * output, ExpressionNode * input, ExpressionNode * clobber, LabelNode * gotolabels ) { 369 370 list< Expression * > out, in; -
src/Parser/TypeData.cc
ra8ef59e rf135b50 918 918 EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 919 919 assert( td->kind == TypeData::Enum ); 920 EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, linkage ); 921 buildList( td->enumeration.constants, ret->get_members() ); 920 Type* baseType = td->base ? typebuild(td->base) : nullptr; 921 EnumDecl * ret = new EnumDecl( *td->enumeration.name, attributes, linkage, baseType ); 922 buildList( td->enumeration.constants, ret->get_members() ); // enumConstant is both a node and a list 922 923 list< Declaration * >::iterator members = ret->get_members().begin(); 923 for ( const DeclarationNode * cur = td->enumeration. 924 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 924 925 if ( cur->has_enumeratorValue() ) { 925 926 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); … … 927 928 } // if 928 929 } // for 929 ret->set_body( td->enumeration.body ); 930 ret->set_body( td->enumeration.body ); // Boolean; if it has body 930 931 return ret; 931 932 } // buildEnum -
src/Parser/TypeData.h
ra8ef59e rf135b50 132 132 Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 133 133 FunctionType * buildFunction( const TypeData * ); 134 Declaration * addEnumBase( Declaration *, const TypeData * ); 134 135 void buildKRFunction( const TypeData::Function_t & function ); 135 136 -
src/Parser/parser.yy
ra8ef59e rf135b50 2292 2292 { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2293 2293 // SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr; 2294 $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 ); 2294 2295 $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 ) -> addEnumBase( $3 ); 2296 // $$ = DeclarationNode::newEnum( nullptr, $7, true, true ) ->addQualifiers( $5 ); 2295 2297 } 2296 2298 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier … … 2301 2303 '{' enumerator_list comma_opt '}' 2302 2304 { 2303 $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2305 $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2306 // $$ = DeclarationNode::newEnum( $6, $10, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2304 2307 } 2305 2308 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' … … 2307 2310 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2308 2311 typedefTable.makeTypedef( *$6->name ); 2309 $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2312 $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2313 // $$ = DeclarationNode::newEnum( $6->name, $9, true, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ); 2310 2314 } 2311 2315 | enum_type_nobody
Note: See TracChangeset
for help on using the changeset viewer.