Changeset 312029a for src/Parser
- Timestamp:
- Dec 11, 2019, 8:52:38 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 737c98a
- Parents:
- 98d6965d
- Location:
- src/Parser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r98d6965d r312029a 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:17:10201913 // Update Count : 11 1612 // Last Modified On : Wed Dec 11 07:40:14 2019 13 // Update Count : 1123 14 14 // 15 15 … … 47 47 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 48 48 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; 49 const char * DeclarationNode::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };50 49 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" }; 51 50 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; … … 267 266 } 268 267 269 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {268 DeclarationNode * DeclarationNode::newAggregate( AggregateDecl::Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 270 269 DeclarationNode * newnode = new DeclarationNode; 271 270 newnode->type = new TypeData( TypeData::Aggregate ); … … 328 327 newnode->type = new TypeData( TypeData::Aggregate ); 329 328 newnode->type->aggregate.name = name; 330 newnode->type->aggregate.kind = Trait;329 newnode->type->aggregate.kind = AggregateDecl::Trait; 331 330 newnode->type->aggregate.params = params; 332 331 newnode->type->aggregate.fields = asserts; … … 338 337 newnode->type = new TypeData( TypeData::AggregateInst ); 339 338 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 340 newnode->type->aggInst.aggregate->aggregate.kind = Trait;339 newnode->type->aggInst.aggregate->aggregate.kind = AggregateDecl::Trait; 341 340 newnode->type->aggInst.aggregate->aggregate.name = name; 342 341 newnode->type->aggInst.params = params; -
src/Parser/ExpressionNode.cc
r98d6965d r312029a 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 4 20:57:55201913 // Update Count : 9 7812 // Last Modified On : Tue Dec 10 23:01:47 2019 13 // Update Count : 980 14 14 // 15 15 … … 434 434 } // build_cast 435 435 436 Expression * build_keyword_cast( KeywordCastExpr::Targettarget, ExpressionNode * expr_node ) {436 Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node ) { 437 437 return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target ); 438 438 } -
src/Parser/ParseNode.h
r98d6965d r312029a 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 22:17:10201913 // Update Count : 8 7612 // Last Modified On : Wed Dec 11 07:40:07 2019 13 // Update Count : 882 14 14 // 15 15 … … 29 29 #include "Common/utility.h" // for maybeClone, maybeBuild 30 30 #include "Parser/LinkageSpec.h" // for Spec 31 #include "SynTree/Declaration.h" // for Aggregate 31 32 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only) 32 33 #include "SynTree/Label.h" // for Label … … 184 185 185 186 Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 186 Expression * build_keyword_cast( KeywordCastExpr::Targettarget, ExpressionNode * expr_node );187 Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node ); 187 188 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ); 188 189 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ); … … 217 218 enum Length { Short, Long, LongLong, NoLength }; 218 219 static const char * lengthNames[]; 219 enum Aggregate { Struct, Union, Exception, Trait, Coroutine, Monitor, Thread, NoAggregate };220 static const char * aggregateNames[];221 220 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass }; 222 221 static const char * typeClassNames[]; … … 237 236 static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * ); 238 237 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 239 static DeclarationNode * newAggregate( Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );238 static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 240 239 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body ); 241 240 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); -
src/Parser/TypeData.cc
r98d6965d r312029a 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 13 18:16:23 201913 // Update Count : 6 4912 // Last Modified On : Wed Dec 11 07:48:33 2019 13 // Update Count : 659 14 14 // 15 15 … … 67 67 case Aggregate: 68 68 // aggregate = new Aggregate_t; 69 aggregate.kind = DeclarationNode::NoAggregate;69 aggregate.kind = AggregateDecl::NoAggregate; 70 70 aggregate.name = nullptr; 71 71 aggregate.params = nullptr; … … 345 345 break; 346 346 case Aggregate: 347 os << DeclarationNode::aggregateNames[ aggregate.kind ]<< ' ' << *aggregate.name << endl;347 os << AggregateDecl::aggrString( aggregate.kind ) << ' ' << *aggregate.name << endl; 348 348 if ( aggregate.params ) { 349 349 os << string( indent + 2, ' ' ) << "with type parameters" << endl; … … 768 768 AggregateDecl * at; 769 769 switch ( td->aggregate.kind ) { 770 case DeclarationNode::Struct:771 case DeclarationNode::Coroutine:772 case DeclarationNode::Monitor:773 case DeclarationNode::Thread:770 case AggregateDecl::Struct: 771 case AggregateDecl::Coroutine: 772 case AggregateDecl::Monitor: 773 case AggregateDecl::Thread: 774 774 at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage ); 775 775 buildForall( td->aggregate.params, at->get_parameters() ); 776 776 break; 777 case DeclarationNode::Union:777 case AggregateDecl::Union: 778 778 at = new UnionDecl( *td->aggregate.name, attributes, linkage ); 779 779 buildForall( td->aggregate.params, at->get_parameters() ); 780 780 break; 781 case DeclarationNode::Trait:781 case AggregateDecl::Trait: 782 782 at = new TraitDecl( *td->aggregate.name, attributes, linkage ); 783 783 buildList( td->aggregate.params, at->get_parameters() ); … … 809 809 AggregateDecl * typedecl = buildAggregate( type, attributes, linkage ); 810 810 switch ( type->aggregate.kind ) { 811 case DeclarationNode::Struct:812 case DeclarationNode::Coroutine:813 case DeclarationNode::Monitor:814 case DeclarationNode::Thread:811 case AggregateDecl::Struct: 812 case AggregateDecl::Coroutine: 813 case AggregateDecl::Monitor: 814 case AggregateDecl::Thread: 815 815 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 816 816 break; 817 case DeclarationNode::Union:817 case AggregateDecl::Union: 818 818 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 819 819 break; 820 case DeclarationNode::Trait:820 case AggregateDecl::Trait: 821 821 assert( false ); 822 822 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); … … 827 827 } else { 828 828 switch ( type->aggregate.kind ) { 829 case DeclarationNode::Struct:830 case DeclarationNode::Coroutine:831 case DeclarationNode::Monitor:832 case DeclarationNode::Thread:829 case AggregateDecl::Struct: 830 case AggregateDecl::Coroutine: 831 case AggregateDecl::Monitor: 832 case AggregateDecl::Thread: 833 833 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 834 834 break; 835 case DeclarationNode::Union:835 case AggregateDecl::Union: 836 836 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 837 837 break; 838 case DeclarationNode::Trait:838 case AggregateDecl::Trait: 839 839 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 840 840 break; … … 863 863 case TypeData::Aggregate: { 864 864 switch ( type->aggregate.kind ) { 865 case DeclarationNode::Struct:866 case DeclarationNode::Coroutine:867 case DeclarationNode::Monitor:868 case DeclarationNode::Thread:865 case AggregateDecl::Struct: 866 case AggregateDecl::Coroutine: 867 case AggregateDecl::Monitor: 868 case AggregateDecl::Thread: 869 869 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 870 870 break; 871 case DeclarationNode::Union:871 case AggregateDecl::Union: 872 872 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 873 873 break; 874 case DeclarationNode::Trait:874 case AggregateDecl::Trait: 875 875 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 876 876 break; -
src/Parser/TypeData.h
r98d6965d r312029a 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Nov 1 20:56:46 201813 // Update Count : 19 612 // Last Modified On : Tue Dec 10 23:01:07 2019 13 // Update Count : 198 14 14 // 15 15 … … 30 30 31 31 struct Aggregate_t { 32 DeclarationNode::Aggregate kind;32 AggregateDecl::Aggregate kind; 33 33 const std::string * name = nullptr; 34 34 DeclarationNode * params = nullptr; -
src/Parser/parser.yy
r98d6965d r312029a 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 7 10:43:44201913 // Update Count : 4 39412 // Last Modified On : Tue Dec 10 23:07:17 2019 13 // Update Count : 4400 14 14 // 15 15 … … 51 51 using namespace std; 52 52 53 #include "SynTree/Declaration.h" 53 54 #include "ParseNode.h" 54 55 #include "TypedefTable.h" … … 211 212 } // forCtrl 212 213 213 KeywordCastExpr::Target Aggregate2Target( DeclarationNode::Aggregate aggr ) {214 KeywordCastExpr::Target target;215 switch ( aggr ) {216 case DeclarationNode::Coroutine: target = KeywordCastExpr::Coroutine; break;217 case DeclarationNode::Monitor: target = KeywordCastExpr::Monitor; break;218 case DeclarationNode::Thread: target = KeywordCastExpr::Thread; break;219 default: abort();220 } // switch221 return target;222 } // Aggregate2Target223 224 225 214 bool forall = false, yyy = false; // aggregate have one or more forall qualifiers ? 226 215 … … 248 237 ExpressionNode * en; 249 238 DeclarationNode * decl; 250 DeclarationNode::Aggregate aggKey;239 AggregateDecl::Aggregate aggKey; 251 240 DeclarationNode::TypeClass tclass; 252 241 StatementNode * sn; … … 662 651 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 663 652 | postfix_expression '.' aggregate_control 664 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); }653 { $$ = new ExpressionNode( build_keyword_cast( $3, $1 ) ); } 665 654 | postfix_expression ARROW identifier 666 655 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } … … 807 796 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 808 797 | '(' aggregate_control '&' ')' cast_expression // CFA 809 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); }798 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 810 799 // VIRTUAL cannot be opt because of look ahead issues 811 800 | '(' VIRTUAL ')' cast_expression // CFA … … 2071 2060 aggregate_data: 2072 2061 STRUCT 2073 { yyy = true; $$ = DeclarationNode::Struct; }2062 { yyy = true; $$ = AggregateDecl::Struct; } 2074 2063 | UNION 2075 { yyy = true; $$ = DeclarationNode::Union; }2064 { yyy = true; $$ = AggregateDecl::Union; } 2076 2065 | EXCEPTION // CFA 2077 { yyy = true; $$ = DeclarationNode::Exception; }2066 { yyy = true; $$ = AggregateDecl::Exception; } 2078 2067 ; 2079 2068 2080 2069 aggregate_control: // CFA 2081 2070 GENERATOR 2082 { yyy = true; $$ = DeclarationNode::Coroutine; }2071 { yyy = true; $$ = AggregateDecl::Coroutine; } 2083 2072 | COROUTINE 2084 { yyy = true; $$ = DeclarationNode::Coroutine; }2073 { yyy = true; $$ = AggregateDecl::Coroutine; } 2085 2074 | MONITOR 2086 { yyy = true; $$ = DeclarationNode::Monitor; }2075 { yyy = true; $$ = AggregateDecl::Monitor; } 2087 2076 | THREAD 2088 { yyy = true; $$ = DeclarationNode::Thread; }2077 { yyy = true; $$ = AggregateDecl::Thread; } 2089 2078 ; 2090 2079
Note: See TracChangeset
for help on using the changeset viewer.