[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
|
---|
[51b73452] | 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;
|
---|
[51b73452] | 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 );
|
---|
| 63 | virtual Declaration *clone() const = 0;
|
---|
[e149f77] | 64 | virtual void accept( Visitor &v ) override = 0;
|
---|
[0dd3a2f] | 65 | virtual Declaration *acceptMutator( Mutator &m ) = 0;
|
---|
[e149f77] | 66 | virtual void print( std::ostream &os, int indent = 0 ) const override = 0;
|
---|
[0dd3a2f] | 67 | virtual void printShort( std::ostream &os, int indent = 0 ) const = 0;
|
---|
| 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;
|
---|
[51b73452] | 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;
|
---|
| 86 |
|
---|
[ddfd945] | 87 | DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
|
---|
[0dd3a2f] | 88 | DeclarationWithType( const DeclarationWithType &other );
|
---|
| 89 | virtual ~DeclarationWithType();
|
---|
[51b73452] | 90 |
|
---|
[0dd3a2f] | 91 | std::string get_mangleName() const { return mangleName; }
|
---|
[58dd019] | 92 | DeclarationWithType * set_mangleName( std::string newValue ) { mangleName = newValue; return this; }
|
---|
[17cd4eb] | 93 |
|
---|
[f326f99] | 94 | std::string get_scopedMangleName() const { return mangleName + "_" + std::to_string(scopeLevel); }
|
---|
| 95 |
|
---|
| 96 | int get_scopeLevel() const { return scopeLevel; }
|
---|
[58dd019] | 97 | DeclarationWithType * set_scopeLevel( int newValue ) { scopeLevel = newValue; return this; }
|
---|
| 98 |
|
---|
[e612146c] | 99 | Expression *get_asmName() const { return asmName; }
|
---|
| 100 | DeclarationWithType * set_asmName( Expression *newValue ) { asmName = newValue; return this; }
|
---|
[f326f99] | 101 |
|
---|
[f9cebb5] | 102 | std::list< Attribute * >& get_attributes() { return attributes; }
|
---|
| 103 | const std::list< Attribute * >& get_attributes() const { return attributes; }
|
---|
| 104 |
|
---|
[ddfd945] | 105 | Type::FuncSpecifiers get_funcSpec() const { return fs; }
|
---|
| 106 | //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
|
---|
[dd020c0] | 107 |
|
---|
[e149f77] | 108 | virtual DeclarationWithType *clone() const override = 0;
|
---|
| 109 | virtual DeclarationWithType *acceptMutator( Mutator &m ) override = 0;
|
---|
[17cd4eb] | 110 |
|
---|
[9aaac6e9] | 111 | virtual Type * get_type() const = 0;
|
---|
[0dd3a2f] | 112 | virtual void set_type(Type *) = 0;
|
---|
[f9cebb5] | 113 |
|
---|
[65cdc1e] | 114 | private:
|
---|
[ddfd945] | 115 | Type::FuncSpecifiers fs;
|
---|
[51b73452] | 116 | };
|
---|
| 117 |
|
---|
[17cd4eb] | 118 | class ObjectDecl : public DeclarationWithType {
|
---|
[0dd3a2f] | 119 | typedef DeclarationWithType Parent;
|
---|
[17cd4eb] | 120 | public:
|
---|
[65cdc1e] | 121 | Type *type;
|
---|
| 122 | Initializer *init;
|
---|
| 123 | Expression *bitfieldWidth;
|
---|
| 124 |
|
---|
[68fe077a] | 125 | ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
|
---|
[ddfd945] | 126 | const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
|
---|
[0dd3a2f] | 127 | ObjectDecl( const ObjectDecl &other );
|
---|
| 128 | virtual ~ObjectDecl();
|
---|
| 129 |
|
---|
[e149f77] | 130 | virtual Type * get_type() const override { return type; }
|
---|
| 131 | virtual void set_type(Type *newType) override { type = newType; }
|
---|
[0dd3a2f] | 132 |
|
---|
| 133 | Initializer *get_init() const { return init; }
|
---|
| 134 | void set_init( Initializer *newValue ) { init = newValue; }
|
---|
[58dd019] | 135 |
|
---|
[0dd3a2f] | 136 | Expression *get_bitfieldWidth() const { return bitfieldWidth; }
|
---|
| 137 | void set_bitfieldWidth( Expression *newValue ) { bitfieldWidth = newValue; }
|
---|
| 138 |
|
---|
[96f9ef5] | 139 | static ObjectDecl * newObject( const std::string & name, Type * type, Initializer * init );
|
---|
| 140 |
|
---|
[e149f77] | 141 | virtual ObjectDecl *clone() const override { return new ObjectDecl( *this ); }
|
---|
| 142 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 143 | virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
| 144 | virtual void print( std::ostream &os, int indent = 0 ) const override;
|
---|
| 145 | virtual void printShort( std::ostream &os, int indent = 0 ) const override;
|
---|
[51b73452] | 146 | };
|
---|
| 147 |
|
---|
[17cd4eb] | 148 | class FunctionDecl : public DeclarationWithType {
|
---|
[0dd3a2f] | 149 | typedef DeclarationWithType Parent;
|
---|
[17cd4eb] | 150 | public:
|
---|
[65cdc1e] | 151 | FunctionType *type;
|
---|
| 152 | CompoundStmt *statements;
|
---|
| 153 |
|
---|
[68fe077a] | 154 | FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
|
---|
[ddfd945] | 155 | const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
|
---|
[0dd3a2f] | 156 | FunctionDecl( const FunctionDecl &other );
|
---|
| 157 | virtual ~FunctionDecl();
|
---|
[51b73452] | 158 |
|
---|
[e149f77] | 159 | virtual Type * get_type() const override { return type; }
|
---|
| 160 | virtual void set_type(Type * t) override { type = strict_dynamic_cast< FunctionType* >( t ); }
|
---|
[51b73452] | 161 |
|
---|
[9aaac6e9] | 162 | FunctionType * get_functionType() const { return type; }
|
---|
[0dd3a2f] | 163 | void set_functionType( FunctionType *newValue ) { type = newValue; }
|
---|
| 164 | CompoundStmt *get_statements() const { return statements; }
|
---|
| 165 | void set_statements( CompoundStmt *newValue ) { statements = newValue; }
|
---|
| 166 |
|
---|
[75626a1] | 167 | static FunctionDecl * newFunction( const std::string & name, FunctionType * type, CompoundStmt * statements );
|
---|
| 168 |
|
---|
[e149f77] | 169 | virtual FunctionDecl *clone() const override { return new FunctionDecl( *this ); }
|
---|
| 170 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 171 | virtual DeclarationWithType *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
| 172 | virtual void print( std::ostream &os, int indent = 0 ) const override;
|
---|
| 173 | virtual void printShort( std::ostream &os, int indent = 0 ) const override;
|
---|
[51b73452] | 174 | };
|
---|
| 175 |
|
---|
[17cd4eb] | 176 | class NamedTypeDecl : public Declaration {
|
---|
[0dd3a2f] | 177 | typedef Declaration Parent;
|
---|
[17cd4eb] | 178 | public:
|
---|
[65cdc1e] | 179 | Type *base;
|
---|
| 180 | std::list< TypeDecl* > parameters;
|
---|
| 181 | std::list< DeclarationWithType* > assertions;
|
---|
| 182 |
|
---|
[68fe077a] | 183 | NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
|
---|
[46f6134] | 184 | NamedTypeDecl( const NamedTypeDecl &other );
|
---|
[0dd3a2f] | 185 | virtual ~NamedTypeDecl();
|
---|
| 186 |
|
---|
| 187 | Type *get_base() const { return base; }
|
---|
| 188 | void set_base( Type *newValue ) { base = newValue; }
|
---|
| 189 | std::list< TypeDecl* >& get_parameters() { return parameters; }
|
---|
| 190 | std::list< DeclarationWithType* >& get_assertions() { return assertions; }
|
---|
| 191 |
|
---|
[e39241b] | 192 | virtual std::string typeString() const = 0;
|
---|
| 193 |
|
---|
[e149f77] | 194 | virtual NamedTypeDecl *clone() const override = 0;
|
---|
| 195 | virtual void print( std::ostream &os, int indent = 0 ) const override;
|
---|
| 196 | virtual void printShort( std::ostream &os, int indent = 0 ) const override;
|
---|
[51b73452] | 197 | };
|
---|
| 198 |
|
---|
[17cd4eb] | 199 | class TypeDecl : public NamedTypeDecl {
|
---|
[0dd3a2f] | 200 | typedef NamedTypeDecl Parent;
|
---|
[17cd4eb] | 201 | public:
|
---|
[8f60f0b] | 202 | enum Kind { Any, Dtype, Ftype, Ttype };
|
---|
[65cdc1e] | 203 |
|
---|
| 204 | Type * init;
|
---|
| 205 | bool sized;
|
---|
| 206 |
|
---|
[2c57025] | 207 | /// Data extracted from a type decl
|
---|
| 208 | struct Data {
|
---|
| 209 | TypeDecl::Kind kind;
|
---|
| 210 | bool isComplete;
|
---|
| 211 | Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {}
|
---|
| 212 | Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {}
|
---|
| 213 | Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {}
|
---|
| 214 | bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; }
|
---|
| 215 | bool operator!=(const Data & other) const { return !(*this == other);}
|
---|
| 216 | };
|
---|
[51b73452] | 217 |
|
---|
[67cf18c] | 218 | TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind, Type * init = nullptr );
|
---|
[0dd3a2f] | 219 | TypeDecl( const TypeDecl &other );
|
---|
[67cf18c] | 220 | virtual ~TypeDecl();
|
---|
[17cd4eb] | 221 |
|
---|
[0dd3a2f] | 222 | Kind get_kind() const { return kind; }
|
---|
[51b73452] | 223 |
|
---|
[67cf18c] | 224 | Type * get_init() const { return init; }
|
---|
| 225 | TypeDecl * set_init( Type * newValue ) { init = newValue; return this; }
|
---|
| 226 |
|
---|
[2c57025] | 227 | bool isComplete() const { return kind == Any || sized; }
|
---|
| 228 | bool get_sized() const { return sized; }
|
---|
| 229 | TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; }
|
---|
| 230 |
|
---|
[e149f77] | 231 | virtual std::string typeString() const override;
|
---|
[bdd0755] | 232 | virtual std::string genTypeString() const;
|
---|
[e39241b] | 233 |
|
---|
[e149f77] | 234 | virtual TypeDecl *clone() const override { return new TypeDecl( *this ); }
|
---|
| 235 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 236 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
| 237 | virtual void print( std::ostream &os, int indent = 0 ) const override;
|
---|
[67cf18c] | 238 |
|
---|
[17cd4eb] | 239 | private:
|
---|
[0dd3a2f] | 240 | Kind kind;
|
---|
[51b73452] | 241 | };
|
---|
| 242 |
|
---|
[17cd4eb] | 243 | class TypedefDecl : public NamedTypeDecl {
|
---|
[0dd3a2f] | 244 | typedef NamedTypeDecl Parent;
|
---|
[17cd4eb] | 245 | public:
|
---|
[cbce272] | 246 | TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type, LinkageSpec::Spec spec = LinkageSpec::Cforall ) : Parent( name, scs, type ) { set_linkage( spec ); }
|
---|
[0dd3a2f] | 247 | TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
|
---|
[17cd4eb] | 248 |
|
---|
[e149f77] | 249 | virtual std::string typeString() const override;
|
---|
[e39241b] | 250 |
|
---|
[e149f77] | 251 | virtual TypedefDecl *clone() const override { return new TypedefDecl( *this ); }
|
---|
| 252 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 253 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[17cd4eb] | 254 | private:
|
---|
[51b73452] | 255 | };
|
---|
| 256 |
|
---|
[17cd4eb] | 257 | class AggregateDecl : public Declaration {
|
---|
[0dd3a2f] | 258 | typedef Declaration Parent;
|
---|
[17cd4eb] | 259 | public:
|
---|
[65cdc1e] | 260 | std::list<Declaration*> members;
|
---|
| 261 | std::list<TypeDecl*> parameters;
|
---|
| 262 | bool body;
|
---|
| 263 | std::list< Attribute * > attributes;
|
---|
| 264 |
|
---|
[fa4805f] | 265 | AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall );
|
---|
[0dd3a2f] | 266 | AggregateDecl( const AggregateDecl &other );
|
---|
| 267 | virtual ~AggregateDecl();
|
---|
[51b73452] | 268 |
|
---|
[0dd3a2f] | 269 | std::list<Declaration*>& get_members() { return members; }
|
---|
| 270 | std::list<TypeDecl*>& get_parameters() { return parameters; }
|
---|
[17cd4eb] | 271 |
|
---|
[c0aa336] | 272 | std::list< Attribute * >& get_attributes() { return attributes; }
|
---|
| 273 | const std::list< Attribute * >& get_attributes() const { return attributes; }
|
---|
| 274 |
|
---|
[5d125e4] | 275 | bool has_body() const { return body; }
|
---|
| 276 | AggregateDecl * set_body( bool body ) { AggregateDecl::body = body; return this; }
|
---|
| 277 |
|
---|
[e149f77] | 278 | virtual void print( std::ostream &os, int indent = 0 ) const override;
|
---|
| 279 | virtual void printShort( std::ostream &os, int indent = 0 ) const override;
|
---|
[17cd4eb] | 280 | protected:
|
---|
[0dd3a2f] | 281 | virtual std::string typeString() const = 0;
|
---|
[51b73452] | 282 | };
|
---|
| 283 |
|
---|
[17cd4eb] | 284 | class StructDecl : public AggregateDecl {
|
---|
[0dd3a2f] | 285 | typedef AggregateDecl Parent;
|
---|
[17cd4eb] | 286 | public:
|
---|
[f196351] | 287 | 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 ) {}
|
---|
| 288 | StructDecl( const StructDecl &other ) : Parent( other ), kind( other.kind ) {}
|
---|
[17cd4eb] | 289 |
|
---|
[409433da] | 290 | bool is_coroutine() { return kind == DeclarationNode::Coroutine; }
|
---|
| 291 | bool is_monitor() { return kind == DeclarationNode::Monitor; }
|
---|
| 292 | bool is_thread() { return kind == DeclarationNode::Thread; }
|
---|
| 293 |
|
---|
[e149f77] | 294 | virtual StructDecl *clone() const override { return new StructDecl( *this ); }
|
---|
| 295 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 296 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[17cd4eb] | 297 | private:
|
---|
[409433da] | 298 | DeclarationNode::Aggregate kind;
|
---|
[e149f77] | 299 | virtual std::string typeString() const override;
|
---|
[51b73452] | 300 | };
|
---|
| 301 |
|
---|
[17cd4eb] | 302 | class UnionDecl : public AggregateDecl {
|
---|
[0dd3a2f] | 303 | typedef AggregateDecl Parent;
|
---|
[17cd4eb] | 304 | public:
|
---|
[fa4805f] | 305 | UnionDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
|
---|
[0dd3a2f] | 306 | UnionDecl( const UnionDecl &other ) : Parent( other ) {}
|
---|
[17cd4eb] | 307 |
|
---|
[e149f77] | 308 | virtual UnionDecl *clone() const override { return new UnionDecl( *this ); }
|
---|
| 309 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 310 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[17cd4eb] | 311 | private:
|
---|
[e149f77] | 312 | virtual std::string typeString() const override;
|
---|
[51b73452] | 313 | };
|
---|
| 314 |
|
---|
[17cd4eb] | 315 | class EnumDecl : public AggregateDecl {
|
---|
[0dd3a2f] | 316 | typedef AggregateDecl Parent;
|
---|
[17cd4eb] | 317 | public:
|
---|
[fa4805f] | 318 | EnumDecl( const std::string &name, const std::list< Attribute * > & attributes = std::list< class Attribute * >(), LinkageSpec::Spec linkage = LinkageSpec::Cforall ) : Parent( name, attributes, linkage ) {}
|
---|
[0dd3a2f] | 319 | EnumDecl( const EnumDecl &other ) : Parent( other ) {}
|
---|
[17cd4eb] | 320 |
|
---|
[e149f77] | 321 | virtual EnumDecl *clone() const override { return new EnumDecl( *this ); }
|
---|
| 322 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 323 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[17cd4eb] | 324 | private:
|
---|
[e149f77] | 325 | virtual std::string typeString() const override;
|
---|
[51b73452] | 326 | };
|
---|
| 327 |
|
---|
[4040425] | 328 | class TraitDecl : public AggregateDecl {
|
---|
[0dd3a2f] | 329 | typedef AggregateDecl Parent;
|
---|
[17cd4eb] | 330 | public:
|
---|
[bd46af4] | 331 | TraitDecl( const std::string &name, const std::list< Attribute * > & attributes, LinkageSpec::Spec linkage ) : Parent( name, attributes, linkage ) {
|
---|
[c0aa336] | 332 | assertf( attributes.empty(), "attribute unsupported for traits" );
|
---|
| 333 | }
|
---|
[4040425] | 334 | TraitDecl( const TraitDecl &other ) : Parent( other ) {}
|
---|
[17cd4eb] | 335 |
|
---|
[e149f77] | 336 | virtual TraitDecl *clone() const override { return new TraitDecl( *this ); }
|
---|
| 337 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 338 | virtual Declaration *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
[17cd4eb] | 339 | private:
|
---|
[e149f77] | 340 | virtual std::string typeString() const override;
|
---|
[51b73452] | 341 | };
|
---|
| 342 |
|
---|
[e994912] | 343 | class AsmDecl : public Declaration {
|
---|
| 344 | public:
|
---|
[65cdc1e] | 345 | AsmStmt *stmt;
|
---|
| 346 |
|
---|
[e994912] | 347 | AsmDecl( AsmStmt *stmt );
|
---|
| 348 | AsmDecl( const AsmDecl &other );
|
---|
| 349 | virtual ~AsmDecl();
|
---|
| 350 |
|
---|
| 351 | AsmStmt *get_stmt() { return stmt; }
|
---|
| 352 | void set_stmt( AsmStmt *newValue ) { stmt = newValue; }
|
---|
| 353 |
|
---|
[e149f77] | 354 | virtual AsmDecl *clone() const override { return new AsmDecl( *this ); }
|
---|
| 355 | virtual void accept( Visitor &v ) override { v.visit( this ); }
|
---|
| 356 | virtual AsmDecl *acceptMutator( Mutator &m ) override { return m.mutate( this ); }
|
---|
| 357 | virtual void print( std::ostream &os, int indent = 0 ) const override;
|
---|
| 358 | virtual void printShort( std::ostream &os, int indent = 0 ) const override;
|
---|
[e994912] | 359 | };
|
---|
| 360 |
|
---|
[2c57025] | 361 | std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
|
---|
[baf7fee] | 362 |
|
---|
[0dd3a2f] | 363 | // Local Variables: //
|
---|
| 364 | // tab-width: 4 //
|
---|
| 365 | // mode: c++ //
|
---|
| 366 | // compile-command: "make install" //
|
---|
| 367 | // End: //
|
---|