Changeset f9cebb5 for src/SynTree
- Timestamp:
- Aug 4, 2016, 4:10:06 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 4819cac
- Parents:
- 73bf8cf2
- Location:
- src/SynTree
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.cc
r73bf8cf2 rf9cebb5 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Declaration.cc -- 7 // Declaration.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 20 20 #include "Initializer.h" 21 21 #include "Type.h" 22 #include "Attribute.h" 22 23 #include "Common/utility.h" 23 24 -
src/SynTree/Declaration.h
r73bf8cf2 rf9cebb5 64 64 class DeclarationWithType : public Declaration { 65 65 public: 66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage );66 DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, const std::list< Attribute * > & attributes ); 67 67 DeclarationWithType( const DeclarationWithType &other ); 68 68 virtual ~DeclarationWithType(); … … 75 75 int get_scopeLevel() const { return scopeLevel; } 76 76 void set_scopeLevel( int newValue ) { scopeLevel = newValue; } 77 78 std::list< Attribute * >& get_attributes() { return attributes; } 79 const std::list< Attribute * >& get_attributes() const { return attributes; } 77 80 78 81 virtual DeclarationWithType *clone() const = 0; … … 87 90 // shadowed identifiers can be accessed 88 91 int scopeLevel = 0; 92 93 std::list< Attribute * > attributes; 89 94 }; 90 95 … … 92 97 typedef DeclarationWithType Parent; 93 98 public: 94 ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline = false, bool isNoreturn = false );99 ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes = std::list< Attribute * >(), bool isInline = false, bool isNoreturn = false ); 95 100 ObjectDecl( const ObjectDecl &other ); 96 101 virtual ~ObjectDecl(); … … 131 136 std::list< std::string >& get_oldIdents() { return oldIdents; } 132 137 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 133 std::list< Attribute * >& get_attributes() { return attributes; }134 138 135 139 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } … … 143 147 std::list< std::string > oldIdents; 144 148 std::list< Declaration* > oldDecls; 145 std::list< Attribute * > attributes;146 149 }; 147 150 -
src/SynTree/DeclarationWithType.cc
r73bf8cf2 rf9cebb5 16 16 #include "Declaration.h" 17 17 #include "Type.h" 18 #include "Attribute.h" 18 19 #include "Common/utility.h" 19 20 20 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage )21 : Declaration( name, sc, linkage ) {21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, const std::list< Attribute * > & attributes ) 22 : Declaration( name, sc, linkage ), attributes( attributes ) { 22 23 } 23 24 24 25 DeclarationWithType::DeclarationWithType( const DeclarationWithType &other ) 25 26 : Declaration( other ), mangleName( other.mangleName ), scopeLevel( other.scopeLevel ) { 27 cloneAll( other.attributes, attributes ); 26 28 } 27 29 28 30 DeclarationWithType::~DeclarationWithType() { 31 deleteAll( attributes ); 29 32 } 30 33 -
src/SynTree/FunctionDecl.cc
r73bf8cf2 rf9cebb5 23 23 24 24 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, std::list< Attribute * > attributes ) 25 : Parent( name, sc, linkage ), type( type ), statements( statements ), attributes( attributes ) {25 : Parent( name, sc, linkage, attributes ), type( type ), statements( statements ) { 26 26 set_isInline( isInline ); 27 27 set_isNoreturn( isNoreturn ); … … 34 34 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 35 35 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 36 cloneAll( other.attributes, attributes );37 36 } 38 37 … … 40 39 delete type; 41 40 delete statements; 42 deleteAll( attributes );43 41 } 44 42 … … 69 67 } // if 70 68 71 printAll( attributes, os, indent );69 printAll( get_attributes(), os, indent ); 72 70 73 71 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { -
src/SynTree/Label.h
r73bf8cf2 rf9cebb5 24 24 class Label { 25 25 public: 26 Label( const std::string & name = "", Statement * labelled = 0 ) : name( name ), labelled( labelled) {}26 Label( const std::string & name = "", Statement * labelled = 0, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : name( name ), labelled( labelled ), attributes( attributes ) {} 27 27 Label( const char * name, Statement * labelled = 0 ) : name( name ), labelled( labelled ) {} 28 28 -
src/SynTree/ObjectDecl.cc
r73bf8cf2 rf9cebb5 18 18 #include "Initializer.h" 19 19 #include "Expression.h" 20 #include "Attribute.h" 20 21 #include "Common/utility.h" 21 22 #include "Statement.h" 22 23 23 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, bool isInline, bool isNoreturn )24 : Parent( name, sc, linkage ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, bool isInline, bool isNoreturn ) 25 : Parent( name, sc, linkage, attributes ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) { 25 26 set_isInline( isInline ); 26 27 set_isNoreturn( isNoreturn ); … … 45 46 os << LinkageSpec::toString( get_linkage() ) << " "; 46 47 } // if 48 49 printAll( get_attributes(), os, indent ); 47 50 48 51 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { … … 80 83 } // if 81 84 85 // xxx - should printShort print attributes? 86 82 87 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 83 88 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
Note: See TracChangeset
for help on using the changeset viewer.