Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r99da267 re67991f  
    3232
    3333// Must be included in *all* AST classes; should be #undef'd at the end of the file
    34 #define MUTATE_FRIEND \
    35     template<typename node_t> friend node_t * mutate(const node_t * node); \
    36         template<typename node_t> friend node_t * shallowCopy(const node_t * node);
     34#define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
    3735
    3836namespace ast {
     
    8987        virtual const Type * get_type() const = 0;
    9088        /// Set type of this declaration. May be verified by subclass
    91         virtual void set_type( const Type * ) = 0;
     89        virtual void set_type(Type *) = 0;
    9290
    9391        const DeclWithType * accept( Visitor & v ) const override = 0;
     
    104102        ptr<Expr> bitfieldWidth;
    105103
    106         ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type, 
    107                 const Init * init = nullptr, Storage::Classes storage = {}, 
    108                 Linkage::Spec linkage = Linkage::C, const Expr * bitWd = nullptr, 
     104        ObjectDecl( const CodeLocation & loc, const std::string & name, const Type * type,
     105                const Init * init = nullptr, Storage::Classes storage = {},
     106                Linkage::Spec linkage = Linkage::C, const Expr * bitWd = nullptr,
    109107                std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} )
    110108        : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
     
    112110
    113111        const Type* get_type() const override { return type; }
    114         void set_type( const Type * ty ) override { type = ty; }
     112        void set_type( Type * ty ) override { type = ty; }
    115113
    116114        const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); }
     
    134132
    135133        const Type * get_type() const override;
    136         void set_type( const Type * t ) override;
     134        void set_type(Type * t) override;
    137135
    138136        bool has_body() const { return stmts; }
     
    151149        std::vector<ptr<DeclWithType>> assertions;
    152150
    153         NamedTypeDecl(
    154                 const CodeLocation & loc, const std::string & name, Storage::Classes storage,
    155                 const Type * b, Linkage::Spec spec = Linkage::Cforall )
     151        NamedTypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
     152                Type* b, Linkage::Spec spec = Linkage::Cforall )
    156153        : Decl( loc, name, storage, spec ), base( b ), params(), assertions() {}
    157154
     
    188185        };
    189186
    190         TypeDecl(
    191                 const CodeLocation & loc, const std::string & name, Storage::Classes storage,
    192                 const Type * b, TypeVar::Kind k, bool s, const Type * i = nullptr )
     187        TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b,
     188                TypeVar::Kind k, bool s, Type* i = nullptr )
    193189        : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ),
    194190          init( i ) {}
     
    325321};
    326322
     323/// With statement `with (...) ...`
     324class WithStmt final : public Decl {
     325public:
     326        std::vector<ptr<Expr>> exprs;
     327        ptr<Stmt> stmt;
     328
     329        WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt * stmt )
     330        : Decl(loc, "", Storage::Auto, Linkage::Cforall), exprs(std::move(exprs)), stmt(stmt) {}
     331
     332        const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
     333private:
     334        WithStmt * clone() const override { return new WithStmt{ *this }; }
     335        MUTATE_FRIEND
     336};
     337
    327338class AsmDecl : public Decl {
    328339public:
Note: See TracChangeset for help on using the changeset viewer.