From 9033985c35c39d66f292ab8f217f3d5cf7828fc3 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 4 Apr 2021 11:55:58 +0200 Subject: [PATCH 1/2] Sync section 25.7 'AST to CFG to Bytecode' with Python/compile.c --- compiler.rst | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/compiler.rst b/compiler.rst index 40384cb07..2bd461194 100644 --- a/compiler.rst +++ b/compiler.rst @@ -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)`` @@ -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 ``IS_OP``, + ``CONTAINS_OP``, or ``COMPARE_OP``. Several helper functions that will emit bytecode and are named :samp:`compiler_{xx}()` where *xx* is what the function helps with (``list``, From cacc6eca1509fbb635e8360daa299b4e66d91eb1 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sun, 4 Apr 2021 12:04:38 +0200 Subject: [PATCH 2/2] Adjust wording --- compiler.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler.rst b/compiler.rst index 2bd461194..0038b6113 100644 --- a/compiler.rst +++ b/compiler.rst @@ -317,8 +317,8 @@ Emission of bytecode is handled by the following macros: 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 ``IS_OP``, - ``CONTAINS_OP``, or ``COMPARE_OP``. + 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``,