Changeset 312029a for src/AST/Decl.cpp


Ignore:
Timestamp:
Dec 11, 2019, 8:52:38 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

move enum Aggregate from DeclarationNode? to AggregateDecl?, add control-keyword field-dereference to replace control-keyword cast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r98d6965d r312029a  
    99// Author           : Aaron B. Moss
    1010// Created On       : Thu May 9 10:00:00 2019
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Thu May 9 10:00:00 2019
    13 // Update Count     : 1
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 16:41:39 2019
     13// Update Count     : 18
    1414//
    1515
     
    1818#include <cassert>             // for assert, strict_dynamic_cast
    1919#include <iostream>
    20 #include <string>
    2120#include <unordered_map>
    2221
     
    5655// --- TypeDecl
    5756
    58 std::string TypeDecl::typeString() const {
    59         static const std::string kindNames[] = { "object type", "function type", "tuple type" };
     57const char * TypeDecl::typeString() const {
     58        static const char * kindNames[] = { "sized object type", "sized function type", "sized tuple type" };
    6059        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1,
    6160                "typeString: kindNames is out of sync." );
    6261        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
    63         return (sized ? "sized " : "") + kindNames[ kind ];
     62        return sized ? kindNames[ kind ] : &kindNames[ kind ][ sizeof("sized") ]; // sizeof includes '\0'
    6463}
    6564
    66 std::string TypeDecl::genTypeString() const {
    67         static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
     65const char * TypeDecl::genTypeString() const {
     66        static const char * kindNames[] = { "dtype", "ftype", "ttype" };
    6867        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
    6968        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     
    7372std::ostream & operator<< ( std::ostream & out, const TypeDecl::Data & data ) {
    7473        return out << data.kind << ", " << data.isComplete;
     74}
     75
     76// --- AggregateDecl
     77
     78// These must harmonize with the corresponding AggregateDecl::Aggregate enumerations.
     79static const char * aggregateNames[] = { "struct", "union", "enum", "exception", "trait", "generator", "coroutine", "monitor", "thread", "NoAggregateName" };
     80
     81const char * AggregateDecl::aggrString( AggregateDecl::Aggregate aggr ) {
     82        return aggregateNames[aggr];
    7583}
    7684
Note: See TracChangeset for help on using the changeset viewer.