8000 Sync section 25.7 with Python/compile.c by erlend-aasland · Pull Request #672 · python/devguide · GitHub
[go: up one dir, main page]

Skip to content

Sync section 25.7 with Python/compile.c #672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions compiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ Emission of bytecode is handled by the following macros:

``ADDOP(struct compiler *, int)``
add a specified opcode
``ADDOP_NOLINE(struct compiler *, int)``
like ``ADDOP`` without a line number; used for artificial opcodes without
no corresponding token in the source code
``ADDOP_IN_SCOPE(struct compiler *, int)``
like ``ADDOP``, but also exits current scope; used for adding return value
opcodes in lambdas and closures
``ADDOP_I(struct compiler *, int, Py_ssize_t)``
add an opcode that takes an integer argument
``ADDOP_O(struct compiler *, int, PyObject *, TYPE)``
Expand All @@ -305,10 +311,14 @@ Emission of bytecode is handled by the following macros:
position of the specified PyObject in the consts table.
``ADDOP_LOAD_CONST_NEW(struct compiler *, PyObject *)``
just like ``ADDOP_LOAD_CONST_NEW``, but steals a reference to PyObject
``ADDOP_JABS(struct compiler *, int, basicblock *)``
create an absolute jump to a basic block
``ADDOP_JREL(struct compiler *, int, basicblock *)``
create a relative jump to a basic block
``ADDOP_JUMP(struct compiler *, int, basicblock *)``
create a jump to a basic block
``ADDOP_JUMP_NOLINE(struct compiler *, int, basicblock *)``
like ``ADDOP_JUMP`` without a line number; used for artificial jumps
without no corresponding token in the source code.
``ADDOP_JUMP_COMPARE(struct compiler *, cmpop_ty)``
depending on the second argument, add an ``ADDOP_I`` with either an
``IS_OP``, ``CONTAINS_OP``, or ``COMPARE_OP`` opcode.

Several helper functions that will emit bytecode and are named
:samp:`compiler_{xx}()` where *xx* is what the function helps with (``list``,
Expand Down
0