Skip to content

Commit

Permalink
Adds const cast for BranchNode
Browse files Browse the repository at this point in the history
Issue: #17
  • Loading branch information
0x7CFE committed May 21, 2016
1 parent 7f43e3f commit aa97c11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ControlNode {
// Dynamically cast node to a specified type.
// If type does not match null is returned.
template<class T> T* cast();
template<class T> const T* cast() const;

uint32_t getIndex() const { return m_index; }

Expand Down Expand Up @@ -484,6 +485,7 @@ template<> PushBlockNode* ControlNode::cast<PushBlockNode>();
template<> PushBlockNode* ControlGraph::newNode<PushBlockNode>();

template<> BranchNode* ControlNode::cast<BranchNode>();
template<> const BranchNode* ControlNode::cast<BranchNode>() const;
template<> BranchNode* ControlGraph::newNode<BranchNode>();

class DomainVisitor {
Expand Down
4 changes: 4 additions & 0 deletions src/ControlGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ template<> BranchNode* ControlNode::cast<BranchNode>() {
return 0;
}

template<> const BranchNode* ControlNode::cast<BranchNode>() const {
return const_cast<ControlNode*>(this)->cast<BranchNode>();
}

template<> BranchNode* ControlGraph::newNode<BranchNode>() {
BranchNode* const node = new BranchNode(m_lastNodeIndex++);
m_nodes.push_back(node);
Expand Down

0 comments on commit aa97c11

Please sign in to comment.