OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
TTAProgram::Label Class Reference

#include <Label.hh>

Inheritance diagram for TTAProgram::Label:
Inheritance graph
Collaboration diagram for TTAProgram::Label:
Collaboration graph

Public Member Functions

virtual ~Label ()
 
std::string name () const
 
virtual Address address () const
 
const Scopescope () const
 
void setAddress (Address address)
 

Protected Member Functions

 Label ()
 
 Label (const std::string &name, Address address, const Scope &scope)
 
void setName (const std::string &name)
 
void setScope (const Scope &scope)
 

Private Attributes

std::string name_
 Name of the label. More...
 
Address address_
 Address of the location corresponding to this label. More...
 
const Scopescope_
 Owning scope of the label. More...
 

Detailed Description

Marks locations of code or data area of the program.

Labels are owned by scopes. Scopes do not provide methods to add new labels, because the labels are automatically registered to a scope by their constructor: a label cannot exist without its scope.

A label must have a unique name within the owning scope. It does not matter if there are other labels with the same name in outer scopes, because the inner scope has precedence. As a result, all labels in global scope must have a unique name.

Definition at line 55 of file Label.hh.

Constructor & Destructor Documentation

◆ ~Label()

TTAProgram::Label::~Label ( )
virtual

The destructor.

Definition at line 65 of file Label.cc.

65  {
66 }

◆ Label() [1/2]

TTAProgram::Label::Label ( )
protected

Definition at line 46 of file Label.cc.

46  : address_(Address(0, NullAddressSpace::instance())) {
47 }

◆ Label() [2/2]

TTAProgram::Label::Label ( const std::string &  name,
Address  address,
const Scope scope 
)
protected

The constructor.

Registers this label to the owning scope.

Parameters
nameName of the label. Must be unique within the owning scope.
addressThe address of the location corresponding to this label.
scopeThe innermost scope that contains this label.

Definition at line 58 of file Label.cc.

58  :
60 }

Member Function Documentation

◆ address()

Address TTAProgram::Label::address ( ) const
virtual

Returns the address of the location corresponding to this label.

Returns
The address of the location corresponding to this label.

Reimplemented in TTAProgram::CodeLabel.

Definition at line 84 of file Label.cc.

84  {
85  return address_;
86 }

References address_.

Referenced by TTAProgram::Program::convertSymbolRef(), TTAProgram::GlobalScope::copyAndRelocate(), TTAProgram::ProgramWriter::createBinary(), SymbolAddressCommand::execute(), SimControlLanguageCommand::parseDataAddressExpression(), setAddress(), and TTAProgram::GlobalScope::setDataLabelAddressSpace().

◆ name()

string TTAProgram::Label::name ( ) const

◆ scope()

const Scope & TTAProgram::Label::scope ( ) const

Returns the innermost scope that contains this label.

Returns
The innermost scope that contains this label.

Definition at line 94 of file Label.cc.

94  {
95  return *scope_;
96 }

References scope_.

Referenced by setScope().

◆ setAddress()

void TTAProgram::Label::setAddress ( Address  address)

Sets the address of the location corresponding to this label.

Definition at line 110 of file Label.cc.

110  {
111  address_ = address;
112 }

References address(), and address_.

Referenced by TTAProgram::CodeLabel::CodeLabel().

Here is the call graph for this function:

◆ setName()

void TTAProgram::Label::setName ( const std::string &  name)
protected

Sets the name of this label.

Definition at line 102 of file Label.cc.

102  {
103  name_ = name;
104 }

References name(), and name_.

Referenced by TTAProgram::CodeLabel::CodeLabel().

Here is the call graph for this function:

◆ setScope()

void TTAProgram::Label::setScope ( const Scope scope)
protected

Sets the innermost scope that contains this label.

Definition at line 118 of file Label.cc.

118  {
119  scope_ = &scope;
120 }

References scope(), and scope_.

Referenced by TTAProgram::CodeLabel::CodeLabel().

Here is the call graph for this function:

Member Data Documentation

◆ address_

Address TTAProgram::Label::address_
private

Address of the location corresponding to this label.

Definition at line 75 of file Label.hh.

Referenced by address(), and setAddress().

◆ name_

std::string TTAProgram::Label::name_
private

Name of the label.

Definition at line 73 of file Label.hh.

Referenced by name(), and setName().

◆ scope_

const Scope* TTAProgram::Label::scope_
private

Owning scope of the label.

Definition at line 77 of file Label.hh.

Referenced by scope(), and setScope().


The documentation for this class was generated from the following files:
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::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