Changeset 7baed7d for src/SynTree
- Timestamp:
- Jun 6, 2016, 5:46:09 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, 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:
- 64a32c6
- Parents:
- 64071c2
- Location:
- src/SynTree
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
r64071c2 r7baed7d 115 115 typedef DeclarationWithType Parent; 116 116 public: 117 // temporary - merge this into general GCC attributes 118 struct Attribute { 119 enum Type { 120 NoAttribute, Constructor, Destructor, 121 } type; 122 enum Priority { 123 // priorities 0-100 are reserved by gcc, so it's okay to use 100 an exceptional case 124 Default = 100, High, 125 } priority; 126 Attribute(Type t = NoAttribute, Priority p = Default) : type(t), priority(p) {}; 127 }; 128 129 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = Attribute() ); 117 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, const std::list< Attribute * > attributes = std::list< Attribute * >() ); 130 118 FunctionDecl( const FunctionDecl &other ); 131 119 virtual ~FunctionDecl(); … … 140 128 std::list< std::string >& get_oldIdents() { return oldIdents; } 141 129 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 142 Attribute get_attribute() const { return attribute; } 143 void set_attribute( Attribute newValue ) { attribute = newValue; } 130 std::list< Attribute * >& get_attributes() { return attributes; } 144 131 145 132 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } … … 153 140 std::list< std::string > oldIdents; 154 141 std::list< Declaration* > oldDecls; 155 Attribute attribute;142 std::list< Attribute * > attributes; 156 143 }; 157 144 -
src/SynTree/FunctionDecl.cc
r64071c2 r7baed7d 19 19 #include "Statement.h" 20 20 #include "Type.h" 21 #include "Attribute.h" 21 22 #include "Common/utility.h" 22 23 23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute)24 : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute ( attribute) {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 26 set_isInline( isInline ); 26 27 set_isNoreturn( isNoreturn ); … … 32 33 33 34 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 34 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) { 35 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) { 36 cloneAll( other.attributes, attributes ); 35 37 } 36 38 … … 38 40 delete type; 39 41 delete statements; 42 deleteAll( attributes ); 40 43 } 41 44 … … 65 68 os << "_Noreturn "; 66 69 } // if 67 switch ( attribute.type ) { 68 case Attribute::Constructor: 69 os << "Global Constructor "; 70 break; 71 case Attribute::Destructor: 72 os << "Global Destructor "; 73 break; 74 default: 75 break; 76 } 77 if ( attribute.priority != Attribute::Default ) { 78 os << "with priority " << attribute.priority << " "; 79 } 70 71 printAll( attributes, os, indent ); 72 80 73 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 81 74 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; … … 118 111 os << "_Noreturn "; 119 112 } // if 120 switch ( attribute.type ) { 121 case Attribute::Constructor: 122 os << " Global Constructor "; 123 break; 124 case Attribute::Destructor: 125 os << " Global Destructor "; 126 break; 127 default: 128 break; 129 } 130 if ( attribute.priority != Attribute::Default ) { 131 os << "with priority " << attribute.priority << " "; 132 } 113 114 // xxx - should printShort print attributes? 115 133 116 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 134 117 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; -
src/SynTree/SynTree.h
r64071c2 r7baed7d 118 118 class TypeSubstitution; 119 119 120 // gcc attribute 121 class Attribute; 122 120 123 #endif // SYNTREE_H 121 124 -
src/SynTree/module.mk
r64071c2 r7baed7d 6 6 ## file "LICENCE" distributed with Cforall. 7 7 ## 8 ## module.mk -- 8 ## module.mk -- 9 9 ## 10 10 ## Author : Richard C. Bilson … … 46 46 SynTree/Visitor.cc \ 47 47 SynTree/Mutator.cc \ 48 SynTree/TypeSubstitution.cc 48 SynTree/TypeSubstitution.cc \ 49 SynTree/Attribute.cc 49 50
Note:
See TracChangeset
for help on using the changeset viewer.