OpenASIP  2.0
Label.cc
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.cc
26  *
27  * Implementation of Label class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "Label.hh"
34 #include "Scope.hh"
35 #include "NullAddressSpace.hh"
36 
37 using std::string;
38 using namespace TTAMachine;
39 
40 namespace TTAProgram {
41 
42 /////////////////////////////////////////////////////////////////////////////
43 // Label
44 /////////////////////////////////////////////////////////////////////////////
45 
46 Label::Label(): address_(Address(0, NullAddressSpace::instance())) {
47 }
48 
49 /**
50  * The constructor.
51  *
52  * Registers this label to the owning scope.
53  *
54  * @param name Name of the label. Must be unique within the owning scope.
55  * @param address The address of the location corresponding to this label.
56  * @param scope The innermost scope that contains this label.
57  */
58 Label::Label(const std::string& name, Address address, const Scope& scope):
59  name_(name), address_(address), scope_(&scope) {
60 }
61 
62 /**
63  * The destructor.
64  */
66 }
67 
68 /**
69  * Returns the name of this label.
70  *
71  * @return The name of this label.
72  */
73 string
74 Label::name() const {
75  return name_;
76 }
77 
78 /**
79  * Returns the address of the location corresponding to this label.
80  *
81  * @return The address of the location corresponding to this label.
82  */
83 Address
84 Label::address() const {
85  return address_;
86 }
87 
88 /**
89  * Returns the innermost scope that contains this label.
90  *
91  * @return The innermost scope that contains this label.
92  */
93 const Scope&
94 Label::scope() const {
95  return *scope_;
96 }
97 
98 /**
99  * Sets the name of this label.
100  */
101 void
102 Label::setName(const string& name) {
103  name_ = name;
104 }
105 
106 /**
107  * Sets the address of the location corresponding to this label.
108  */
109 void
111  address_ = address;
112 }
113 
114 /**
115  * Sets the innermost scope that contains this label.
116  */
117 void
118 Label::setScope(const Scope& scope) {
119  scope_ = &scope;
120 }
121 
122 }
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::Scope
Definition: Scope.hh:53
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
TTAMachine::NullAddressSpace
Definition: NullAddressSpace.hh:45
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
Scope.hh
TTAProgram::Label::~Label
virtual ~Label()
Definition: Label.cc:65
NullAddressSpace.hh
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
TTAProgram::Label::scope
const Scope & scope() const
Definition: Label.cc:94
Label.hh
TTAMachine
Definition: Assembler.hh:48