Changes in src/AST/Decl.hpp [e67991f:99da267]
- File:
-
- 1 edited
-
src/AST/Decl.hpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
re67991f r99da267 32 32 33 33 // 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); 35 37 36 38 namespace ast { … … 87 89 virtual const Type * get_type() const = 0; 88 90 /// 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; 90 92 91 93 const DeclWithType * accept( Visitor & v ) const override = 0; … … 102 104 ptr<Expr> bitfieldWidth; 103 105 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, 107 109 std::vector< ptr<Attribute> > && attrs = {}, Function::Specs fs = {} ) 108 110 : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ), … … 110 112 111 113 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; } 113 115 114 116 const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); } … … 132 134 133 135 const Type * get_type() const override; 134 void set_type( Type * t) override;136 void set_type( const Type * t ) override; 135 137 136 138 bool has_body() const { return stmts; } … … 149 151 std::vector<ptr<DeclWithType>> assertions; 150 152 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 ) 153 156 : Decl( loc, name, storage, spec ), base( b ), params(), assertions() {} 154 157 … … 185 188 }; 186 189 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 ) 189 193 : NamedTypeDecl( loc, name, storage, b ), kind( k ), sized( k == TypeVar::Ttype || s ), 190 194 init( i ) {} … … 321 325 }; 322 326 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_FRIEND336 };337 338 327 class AsmDecl : public Decl { 339 328 public:
Note:
See TracChangeset
for help on using the changeset viewer.