Changes in src/AST/Decl.hpp [a00a2c1:07de76b]
- File:
-
- 1 edited
-
src/AST/Decl.hpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
ra00a2c1 r07de76b 33 33 34 34 // 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); 38 36 39 37 namespace ast { … … 79 77 ptr<Expr> asmName; 80 78 bool isDeleted = false; 81 bool isTypeFixed = false;82 79 83 80 DeclWithType( const CodeLocation& loc, const std::string& name, Storage::Classes storage, … … 91 88 virtual const Type * get_type() const = 0; 92 89 /// 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; 94 91 95 92 const DeclWithType * accept( Visitor & v ) const override = 0; … … 114 111 115 112 const Type* get_type() const override { return type; } 116 void set_type( constType * ty ) override { type = ty; }113 void set_type( Type * ty ) override { type = ty; } 117 114 118 115 const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); } … … 125 122 class FunctionDecl : public DeclWithType { 126 123 public: 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 declarations132 124 ptr<FunctionType> type; 133 125 ptr<CompoundStmt> stmts; 134 126 std::vector< ptr<Expr> > withExprs; 135 127 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, 139 129 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 ) {} 143 133 144 134 const Type * get_type() const override; 145 void set_type( const Type * t) override;135 void set_type(Type * t) override; 146 136 147 137 bool has_body() const { return stmts; } … … 157 147 public: 158 148 ptr<Type> base; 149 std::vector<ptr<TypeDecl>> params; 159 150 std::vector<ptr<DeclWithType>> assertions; 160 151 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() {} 165 155 166 156 /// Produces a name for the kind of alias … … 196 186 }; 197 187 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 ) {} 203 192 204 193 const char * typeString() const override; … … 270 259 271 260 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; } 275 263 276 264 const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
Note:
See TracChangeset
for help on using the changeset viewer.