boost::intrusive_ptr< Group > GroupPtr
Definition: Graph.h:76
Graph::vertex_descriptor GraphVertex
Definition: Graph.h:171
boost::adjacency_list< boost::setS, boost::listS, boost::bidirectionalS, GraphProperty, EdgeProperty > Graph
Definition: Graph.h:169
boost::intrusive_ptr< Instruction > InstPtr
Pointer to an Instruction.
Definition: Instruction.h:43
InstVec::const_iterator ConstInstIterator
Type representing a const_iterator over InstPtrs.
Definition: Instruction.h:392
std::vector< InstPtr > InstVec
Type representing a vector of InstPtrs.
Definition: Instruction.h:382
Class for doing code flow analysis.
Definition: ControlFlow.h:24
void DetectDoWhile()
Detects do-while blocks.
Definition: ControlFlow.cpp:347
std::map< uint32, GraphVertex > addr_map_
Map of addresses and vertices.
Definition: ControlFlow.h:96
bool ValidateElseBlock(GroupPtr if_group, GroupPtr start, GroupPtr end)
Checks if a candidate else block will cross block boundaries.
Definition: ControlFlow.cpp:551
void DetectShortCircuit()
Merged groups that are part of the same short-circuited condition.
Definition: ControlFlow.cpp:277
void CreateGroups()
Creates groups suitable for a stack-based machine.
Definition: ControlFlow.cpp:188
Engine & engine_
The engine used for the script.
Definition: ControlFlow.h:86
ControlFlow(InstVec &insts, Engine &engine)
Constructor for the control flow graph.
Definition: ControlFlow.cpp:64
const Graph & Analyze()
Performs control flow analysis.
Definition: ControlFlow.cpp:313
void DetectBreak()
Detects break statements.
Definition: ControlFlow.cpp:364
void DetectIf()
Detects if blocks.
Definition: ControlFlow.cpp:499
void SetStackLevel(GraphVertex graph, int level)
Sets the stack level for all instructions, using depth-first search.
Definition: ControlFlow.cpp:160
void DetectContinue()
Detects continue statements.
Definition: ControlFlow.cpp:395
void DetectWhile()
Detects while blocks.
Definition: ControlFlow.cpp:323
bool ValidateBreakOrContinue(GroupPtr group, GroupPtr condition_group)
Checks if a candidate break/continue goes to the closest loop.
Definition: ControlFlow.cpp:441
void DetectElse()
Detects else blocks.
Definition: ControlFlow.cpp:509
InstVec & insts_
The instructions being analyzed.
Definition: ControlFlow.h:91
Graph graph_
The control flow graph.
Definition: ControlFlow.h:81
ControlFlow & operator=(const ControlFlow &control_flow)=delete
Copy constructor disabled.
ControlFlow(const ControlFlow &control_flow)=delete
Copy constructor disabled.
GraphVertex Find(const InstPtr inst)
Finds a graph vertex through an instruction.
Definition: ControlFlow.cpp:118
const Graph & GetGraph() const
Retrieves the current control flow graph.
Definition: ControlFlow.cpp:116
void Merge(GraphVertex graph_1, GraphVertex graph_2)
Merges two graph vertices.
Definition: ControlFlow.cpp:131
Base class for engines.
Definition: Engine.h:34
unsigned int uint32
Definition: scummsys.h:435