- Timestamp:
- Feb 23, 2017, 5:10:56 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 783dfd6
- Parents:
- 51f3798 (diff), 24cde55 (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/Parser
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r51f3798 r6ce9f7c7 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 16 13:06:50201713 // Update Count : 75 312 // Last Modified On : Thu Feb 23 15:45:02 2017 13 // Update Count : 759 14 14 // 15 15 … … 174 174 } // if 175 175 176 if ( body ) {177 newnode->type->function.hasBody = true;178 } // if179 180 176 if ( ret ) { 181 177 newnode->type->base = ret->type; … … 259 255 } // DeclarationNode::newAggregate 260 256 261 DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants ) {257 DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants, bool body ) { 262 258 DeclarationNode * newnode = new DeclarationNode; 263 259 newnode->type = new TypeData( TypeData::Enum ); … … 268 264 } // if 269 265 newnode->type->enumeration.constants = constants; 266 newnode->type->enumeration.body = body; 270 267 return newnode; 271 268 } // DeclarationNode::newEnum … … 698 695 assert( ! type->function.body ); 699 696 type->function.body = body; 700 type->function.hasBody = true;701 697 return this; 702 698 } … … 1040 1036 switch ( type->kind ) { 1041 1037 case TypeData::Enum: { 1042 EnumDecl * typedecl = buildEnum( type, attributes ); 1043 return new EnumInstType( buildQualifiers( type ), typedecl ); 1038 if ( type->enumeration.body ) { 1039 EnumDecl * typedecl = buildEnum( type, attributes ); 1040 return new EnumInstType( buildQualifiers( type ), typedecl ); 1041 } else { 1042 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 1043 } 1044 1044 } 1045 1045 case TypeData::Aggregate: { 1046 AggregateDecl * typedecl = buildAggregate( type, attributes );1047 1046 ReferenceToType * ret; 1048 switch ( type->aggregate.kind ) { 1049 case DeclarationNode::Struct: 1050 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 1051 break; 1052 case DeclarationNode::Union: 1053 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 1054 break; 1055 case DeclarationNode::Trait: 1056 assert( false ); 1057 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 1058 break; 1059 default: 1060 assert( false ); 1061 } // switch 1047 if ( type->aggregate.body ) { 1048 AggregateDecl * typedecl = buildAggregate( type, attributes ); 1049 switch ( type->aggregate.kind ) { 1050 case DeclarationNode::Struct: 1051 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 1052 break; 1053 case DeclarationNode::Union: 1054 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 1055 break; 1056 case DeclarationNode::Trait: 1057 assert( false ); 1058 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 1059 break; 1060 default: 1061 assert( false ); 1062 } // switch 1063 } else { 1064 switch ( type->aggregate.kind ) { 1065 case DeclarationNode::Struct: 1066 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 1067 break; 1068 case DeclarationNode::Union: 1069 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 1070 break; 1071 case DeclarationNode::Trait: 1072 assert( false ); 1073 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 1074 break; 1075 default: 1076 assert( false ); 1077 } // switch 1078 } // if 1062 1079 buildList( type->aggregate.actuals, ret->get_parameters() ); 1063 1080 return ret; -
src/Parser/ParseNode.h
r51f3798 r6ce9f7c7 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 16 13:15:55201713 // Update Count : 66 112 // Last Modified On : Thu Feb 23 15:22:10 2017 13 // Update Count : 662 14 14 // 15 15 … … 238 238 static DeclarationNode * newFromTypedef( std::string * ); 239 239 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 240 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants );240 static DeclarationNode * newEnum( std::string * name, DeclarationNode * constants, bool body ); 241 241 static DeclarationNode * newEnumConstant( std::string * name, ExpressionNode * constant ); 242 242 static DeclarationNode * newName( std::string * ); -
src/Parser/TypeData.cc
r51f3798 r6ce9f7c7 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 19 09:49:33201713 // Update Count : 4 6712 // Last Modified On : Thu Feb 23 16:26:39 2017 13 // Update Count : 477 14 14 // 15 15 … … 48 48 function.oldDeclList = nullptr; 49 49 function.body = nullptr; 50 function.hasBody = false;51 50 function.newStyle = false; 52 51 break; … … 68 67 enumeration.name = nullptr; 69 68 enumeration.constants = nullptr; 69 enumeration.body = false; 70 70 break; 71 71 case Symbolic: … … 182 182 newtype->function.oldDeclList = maybeClone( function.oldDeclList ); 183 183 newtype->function.body = maybeClone( function.body ); 184 newtype->function.hasBody = function.hasBody;185 184 newtype->function.newStyle = function.newStyle; 186 185 break; … … 200 199 newtype->enumeration.name = enumeration.name ? new string( *enumeration.name ) : nullptr; 201 200 newtype->enumeration.constants = maybeClone( enumeration.constants ); 201 newtype->enumeration.body = enumeration.body; 202 202 break; 203 203 case Symbolic: … … 293 293 } // if 294 294 os << endl; 295 if ( function. hasBody ) {295 if ( function.body ) { 296 296 os << string( indent + 2, ' ' ) << "with body " << endl; 297 } // if298 if ( function.body ) {299 297 function.body->printList( os, indent + 2 ); 300 298 } // if … … 335 333 os << "with constants" << endl; 336 334 enumeration.constants->printList( os, indent + 2 ); 335 } // if 336 if ( enumeration.body ) { 337 os << string( indent + 2, ' ' ) << " with body " << endl; 337 338 } // if 338 339 break; … … 696 697 } // if 697 698 } // for 699 ret->set_body( td->enumeration.body ); 698 700 return ret; 699 701 } // buildEnum … … 724 726 Declaration * buildDecl( const TypeData * td, const string &name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 725 727 if ( td->kind == TypeData::Function ) { 726 if ( td->function.idList ) { 727 buildKRFunction( td->function ); 728 if ( td->function.idList ) { // KR function ? 729 buildKRFunction( td->function ); // transform into C11 function 728 730 } // if 729 731 730 732 FunctionDecl * decl; 731 if ( td->function.hasBody ) { 732 if ( td->function.body ) { 733 Statement * stmt = td->function.body->build(); 734 CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt ); 735 assert( body ); 736 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn, attributes ); 737 } else { 738 // list< Label > ls; 739 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), new CompoundStmt( list< Label >() ), isInline, isNoreturn, attributes ); 740 } // if 741 } else { 742 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), nullptr, isInline, isNoreturn, attributes ); 743 } // if 733 Statement * stmt = maybeBuild<Statement>( td->function.body ); 734 CompoundStmt * body = dynamic_cast< CompoundStmt* >( stmt ); 735 decl = new FunctionDecl( name, sc, linkage, buildFunction( td ), body, isInline, isNoreturn, attributes ); 744 736 return decl->set_asmName( asmName ); 745 737 } else if ( td->kind == TypeData::Aggregate ) { … … 816 808 817 809 for ( DeclarationNode * param = function.idList; param != nullptr; param = dynamic_cast< DeclarationNode* >( param->get_next() ) ) { 818 if ( ! param->type ) { // generate type int for empty parameter s810 if ( ! param->type ) { // generate type int for empty parameter type 819 811 param->type = new TypeData( TypeData::Basic ); 820 812 param->type->basictype = DeclarationNode::Int; -
src/Parser/TypeData.h
r51f3798 r6ce9f7c7 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 16 14:30:05201713 // Update Count : 15 312 // Last Modified On : Thu Feb 23 15:16:18 2017 13 // Update Count : 155 14 14 // 15 15 … … 49 49 const std::string * name; 50 50 DeclarationNode * constants; 51 bool body; 51 52 }; 52 53 … … 56 57 mutable DeclarationNode * oldDeclList; 57 58 StatementNode * body; 58 bool hasBody;59 59 bool newStyle; 60 60 }; -
src/Parser/parser.cc
r51f3798 r6ce9f7c7 7292 7292 /* Line 1806 of yacc.c */ 7293 7293 #line 1651 "parser.yy" 7294 { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(4) - (6)].decl) )->addQualifiers( (yyvsp[(2) - (6)].decl) ); }7294 { (yyval.decl) = DeclarationNode::newEnum( nullptr, (yyvsp[(4) - (6)].decl), true )->addQualifiers( (yyvsp[(2) - (6)].decl) ); } 7295 7295 break; 7296 7296 … … 7301 7301 { 7302 7302 typedefTable.makeTypedef( *(yyvsp[(3) - (3)].tok) ); 7303 (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (3)].tok), 0 )->addQualifiers( (yyvsp[(2) - (3)].decl) );7303 (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (3)].tok), 0, false )->addQualifiers( (yyvsp[(2) - (3)].decl) ); 7304 7304 } 7305 7305 break; … … 7316 7316 /* Line 1806 of yacc.c */ 7317 7317 #line 1660 "parser.yy" 7318 { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (8)].tok), (yyvsp[(6) - (8)].decl) )->addQualifiers( (yyvsp[(2) - (8)].decl) ); }7318 { (yyval.decl) = DeclarationNode::newEnum( (yyvsp[(3) - (8)].tok), (yyvsp[(6) - (8)].decl), true )->addQualifiers( (yyvsp[(2) - (8)].decl) ); } 7319 7319 break; 7320 7320 -
src/Parser/parser.yy
r51f3798 r6ce9f7c7 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 16 15:56:33201713 // Update Count : 218 612 // Last Modified On : Thu Feb 23 15:23:49 2017 13 // Update Count : 2187 14 14 // 15 15 … … 1649 1649 enum_type: 1650 1650 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 1651 { $$ = DeclarationNode::newEnum( nullptr, $4 )->addQualifiers( $2 ); }1651 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 1652 1652 | ENUM attribute_list_opt no_attr_identifier_or_type_name 1653 1653 { 1654 1654 typedefTable.makeTypedef( *$3 ); 1655 $$ = DeclarationNode::newEnum( $3, 0 )->addQualifiers( $2 );1655 $$ = DeclarationNode::newEnum( $3, 0, false )->addQualifiers( $2 ); 1656 1656 } 1657 1657 | ENUM attribute_list_opt no_attr_identifier_or_type_name 1658 1658 { typedefTable.makeTypedef( *$3 ); } 1659 1659 '{' enumerator_list comma_opt '}' 1660 { $$ = DeclarationNode::newEnum( $3, $6 )->addQualifiers( $2 ); }1660 { $$ = DeclarationNode::newEnum( $3, $6, true )->addQualifiers( $2 ); } 1661 1661 ; 1662 1662
Note: See TracChangeset
for help on using the changeset viewer.