OpenASIP 2.2
Loading...
Searching...
No Matches
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
37using std::string;
38using namespace TTAMachine;
39
40namespace TTAProgram {
41
42/////////////////////////////////////////////////////////////////////////////
43// Label
44/////////////////////////////////////////////////////////////////////////////
45
46Label::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 */
58Label::Label(const std::string& name, Address address, const Scope& scope):
59 name_(name), address_(address), scope_(&scope) {
60}
61
62/**
63 * The destructor.
64 */
67
68/**
69 * Returns the name of this label.
70 *
71 * @return The name of this label.
72 */
73string
74Label::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 */
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 */
93const Scope&
94Label::scope() const {
95 return *scope_;
96}
97
98/**
99 * Sets the name of this label.
100 */
101void
102Label::setName(const string& name) {
103 name_ = name;
104}
105
106/**
107 * Sets the address of the location corresponding to this label.
108 */
109void
113
114/**
115 * Sets the innermost scope that contains this label.
116 */
117void
118Label::setScope(const Scope& scope) {
119 scope_ = &scope;
120}
121
122}
void setScope(const Scope &scope)
Definition Label.cc:118
std::string name() const
Definition Label.cc:74
void setAddress(Address address)
Definition Label.cc:110
const Scope * scope_
Owning scope of the label.
Definition Label.hh:77
virtual ~Label()
Definition Label.cc:65
virtual Address address() const
Definition Label.cc:84
std::string name_
Name of the label.
Definition Label.hh:73
Address address_
Address of the location corresponding to this label.
Definition Label.hh:75
void setName(const std::string &name)
Definition Label.cc:102
const Scope & scope() const
Definition Label.cc:94