Changeset 07de76b for src/Parser
- Timestamp:
- Dec 16, 2019, 2:30:41 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:
- bffcd66
- Parents:
- ab5c0008
- git-author:
- Peter A. Buhr <pabuhr@…> (12/16/19 14:23:00)
- git-committer:
- Peter A. Buhr <pabuhr@…> (12/16/19 14:30:41)
- Location:
- src/Parser
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rab5c0008 r07de76b 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:40:14201913 // Update Count : 11 2312 // Last Modified On : Mon Dec 16 09:32:40 2019 13 // Update Count : 1132 14 14 // 15 15 … … 24 24 #include "Common/UniqueName.h" // for UniqueName 25 25 #include "Common/utility.h" // for maybeClone, maybeBuild, CodeLocation 26 #include "Parser/LinkageSpec.h" // for Spec, linkageName, Cforall27 26 #include "Parser/ParseNode.h" // for DeclarationNode, ExpressionNode 27 #include "SynTree/LinkageSpec.h" // for Spec, linkageName, Cforall 28 28 #include "SynTree/Attribute.h" // for Attribute 29 29 #include "SynTree/Declaration.h" // for TypeDecl, ObjectDecl, Declaration … … 47 47 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 48 48 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; 49 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };50 49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; 51 50 … … 58 57 59 58 // variable.name = nullptr; 60 variable.tyClass = NoTypeClass;59 variable.tyClass = TypeDecl::NUMBER_OF_KINDS; 61 60 variable.assertions = nullptr; 62 61 variable.initializer = nullptr; … … 312 311 } // DeclarationNode::newFromTypeGen 313 312 314 DeclarationNode * DeclarationNode::newTypeParam( Type Classtc, const string * name ) {313 DeclarationNode * DeclarationNode::newTypeParam( TypeDecl::Kind tc, const string * name ) { 315 314 DeclarationNode * newnode = new DeclarationNode; 316 315 newnode->type = nullptr; … … 670 669 671 670 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 672 if ( variable.tyClass != NoTypeClass) {671 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { 673 672 if ( variable.assertions ) { 674 673 variable.assertions->appendList( assertions ); … … 875 874 876 875 DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) { 877 assertf( variable.tyClass != NoTypeClass, "Called addTypeInitializer on something that isn't a type variable." );876 assertf( variable.tyClass != TypeDecl::NUMBER_OF_KINDS, "Called addTypeInitializer on something that isn't a type variable." ); 878 877 variable.initializer = init; 879 878 return this; … … 1074 1073 } // if 1075 1074 1076 if ( variable.tyClass != NoTypeClass) {1075 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { 1077 1076 // otype is internally converted to dtype + otype parameters 1078 1077 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1079 assertf( sizeof(kindMap)/sizeof(kindMap[0]) == NoTypeClass, "DeclarationNode::build: kindMap is out of sync." );1078 static_assert( sizeof(kindMap)/sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." ); 1080 1079 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1081 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr );1080 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr ); 1082 1081 buildList( variable.assertions, ret->get_assertions() ); 1083 1082 return ret; -
src/Parser/ParseNode.h
rab5c0008 r07de76b 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:40:07201913 // Update Count : 88 212 // Last Modified On : Mon Dec 16 07:46:01 2019 13 // Update Count : 888 14 14 // 15 15 … … 28 28 #include "Common/UniqueName.h" // for UniqueName 29 29 #include "Common/utility.h" // for maybeClone, maybeBuild 30 #include " Parser/LinkageSpec.h"// for Spec30 #include "SynTree/LinkageSpec.h" // for Spec 31 31 #include "SynTree/Declaration.h" // for Aggregate 32 32 #include "SynTree/Expression.h" // for Expression, ConstantExpr (ptr only) … … 218 218 enum Length { Short, Long, LongLong, NoLength }; 219 219 static const char * lengthNames[]; 220 enum TypeClass { Otype, Dtype, Ftype, Ttype, NoTypeClass };221 static const char * typeClassNames[];222 220 enum BuiltinType { Valist, AutoType, Zero, One, NoBuiltinType }; 223 221 static const char * builtinTypeNames[]; … … 241 239 static DeclarationNode * newName( const std::string * ); 242 240 static DeclarationNode * newFromTypeGen( const std::string *, ExpressionNode * params ); 243 static DeclarationNode * newTypeParam( Type Class, const std::string * );241 static DeclarationNode * newTypeParam( TypeDecl::Kind, const std::string * ); 244 242 static DeclarationNode * newTrait( const std::string * name, DeclarationNode * params, DeclarationNode * asserts ); 245 243 static DeclarationNode * newTraitUse( const std::string * name, ExpressionNode * params ); … … 311 309 struct Variable_t { 312 310 // const std::string * name; 313 DeclarationNode::TypeClasstyClass;311 TypeDecl::Kind tyClass; 314 312 DeclarationNode * assertions; 315 313 DeclarationNode * initializer; -
src/Parser/TypeData.cc
rab5c0008 r07de76b 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 11 07:48:33201913 // Update Count : 6 5912 // Last Modified On : Mon Dec 16 07:56:46 2019 13 // Update Count : 662 14 14 // 15 15 … … 489 489 for ( typename ForallList::iterator i = outputList.begin(); i != outputList.end(); ++i, n = (DeclarationNode*)n->get_next() ) { 490 490 TypeDecl * td = static_cast<TypeDecl *>(*i); 491 if ( n->variable.tyClass == DeclarationNode::Otype ) {491 if ( n->variable.tyClass == TypeDecl::Otype ) { 492 492 // add assertion parameters to `type' tyvars in reverse order 493 493 // add dtor: void ^?{}(T *) … … 522 522 switch ( td->kind ) { 523 523 case TypeData::Unknown: 524 525 524 // fill in implicit int 525 return new BasicType( buildQualifiers( td ), BasicType::SignedInt ); 526 526 case TypeData::Basic: 527 527 return buildBasicType( td ); 528 528 case TypeData::Pointer: 529 529 return buildPointer( td ); 530 530 case TypeData::Array: 531 531 return buildArray( td ); 532 532 case TypeData::Reference: 533 533 return buildReference( td ); 534 534 case TypeData::Function: 535 535 return buildFunction( td ); 536 536 case TypeData::AggregateInst: 537 537 return buildAggInst( td ); 538 538 case TypeData::EnumConstant: 539 540 539 // the name gets filled in later -- by SymTab::Validate 540 return new EnumInstType( buildQualifiers( td ), "" ); 541 541 case TypeData::SymbolicInst: 542 542 return buildSymbolicInst( td ); 543 543 case TypeData::Tuple: 544 544 return buildTuple( td ); 545 545 case TypeData::Typeof: 546 546 case TypeData::Basetypeof: 547 547 return buildTypeof( td ); 548 548 case TypeData::Builtin: 549 if (td->builtintype == DeclarationNode::Zero) { 550 return new ZeroType( noQualifiers ); 551 } 552 else if (td->builtintype == DeclarationNode::One) { 553 return new OneType( noQualifiers ); 554 } 555 else { 556 return new VarArgsType( buildQualifiers( td ) ); 557 } 549 switch ( td->builtintype ) { 550 case DeclarationNode::Zero: 551 return new ZeroType( noQualifiers ); 552 case DeclarationNode::One: 553 return new OneType( noQualifiers ); 554 default: 555 return new VarArgsType( buildQualifiers( td ) ); 556 } // switch 558 557 case TypeData::GlobalScope: 559 560 561 558 return new GlobalScopeType(); 559 case TypeData::Qualified: 560 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) ); 562 561 case TypeData::Symbolic: 563 562 case TypeData::Enum: 564 563 case TypeData::Aggregate: 565 564 assert( false ); 566 565 } // switch 567 566 -
src/Parser/TypeData.h
rab5c0008 r07de76b 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Dec 10 23:01:07201913 // Update Count : 19 812 // Last Modified On : Fri Dec 13 23:42:35 2019 13 // Update Count : 199 14 14 // 15 15 … … 21 21 22 22 #include "ParseNode.h" // for DeclarationNode, DeclarationNode::Ag... 23 #include " Parser/LinkageSpec.h"// for Spec23 #include "SynTree/LinkageSpec.h" // for Spec 24 24 #include "SynTree/Type.h" // for Type, ReferenceToType (ptr only) 25 25 #include "SynTree/SynTree.h" // for Visitor Nodes -
src/Parser/module.mk
rab5c0008 r07de76b 11 11 ## Created On : Sat May 16 15:29:09 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Wed Jun 28 21:58:29 201714 ## Update Count : 10 413 ## Last Modified On : Sat Dec 14 07:34:47 2019 14 ## Update Count : 107 15 15 ############################################################################### 16 16 … … 19 19 AM_YFLAGS = -d -t -v 20 20 21 SRC += Parser/parser.yy \ 22 Parser/lex.ll \ 23 Parser/TypedefTable.cc \ 24 Parser/ParseNode.cc \ 21 SRC += \ 25 22 Parser/DeclarationNode.cc \ 26 23 Parser/ExpressionNode.cc \ 24 Parser/InitializerNode.cc \ 25 Parser/ParseNode.cc \ 27 26 Parser/StatementNode.cc \ 28 Parser/InitializerNode.cc \29 27 Parser/TypeData.cc \ 30 Parser/LinkageSpec.cc \ 28 Parser/TypedefTable.cc \ 29 Parser/lex.ll \ 30 Parser/parser.yy \ 31 31 Parser/parserutility.cc 32 32 33 SRCDEMANGLE += \34 Parser/LinkageSpec.cc35 36 37 33 MOSTLYCLEANFILES += Parser/lex.cc Parser/parser.cc Parser/parser.hh Parser/parser.output -
src/Parser/parser.yy
rab5c0008 r07de76b 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Dec 12 17:54:22201913 // Update Count : 440 412 // Last Modified On : Mon Dec 16 07:45:59 2019 13 // Update Count : 4408 14 14 // 15 15 … … 55 55 #include "TypedefTable.h" 56 56 #include "TypeData.h" 57 #include " LinkageSpec.h"57 #include "SynTree/LinkageSpec.h" 58 58 #include "Common/SemanticError.h" // error_str 59 59 #include "Common/utility.h" // for maybeMoveBuild, maybeBuild, CodeLo... … … 238 238 DeclarationNode * decl; 239 239 AggregateDecl::Aggregate aggKey; 240 DeclarationNode::TypeClasstclass;240 TypeDecl::Kind tclass; 241 241 StatementNode * sn; 242 242 WaitForStmt * wfs; … … 2437 2437 | type_specifier identifier_parameter_declarator 2438 2438 | assertion_list 2439 { $$ = DeclarationNode::newTypeParam( DeclarationNode::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); }2439 { $$ = DeclarationNode::newTypeParam( TypeDecl::Dtype, new string( DeclarationNode::anonymous.newName() ) )->addAssertions( $1 ); } 2440 2440 ; 2441 2441 2442 2442 type_class: // CFA 2443 2443 OTYPE 2444 { $$ = DeclarationNode::Otype; }2444 { $$ = TypeDecl::Otype; } 2445 2445 | DTYPE 2446 { $$ = DeclarationNode::Dtype; }2446 { $$ = TypeDecl::Dtype; } 2447 2447 | FTYPE 2448 { $$ = DeclarationNode::Ftype; }2448 { $$ = TypeDecl::Ftype; } 2449 2449 | TTYPE 2450 { $$ = DeclarationNode::Ttype; }2450 { $$ = TypeDecl::Ttype; } 2451 2451 ; 2452 2452
Note: See TracChangeset
for help on using the changeset viewer.