Changeset 136ccd7 for src/SynTree


Ignore:
Timestamp:
Nov 3, 2017, 3:01:31 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4ee36bf0
Parents:
4ee1efb (diff), 760ba67 (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.
Message:

Merge branch 'master' into cleanup-dtors

Location:
src/SynTree
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    r4ee1efb r136ccd7  
    200200        typedef NamedTypeDecl Parent;
    201201  public:
    202         enum Kind { Any, Dtype, Ftype, Ttype };
     202        enum Kind { Dtype, Ftype, Ttype };
    203203
    204204        Type * init;
     
    216216        };
    217217
    218         TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );
     218        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr );
    219219        TypeDecl( const TypeDecl &other );
    220220        virtual ~TypeDecl();
     
    225225        TypeDecl * set_init( Type * newValue ) { init = newValue; return this; }
    226226
    227         bool isComplete() const { return kind == Any || sized; }
     227        bool isComplete() const { return sized; }
    228228        bool get_sized() const { return sized; }
    229229        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
  • src/SynTree/TypeDecl.cc

    r4ee1efb r136ccd7  
    2121#include "Type.h"            // for Type, Type::StorageClasses
    2222
    23 TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Any || kind == Ttype ), kind( kind ) {
     23TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), init( init ), sized( kind == Ttype || sized ), kind( kind ) {
    2424}
    2525
     
    3232
    3333std::string TypeDecl::typeString() const {
    34         static const std::string kindNames[] = { "type", "incomplete type", "function type", "tuple type" };
    35         return (kind != Any && isComplete() ? "sized " : "") + kindNames[ kind ];
     34        static const std::string kindNames[] = { "object type", "function type", "tuple type" };
     35        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "typeString: kindNames is out of sync." );
     36        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
     37        return (isComplete() ? "sized " : "") + kindNames[ kind ];
    3638}
    3739
    3840std::string TypeDecl::genTypeString() const {
    39         static const std::string kindNames[] = { "otype", "dtype", "ftype", "ttype" };
     41        static const std::string kindNames[] = { "dtype", "ftype", "ttype" };
     42        assertf( sizeof(kindNames)/sizeof(kindNames[0]) == DeclarationNode::NoTypeClass-1, "genTypeString: kindNames is out of sync." );
     43        assertf( kind < sizeof(kindNames)/sizeof(kindNames[0]), "TypeDecl's kind is out of bounds." );
    4044        return kindNames[ kind ];
    4145}
Note: See TracChangeset for help on using the changeset viewer.