Besides cleanup code, all code has access to the %(fail)s template. For three code blocks, the generated C code will pretty much look like this:
.. code-block:: CPP
int failure = 0;
{
<code1>
...
...
@@ -92,6 +93,7 @@ And %(fail)s in the nth code block will take the value "{failure = n; goto label
When compiling an Op, we want to sync the outputs so we can get the results from Python. In case of failure, we will not necessarily want to sync. Because of that, typical code will look like this:
.. code-block:: CPP
int failure = 0;
<declare input>
<declare output>
...
...
@@ -144,6 +146,7 @@ Example Op
The following ResultBase represents addition of two nonnegative doubles (we only care about the C part).
.. code-block:: python
class Add(Op):
<snip>
def c_var_names(self):
...
...
@@ -163,6 +166,7 @@ Generating a C function
For the example Op, the generated C function will typically look like this: