Changeset eef8dfb for src/AST/Decl.hpp


Ignore:
Timestamp:
Jan 7, 2021, 2:55:57 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
58fe85a
Parents:
bdfc032 (diff), 44e37ef (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 dkobets-vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    rbdfc032 reef8dfb  
    3333
    3434// Must be included in *all* AST classes; should be #undef'd at the end of the file
    35 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     35#define MUTATE_FRIEND \
     36    template<typename node_t> friend node_t * mutate(const node_t * node); \
     37        template<typename node_t> friend node_t * shallowCopy(const node_t * node);
    3638
    3739namespace ast {
     
    7779        ptr<Expr> asmName;
    7880        bool isDeleted = false;
     81        bool isTypeFixed = false;
    7982
    8083        DeclWithType( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
     
    8891        virtual const Type * get_type() const = 0;
    8992        /// Set type of this declaration. May be verified by subclass
    90         virtual void set_type(Type *) = 0;
     93        virtual void set_type( const Type * ) = 0;
    9194
    9295        const DeclWithType * accept( Visitor & v ) const override = 0;
     
    111114
    112115        const Type* get_type() const override { return type; }
    113         void set_type( Type * ty ) override { type = ty; }
     116        void set_type( const Type * ty ) override { type = ty; }
    114117
    115118        const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); }
     
    122125class FunctionDecl : public DeclWithType {
    123126public:
     127        std::vector<ptr<DeclWithType>> params;
     128        std::vector<ptr<DeclWithType>> returns;
     129        std::vector<ptr<TypeDecl>> type_params;
     130        std::vector<ptr<DeclWithType>> assertions;
     131        // declared type, derived from parameter declarations
    124132        ptr<FunctionType> type;
    125133        ptr<CompoundStmt> stmts;
    126134        std::vector< ptr<Expr> > withExprs;
    127135
    128         FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,
     136
     137        FunctionDecl( const CodeLocation & loc, const std::string & name, std::vector<ptr<TypeDecl>>&& forall,
     138                std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
    129139                CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C,
    130                 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {})
    131         : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
    132           stmts( stmts ) {}
     140                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, bool isVarArgs = false);
     141        // : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), params(std::move(params)), returns(std::move(returns)),
     142        //  stmts( stmts ) {}
    133143
    134144        const Type * get_type() const override;
    135         void set_type(Type * t) override;
     145        void set_type( const Type * t ) override;
    136146
    137147        bool has_body() const { return stmts; }
     
    147157public:
    148158        ptr<Type> base;
    149         std::vector<ptr<TypeDecl>> params;
    150159        std::vector<ptr<DeclWithType>> assertions;
    151160
    152         NamedTypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
    153                 Type* b, Linkage::Spec spec = Linkage::Cforall )
    154         : Decl( loc, name, storage, spec ), base( b ), params(), assertions() {}
     161        NamedTypeDecl(
     162                const CodeLocation & loc, const std::string & name, Storage::Classes storage,
     163                const Type * b, Linkage::Spec spec = Linkage::Cforall )
     164        : Decl( loc, name, storage, spec ), base( b ), assertions() {}
    155165
    156166        /// Produces a name for the kind of alias
     
    186196        };
    187197
    188         TypeDecl( const CodeLocation & loc, const std::string & name, Storage::Classes storage, Type * b,
    189                           Kind k, bool s, Type * i = nullptr )
    190                 : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == Ttype || s ),
    191                 init( i ) {}
     198        TypeDecl(
     199                const CodeLocation & loc, const std::string & name, Storage::Classes storage,
     200                const Type * b, TypeDecl::Kind k, bool s, const Type * i = nullptr )
     201        : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeDecl::Ttype || s ),
     202          init( i ) {}
    192203
    193204        const char * typeString() const override;
     
    259270
    260271        bool is_coroutine() { return kind == Coroutine; }
    261         bool is_monitor() { return kind == Monitor; }
    262         bool is_thread() { return kind == Thread; }
     272        bool is_generator() { return kind == Generator; }
     273        bool is_monitor  () { return kind == Monitor  ; }
     274        bool is_thread   () { return kind == Thread   ; }
    263275
    264276        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
Note: See TracChangeset for help on using the changeset viewer.