diff --git a/include/analysis.h b/include/analysis.h index 875c0ed..5448652 100644 --- a/include/analysis.h +++ b/include/analysis.h @@ -105,6 +105,7 @@ class ControlNode { // Dynamically cast node to a specified type. // If type does not match null is returned. template T* cast(); + template const T* cast() const; uint32_t getIndex() const { return m_index; } @@ -484,6 +485,7 @@ template<> PushBlockNode* ControlNode::cast(); template<> PushBlockNode* ControlGraph::newNode(); template<> BranchNode* ControlNode::cast(); +template<> const BranchNode* ControlNode::cast() const; template<> BranchNode* ControlGraph::newNode(); class DomainVisitor { diff --git a/src/ControlGraph.cpp b/src/ControlGraph.cpp index b96c423..1e39dec 100644 --- a/src/ControlGraph.cpp +++ b/src/ControlGraph.cpp @@ -57,6 +57,10 @@ template<> BranchNode* ControlNode::cast() { return 0; } +template<> const BranchNode* ControlNode::cast() const { + return const_cast(this)->cast(); +} + template<> BranchNode* ControlGraph::newNode() { BranchNode* const node = new BranchNode(m_lastNodeIndex++); m_nodes.push_back(node);