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:
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::
.. code-block:: CPP
int failure = 0;
int failure = 0;
{
{
<code1>
<code1>
...
@@ -91,7 +91,7 @@ And %(fail)s in the nth code block will take the value "{failure = n; goto label
...
@@ -91,7 +91,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:
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::
.. code-block:: CPP
int failure = 0;
int failure = 0;
<declare input>
<declare input>
<declare output>
<declare output>
...
@@ -122,7 +122,7 @@ Example ResultBase
...
@@ -122,7 +122,7 @@ Example ResultBase
The following ResultBase represents a double (we only care about the C part).
The following ResultBase represents a double (we only care about the C part).
.. code-block::
.. code-block:: CPP
class Double(ResultBase):
class Double(ResultBase):
<snip>
<snip>
...
@@ -143,7 +143,7 @@ Example Op
...
@@ -143,7 +143,7 @@ Example Op
The following ResultBase represents addition of two nonnegative doubles (we only care about the C part).
The following ResultBase represents addition of two nonnegative doubles (we only care about the C part).
.. code-block::
.. code-block:: python
class Add(Op):
class Add(Op):
<snip>
<snip>
def c_var_names(self):
def c_var_names(self):
...
@@ -162,7 +162,7 @@ Generating a C function
...
@@ -162,7 +162,7 @@ Generating a C function
For the example Op, the generated C function will typically look like this:
For the example Op, the generated C function will typically look like this: