Skip to content

Commit

Permalink
Add positionContext save/restore around recursion into sub computation
Browse files Browse the repository at this point in the history
  • Loading branch information
riftEmber committed Nov 25, 2021
1 parent 63b493d commit 8d6f76e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ComputationBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ void ComputationBuilder::processSingleStmt(clang::Stmt *stmt) {
std::string calleeName = calleeDefinition->getNameAsString();
if (!subComputations.count(calleeName)) {
// build Computation from calleeDefinition, if we haven't done so already
PositionContext oldContext = *positionContext;
auto builder = new ComputationBuilder();
subComputations[calleeName] = builder->buildComputationFromFunction(calleeDefinition);
*positionContext = oldContext;
}
std::vector<std::string> callArgStrings;
for (unsigned int i = 0; i < asCallExpr->getNumArgs(); ++i) {
Expand Down
6 changes: 5 additions & 1 deletion src/ComputationBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,11 @@ TEST_F(ComputationBuilderTest, basic_nesting) {
"{[i]->[1,i,1]}",
{{"x", "{[i]->[0]}"}},
{{"_iegen_0x", "{[i]->[0]}"}}));
expectedComputation->addStmt(new iegenlib::Stmt("_iegen_0x*=5;", "{[i]: 0<=i<N}", "{[i]->[1,i,2]}", {}, {}));
expectedComputation->addStmt(new iegenlib::Stmt("_iegen_0x*=5;",
"{[i]: 0<=i<N}",
"{[i]->[1,i,2]}",
{{"_iegen_0x", "{[i]->[0]}"}},
{{"_iegen_0x", "{[i]->[0]}"}}));

expectedComputation->addReturnValue("3", false);

Expand Down

0 comments on commit 8d6f76e

Please sign in to comment.