Skip to content

Commit

Permalink
Fixed some framework bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
nibblebits committed Apr 8, 2017
1 parent 733266a commit 131e33a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Compiler/src/Branch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ void Branch::addChild(std::shared_ptr<Branch> branch, std::shared_ptr<Branch> ch
throw Exception("Branch::addChild(std::shared_ptr<Branch> branch): NULL children are not allowed!");
}

if (branch->hasParent())
{
throw Exception("Branch::addChild(std::shared_ptr<Branch> branch): child already has a parent! Try cloning the branch first");
}

if (!force_add)
{
if (branch->hasParent())
{
throw Exception("Branch::addChild(std::shared_ptr<Branch> branch): child already has a parent! Try cloning the branch first");
}

try
{
branch->validate_identity_on_tree();
Expand Down Expand Up @@ -120,12 +120,12 @@ void Branch::replaceChild(std::shared_ptr<Branch> child, std::shared_ptr<Branch>
{
throw Exception("The child provided is NULL", "void Branch::replaceChild(std::shared_ptr<Branch> child, std::shared_ptr<Branch> new_branch)");
}

if (new_branch == NULL)
{
throw Exception("The new_branch is NULL", "void Branch::replaceChild(std::shared_ptr<Branch> child, std::shared_ptr<Branch> new_branch)");
}

try
{
validate_identity_on_tree();
Expand Down Expand Up @@ -165,6 +165,10 @@ void Branch::replaceChild(std::shared_ptr<Branch> child, std::shared_ptr<Branch>

void Branch::replaceSelf(std::shared_ptr<Branch> replacee_branch)
{
if (!hasParent())
{
throw Exception("This branch does not have a parent, this is required for replacing of self", "void Branch::replaceSelf(std::shared_ptr<Branch> replacee_branch)");
}
try
{
validate_identity_on_tree();
Expand All @@ -174,7 +178,7 @@ void Branch::replaceSelf(std::shared_ptr<Branch> replacee_branch)
ex.setFunctionName("void Branch::replaceSelf(std::shared_ptr<Branch> replacee_branch)");
throw ex;
}

getParent()->replaceChild(this->getptr(), replacee_branch);
}

Expand Down
6 changes: 6 additions & 0 deletions Compiler/src/CustomBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ CustomBranch::~CustomBranch()

void CustomBranch::registerBranch(std::string name, std::shared_ptr<Branch> branch)
{
if (isBranchRegistered(name))
{
// This branch is already registered lets remove it
removeChild(getRegisteredBranchByName(name));
this->registered_branches[name] = NULL;
}
if (branch != NULL)
{
// If the branch getting registered is currently not a child then make it one
Expand Down

0 comments on commit 131e33a

Please sign in to comment.