Changes in src/AST/Decl.cpp [07de76b:d76c588]
- File:
-
- 1 edited
-
src/AST/Decl.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.cpp
r07de76b rd76c588 9 9 // Author : Aaron B. Moss 10 10 // Created On : Thu May 9 10:00:00 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Dec 13 16:23:15201913 // Update Count : 2011 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Thu May 9 10:00:00 2019 13 // Update Count : 1 14 14 // 15 15 … … 18 18 #include <cassert> // for assert, strict_dynamic_cast 19 19 #include <iostream> 20 #include <string> 20 21 #include <unordered_map> 21 22 … … 26 27 #include "Node.hpp" // for readonly 27 28 #include "Type.hpp" // for readonly 29 #include "Parser/ParseNode.h" // for DeclarationNode 28 30 29 31 namespace ast { … … 54 56 // --- TypeDecl 55 57 56 const char * TypeDecl::typeString() const { 57 static const char * kindNames[] = { "sized data type", "sized object type", "sized function type", "sized tuple type" }; 58 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "typeString: kindNames is out of sync." ); 59 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDecl kind is out of bounds." ); 60 return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0' 58 std::string TypeDecl::typeString() const { 59 static const std::string kindNames[] = { "object type", "function type", "tuple type" }; 60 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, 61 "typeString: kindNames is out of sync." ); 62 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 63 return (sized ? "sized " : "") + kindNames[ kind ]; 61 64 } 62 65 63 const char *TypeDecl::genTypeString() const {64 static const char * kindNames[] = { "dtype", "otype", "ftype", "ttype" };65 static_assert( sizeof(kindNames)/sizeof(kindNames[0]) == TypeDecl::NUMBER_OF_KINDS, "genTypeString: kindNames is out of sync." );66 assertf( kind < TypeDecl::NUMBER_OF_KINDS, "TypeDeclkind is out of bounds." );66 std::string TypeDecl::genTypeString() const { 67 static const std::string kindNames[] = { "dtype", "ftype", "ttype" }; 68 assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." ); 69 assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." ); 67 70 return kindNames[ kind ]; 68 71 } … … 70 73 std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) { 71 74 return out << data.kind << ", " << data.isComplete; 72 }73 74 // --- AggregateDecl75 76 // These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.77 static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };78 79 const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {80 return aggregateNames[aggr];81 75 } 82 76
Note:
See TracChangeset
for help on using the changeset viewer.