Changes in src/Parser/DeclarationNode.cc [d912bed:033ff37]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rd912bed r033ff37 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 15:32:22201913 // Update Count : 11 3312 // Last Modified On : Thu Jul 25 22:17:10 2019 13 // Update Count : 1116 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, Cforall 26 27 #include "Parser/ParseNode.h" // for DeclarationNode, ExpressionNode 27 #include "SynTree/LinkageSpec.h" // for Spec, linkageName, Cforall28 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" }; 49 51 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; 50 52 … … 57 59 58 60 // variable.name = nullptr; 59 variable.tyClass = TypeDecl::NUMBER_OF_KINDS;61 variable.tyClass = NoTypeClass; 60 62 variable.assertions = nullptr; 61 63 variable.initializer = nullptr; … … 133 135 134 136 if ( linkage != LinkageSpec::Cforall ) { 135 os << LinkageSpec:: name( linkage ) << " ";137 os << LinkageSpec::linkageName( linkage ) << " "; 136 138 } // if 137 139 … … 265 267 } 266 268 267 DeclarationNode * DeclarationNode::newAggregate( Aggregate Decl::Aggregatekind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) {269 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 268 270 DeclarationNode * newnode = new DeclarationNode; 269 271 newnode->type = new TypeData( TypeData::Aggregate ); … … 311 313 } // DeclarationNode::newFromTypeGen 312 314 313 DeclarationNode * DeclarationNode::newTypeParam( Type Decl::Kindtc, const string * name ) {315 DeclarationNode * DeclarationNode::newTypeParam( TypeClass tc, const string * name ) { 314 316 DeclarationNode * newnode = new DeclarationNode; 315 317 newnode->type = nullptr; … … 326 328 newnode->type = new TypeData( TypeData::Aggregate ); 327 329 newnode->type->aggregate.name = name; 328 newnode->type->aggregate.kind = AggregateDecl::Trait;330 newnode->type->aggregate.kind = Trait; 329 331 newnode->type->aggregate.params = params; 330 332 newnode->type->aggregate.fields = asserts; … … 336 338 newnode->type = new TypeData( TypeData::AggregateInst ); 337 339 newnode->type->aggInst.aggregate = new TypeData( TypeData::Aggregate ); 338 newnode->type->aggInst.aggregate->aggregate.kind = AggregateDecl::Trait;340 newnode->type->aggInst.aggregate->aggregate.kind = Trait; 339 341 newnode->type->aggInst.aggregate->aggregate.name = name; 340 342 newnode->type->aggInst.params = params; … … 669 671 670 672 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 671 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS) {673 if ( variable.tyClass != NoTypeClass ) { 672 674 if ( variable.assertions ) { 673 675 variable.assertions->appendList( assertions ); … … 874 876 875 877 DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) { 876 assertf( variable.tyClass != TypeDecl::NUMBER_OF_KINDS, "Called addTypeInitializer on something that isn't a type variable." );878 assertf( variable.tyClass != NoTypeClass, "Called addTypeInitializer on something that isn't a type variable." ); 877 879 variable.initializer = init; 878 880 return this; … … 1073 1075 } // if 1074 1076 1075 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS) {1077 if ( variable.tyClass != NoTypeClass ) { 1076 1078 // otype is internally converted to dtype + otype parameters 1077 1079 static const TypeDecl::Kind kindMap[] = { TypeDecl::Dtype, TypeDecl::Dtype, TypeDecl::Ftype, TypeDecl::Ttype }; 1078 static_assert( sizeof(kindMap)/sizeof(kindMap[0]) == TypeDecl::NUMBER_OF_KINDS, "DeclarationNode::build: kindMap is out of sync." );1080 assertf( sizeof(kindMap)/sizeof(kindMap[0]) == NoTypeClass, "DeclarationNode::build: kindMap is out of sync." ); 1079 1081 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1080 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == TypeDecl::Otype, variable.initializer ? variable.initializer->buildType() : nullptr );1082 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.tyClass == Otype, variable.initializer ? variable.initializer->buildType() : nullptr ); 1081 1083 buildList( variable.assertions, ret->get_assertions() ); 1082 1084 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.