[0dd3a2f] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
[974906e2] | 7 | // Declaration.h -- |
---|
[0dd3a2f] | 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[e612146c] | 11 | // Last Modified By : Peter A. Buhr |
---|
| 12 | // Last Modified On : Sun Sep 3 19:24:06 2017 |
---|
| 13 | // Update Count : 131 |
---|
[0dd3a2f] | 14 | // |
---|
| 15 | |
---|
[6b0b624] | 16 | #pragma once |
---|
[51b7345] | 17 | |
---|
[ea6332d] | 18 | #include <cassert> // for assertf |
---|
| 19 | #include <iosfwd> // for ostream |
---|
| 20 | #include <list> // for list |
---|
| 21 | #include <string> // for string, operator+, allocator, to_string |
---|
| 22 | |
---|
| 23 | #include "BaseSyntaxNode.h" // for BaseSyntaxNode |
---|
| 24 | #include "Mutator.h" // for Mutator |
---|
| 25 | #include "Parser/LinkageSpec.h" // for Spec, Cforall |
---|
| 26 | #include "Parser/ParseNode.h" // for DeclarationNode, DeclarationNode::Ag... |
---|
| 27 | #include "SynTree.h" // for UniqueId |
---|
| 28 | #include "SynTree/Type.h" // for Type, Type::StorageClasses, Type::Fu... |
---|
| 29 | #include "Visitor.h" // for Visitor |
---|
| 30 | |
---|
| 31 | class AsmStmt; |
---|
| 32 | class Attribute; |
---|
| 33 | class CompoundStmt; |
---|
| 34 | class ConstantExpr; |
---|
| 35 | class Expression; |
---|
| 36 | class Initializer; |
---|
| 37 | class TypeDecl; |
---|
[51b7345] | 38 | |
---|
[294647b] | 39 | class Declaration : public BaseSyntaxNode { |
---|
[17cd4eb] | 40 | public: |
---|
[65cdc1e] | 41 | std::string name; |
---|
| 42 | LinkageSpec::Spec linkage; |
---|
| 43 | bool extension = false; |
---|
| 44 | |
---|
[68fe077a] | 45 | Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage ); |
---|
[0dd3a2f] | 46 | Declaration( const Declaration &other ); |
---|
| 47 | virtual ~Declaration(); |
---|
| 48 | |
---|
[5f2f2d7] | 49 | const std::string &get_name() const { return name; } |
---|
[0dd3a2f] | 50 | void set_name( std::string newValue ) { name = newValue; } |
---|
[a7c90d4] | 51 | |
---|
[68fe077a] | 52 | Type::StorageClasses get_storageClasses() const { return storageClasses; } |
---|
[a7c90d4] | 53 | |
---|
[8b7ee09] | 54 | LinkageSpec::Spec get_linkage() const { return linkage; } |
---|
| 55 | void set_linkage( LinkageSpec::Spec newValue ) { linkage = newValue; } |
---|
[a7c90d4] | 56 | |
---|
[0dd3a2f] | 57 | UniqueId get_uniqueId() const { return uniqueId; } |
---|
[a7c90d4] | 58 | |
---|
[8e9cbb2] | 59 | bool get_extension() const { return extension; } |
---|
| 60 | Declaration *set_extension( bool exten ) { extension = exten; return this; } |
---|
[0dd3a2f] | 61 | |
---|
| 62 | void fixUniqueId( void ); |
---|
[fa16264] | 63 | virtual Declaration *clone() const override = 0; |
---|
[e149f77] | 64 | virtual void accept( Visitor &v ) override = 0; |
---|
[fa16264] | 65 | virtual Declaration *acceptMutator( Mutator &m ) override = 0; |
---|
[50377a4] | 66 | virtual void print( std::ostream &os, Indenter indent = {} ) const override = 0; |
---|
| 67 | virtual void printShort( std::ostream &os, Indenter indent = {} ) const = 0; |
---|
[0dd3a2f] | 68 | |
---|
| 69 | static void dumpIds( std::ostream &os ); |
---|
| 70 | static Declaration *declFromId( UniqueId id ); |
---|
[65cdc1e] | 71 | |
---|
[17cd4eb] | 72 | private: |
---|
[68fe077a] | 73 | Type::StorageClasses storageClasses; |
---|
[0dd3a2f] | 74 | UniqueId uniqueId; |
---|
[51b7345] | 75 | }; |
---|
| 76 | |
---|
[17cd4eb] | 77 | class DeclarationWithType : public Declaration { |
---|
| 78 | public: |
---|
[65cdc1e] | 79 | // this represents the type with all types and typedefs expanded it is generated by SymTab::Validate::Pass2 |
---|
| 80 | std::string mangleName; |
---|
| 81 | // need to remember the scope level at which the variable was declared, so that shadowed identifiers can be accessed |
---|
| 82 | int scopeLevel = 0; |
---|
| 83 | |
---|
[e612146c] | 84 | Expression *asmName; |
---|
[65cdc1e] | 85 | std::list< Attribute * > attributes; |
---|
[3ed994e] | 86 | bool isDeleted = false; |
---|
[65cdc1e] | 87 | |
---|
[ddfd945] | 88 | DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs ); |
---|
[0dd3a2f] | 89 | DeclarationWithType( const DeclarationWithType &other ); |
---|
| 90 | virtual ~DeclarationWithType(); |
---|
[51b7345] | 91 | |
---|
[0dd3a2f] | 92 | std::string get_mangleName() const { return mangleName; } |
---|
[58dd019] | 93 | DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; } |
---|
[17cd4eb] | 94 | |
---|
[f326f99] | 95 | std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); } |
---|
| 96 | |
---|
| 97 | int get_scopeLevel() const { return scopeLevel; } |
---|
[58dd019] | 98 | DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; } |
---|
| 99 | |
---|
[e612146c] | 100 | Expression *get_asmName() const { return asmName; } |
---|
| 101 | DeclarationWithType * set_asmName( Expression *newValue ) { asmName = newValue; return this; } |
---|
[f326f99] | 102 | |
---|
[f9cebb5] | 103 | std::list< Attribute * >& get_attributes() { return attributes; } |
---|
| 104 | const std::list< Attribute * >& get_attributes() const { return attributes; } |
---|
| 105 | |
---|
[ddfd945] | 106 | Type::FuncSpecifiers get_funcSpec() const { return fs; } |
---|
| 107 | //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; } |
---|
[dd020c0] | 108 | |
---|
[e149f77] | 109 | virtual DeclarationWithType *clone() const override = 0; |
---|
| 110 | virtual DeclarationWithType *acceptMutator( Mutator &m ) override = 0; |
---|
[17cd4eb] | 111 | |
---|
[9aaac6e9] | 112 | virtual Type * get_type() const = 0; |
---|
[0dd3a2f] | 113 | virtual void set_type(Type *) = 0; |
---|
[f9cebb5] | 114 | |
---|
[65cdc1e] | 115 | private: |
---|
[ddfd945] | 116 | Type::FuncSpecifiers fs; |
---|
[51b7345] | 117 | }; |
---|
| 118 | |
---|
[17cd4eb] | 119 | class ObjectDecl : public DeclarationWithType { |
---|
[0dd3a2f] | 120 | typedef DeclarationWithType Parent; |
---|
[17cd4eb] | 121 | public: |
---|
[65cdc1e] | 122 | Type *type; |
---|
| 123 | Initializer *init; |
---|
| 124 | Expression *bitfieldWidth; |
---|
| 125 | |
---|
[68fe077a] | 126 | ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, |
---|
[ddfd945] | 127 | const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); |
---|
[0dd3a2f] | 128 | ObjectDecl( const ObjectDecl &other ); |
---|
| 129 | virtual ~ObjectDecl(); |
---|
| 130 | |
---|
[e149f77] | 131 | virtual Type * get_type() const override { return type; } |
---|
| 132 | virtual void set_type(Type *newType) override { type = newType; } |
---|
[0dd3a2f] | 133 | |
---|
| 134 | Initializer *get_init() const { return init; } |
---|
| 135 | void set_init( Initializer *newValue ) { init = newValue; } |
---|
[58dd019] | 136 | |
---|
[0dd3a2f] | 137 | Expression *get_bitfieldWidth() const { return bitfieldWidth; } |
---|
| 138 | void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; } |
---|
| 139 | |
---|
[96f9ef5] | 140 | static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init ); |
---|
| 141 | |
---|
[e149f77] | 142 | virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); } |
---|
| 143 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 144 | virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 145 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
| 146 | virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 147 | }; |
---|
| 148 | |
---|
[17cd4eb] | 149 | class FunctionDecl : public DeclarationWithType { |
---|
[0dd3a2f] | 150 | typedef DeclarationWithType Parent; |
---|
[17cd4eb] | 151 | public: |
---|
[65cdc1e] | 152 | FunctionType *type; |
---|
| 153 | CompoundStmt *statements; |
---|
[574894d] | 154 | std::list< Expression * > withExprs; |
---|
[65cdc1e] | 155 | |
---|
[68fe077a] | 156 | FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, |
---|
[ddfd945] | 157 | const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() ); |
---|
[0dd3a2f] | 158 | FunctionDecl( const FunctionDecl &other ); |
---|
| 159 | virtual ~FunctionDecl(); |
---|
[51b7345] | 160 | |
---|
[e149f77] | 161 | virtual Type * get_type() const override { return type; } |
---|
| 162 | virtual void set_type(Type * t) override { type = strict_dynamic_cast< FunctionType* >( t ); } |
---|
[51b7345] | 163 | |
---|
[9aaac6e9] | 164 | FunctionType * get_functionType() const { return type; } |
---|
[0dd3a2f] | 165 | void set_functionType( FunctionType *newValue ) { type = newValue; } |
---|
| 166 | CompoundStmt *get_statements() const { return statements; } |
---|
| 167 | void set_statements( CompoundStmt *newValue ) { statements = newValue; } |
---|
| 168 | |
---|
[75626a1] | 169 | static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements ); |
---|
| 170 | |
---|
[e149f77] | 171 | virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); } |
---|
| 172 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 173 | virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 174 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
| 175 | virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 176 | }; |
---|
| 177 | |
---|
[17cd4eb] | 178 | class NamedTypeDecl : public Declaration { |
---|
[0dd3a2f] | 179 | typedef Declaration Parent; |
---|
[17cd4eb] | 180 | public: |
---|
[65cdc1e] | 181 | Type *base; |
---|
| 182 | std::list< TypeDecl* > parameters; |
---|
| 183 | std::list< DeclarationWithType* > assertions; |
---|
| 184 | |
---|
[68fe077a] | 185 | NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type ); |
---|
[46f6134] | 186 | NamedTypeDecl( const NamedTypeDecl &other ); |
---|
[0dd3a2f] | 187 | virtual ~NamedTypeDecl(); |
---|
| 188 | |
---|
| 189 | Type *get_base() const { return base; } |
---|
| 190 | void set_base( Type *newValue ) { base = newValue; } |
---|
| 191 | std::list< TypeDecl* >& get_parameters() { return parameters; } |
---|
| 192 | std::list< DeclarationWithType* >& get_assertions() { return assertions; } |
---|
| 193 | |
---|
[e39241b] | 194 | virtual std::string typeString() const = 0; |
---|
| 195 | |
---|
[e149f77] | 196 | virtual NamedTypeDecl *clone() const override = 0; |
---|
[50377a4] | 197 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
| 198 | virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; |
---|
[51b7345] | 199 | }; |
---|
| 200 | |
---|
[17cd4eb] | 201 | class TypeDecl : public NamedTypeDecl { |
---|
[0dd3a2f] | 202 | typedef NamedTypeDecl Parent; |
---|
[17cd4eb] | 203 | public: |
---|
[f0ecf9b] | 204 | enum Kind { Dtype, Ftype, Ttype }; |
---|
[65cdc1e] | 205 | |
---|
| 206 | Type * init; |
---|
| 207 | bool sized; |
---|
| 208 | |
---|
[2c57025] | 209 | /// Data extracted from a type decl |
---|
| 210 | struct Data { |
---|
| 211 | TypeDecl::Kind kind; |
---|
| 212 | bool isComplete; |
---|
| 213 | Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {} |
---|
| 214 | Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {} |
---|
| 215 | Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {} |
---|
| 216 | bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; } |
---|
| 217 | bool operator!=(const Data & other) const { return !(*this == other);} |
---|
| 218 | }; |
---|
[51b7345] | 219 | |
---|
[f0ecf9b] | 220 | TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, bool sized, Type * init = nullptr ); |
---|
[0dd3a2f] | 221 | TypeDecl( const TypeDecl &other ); |
---|
[67cf18c] | 222 | virtual ~TypeDecl(); |
---|
[17cd4eb] | 223 | |
---|
[0dd3a2f] | 224 | Kind get_kind() const { return kind; } |
---|
[51b7345] | 225 | |
---|
[67cf18c] | 226 | Type * get_init() const { return init; } |
---|
| 227 | TypeDecl * set_init( Type * newValue ) { init = newValue; return this; } |
---|
| 228 | |
---|
[f0ecf9b] | 229 | bool isComplete() const { return sized; } |
---|
[2c57025] | 230 | bool get_sized() const { return sized; } |
---|
| 231 | TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } |
---|
| 232 | |
---|
[e149f77] | 233 | virtual std::string typeString() const override; |
---|
[bdd0755] | 234 | virtual std::string genTypeString() const; |
---|
[e39241b] | 235 | |
---|
[e149f77] | 236 | virtual TypeDecl *clone() const override { return new TypeDecl( *this ); } |
---|
| 237 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 238 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 239 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
[67cf18c] | 240 | |
---|
[17cd4eb] | 241 | private: |
---|
[0dd3a2f] | 242 | Kind kind; |
---|
[51b7345] | 243 | }; |
---|
| 244 | |
---|
[17cd4eb] | 245 | class TypedefDecl : public NamedTypeDecl { |
---|
[0dd3a2f] | 246 | typedef NamedTypeDecl Parent; |
---|
[17cd4eb] | 247 | public: |
---|
[0b0f1dd] | 248 | TypedefDecl( const std::string &name, CodeLocation location, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) |
---|
| 249 | : Parent( name, scs, type ) { set_linkage( spec ); this->location = location; } |
---|
| 250 | |
---|
[0dd3a2f] | 251 | TypedefDecl( const TypedefDecl &other ) : Parent( other ) {} |
---|
[17cd4eb] | 252 | |
---|
[e149f77] | 253 | virtual std::string typeString() const override; |
---|
[e39241b] | 254 | |
---|
[e149f77] | 255 | virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); } |
---|
| 256 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 257 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[17cd4eb] | 258 | private: |
---|
[51b7345] | 259 | }; |
---|
| 260 | |
---|
[17cd4eb] | 261 | class AggregateDecl : public Declaration { |
---|
[0dd3a2f] | 262 | typedef Declaration Parent; |
---|
[17cd4eb] | 263 | public: |
---|
[65cdc1e] | 264 | std::list<Declaration*> members; |
---|
| 265 | std::list<TypeDecl*> parameters; |
---|
| 266 | bool body; |
---|
| 267 | std::list< Attribute * > attributes; |
---|
| 268 | |
---|
[fa4805f] | 269 | AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ); |
---|
[0dd3a2f] | 270 | AggregateDecl( const AggregateDecl &other ); |
---|
| 271 | virtual ~AggregateDecl(); |
---|
[51b7345] | 272 | |
---|
[0dd3a2f] | 273 | std::list<Declaration*>& get_members() { return members; } |
---|
| 274 | std::list<TypeDecl*>& get_parameters() { return parameters; } |
---|
[17cd4eb] | 275 | |
---|
[c0aa336] | 276 | std::list< Attribute * >& get_attributes() { return attributes; } |
---|
| 277 | const std::list< Attribute * >& get_attributes() const { return attributes; } |
---|
| 278 | |
---|
[5d125e4] | 279 | bool has_body() const { return body; } |
---|
| 280 | AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; } |
---|
| 281 | |
---|
[50377a4] | 282 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
| 283 | virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; |
---|
[17cd4eb] | 284 | protected: |
---|
[0dd3a2f] | 285 | virtual std::string typeString() const = 0; |
---|
[51b7345] | 286 | }; |
---|
| 287 | |
---|
[17cd4eb] | 288 | class StructDecl : public AggregateDecl { |
---|
[0dd3a2f] | 289 | typedef AggregateDecl Parent; |
---|
[17cd4eb] | 290 | public: |
---|
[f196351] | 291 | StructDecl( const std::string &name, DeclarationNode::Aggregate kind = DeclarationNode::Struct, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ), kind( kind ) {} |
---|
| 292 | StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {} |
---|
[17cd4eb] | 293 | |
---|
[409433da] | 294 | bool is_coroutine() { return kind == DeclarationNode::Coroutine; } |
---|
| 295 | bool is_monitor() { return kind == DeclarationNode::Monitor; } |
---|
| 296 | bool is_thread() { return kind == DeclarationNode::Thread; } |
---|
| 297 | |
---|
[e149f77] | 298 | virtual StructDecl *clone() const override { return new StructDecl( *this ); } |
---|
| 299 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 300 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[17cd4eb] | 301 | private: |
---|
[409433da] | 302 | DeclarationNode::Aggregate kind; |
---|
[e149f77] | 303 | virtual std::string typeString() const override; |
---|
[51b7345] | 304 | }; |
---|
| 305 | |
---|
[17cd4eb] | 306 | class UnionDecl : public AggregateDecl { |
---|
[0dd3a2f] | 307 | typedef AggregateDecl Parent; |
---|
[17cd4eb] | 308 | public: |
---|
[fa4805f] | 309 | UnionDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {} |
---|
[0dd3a2f] | 310 | UnionDecl( const UnionDecl &other ) : Parent( other ) {} |
---|
[17cd4eb] | 311 | |
---|
[e149f77] | 312 | virtual UnionDecl *clone() const override { return new UnionDecl( *this ); } |
---|
| 313 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 314 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[17cd4eb] | 315 | private: |
---|
[e149f77] | 316 | virtual std::string typeString() const override; |
---|
[51b7345] | 317 | }; |
---|
| 318 | |
---|
[17cd4eb] | 319 | class EnumDecl : public AggregateDecl { |
---|
[0dd3a2f] | 320 | typedef AggregateDecl Parent; |
---|
[17cd4eb] | 321 | public: |
---|
[fa4805f] | 322 | EnumDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {} |
---|
[0dd3a2f] | 323 | EnumDecl( const EnumDecl &other ) : Parent( other ) {} |
---|
[17cd4eb] | 324 | |
---|
[fc9153d] | 325 | bool valueOf( Declaration * enumerator, long long int & value ); |
---|
| 326 | |
---|
[e149f77] | 327 | virtual EnumDecl *clone() const override { return new EnumDecl( *this ); } |
---|
| 328 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 329 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[17cd4eb] | 330 | private: |
---|
[fc9153d] | 331 | std::map< std::string, long long int > enumValues; |
---|
[e149f77] | 332 | virtual std::string typeString() const override; |
---|
[51b7345] | 333 | }; |
---|
| 334 | |
---|
[4040425] | 335 | class TraitDecl : public AggregateDecl { |
---|
[0dd3a2f] | 336 | typedef AggregateDecl Parent; |
---|
[17cd4eb] | 337 | public: |
---|
[bd46af4] | 338 | TraitDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) { |
---|
[c0aa336] | 339 | assertf( attributes.empty(), "attribute unsupported for traits" ); |
---|
| 340 | } |
---|
[4040425] | 341 | TraitDecl( const TraitDecl &other ) : Parent( other ) {} |
---|
[17cd4eb] | 342 | |
---|
[e149f77] | 343 | virtual TraitDecl *clone() const override { return new TraitDecl( *this ); } |
---|
| 344 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 345 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[17cd4eb] | 346 | private: |
---|
[e149f77] | 347 | virtual std::string typeString() const override; |
---|
[51b7345] | 348 | }; |
---|
| 349 | |
---|
[e994912] | 350 | class AsmDecl : public Declaration { |
---|
| 351 | public: |
---|
[65cdc1e] | 352 | AsmStmt *stmt; |
---|
| 353 | |
---|
[e994912] | 354 | AsmDecl( AsmStmt *stmt ); |
---|
| 355 | AsmDecl( const AsmDecl &other ); |
---|
| 356 | virtual ~AsmDecl(); |
---|
| 357 | |
---|
| 358 | AsmStmt *get_stmt() { return stmt; } |
---|
| 359 | void set_stmt( AsmStmt *newValue ) { stmt = newValue; } |
---|
| 360 | |
---|
[e149f77] | 361 | virtual AsmDecl *clone() const override { return new AsmDecl( *this ); } |
---|
| 362 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 363 | virtual AsmDecl *acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
[50377a4] | 364 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
| 365 | virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; |
---|
[e994912] | 366 | }; |
---|
| 367 | |
---|
[f6e3e34] | 368 | class StaticAssertDecl : public Declaration { |
---|
| 369 | public: |
---|
| 370 | Expression * condition; |
---|
| 371 | ConstantExpr * message; // string literal |
---|
| 372 | |
---|
| 373 | StaticAssertDecl( Expression * condition, ConstantExpr * message ); |
---|
| 374 | StaticAssertDecl( const StaticAssertDecl & other ); |
---|
| 375 | virtual ~StaticAssertDecl(); |
---|
| 376 | |
---|
| 377 | virtual StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); } |
---|
| 378 | virtual void accept( Visitor &v ) override { v.visit( this ); } |
---|
| 379 | virtual StaticAssertDecl * acceptMutator( Mutator &m ) override { return m.mutate( this ); } |
---|
| 380 | virtual void print( std::ostream &os, Indenter indent = {} ) const override; |
---|
| 381 | virtual void printShort( std::ostream &os, Indenter indent = {} ) const override; |
---|
| 382 | }; |
---|
| 383 | |
---|
[2c57025] | 384 | std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); |
---|
[baf7fee] | 385 | |
---|
[0dd3a2f] | 386 | // Local Variables: // |
---|
| 387 | // tab-width: 4 // |
---|
| 388 | // mode: c++ // |
---|
| 389 | // compile-command: "make install" // |
---|
| 390 | // End: // |
---|