Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    re67991f r99da267  
    3232
    3333// Must be included in *all* AST classes; should be #undef'd at the end of the file
    34 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
     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);
    3537
    3638namespace ast {
     
    8789        virtual const Type * get_type() const = 0;
    8890        /// Set type of this declaration. May be verified by subclass
    89         virtual void set_type(Type *) = 0;
     91        virtual void set_type( const Type * ) = 0;
    9092
    9193        const DeclWithType * accept( Visitor & v ) const override = 0;
     
    102104        ptr<Expr> bitfieldWidth;
    103105
    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,
     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, 
    107109                std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} )
    108110        : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
     
    110112
    111113        const Type* get_type() const override { return type; }
    112         void set_type( Type * ty ) override { type = ty; }
     114        void set_type( const Type * ty ) override { type = ty; }
    113115
    114116        const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); }
     
    132134
    133135        const Type * get_type() const override;
    134         void set_type(Type * t) override;
     136        void set_type( const Type * t ) override;
    135137
    136138        bool has_body() const { return stmts; }
     
    149151        std::vector<ptr<DeclWithType>> assertions;
    150152
    151         NamedTypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage,
    152                 Type* b, Linkage::Spec spec = Linkage::Cforall )
     153        NamedTypeDecl(
     154                const CodeLocation & loc, const std::string & name, Storage::Classes storage,
     155                const Type * b, Linkage::Spec spec = Linkage::Cforall )
    153156        : Decl( loc, name, storage, spec ), base( b ), params(), assertions() {}
    154157
     
    185188        };
    186189
    187         TypeDecl( const CodeLocation& loc, const std::string& name, Storage::Classes storage, Type* b,
    188                 TypeVar::Kind k, bool s, Type* i = nullptr )
     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 )
    189193        : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ),
    190194          init( i ) {}
     
    321325};
    322326
    323 /// With statement `with (...) ...`
    324 class WithStmt final : public Decl {
    325 public:
    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 ); }
    333 private:
    334         WithStmt * clone() const override { return new WithStmt{ *this }; }
    335         MUTATE_FRIEND
    336 };
    337 
    338327class AsmDecl : public Decl {
    339328public:
Note: See TracChangeset for help on using the changeset viewer.