| 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 | //
 | 
|---|
| 7 | // Label.h --
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // Author           : Rob Schluntz
 | 
|---|
| 10 | // Created On       : Wed Jun 8 12:53:12 2016
 | 
|---|
| 11 | // Last Modified By : Rob Schluntz
 | 
|---|
| 12 | // Last Modified On : Wed Jun 8 12:53:28 2016
 | 
|---|
| 13 | // Update Count     : 1
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #ifndef LABEL_H
 | 
|---|
| 17 | #define LABEL_H
 | 
|---|
| 18 | 
 | 
|---|
| 19 | #include <string>
 | 
|---|
| 20 | #include <list>
 | 
|---|
| 21 | #include <iostream>
 | 
|---|
| 22 | #include "SynTree.h"
 | 
|---|
| 23 | 
 | 
|---|
| 24 | class Label {
 | 
|---|
| 25 |   public:
 | 
|---|
| 26 |         Label( const std::string & name = "", Statement * labelled = 0 ) : name( name ), labelled( labelled ) {}
 | 
|---|
| 27 |         Label( const char * name, Statement * labelled = 0 ) : name( name ), labelled( labelled ) {}
 | 
|---|
| 28 | 
 | 
|---|
| 29 |         const std::string & get_name() const { return name; }
 | 
|---|
| 30 |         void set_name( const std::string & newValue ) { name = newValue; }
 | 
|---|
| 31 | 
 | 
|---|
| 32 |         Statement * get_statement() const { return labelled; }
 | 
|---|
| 33 |         void set_statement( Statement * newValue ) { labelled = newValue; }
 | 
|---|
| 34 |         std::list< Attribute * >& get_attributes() { return attributes; }
 | 
|---|
| 35 | 
 | 
|---|
| 36 |         operator std::string() { return name; }
 | 
|---|
| 37 |         bool empty() { return name.empty(); }
 | 
|---|
| 38 |   private:
 | 
|---|
| 39 |         std::string name;
 | 
|---|
| 40 |         Statement * labelled;
 | 
|---|
| 41 |         std::list< Attribute * > attributes;
 | 
|---|
| 42 | };
 | 
|---|
| 43 | 
 | 
|---|
| 44 | inline bool operator==( Label l1, Label l2 ) { return l1.get_name() == l2.get_name(); }
 | 
|---|
| 45 | inline bool operator!=( Label l1, Label l2 ) { return ! (l1 == l2); }
 | 
|---|
| 46 | inline bool operator<( Label l1, Label l2 ) { return l1.get_name() < l2.get_name(); }
 | 
|---|
| 47 | // inline Label operator+( Label l1, Label l2 ) { return l1.get_name() + l2.get_name(); }
 | 
|---|
| 48 | // inline Label operator+( Label l1, const char * str ) { return l1.get_name() + Label( str ); }
 | 
|---|
| 49 | inline std::ostream & operator<<( std::ostream & out, const Label & l ) { return out << l.get_name(); }
 | 
|---|
| 50 | 
 | 
|---|
| 51 | static const std::list< Label > noLabels;
 | 
|---|
| 52 | 
 | 
|---|
| 53 | #endif // LABEL_H
 | 
|---|
| 54 | 
 | 
|---|
| 55 | // Local Variables: //
 | 
|---|
| 56 | // tab-width: 4 //
 | 
|---|
| 57 | // mode: c++ //
 | 
|---|
| 58 | // compile-command: "make install" //
 | 
|---|
| 59 | // End: //
 | 
|---|