OpenASIP  2.0
Label.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file Label.hh
26  *
27  * Declaration of Label class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_LABEL_HH
34 #define TTA_LABEL_HH
35 
36 #include <string>
37 #include "Address.hh"
38 
39 namespace TTAProgram {
40 
41 class Scope;
42 
43 /**
44  * Marks locations of code or data area of the program.
45  *
46  * Labels are owned by scopes. Scopes do not provide methods to add
47  * new labels, because the labels are automatically registered to a
48  * scope by their constructor: a label cannot exist without its scope.
49  *
50  * A label must have a unique name within the owning scope. It does
51  * not matter if there are other labels with the same name in outer
52  * scopes, because the inner scope has precedence. As a result, all
53  * labels in global scope must have a unique name.
54  */
55 class Label {
56 public:
57  virtual ~Label();
58 
59  std::string name() const;
60  virtual Address address() const;
61  const Scope& scope() const;
62 
64 
65 protected:
66  Label();
67  Label(const std::string& name, Address address, const Scope& scope);
68  void setName(const std::string& name);
69  void setScope(const Scope& scope);
70 
71 private:
72  /// Name of the label.
73  std::string name_;
74  /// Address of the location corresponding to this label.
76  /// Owning scope of the label.
77  const Scope* scope_;
78 };
79 
80 }
81 
82 #endif
TTAProgram
Definition: Estimator.hh:65
TTAProgram::Address
Definition: Address.hh:51
TTAProgram::Label::setName
void setName(const std::string &name)
Definition: Label.cc:102
TTAProgram::Label::Label
Label()
Definition: Label.cc:46
TTAProgram::Label
Definition: Label.hh:55
TTAProgram::Scope
Definition: Scope.hh:53
Scope
Definition: MoveNode.hh:50
TTAProgram::Label::setAddress
void setAddress(Address address)
Definition: Label.cc:110
TTAProgram::Label::setScope
void setScope(const Scope &scope)
Definition: Label.cc:118
TTAProgram::Label::scope_
const Scope * scope_
Owning scope of the label.
Definition: Label.hh:77
TTAProgram::Label::name
std::string name() const
Definition: Label.cc:74
TTAProgram::Label::name_
std::string name_
Name of the label.
Definition: Label.hh:73
TTAProgram::Label::~Label
virtual ~Label()
Definition: Label.cc:65
TTAProgram::Label::address
virtual Address address() const
Definition: Label.cc:84
TTAProgram::Label::address_
Address address_
Address of the location corresponding to this label.
Definition: Label.hh:75
Address.hh
TTAProgram::Label::scope
const Scope & scope() const
Definition: Label.cc:94