source: icGREP/icgrep-devel/icgrep/pablo/ps_if.h @ 4532

Last change on this file since 4532 was 4524, checked in by nmedfort, 5 years ago

Safer use of initializer_list

File size: 1.7 KB
Line 
1/*
2 *  Copyright (c) 2014 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef PS_IF_H
8#define PS_IF_H
9
10#include <pablo/pabloAST.h>
11#include <vector>
12
13namespace pablo {
14
15class Assign;
16
17class If : public Statement {
18    friend class PabloBlock;
19public:
20    using DefinedVars = std::vector<PabloAST *, VectorAllocator>;
21
22    static inline bool classof(const PabloAST * e) {
23        return e->getClassTypeId() == ClassTypeId::If;
24    }
25    static inline bool classof(const void *) {
26        return false;
27    }
28    virtual ~If() {
29        mDefined.clear();
30    }
31    inline PabloAST * getCondition() const {
32        return getOperand(0);
33    }
34    inline PabloBlock & getBody() {
35        return mBody;
36    }
37    inline const PabloBlock & getBody() const {
38        return mBody;
39    }
40    inline const DefinedVars & getDefined() const {
41        return mDefined;
42    }
43    inline void setInclusiveCarryCount(const unsigned count) {
44        mCarryCount = count;
45    }
46    inline unsigned getInclusiveCarryCount() const {
47        return mCarryCount;
48    }
49    inline void setInclusiveAdvanceCount(const unsigned count) {
50        mAdvanceCount = count;
51    }
52    inline unsigned getInclusiveAdvanceCount() const {
53        return mAdvanceCount;
54    }
55protected:
56    If(PabloAST * expr, const std::initializer_list<Assign *> definedVars, PabloBlock & body, PabloBlock * parent);
57
58    If(PabloAST * expr, const std::vector<Assign *> & definedVars, PabloBlock & body, PabloBlock * parent);
59private:
60    PabloBlock &    mBody;
61    DefinedVars     mDefined;
62    unsigned        mCarryCount;
63    unsigned        mAdvanceCount;
64};
65
66}
67
68#endif // PS_IF_H
69
70
Note: See TracBrowser for help on using the repository browser.