Ignore:
Timestamp:
Aug 11, 2017, 10:33:37 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
54cd58b0
Parents:
3d4b23fa (diff), 59a75cb (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' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Declaration.h

    r3d4b23fa r0720e049  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jun 27 15:31:00 2017
    13 // Update Count     : 122
    14 //
    15 
    16 #ifndef DECLARATION_H
    17 #define DECLARATION_H
     12// Last Modified On : Wed Aug  9 14:45:00 2017
     13// Update Count     : 126
     14//
     15
     16#pragma once
    1817
    1918#include <string>
     
    2827class Declaration : public BaseSyntaxNode {
    2928  public:
     29        std::string name;
     30        LinkageSpec::Spec linkage;
     31        bool extension = false;
     32
    3033        Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    3134        Declaration( const Declaration &other );
     
    5457        static void dumpIds( std::ostream &os );
    5558        static Declaration *declFromId( UniqueId id );
    56   private:
    57         std::string name;
     59
     60  private:
    5861        Type::StorageClasses storageClasses;
    59         LinkageSpec::Spec linkage;
    6062        UniqueId uniqueId;
    61         bool extension = false;
    6263};
    6364
    6465class DeclarationWithType : public Declaration {
    6566  public:
    66         DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    67         DeclarationWithType( const DeclarationWithType &other );
    68         virtual ~DeclarationWithType();
    69 
    70         std::string get_mangleName() const { return mangleName; }
    71         DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
    72 
    73         std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
    74 
    75         int get_scopeLevel() const { return scopeLevel; }
    76         DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
    77 
    78         ConstantExpr *get_asmName() const { return asmName; }
    79         DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }
    80 
    81         std::list< Attribute * >& get_attributes() { return attributes; }
    82         const std::list< Attribute * >& get_attributes() const { return attributes; }
    83 
    84         Type::FuncSpecifiers get_funcSpec() const { return fs; }
    85         //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    86 
    87         virtual DeclarationWithType *clone() const = 0;
    88         virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
    89 
    90         virtual Type *get_type() const = 0;
    91         virtual void set_type(Type *) = 0;
    92   private:
    9367        // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2
    9468        std::string mangleName;
     
    9872        ConstantExpr *asmName;
    9973        std::list< Attribute * > attributes;
     74
     75        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
     76        DeclarationWithType( const DeclarationWithType &other );
     77        virtual ~DeclarationWithType();
     78
     79        std::string get_mangleName() const { return mangleName; }
     80        DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
     81
     82        std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
     83
     84        int get_scopeLevel() const { return scopeLevel; }
     85        DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
     86
     87        ConstantExpr *get_asmName() const { return asmName; }
     88        DeclarationWithType * set_asmName( ConstantExpr *newValue ) { asmName = newValue; return this; }
     89
     90        std::list< Attribute * >& get_attributes() { return attributes; }
     91        const std::list< Attribute * >& get_attributes() const { return attributes; }
     92
     93        Type::FuncSpecifiers get_funcSpec() const { return fs; }
     94        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
     95
     96        virtual DeclarationWithType *clone() const = 0;
     97        virtual DeclarationWithType *acceptMutator( Mutator &m ) = 0;
     98
     99        virtual Type *get_type() const = 0;
     100        virtual void set_type(Type *) = 0;
     101
     102  private:
    100103        Type::FuncSpecifiers fs;
    101104};
     
    104107        typedef DeclarationWithType Parent;
    105108  public:
     109        Type *type;
     110        Initializer *init;
     111        Expression *bitfieldWidth;
     112
    106113        ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
    107114                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    123130        virtual void print( std::ostream &os, int indent = 0 ) const;
    124131        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    125   private:
    126         Type *type;
    127         Initializer *init;
    128         Expression *bitfieldWidth;
    129132};
    130133
     
    132135        typedef DeclarationWithType Parent;
    133136  public:
     137        FunctionType *type;
     138        CompoundStmt *statements;
     139
    134140        FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
    135141                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
     
    150156        virtual void print( std::ostream &os, int indent = 0 ) const;
    151157        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    152   private:
    153         FunctionType *type;
    154         CompoundStmt *statements;
    155158};
    156159
     
    158161        typedef Declaration Parent;
    159162  public:
     163        Type *base;
     164        std::list< TypeDecl* > parameters;
     165        std::list< DeclarationWithType* > assertions;
     166
    160167        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    161168        NamedTypeDecl( const NamedTypeDecl &other );
     
    172179        virtual void print( std::ostream &os, int indent = 0 ) const;
    173180        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    174   protected:
    175   private:
    176         Type *base;
    177         std::list< TypeDecl* > parameters;
    178         std::list< DeclarationWithType* > assertions;
    179181};
    180182
     
    183185  public:
    184186        enum Kind { Any, Dtype, Ftype, Ttype };
     187
     188        Type * init;
     189        bool sized;
     190
    185191        /// Data extracted from a type decl
    186192        struct Data {
     
    217223  private:
    218224        Kind kind;
    219         Type * init;
    220         bool sized;
    221225};
    222226
     
    224228        typedef NamedTypeDecl Parent;
    225229  public:
    226         TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}
     230        TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec ); }
    227231        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    228232
     
    238242        typedef Declaration Parent;
    239243  public:
    240         AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
    241         AggregateDecl( const AggregateDecl &other );
    242         virtual ~AggregateDecl();
    243 
    244         std::list<Declaration*>& get_members() { return members; }
    245         std::list<TypeDecl*>& get_parameters() { return parameters; }
    246 
    247         std::list< Attribute * >& get_attributes() { return attributes; }
    248         const std::list< Attribute * >& get_attributes() const { return attributes; }
    249 
    250         bool has_body() const { return body; }
    251         AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
    252 
    253         virtual void print( std::ostream &os, int indent = 0 ) const;
    254         virtual void printShort( std::ostream &os, int indent = 0 ) const;
    255   protected:
    256         virtual std::string typeString() const = 0;
    257 
    258   private:
    259244        std::list<Declaration*> members;
    260245        std::list<TypeDecl*> parameters;
    261246        bool body;
    262247        std::list< Attribute * > attributes;
     248
     249        AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
     250        AggregateDecl( const AggregateDecl &other );
     251        virtual ~AggregateDecl();
     252
     253        std::list<Declaration*>& get_members() { return members; }
     254        std::list<TypeDecl*>& get_parameters() { return parameters; }
     255
     256        std::list< Attribute * >& get_attributes() { return attributes; }
     257        const std::list< Attribute * >& get_attributes() const { return attributes; }
     258
     259        bool has_body() const { return body; }
     260        AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
     261
     262        virtual void print( std::ostream &os, int indent = 0 ) const;
     263        virtual void printShort( std::ostream &os, int indent = 0 ) const;
     264  protected:
     265        virtual std::string typeString() const = 0;
    263266};
    264267
     
    266269        typedef AggregateDecl Parent;
    267270  public:
    268         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 ) {}
     271        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 ), tagged( false ), parent_name( "" ) {}
     272        StructDecl( const std::string &name, const std::string *parent, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( DeclarationNode::Struct ), tagged( true ), parent_name( parent ? *parent : "" ) {}
    269273        StructDecl( const StructDecl &other ) : Parent( other ) {}
    270274
     
    273277        bool is_thread() { return kind == DeclarationNode::Thread; }
    274278
     279        // Tagged/Tree Structure Excetion
     280        bool get_tagged() { return tagged; }
     281        void set_tagged( bool newValue ) { tagged = newValue; }
     282        bool has_parent() { return parent_name != ""; }
     283        std::string get_parentName() { return parent_name; }
     284
    275285        virtual StructDecl *clone() const { return new StructDecl( *this ); }
    276286        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    279289        DeclarationNode::Aggregate kind;
    280290        virtual std::string typeString() const;
     291
     292        bool tagged;
     293        std::string parent_name;
    281294};
    282295
     
    324337class AsmDecl : public Declaration {
    325338  public:
     339        AsmStmt *stmt;
     340
    326341        AsmDecl( AsmStmt *stmt );
    327342        AsmDecl( const AsmDecl &other );
     
    336351        virtual void print( std::ostream &os, int indent = 0 ) const;
    337352        virtual void printShort( std::ostream &os, int indent = 0 ) const;
    338   private:
    339         AsmStmt *stmt;
    340353};
    341354
    342355std::ostream & operator<<( std::ostream & out, const Declaration * decl );
    343356std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    344 
    345 #endif // DECLARATION_H
    346357
    347358// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.