File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,9 +26,10 @@ const cstring staticAssertMethodName = "static_assert"_cs;
2626class 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
8992class 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};
You can’t perform that action at this time.
0 commit comments