#include <include/EDoc/CodeBlock.h>
Inheritance diagram for EDoc::CodeBlock:
A CodeBlock contains a list of:
Definition at line 58 of file CodeBlock.h.
Public Member Functions | |
CodeBlock (Dictionary *dict_in=NULL) | |
Create a new instance that belongs to the given dictionary. | |
CodeBlock (const CodeBlock &right) | |
Copy constructor. | |
CodeBlock (const CodeBlock &right, Dictionary &dict_in) | |
Create a new instance as a copy of another instance but place this one in a different dictionary. | |
CodeBlock & | operator= (const CodeBlock &right) |
Assignment operator. | |
void | Read (PersistenceIFace &file, IndexedDictionary &idict) |
Read the contents of this object data from the given file persistence interface. | |
void | Write (PersistenceIFace &file) const |
Write the contents of this objects data to the given file persistence interface. | |
bool | Merge (const CodeBlock &right) |
Will merge the contents of the given instance into the current instance. | |
virtual size_t | ReplaceReferences (PStack &stack, void *remove, void *replace) |
See DictionarySpecific::ReplaceReferences(). | |
virtual std::ostream & | Print (std::ostream &out, std::string prefix="") const |
See DictionarySpecific::Print(). | |
virtual void | Validate (PStack &stack, const Dictionary &dict_in) const |
See DictionarySpecific::Validate(). | |
bool | operator== (const CodeBlock &right) const |
Returns true if the contents of the two instances are the same. | |
bool | operator!= (const CodeBlock &right) const |
Returns true if the contents of the two instances differ. | |
std::list< FunctionLoc > | AllFunctionCalls () |
Returns an amalgamated list of all function calls and possible function calls. | |
void | ExpandCallGraph (Function &function) |
This will populate the list of "possible_function_calls" from this objects list of function_pointer_calls. | |
void | AddPossCall (FunctionLoc func) |
Adds a possible function call to the possible_function_calls list. | |
std::list< CodeBlock * > | GetAllCodeBlocks () |
Traverses the heirarch of CodeBlock's (Through CatchBlock's and TryBlock's) and constructs a flat file list of all CodeBlock's within this heirarchy. | |
std::list< EDoc::Exception * > | GetOriginatingExceptions () |
Returns a list of originating exceptions as pointers to the original Exception objects so that their values can be easily modified. | |
std::string | ToString (std::string prefix="") const |
Returns a string representing the current object in a user readable manner. | |
Data Fields | |
std::list< FunctionLoc > | function_calls |
A list of functions that this code block makes direct calls to. | |
std::list< Exception > | originating_exceptions |
A list of exceptions that this code block throws directly. | |
std::list< FunctionTypeLoc > | function_pointer_calls |
A list of function pointer types that this code block calls. | |
std::list< TryBlock > | try_blocks |
A list of try blocks that are within this code block. | |
std::list< FunctionLoc > | possible_function_calls |
A list of functions that may "possibly" be called from this code block indirectly. | |
Protected Attributes | |
Dictionary & | dict |
A reference to the dictionary this object belongs to. |
EDoc::CodeBlock::CodeBlock | ( | Dictionary * | dict_in = NULL |
) |
Create a new instance that belongs to the given dictionary.
dict_in | See DictionarySpecific::DictionarySpecific() |
Definition at line 39 of file CodeBlock.cpp.
EDoc::CodeBlock::CodeBlock | ( | const CodeBlock & | right | ) |
Copy constructor.
New object will belong to the same dictionary as the object being copied from.
Definition at line 44 of file CodeBlock.cpp.
EDoc::CodeBlock::CodeBlock | ( | const CodeBlock & | right, | |
EDoc::Dictionary & | dict_in | |||
) |
Create a new instance as a copy of another instance but place this one in a different dictionary.
Definition at line 50 of file CodeBlock.cpp.
EDoc::CodeBlock::operator= | ( | const CodeBlock & | right | ) |
Assignment operator.
Can be used to assign from an object that belongs to a different dictionary. However you must be careful that the StringIdentifiedObject objects that are being copied already exist in this dictionary OR will be populated soon after the assignment.
Definition at line 56 of file CodeBlock.cpp.
References EDoc::DictionarySpecific::dict, EDOC_FOREACH_CONST, EDoc::Erase(), function_calls, function_pointer_calls, originating_exceptions, possible_function_calls, and try_blocks.
EDoc::CodeBlock::Read | ( | PersistenceIFace & | file, | |
IndexedDictionary & | idict | |||
) |
Read the contents of this object data from the given file persistence interface.
Use of the PersistenceIFace requires that data be read in the same order it was written (Regardless of the fact that we provide a key which is primarily used for debugging purposes).
file | The interface to the file from which we will load the data. Using this interface allows us to easily modify the format of the file being read/written without having to modify the reading/writing code. | |
idict | The IndexedDictionary object being used to load the translation units data from the file. See Dictionary::Read() for more information on how the IndexedDictionary is used. |
Definition at line 92 of file CodeBlock.cpp.
References EDoc::DictionarySpecific::dict, EDoc::Erase(), function_calls, function_pointer_calls, KEY_FUNCP_CALLS_LS, KEY_FUNCTION_CALL_LS, KEY_ORIGINATING_EXCEPTIONS_LS, KEY_TRY_BLOCKS_LS, originating_exceptions, EDoc::PersistenceIFace::ReadUInt32(), and try_blocks.
Referenced by EDoc::TryBlock::Read(), EDoc::Function::Read(), and EDoc::CatchBlock::Read().
EDoc::CodeBlock::Write | ( | PersistenceIFace & | file | ) | const |
Write the contents of this objects data to the given file persistence interface.
Use of the PersistenceIFace requires that data be read in the same order it was written (Regardless of the fact that we provide a key which is primarily used for debugging purposes).
file | The interface to the file from which we will load the data. Using this interface allows us to easily modify the format of the file being read/written without having to modify the reading/writing code. |
Definition at line 129 of file CodeBlock.cpp.
References EDOC_FOREACH_CONST, function_calls, function_pointer_calls, KEY_FUNCP_CALLS_LS, KEY_FUNCTION_CALL_LS, KEY_ORIGINATING_EXCEPTIONS_LS, KEY_TRY_BLOCKS_LS, originating_exceptions, try_blocks, and EDoc::PersistenceIFace::WriteUInt32().
Referenced by EDoc::TryBlock::Write(), EDoc::Function::Write(), and EDoc::CatchBlock::Write().
EDoc::CodeBlock::Merge | ( | const CodeBlock & | right | ) |
Will merge the contents of the given instance into the current instance.
GEBERAL INFORMATION ABOUT MERGING
Merging is performed between two instances which MAY or MAY NOT belong to different dictionaries. The idea is to create a union of the two instances in a way that is meaningful for the particular object type. For example merging two Type instances will require that the two objects have exactly the same names and throw types, but may have different types in the identical/catchable lists.
Merging will usually be performed starting at instances of StringIdentifiedObject's when doing a Dictionary::Merge() If two of these objects have the same string identifiers it will be eithre possible to merge them or will cause a conflict in which case the merge will fail and throw a MergeException.
Each type will have specifics about what it means to merge them and they are documented in the appropiate types documentation.
INFORMATION SPECIFIC TO CodeBlock::Merge():
This merge differs from others in that it will always be successful in merging the two CodeBlock instances together, however unlike all other Merge() calls this one may return a boolean value indicating if the merge did not have to modify anything in order to produce the union because the two were already equivilant or will return false to indicate that they were not equivilant and the merge was necessary.
This information is used by the Function::Merge() in order to resolve linking together multiple implementations of a single function. See Function::Merge() for more information (Especially regarding Vague Linkage of Functions).
Definition at line 168 of file CodeBlock.cpp.
References EDOC_LIST_MERGE, function_calls, function_pointer_calls, originating_exceptions, and try_blocks.
Referenced by EDoc::Function::Merge().
EDoc::CodeBlock::ReplaceReferences | ( | EDoc::PStack & | stack, | |
void * | remove, | |||
void * | replace | |||
) | [virtual] |
See DictionarySpecific::ReplaceReferences().
Implements EDoc::DictionarySpecific.
Definition at line 296 of file CodeBlock.cpp.
References EDOC_FOREACH, function_calls, function_pointer_calls, originating_exceptions, possible_function_calls, EDoc::PStack::Push(), and try_blocks.
Referenced by EDoc::TryBlock::ReplaceReferences(), EDoc::Function::ReplaceReferences(), and EDoc::CatchBlock::ReplaceReferences().
EDoc::CodeBlock::Print | ( | std::ostream & | out, | |
std::string | prefix = "" | |||
) | const [virtual] |
See DictionarySpecific::Print().
Implements EDoc::DictionarySpecific.
Definition at line 334 of file CodeBlock.cpp.
References EDOC_FOREACH_CONST, function_calls, function_pointer_calls, EDoc::INDENT_STR, originating_exceptions, possible_function_calls, and try_blocks.
Referenced by EDoc::TryBlock::Print(), EDoc::Function::Print(), and EDoc::CatchBlock::Print().
EDoc::CodeBlock::Validate | ( | EDoc::PStack & | stack, | |
const Dictionary & | dict_in | |||
) | const [virtual] |
See DictionarySpecific::Validate().
Implements EDoc::DictionarySpecific.
Definition at line 391 of file CodeBlock.cpp.
References EDoc::DictionarySpecific::dict, EDOC_ASSERT, EDOC_FOREACH_CONST, function_calls, function_pointer_calls, originating_exceptions, possible_function_calls, and try_blocks.
Referenced by EDoc::TryBlock::Validate(), EDoc::Function::Validate(), and EDoc::CatchBlock::Validate().
EDoc::CodeBlock::operator== | ( | const CodeBlock & | right | ) | const |
Returns true if the contents of the two instances are the same.
This treats two code blocks with the same contents but in a different order as the equivilant.
Definition at line 224 of file CodeBlock.cpp.
References EDOC_LIST_COMPARE, function_calls, function_pointer_calls, originating_exceptions, and try_blocks.
EDoc::CodeBlock::operator!= | ( | const CodeBlock & | right | ) | const [inline] |
Returns true if the contents of the two instances differ.
Definition at line 202 of file CodeBlock.h.
EDoc::CodeBlock::AllFunctionCalls | ( | ) |
Returns an amalgamated list of all function calls and possible function calls.
Note: The FunctionLoc::possible flag is set to true if this is a "possible" function call.
Definition at line 263 of file CodeBlock.cpp.
References EDoc::Append(), function_calls, and possible_function_calls.
Referenced by EDoc::Dictionary::ProcessCodeBlock().
EDoc::CodeBlock::ExpandCallGraph | ( | Function & | function | ) |
This will populate the list of "possible_function_calls" from this objects list of function_pointer_calls.
A function pointer call is expanded into 0 or more possible function calls. Basically every function whose prototype matches the function pointer and whose address has been taken at some point in code is added as a possible call. I.e. through the function pointer this code block may possibly call those functions.
A possible function call is marked as such with the FunctionLoc::possible flag being set to true.
Note: the expansion of calls to virtual functions into additional possible calls is done in Function::ExpandCallGraph() not here.
Definition at line 371 of file CodeBlock.cpp.
References AddPossCall(), EDoc::DictionarySpecific::dict, EDOC_FOREACH, function_pointer_calls, and try_blocks.
Referenced by EDoc::TryBlock::ExpandCallGraph(), EDoc::Function::ExpandCallGraph(), and EDoc::CatchBlock::ExpandCallGraph().
EDoc::CodeBlock::AddPossCall | ( | FunctionLoc | func | ) |
Adds a possible function call to the possible_function_calls list.
This is generally used by the ExpandCallGraph() function.
Definition at line 270 of file CodeBlock.cpp.
References possible_function_calls.
Referenced by EDoc::Function::ExpandCallGraph(), and ExpandCallGraph().
EDoc::CodeBlock::GetAllCodeBlocks | ( | ) |
Traverses the heirarch of CodeBlock's (Through CatchBlock's and TryBlock's) and constructs a flat file list of all CodeBlock's within this heirarchy.
This can be used by a function to get a list of all blocks of code in the function regardless of the codes heirarchy. This is useful for the user to apply suppressions across an entire function.
Definition at line 276 of file CodeBlock.cpp.
References EDoc::Append(), EDOC_FOREACH, and try_blocks.
EDoc::CodeBlock::GetOriginatingExceptions | ( | ) |
Returns a list of originating exceptions as pointers to the original Exception objects so that their values can be easily modified.
This us used by the python wrappers in order to apply suppressions directly to originating exception objects.
Definition at line 438 of file CodeBlock.cpp.
References originating_exceptions.
EDoc::DictionarySpecific::ToString | ( | std::string | prefix = "" |
) | const [inherited] |
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 EDoc::DictionarySpecific::Print().
Referenced by EDoc::Dictionary::Read().
std::list<FunctionLoc> EDoc::CodeBlock::function_calls |
A list of functions that this code block makes direct calls to.
Definition at line 275 of file CodeBlock.h.
Referenced by AllFunctionCalls(), EDoc::CalculateTotalFunctionCalls(), Merge(), operator=(), operator==(), Print(), Read(), ReplaceReferences(), Validate(), and Write().
std::list<Exception> EDoc::CodeBlock::originating_exceptions |
A list of exceptions that this code block throws directly.
Definition at line 280 of file CodeBlock.h.
Referenced by GetOriginatingExceptions(), Merge(), operator=(), operator==(), Print(), EDoc::Dictionary::ProcessCodeBlock(), Read(), ReplaceReferences(), Validate(), and Write().
A list of function pointer types that this code block calls.
Definition at line 285 of file CodeBlock.h.
Referenced by ExpandCallGraph(), Merge(), operator=(), operator==(), Print(), Read(), ReplaceReferences(), Validate(), and Write().
std::list<TryBlock> EDoc::CodeBlock::try_blocks |
A list of try blocks that are within this code block.
Definition at line 290 of file CodeBlock.h.
Referenced by EDoc::CalculateTotalFunctionCalls(), ExpandCallGraph(), GetAllCodeBlocks(), Merge(), operator=(), operator==(), Print(), EDoc::Dictionary::ProcessCodeBlock(), Read(), ReplaceReferences(), Validate(), and Write().
A list of functions that may "possibly" be called from this code block indirectly.
This is populated when expanding the call graph. It is expanded based on virtual function calls and function pointer calls.
Definition at line 304 of file CodeBlock.h.
Referenced by AddPossCall(), AllFunctionCalls(), EDoc::CalculateTotalFunctionCalls(), operator=(), Print(), ReplaceReferences(), and Validate().
Dictionary& EDoc::DictionarySpecific::dict [protected, inherited] |
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(), 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=(), operator=(), EDoc::PropogatingException::PropogatingException(), EDoc::TryBlock::Read(), EDoc::Function::Read(), 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(), Validate(), EDoc::CatchBlock::Validate(), EDoc::Type::Write(), and EDoc::Function::Write().