#include <include/EDoc/DictionarySpecific.h>
Inheritance diagram for EDoc::DictionarySpecific:
A dictionary specific type is a type/class which "belongs" to a particular instance of the Dictionary class. Objects that belong to one dictionary can NOT be referenced by object from another dictionary. They need to be specially copied/merged. For this reason there is special processing that occurs for assignment and copies of dictionary specific objects to ensure that these rules are not violated.
HISTORY
This was done because the other option was to use identifiers and lookups or copies of all the data. Initially this was attempted but processing time and memory usage were enormous, so the method was changed in order to store pointers directly to members. However objects can only store pointers to other members that belong to the same Dictionary instance. This means that when a dictionary object is destroyed along with all objects that "belong" to it, no other objects are invalidated.
As a result this class was created in order to simplify management of these objects.
All DictionarySpecific objects have functionality to replace pointer references and to validate themselves.
Definition at line 64 of file DictionarySpecific.h.
Public Member Functions | |
DictionarySpecific (Dictionary *dict_in) | |
Create this dictionary specific object belonging to the given dictionary. | |
virtual | ~DictionarySpecific () |
Destructor. | |
virtual size_t | ReplaceReferences (PStack &stack, void *remove, void *replace)=0 |
Replaces all references of pointers referencing remove with pointers to replace. | |
virtual std::ostream & | Print (std::ostream &out, std::string prefix="") const =0 |
Print the current object to the given stream in a user readable manner. | |
std::string | ToString (std::string prefix="") const |
Returns a string representing the current object in a user readable manner. | |
virtual void | Validate (PStack &stack, const Dictionary &dict_in) const =0 |
Performs internal valtidation on the current object and will throw a BugException if the validation fails. | |
Protected Attributes | |
Dictionary & | dict |
A reference to the dictionary this object belongs to. | |
Private Member Functions | |
DictionarySpecific (const DictionarySpecific &right) | |
COPY DISALLOWED. | |
DictionarySpecific & | operator= (const DictionarySpecific &right) |
ASSIGNMENT DISALLOWED. | |
Friends | |
class | ManagedObject |
EDoc::DictionarySpecific::DictionarySpecific | ( | Dictionary * | dict_in | ) |
Create this dictionary specific object belonging to the given dictionary.
dict_in | The dictionary that this object will belong to if NULL then will use the dictionary that can be obtained by: GetCurrentDictionaryAssert() |
Definition at line 29 of file DictionarySpecific.cpp.
EDoc::DictionarySpecific::~DictionarySpecific | ( | ) | [inline, virtual] |
EDoc::DictionarySpecific::DictionarySpecific | ( | const DictionarySpecific & | right | ) | [private] |
COPY DISALLOWED.
EDoc::DictionarySpecific::ReplaceReferences | ( | PStack & | stack, | |
void * | remove, | |||
void * | replace | |||
) | [pure virtual] |
Replaces all references of pointers referencing remove with pointers to replace.
The replacement is used because when after Read()'ing it is possible to have two instances of an object indexed by the same key. The contents of them must be merged and all references to one object be changed to reference the other. Then the now unreferenced object would be deleted. This is a part of the loading phase and is a result of the fact that GCC can generate multiple tree nodes for a single type. Thus when loading we often get the same type multiple times.
Implemented in EDoc::CatchBlock, EDoc::CodeBlock, EDoc::Exception, EDoc::File, EDoc::Function, EDoc::FunctionLoc, EDoc::FunctionType, EDoc::FunctionTypeLoc, EDoc::Location, EDoc::ManagedObject, EDoc::PropogatingException, EDoc::TryBlock, EDoc::Type, and EDoc::TypeLoc.
EDoc::DictionarySpecific::Print | ( | std::ostream & | out, | |
std::string | prefix = "" | |||
) | const [pure virtual] |
Print the current object to the given stream in a user readable manner.
out | The stream to print to. | |
prefix | A string prefix to display at the start of every line. As an example this can be used in order to indent the print by passing "\t" as the string. |
Implemented in EDoc::CatchBlock, EDoc::CodeBlock, EDoc::Exception, EDoc::File, EDoc::Function, EDoc::FunctionLoc, EDoc::FunctionType, EDoc::FunctionTypeLoc, EDoc::Location, EDoc::ManagedObject, EDoc::PropogatingException, EDoc::TryBlock, EDoc::Type, and EDoc::TypeLoc.
Referenced by std::operator<<(), and ToString().
EDoc::DictionarySpecific::ToString | ( | std::string | prefix = "" |
) | const |
Returns a string representing the current object in a user readable manner.
This will return as a string exactly what Print() would display. This is primarily here for use from within python and for debugging.
Definition at line 34 of file DictionarySpecific.cpp.
References Print().
Referenced by EDoc::Dictionary::Read().
EDoc::DictionarySpecific::Validate | ( | PStack & | stack, | |
const Dictionary & | dict_in | |||
) | const [pure virtual] |
Performs internal valtidation on the current object and will throw a BugException if the validation fails.
This is primarily used to ensure that all DictionarySpecific objects are internally consistent, not referencing dictionaries that they actually do not belong to. It is also used for a few other validations too that if they fail would indicate a bug in the code somewhere.
Implemented in EDoc::CatchBlock, EDoc::CodeBlock, EDoc::Exception, EDoc::File, EDoc::Function, EDoc::FunctionLoc, EDoc::FunctionType, EDoc::FunctionTypeLoc, EDoc::Location, EDoc::ManagedObject, EDoc::PropogatingException, EDoc::TryBlock, EDoc::Type, and EDoc::TypeLoc.
EDoc::DictionarySpecific::operator= | ( | const DictionarySpecific & | right | ) | [private] |
ASSIGNMENT DISALLOWED.
friend class ManagedObject [friend] |
Definition at line 66 of file DictionarySpecific.h.
Dictionary& EDoc::DictionarySpecific::dict [protected] |
A reference to the dictionary this object belongs to.
Definition at line 150 of file DictionarySpecific.h.
Referenced by EDoc::ManagedObject::CAlwaysGet(), EDoc::CatchBlock::CatchBlock(), EDoc::Exception::Exception(), EDoc::Function::ExpandCallGraph(), EDoc::CodeBlock::ExpandCallGraph(), EDoc::FunctionLoc::FunctionLoc(), EDoc::FunctionTypeLoc::FunctionTypeLoc(), EDoc::Function::GetSubstException(), EDoc::Location::Location(), EDoc::ManagedObject::ManagedObject(), EDoc::Type::Merge(), EDoc::Location::Merge(), EDoc::Function::Merge(), EDoc::SpecificManagedObject< EDoc::Type >::New(), EDoc::TypeLoc::operator=(), EDoc::Type::operator=(), EDoc::TryBlock::operator=(), EDoc::PropogatingException::operator=(), EDoc::Location::operator=(), EDoc::FunctionTypeLoc::operator=(), EDoc::FunctionType::operator=(), EDoc::FunctionLoc::operator=(), EDoc::Function::operator=(), EDoc::Exception::operator=(), EDoc::CodeBlock::operator=(), EDoc::PropogatingException::PropogatingException(), EDoc::TryBlock::Read(), EDoc::Function::Read(), EDoc::CodeBlock::Read(), EDoc::TryBlock::TryBlock(), EDoc::TypeLoc::TypeLoc(), EDoc::TypeLoc::Validate(), EDoc::Type::Validate(), EDoc::TryBlock::Validate(), EDoc::PropogatingException::Validate(), EDoc::ManagedObject::Validate(), EDoc::Location::Validate(), EDoc::FunctionTypeLoc::Validate(), EDoc::FunctionType::Validate(), EDoc::FunctionLoc::Validate(), EDoc::Function::Validate(), EDoc::File::Validate(), EDoc::Exception::Validate(), EDoc::CodeBlock::Validate(), EDoc::CatchBlock::Validate(), EDoc::Type::Write(), and EDoc::Function::Write().