Changes in src/AST/Label.hpp [e0115286:14cebb7a]
- File:
-
- 1 edited
-
src/AST/Label.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Label.hpp
re0115286 r14cebb7a 25 25 namespace ast { 26 26 27 class Attribute;27 class Attribute; 28 28 29 /// Named labels for statements30 class Label {31 public:32 CodeLocation location;33 std::string name;34 std::vector< ptr<Attribute> > attributes;29 /// Named labels for statements 30 class Label { 31 public: 32 CodeLocation location; 33 std::string name; 34 std::vector< ptr<Attribute> > attributes; 35 35 36 Label( CodeLocation loc, const std::string& name = "",37 const std::vector<ptr<Attribute>>& attrs = std::vector<ptr<Attribute>>{} )38 : location( loc ), name( name ), attributes( attrs ) {}36 Label( CodeLocation loc, const std::string& name = "", 37 const std::vector<ptr<Attribute>>& attrs = std::vector<ptr<Attribute>>{} ) 38 : location( loc ), name( name ), attributes( attrs ) {} 39 39 40 operator std::string () const { return name; }41 bool empty() { return name.empty(); }42 };40 operator std::string () const { return name; } 41 bool empty() { return name.empty(); } 42 }; 43 43 44 inline bool operator== ( const Label& l1, const Label& l2 ) { return l1.name == l2.name; }45 inline bool operator!= ( const Label& l1, const Label& l2 ) { return !(l1 == l2); }46 inline bool operator< ( const Label& l1, const Label& l2 ) { return l1.name < l2.name; }44 inline bool operator== ( const Label& l1, const Label& l2 ) { return l1.name == l2.name; } 45 inline bool operator!= ( const Label& l1, const Label& l2 ) { return !(l1 == l2); } 46 inline bool operator< ( const Label& l1, const Label& l2 ) { return l1.name < l2.name; } 47 47 48 inline std::ostream& operator<< ( std::ostream& out, const Label& l ) { return out << l.name; } 49 50 51 //================================================================================================= 52 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency 53 /// remove only if there is a better solution 54 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with 55 /// forward declarations 56 inline void increment( const class Label * node, Node::ref_type ref ) { node->increment( ref ); } 57 inline void decrement( const class Label * node, Node::ref_type ref ) { node->decrement( ref ); } 48 inline std::ostream& operator<< ( std::ostream& out, const Label& l ) { return out << l.name; } 58 49 59 50 }
Note:
See TracChangeset
for help on using the changeset viewer.