Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    ra00a2c1 r07de76b  
    3333
    3434// Must be included in *all* AST classes; should be #undef'd at the end of the file
    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);
     35#define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
    3836
    3937namespace ast {
     
    7977        ptr<Expr> asmName;
    8078        bool isDeleted = false;
    81         bool isTypeFixed = false;
    8279
    8380        DeclWithType( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
     
    9188        virtual const Type * get_type() const = 0;
    9289        /// Set type of this declaration. May be verified by subclass
    93         virtual void set_type( const Type * ) = 0;
     90        virtual void set_type(Type *) = 0;
    9491
    9592        const DeclWithType * accept( Visitor & v ) const override = 0;
     
    114111
    115112        const Type* get_type() const override { return type; }
    116         void set_type( const Type * ty ) override { type = ty; }
     113        void set_type( Type * ty ) override { type = ty; }
    117114
    118115        const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); }
     
    125122class FunctionDecl : public DeclWithType {
    126123public:
    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
    132124        ptr<FunctionType> type;
    133125        ptr<CompoundStmt> stmts;
    134126        std::vector< ptr<Expr> > withExprs;
    135127
    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,
     128        FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type,
    139129                CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C,
    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 ) {}
     130                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {})
     131        : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
     132          stmts( stmts ) {}
    143133
    144134        const Type * get_type() const override;
    145         void set_type( const Type * t ) override;
     135        void set_type(Type * t) override;
    146136
    147137        bool has_body() const { return stmts; }
     
    157147public:
    158148        ptr<Type> base;
     149        std::vector<ptr<TypeDecl>> params;
    159150        std::vector<ptr<DeclWithType>> assertions;
    160151
    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() {}
     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() {}
    165155
    166156        /// Produces a name for the kind of alias
     
    196186        };
    197187
    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 ) {}
     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 ) {}
    203192
    204193        const char * typeString() const override;
     
    270259
    271260        bool is_coroutine() { return kind == Coroutine; }
    272         bool is_generator() { return kind == Generator; }
    273         bool is_monitor  () { return kind == Monitor  ; }
    274         bool is_thread   () { return kind == Thread   ; }
     261        bool is_monitor() { return kind == Monitor; }
     262        bool is_thread() { return kind == Thread; }
    275263
    276264        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
Note: See TracChangeset for help on using the changeset viewer.