source: icGREP/icgrep-devel/icgrep/pablo/ps_while.cpp @ 4896

Last change on this file since 4896 was 4896, checked in by nmedfort, 3 years ago

Work on coalescing algorithm + minor changes.

File size: 1.1 KB
Line 
1#include <pablo/ps_while.h>
2#include <pablo/codegenstate.h>
3
4namespace pablo {
5
6While::While(PabloAST * expr, const std::initializer_list<Next *> nextVars, PabloBlock * body)
7: Statement(ClassTypeId::While, {expr}, nullptr)
8, mBody(body)
9, mVariant(nextVars.begin(), nextVars.end(), reinterpret_cast<NextAllocator &>(mAllocator)) {
10    mBody->setBranch(this);
11    mBody->setParent(getParent());
12    for (Next * variant : nextVars) {
13        variant->addUser(this);
14        this->addUser(variant);
15    }
16}
17
18While::While(PabloAST * expr, const std::vector<Next *> & nextVars, PabloBlock * body)
19: Statement(ClassTypeId::While, {expr}, nullptr)
20, mBody(body)
21, mVariant(nextVars.begin(), nextVars.end(), reinterpret_cast<NextAllocator &>(mAllocator)) {
22    mBody->setBranch(this);
23    mBody->setParent(getParent());
24    for (Next * variant : nextVars) {
25        variant->addUser(this);
26        this->addUser(variant);
27    }
28}
29
30PabloBlock * While::setBody(PabloBlock * body) {
31    body->setParent(mBody->getParent());
32    std::swap(mBody, body);
33    body->setParent(nullptr);
34    return body;
35}
36
37}
Note: See TracBrowser for help on using the repository browser.