Skip to content

Commit 746b102

Browse files
committed
Add isFinal paratemer to StaticAssert pass
1 parent cd19753 commit 746b102

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

frontends/p4/staticAssert.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ const cstring staticAssertMethodName = "static_assert"_cs;
2626
class DoStaticAssert : public Transform, public ResolutionContext {
2727
TypeMap *typeMap;
2828
bool removeStatement = false;
29+
bool isFinal = true;
2930

3031
public:
31-
explicit DoStaticAssert(TypeMap *typeMap) : typeMap(typeMap) {
32+
explicit DoStaticAssert(TypeMap *typeMap, bool isFinal) : typeMap(typeMap), isFinal(isFinal) {
3233
CHECK_NULL(typeMap);
3334
setName("DoStaticAssert");
3435
}
@@ -67,6 +68,8 @@ class DoStaticAssert : public Transform, public ResolutionContext {
6768
return method;
6869
}
6970
return new IR::BoolLiteral(method->srcInfo, true);
71+
} else if (!isFinal) {
72+
return method;
7073
} else {
7174
::P4::error(ErrorType::ERR_UNEXPECTED,
7275
"Could not evaluate static_assert to a constant: %1%", arg);
@@ -88,9 +91,9 @@ class DoStaticAssert : public Transform, public ResolutionContext {
8891

8992
class StaticAssert : public PassManager {
9093
public:
91-
explicit StaticAssert(TypeMap *typeMap) {
94+
explicit StaticAssert(TypeMap *typeMap, bool isFinal = true) {
9295
passes.push_back(new ReadOnlyTypeInference(typeMap));
93-
passes.push_back(new DoStaticAssert(typeMap));
96+
passes.push_back(new DoStaticAssert(typeMap, isFinal));
9497
setName("StaticAssert");
9598
}
9699
};

0 commit comments

Comments
 (0)