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

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

Initial work for incorporating Types into Pablo AST.

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