Fixed more code spacing in docs
This commit is contained in:
parent
d322b66a69
commit
92b8225dc2
1 changed files with 31 additions and 22 deletions
|
|
@ -419,13 +419,13 @@ LLVM Function object that is ready to go for us.
|
||||||
don't have any control flow, our functions will only contain one block
|
don't have any control flow, our functions will only contain one block
|
||||||
at this point. We'll fix this in `Chapter 5 <PythonLangImpl5.html>`_ :).
|
at this point. We'll fix this in `Chapter 5 <PythonLangImpl5.html>`_ :).
|
||||||
|
|
||||||
# Finish off the function. try: return_value =
|
# Finish off the function.
|
||||||
self.body.CodeGen() g_llvm_builder.ret(return_value)
|
try:
|
||||||
|
return_value = self.body.CodeGen()
|
||||||
|
g_llvm_builder.ret(return_value)
|
||||||
|
|
||||||
::
|
# Validate the generated code, checking for consistency.
|
||||||
|
function.verify()
|
||||||
# Validate the generated code, checking for consistency.
|
|
||||||
function.verify()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -445,9 +445,9 @@ Once the function is finished and validated, we return it.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
except: function.delete() raise
|
except:
|
||||||
|
function.delete()
|
||||||
::
|
raise
|
||||||
|
|
||||||
return function
|
return function
|
||||||
|
|
||||||
|
|
@ -469,9 +469,9 @@ this bug; see what you can come up with! Here is a testcase:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
extern foo(a b) # ok, defines foo. def foo(a b) c
|
extern foo(a b) # ok, defines foo.
|
||||||
# error, 'c' is invalid. def bar() foo(1, 2) # error, unknown function
|
def foo(a b) c # error, 'c' is invalid.
|
||||||
"foo"
|
def bar() foo(1, 2) # error, unknown function "foo"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -489,8 +489,12 @@ example:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
ready> 4+5 Read a top-level expression: define
|
ready> 4+5
|
||||||
double @0() { entry: ret double 9.000000e+00 }
|
Read a top-level expression:
|
||||||
|
define double @0() {
|
||||||
|
entry:
|
||||||
|
ret double 9.000000e+00
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -503,13 +507,18 @@ the Builder. We will add optimizations explicitly in the next chapter.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
ready> def foo(a b) a\ *a + 2*\ a\ *b + b*\ b Read
|
ready> def foo(a b) a *a + 2* a *b + b* b
|
||||||
a function definition: define double @foo(double %a, double %b) { entry:
|
Read a function definition:
|
||||||
%multmp = fmul double %a, %a ; [#uses=1] %multmp1 = fmul double
|
define double @foo(double %a, double %b) {
|
||||||
2.000000e+00, %a ; [#uses=1] %multmp2 = fmul double %multmp1, %b ;
|
entry:
|
||||||
[#uses=1] %addtmp = fadd double %multmp, %multmp2 ; [#uses=1] %multmp3 =
|
%multmp = fmul double %a, %a ; [#uses=1]
|
||||||
fmul double %b, %b ; [#uses=1] %addtmp4 = fadd double %addtmp, %multmp3
|
%multmp1 = fmul double 2.000000e+00, %a ; [#uses=1]
|
||||||
; [#uses=1] ret double %addtmp4 }
|
%multmp2 = fmul double %multmp1, %b ; [#uses=1]
|
||||||
|
%addtmp = fadd double %multmp, %multmp2 ; [#uses=1]
|
||||||
|
%multmp3 = fmul double %b, %b ; [#uses=1]
|
||||||
|
%addtmp4 = fadd double %addtmp, %multmp3 ; [#uses=1]
|
||||||
|
ret double %addtmp4
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue