Changeset 7030dab for src/Parser/DeclarationNode.cc
- Timestamp:
- Apr 6, 2020, 4:46:28 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- e3bc51c
- Parents:
- 71d6bd8 (diff), 057298e (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r71d6bd8 r7030dab 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 : Mon Dec 16 15:32:22 2019 13 // Update Count : 1133 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::aggregateNames[] = { "struct", "union", "trait", "coroutine", "monitor", "thread", "NoAggregateNames" };50 const char * DeclarationNode::typeClassNames[] = { "otype", "dtype", "ftype", "NoTypeClassNames" };51 49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; 52 50 … … 59 57 60 58 // variable.name = nullptr; 61 variable.tyClass = NoTypeClass;59 variable.tyClass = TypeDecl::NUMBER_OF_KINDS; 62 60 variable.assertions = nullptr; 63 61 variable.initializer = nullptr; … … 135 133 136 134 if ( linkage != LinkageSpec::Cforall ) { 137 os << LinkageSpec:: linkageName( linkage ) << " ";135 os << LinkageSpec::name( linkage ) << " "; 138 136 } // if 139 137 … … 267 265 } 268 266 269 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {267 DeclarationNode * DeclarationNode::newAggregate( AggregateDecl::Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 270 268 DeclarationNode * newnode = new DeclarationNode; 271 269 newnode->type = new TypeData( TypeData::Aggregate ); … … 313 311 } // DeclarationNode::newFromTypeGen 314 312 315 DeclarationNode * DeclarationNode::newTypeParam( Type Classtc, const string * name ) {313 DeclarationNode * DeclarationNode::newTypeParam( TypeDecl::Kind tc, const string * name ) { 316 314 DeclarationNode * newnode = new DeclarationNode; 317 315 newnode->type = nullptr; … … 328 326 newnode->type = new TypeData( TypeData::Aggregate ); 329 327 newnode->type->aggregate.name = name; 330 newnode->type->aggregate.kind = Trait;328 newnode->type->aggregate.kind = AggregateDecl::Trait; 331 329 newnode->type->aggregate.params = params; 332 330 newnode->type->aggregate.fields = asserts; … … 338 336 newnode->type = new TypeData( TypeData::AggregateInst ); 339 337 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 340 newnode->type->aggInst.aggregate->aggregate.kind = Trait;338 newnode->type->aggInst.aggregate->aggregate.kind = AggregateDecl::Trait; 341 339 newnode->type->aggInst.aggregate->aggregate.name = name; 342 340 newnode->type->aggInst.params = params; … … 671 669 672 670 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 673 if ( variable.tyClass != NoTypeClass) {671 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { 674 672 if ( variable.assertions ) { 675 673 variable.assertions->appendList( assertions ); … … 876 874 877 875 DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) { 878 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." ); 879 877 variable.initializer = init; 880 878 return this; … … 1075 1073 } // if 1076 1074 1077 if ( variable.tyClass != NoTypeClass) {1075 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { 1078 1076 // otype is internally converted to dtype + otype parameters 1079 1077 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1080 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." ); 1081 1079 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1082 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 ); 1083 1081 buildList( variable.assertions, ret->get_assertions() ); 1084 1082 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.