Changeset 360b2e1 for src/AST/Decl.cpp


Ignore:
Timestamp:
May 10, 2019, 2:28:54 PM (4 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
arm-eh, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
7e89526, b96d7c1
Parents:
9131e54
Message:

Add TypeDecl? to new AST

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.cpp

    r9131e54 r360b2e1  
    1414//
    1515
    16 #include <cassert>        // for assert, strict_dynamic_cast
     16#include "Decl.hpp"
     17
     18#include <cassert>             // for assert, strict_dynamic_cast
     19#include <string>
    1720#include <unordered_map>
    1821
    19 #include "Decl.hpp"
    20 
    21 #include "Fwd.hpp"        // for UniqueId
     22#include "Fwd.hpp"             // for UniqueId
    2223#include "Init.hpp"
    23 #include "Node.hpp"       // for readonly
     24#include "Node.hpp"            // for readonly
     25#include "Parser/ParseNode.h"  // for DeclarationNode
    2426
    2527namespace ast {
     
    4143        if ( i != idMap.end() ) return i->second;
    4244        return {};
     45}
     46
     47// --- TypeDecl
     48
     49std::string TypeDecl::typeString() const {
     50        static const std::string kindNames[] = { "object type", "function type", "tuple type" };
     51        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1,
     52                "typeString: kindNames is out of sync." );
     53        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     54        return (sized ? "sized " : "") + kindNames[ kind ];
     55}
     56
     57std::string TypeDecl::genTypeString() const {
     58        static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
     59        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
     60        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     61        return kindNames[ kind ];
    4362}
    4463
Note: See TracChangeset for help on using the changeset viewer.