Ignore:
Timestamp:
Dec 11, 2019, 8:52:38 PM (5 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/SynTree/Declaration.h

    r98d6965d r312029a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr May  2 10:47:00 2019
    13 // Update Count     : 135
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Dec 11 16:48:20 2019
     13// Update Count     : 149
    1414//
    1515
     
    2525#include "Mutator.h"             // for Mutator
    2626#include "Parser/LinkageSpec.h"  // for Spec, Cforall
    27 #include "Parser/ParseNode.h"    // for DeclarationNode, DeclarationNode::Ag...
    2827#include "SynTree.h"             // for UniqueId
    2928#include "SynTree/Type.h"        // for Type, Type::StorageClasses, Type::Fu...
     
    194193        std::list< DeclarationWithType* >& get_assertions() { return assertions; }
    195194
    196         virtual std::string typeString() const = 0;
     195        virtual const char * typeString() const = 0;
    197196
    198197        virtual NamedTypeDecl *clone() const override = 0;
     
    237236        TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
    238237
    239         virtual std::string typeString() const override;
    240         virtual std::string genTypeString() const;
     238        virtual const char * typeString() const override;
     239        virtual const char * genTypeString() const;
    241240
    242241        virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
     
    257256        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    258257
    259         virtual std::string typeString() const override;
     258        virtual const char * typeString() const override;
    260259
    261260        virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
     
    269268        typedef Declaration Parent;
    270269  public:
     270        enum Aggregate { Struct, Union, Enum, Exception, Trait, Generator, Coroutine, Monitor, Thread, NoAggregate };
     271        static const char * aggrString( Aggregate aggr );
     272
    271273        std::list<Declaration*> members;
    272274        std::list<TypeDecl*> parameters;
     
    291293        virtual void printShort( std::ostream &os, Indenter indent = {} ) const override;
    292294  protected:
    293         virtual std::string typeString() const = 0;
     295        virtual const char * typeString() const = 0;
    294296};
    295297
     
    297299        typedef AggregateDecl Parent;
    298300  public:
    299         StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
     301        StructDecl( const std::string &name, Aggregate kind = Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {}
    300302        StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {}
    301303
    302         bool is_coroutine() { return kind == DeclarationNode::Coroutine; }
    303         bool is_monitor() { return kind == DeclarationNode::Monitor; }
    304         bool is_thread() { return kind == DeclarationNode::Thread; }
     304        bool is_coroutine() { return kind == Coroutine; }
     305        bool is_monitor() { return kind == Monitor; }
     306        bool is_thread() { return kind == Thread; }
    305307
    306308        virtual StructDecl *clone() const override { return new StructDecl( *this ); }
     
    308310        virtual void accept( Visitor & v ) const override { v.visit( this ); }
    309311        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    310         DeclarationNode::Aggregate kind;
    311   private:
    312         virtual std::string typeString() const override;
     312        Aggregate kind;
     313  private:
     314        virtual const char * typeString() const override;
    313315};
    314316
     
    324326        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    325327  private:
    326         virtual std::string typeString() const override;
     328        virtual const char * typeString() const override;
    327329};
    328330
     
    341343  private:
    342344        std::unordered_map< std::string, long long int > enumValues;
    343         virtual std::string typeString() const override;
     345        virtual const char * typeString() const override;
    344346};
    345347
     
    357359        virtual Declaration *acceptMutator( Mutator &m )  override { return m.mutate( this ); }
    358360  private:
    359         virtual std::string typeString() const override;
     361        virtual const char * typeString() const override;
    360362};
    361363
Note: See TracChangeset for help on using the changeset viewer.