Changeset eef8dfb for src/AST/Decl.hpp
- Timestamp:
- Jan 7, 2021, 2:55:57 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 58fe85a
- Parents:
- bdfc032 (diff), 44e37ef (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Decl.hpp
rbdfc032 reef8dfb 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 template<typename node_t> friend node_t * mutate(const node_t * node); 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); 36 38 37 39 namespace ast { … … 77 79 ptr<Expr> asmName; 78 80 bool isDeleted = false; 81 bool isTypeFixed = false; 79 82 80 83 DeclWithType( const CodeLocation& loc, const std::string& name, Storage::Classes storage, … … 88 91 virtual const Type * get_type() const = 0; 89 92 /// Set type of this declaration. May be verified by subclass 90 virtual void set_type( Type *) = 0;93 virtual void set_type( const Type * ) = 0; 91 94 92 95 const DeclWithType * accept( Visitor & v ) const override = 0; … … 111 114 112 115 const Type* get_type() const override { return type; } 113 void set_type( Type * ty ) override { type = ty; }116 void set_type( const Type * ty ) override { type = ty; } 114 117 115 118 const DeclWithType * accept( Visitor& v ) const override { return v.visit( this ); } … … 122 125 class FunctionDecl : public DeclWithType { 123 126 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 declarations 124 132 ptr<FunctionType> type; 125 133 ptr<CompoundStmt> stmts; 126 134 std::vector< ptr<Expr> > withExprs; 127 135 128 FunctionDecl( const CodeLocation & loc, const std::string & name, FunctionType * type, 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, 129 139 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, 130 std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {} )131 : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type),132 stmts( stmts ) {}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 ) {} 133 143 134 144 const Type * get_type() const override; 135 void set_type( Type * t) override;145 void set_type( const Type * t ) override; 136 146 137 147 bool has_body() const { return stmts; } … … 147 157 public: 148 158 ptr<Type> base; 149 std::vector<ptr<TypeDecl>> params;150 159 std::vector<ptr<DeclWithType>> assertions; 151 160 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() {} 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() {} 155 165 156 166 /// Produces a name for the kind of alias … … 186 196 }; 187 197 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 ) {} 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 ) {} 192 203 193 204 const char * typeString() const override; … … 259 270 260 271 bool is_coroutine() { return kind == Coroutine; } 261 bool is_monitor() { return kind == Monitor; } 262 bool is_thread() { return kind == Thread; } 272 bool is_generator() { return kind == Generator; } 273 bool is_monitor () { return kind == Monitor ; } 274 bool is_thread () { return kind == Thread ; } 263 275 264 276 const Decl * accept( Visitor & v ) const override { return v.visit( this ); }
Note:
See TracChangeset
for help on using the changeset viewer.