When you call Generator::add_requirement (in either C++ or Python), we add the requirements to a list in the Pipeline we create; then, when lowering, convert those into a series of AssertStmts at the top of the block.
A subtle issue here comes in when you want to re-use a Generator at language-composition time, either via cpp_stubs or via the equivalent call() method in our Python Generators: instead of returning the Pipeline, these return the output(s) as a list of Func, extracted from the Pipeline... so the requirements are lost, meaning a possibly-vital error check is now missing.
Thinking out loud: perhaps we should:
- move the
add_requirements method to Func
- have
Pipeline aggregate all the requirements in its output Funcs and emit them at the top of its block (taking care to remove duplicates)
@abadams -- what do you think?