OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
TTAProgram::InstructionReference Class Reference

#include <InstructionReference.hh>

Collaboration diagram for TTAProgram::InstructionReference:
Collaboration graph

Public Member Functions

 InstructionReference (InstructionReferenceImpl *impl)
 
 InstructionReference (const InstructionReference &ir)
 
virtual ~InstructionReference ()
 
InstructionReferenceoperator= (const InstructionReference &)
 
Instructioninstruction () const
 
bool setImpl (InstructionReferenceImpl *impl)
 
bool operator== (const InstructionReference &other) const
 

Private Attributes

InstructionReferenceImplimpl_
 

Detailed Description

Represents a reference to an Instruction instance.

The target of the reference can be changed as needed.

Definition at line 49 of file InstructionReference.hh.

Constructor & Destructor Documentation

◆ InstructionReference() [1/2]

TTAProgram::InstructionReference::InstructionReference ( InstructionReferenceImpl impl)
explicit

Constructor.

Note
Instruction references should be created using InstructionReferenceManager.
Parameters
insReferred instruction.

Definition at line 51 of file InstructionReference.cc.

51 :
52 impl_(impl) {
53 if (impl_ != NULL) {
54 impl_->addRef(*this);
55 }
56}

References TTAProgram::InstructionReferenceImpl::addRef(), and impl_.

Here is the call graph for this function:

◆ InstructionReference() [2/2]

TTAProgram::InstructionReference::InstructionReference ( const InstructionReference ref)

Constructor.

Note
Instruction references should be created using InstructionReferenceManager.
Parameters
insReferred instruction.

Definition at line 65 of file InstructionReference.cc.

65 :
66 impl_(ref.impl_) {
67 if (impl_ != NULL) {
68 impl_->addRef(*this);
69 }
70}

References TTAProgram::InstructionReferenceImpl::addRef(), and impl_.

Here is the call graph for this function:

◆ ~InstructionReference()

TTAProgram::InstructionReference::~InstructionReference ( )
virtual

Destructor.

Tells the impl that we are no longer pointing to it. It may get also deleted if this was the last reference to it.

Definition at line 103 of file InstructionReference.cc.

103 {
104 if (impl_ != NULL) {
105 impl_->removeRef(*this);
106 }
107}
bool removeRef(InstructionReference &ref)

References impl_, and TTAProgram::InstructionReferenceImpl::removeRef().

Here is the call graph for this function:

Member Function Documentation

◆ instruction()

Instruction & TTAProgram::InstructionReference::instruction ( ) const

◆ operator=()

InstructionReference & TTAProgram::InstructionReference::operator= ( const InstructionReference ref)

Assignment operator.

Changes this reference to point to another instruction. Only changes this reference, not other references pointing to same instruction.

Definition at line 79 of file InstructionReference.cc.

80 {
81 // if both point to same instruction, no need to do anything.
82 if (ref.impl_ != impl_) {
83 // stop pointing to old instruction
84 if (impl_ != NULL) {
85 impl_->removeRef(*this);
86 }
87 // pointing to new instruction
88 impl_ = ref.impl_;
89 if (impl_ != NULL) {
90 impl_->addRef(*this);
91 }
92 }
93 return *this;
94}

References TTAProgram::InstructionReferenceImpl::addRef(), impl_, and TTAProgram::InstructionReferenceImpl::removeRef().

Here is the call graph for this function:

◆ operator==()

bool TTAProgram::InstructionReference::operator== ( const InstructionReference other) const

Definition at line 147 of file InstructionReference.cc.

147 {
148 return impl_ == other.impl_;
149}

References impl_.

◆ setImpl()

bool TTAProgram::InstructionReference::setImpl ( InstructionReferenceImpl newImpl)

Sets a new referred instruction.

The InstructionReferenceImpl is a "proxy object" that counts and keeps book of references

Parameters
newImplNew referred instruction.
Returns
true if old impl stays alive, false if it is deleted.

Definition at line 119 of file InstructionReference.cc.

119 {
120 bool staysAlive = true;
121 assert(newImpl != impl_);
122 if (impl_ != NULL) {
123 staysAlive = impl_->removeRef(*this);
124 }
125 impl_ = newImpl;
126 if (impl_ != NULL) {
127 impl_->addRef(*this);
128 }
129 return staysAlive;
130}
#define assert(condition)

References TTAProgram::InstructionReferenceImpl::addRef(), assert, impl_, and TTAProgram::InstructionReferenceImpl::removeRef().

Here is the call graph for this function:

Member Data Documentation

◆ impl_

InstructionReferenceImpl* TTAProgram::InstructionReference::impl_
private

The documentation for this class was generated from the following files: