"dis" --- Python バイトコードの逆アセンブラ
*******************************************

**ソースコード:** Lib/dis.py

======================================================================

"dis" モジュールは CPython *バイトコード bytecode* を逆アセンブルする
ことでバイトコードの解析をサポートします。 このモジュールが入力として
受け取る CPython バイトコードはファイル "Include/opcode.h" に定義され
ており、 コンパイラとインタプリタが使用しています。

**CPython implementation detail:** バイトコードは CPython インタプリタ
の実装詳細です。Python のバージョン間でバイトコードの追加や、削除、変
更がないという保証はありません。このモジュールを使用することによって
Python の異なる VM または異なるリリースの間で動作すると考えるべきでは
ありません。

バージョン 3.6 で変更: 従来は使用されるバイト数は命令ごとに異なりまし
たが、このモジュールでは各々一つの命令につき2バイト使用することとなっ
ています。

例: 以下の関数 "myfunc()" を考えると

   def myfunc(alist):
       return len(alist)

"myfunc()" の逆アセンブル結果を表示するために次のコマンドを使うことが
できます:

   >>> dis.dis(myfunc)
     2           0 LOAD_GLOBAL              0 (len)
                 2 LOAD_FAST                0 (alist)
                 4 CALL_FUNCTION            1
                 6 RETURN_VALUE

("2" は行番号です)。


バイトコード解析
================

バージョン 3.4 で追加.

バイトコード解析の API を使うと、 Python のコード片を "Bytecode" オブ
ジェクトでラップでき、コンパイルされたコードの細かいところに簡単にアク
セスできます。

class dis.Bytecode(x, *, first_line=None, current_offset=None)

   関数、ジェネレータ、非同期ジェネレータ、コルーチン、メソッド、ソー
   スコード文字列、("compile()" が返すような) コードオブジェクトに対応
   するバイトコードを解析します。

   これは、下で並べられている関数の多くのものをまとめた便利なラッパー
   です。 とりわけ目立つのは "get_instructions()" で、 "Bytecode" イン
   スタンスに対し反復処理をしながら、バイトコード命令を "Instruction"
   インスタンスとして返します。

   *first_line* が "None" でない場合は、それを逆アセンブルしたコードの
   ソースの最初の行に表示する行番号とします。 そうでない場合は、ソース
   の行の情報 (もしあれば) を逆アセンブルされたコードオブジェクトから
   直接取得します。

   *current_offset* が "None" でない場合は、逆アセンブルされたコードで
   のあるインストラクションのオフセット位置を示します。 これを設定する
   と、 "dis()" の出力において、指定された命令コード (opcode) に "現在
   の命令 (instruction)" を表す印が表示されます。

   classmethod from_traceback(tb)

      与えられたトレースバックから "Bytecode" インスタンスを構築し、
      *current_offset* がその例外の原因となった命令となるよう設定しま
      す。

   codeobj

      コンパイルされたコードオブジェクト。

   first_line

      コードオブジェクトのソースの最初の行 (利用可能であれば)

   dis()

      バイトコード命令の整形された表示を返します ("dis.dis()" と同じ出
      力になりますが、複数行文字列として返されます)。

   info()

      "code_info()" のようなコードオブジェクトの詳細を含んだ整形された
      複数行文字列を返します。

   バージョン 3.7 で変更: This can now handle coroutine and
   asynchronous generator objects.

以下はプログラム例です:

   >>> bytecode = dis.Bytecode(myfunc)
   >>> for instr in bytecode:
   ...     print(instr.opname)
   ...
   LOAD_GLOBAL
   LOAD_FAST
   CALL_FUNCTION
   RETURN_VALUE


解析関数
========

"dis" モジュールには、以下に挙げる入力を直接欲しい出力に変換する解析関
数も定義してあります。 1つの命令だけが実行されている場合は、解析オブジ
ェクトをいったん作るよりはこちらの方が便利です:

dis.code_info(x)

   渡された関数、ジェネレータ、非同期ジェネレータ、コルーチン、メソッ
   ド、ソースコード文字列、コードオブジェクトに対する、詳細なコードオ
   ブジェクトの情報を、整形された複数行の文字列として返します。

   この結果は実装に強く依存しており、Python VM や Python のバージョン
   によって異なることがあります。

   バージョン 3.2 で追加.

   バージョン 3.7 で変更: This can now handle coroutine and
   asynchronous generator objects.

dis.show_code(x, *, file=None)

   渡された関数、メソッド、ソースコード文字列、コードオブジェクトに対
   する、詳細なコードオブジェクトの情報を、*file* (または *file* が指
   定されていなければ "sys.stdout") に表示します。

   これは、インタラクティブシェル上で使うことを想定した、
   "print(code_info(x), file=file)" の便利なショートカットです。

   バージョン 3.2 で追加.

   バージョン 3.4 で変更: *file* 引数が追加されました。

dis.dis(x=None, *, file=None, depth=None)

   Disassemble the *x* object.  *x* can denote either a module, a
   class, a method, a function, a generator, an asynchronous
   generator, a coroutine, a code object, a string of source code or a
   byte sequence of raw bytecode. For a module, it disassembles all
   functions. For a class, it disassembles all methods (including
   class and static methods). For a code object or sequence of raw
   bytecode, it prints one line per bytecode instruction. It also
   recursively disassembles nested code objects (the code of
   comprehensions, generator expressions and nested functions, and the
   code used for building nested classes). Strings are first compiled
   to code objects with the "compile()" built-in function before being
   disassembled.  If no object is provided, this function disassembles
   the last traceback.

   *file* 引数が渡された場合は、アセンブリをそこに書き込みます。 そう
   でない場合は "sys.stdout" に出力します。

   The maximal depth of recursion is limited by *depth* unless it is
   "None". "depth=0" means no recursion.

   バージョン 3.4 で変更: *file* 引数が追加されました。

   バージョン 3.7 で変更: Implemented recursive disassembling and
   added *depth* parameter.

   バージョン 3.7 で変更: This can now handle coroutine and
   asynchronous generator objects.

dis.distb(tb=None, *, file=None)

   トレースバックのスタックの先頭の関数を逆アセンブルします。Noneが渡
   された場合は最後のトレースバックを使います。例外を引き起こした命令
   が表示されます。

   *file* 引数が渡された場合は、アセンブリをそこに書き込みます。 そう
   でない場合は "sys.stdout" に出力します。

   バージョン 3.4 で変更: *file* 引数が追加されました。

dis.disassemble(code, lasti=-1, *, file=None)
dis.disco(code, lasti=-1, *, file=None)

   コードオブジェクトを逆アセンブルします。*lasti* が与えられた場合は
   、最後の命令を示します。出力は次のようなカラムに分割されます:

   1. 各行の最初の命令に対する行番号。

   2. 現在の命令。 "-->" として示されます。

   3. ラベル付けされた命令。 ">>" とともに表示されます。

   4. 命令のアドレス。

   5. 命令コード名。

   6. 命令パラメタ。

   7. パラメタの解釈を括弧で囲んだもの。

   パラメタの解釈は、ローカル変数とグローバル変数の名前、定数の値、 分
   岐先、比較命令を認識します。

   *file* 引数が渡された場合は、アセンブリをそこに書き込みます。 そう
   でない場合は "sys.stdout" に出力します。

   バージョン 3.4 で変更: *file* 引数が追加されました。

dis.get_instructions(x, *, first_line=None)

   渡された関数、メソッド、ソースコード文字列、コードオブジェクトにあ
   る命令のイテレータを返します。

   イテレータは、与えられたコードの各命令の詳細情報を保持する名前付き
   タプル "Instruction" からなる列を生成します。

   *first_line* が "None" でない場合は、それを逆アセンブルしたコードの
   ソースの最初の行に表示する行番号とします。 そうでない場合は、ソース
   の行の情報 (もしあれば) を逆アセンブルされたコードオブジェクトから
   直接取得します。

   バージョン 3.4 で追加.

dis.findlinestarts(code)

   This generator function uses the "co_firstlineno" and "co_lnotab"
   attributes of the code object *code* to find the offsets which are
   starts of lines in the source code.  They are generated as
   "(offset, lineno)" pairs. See Objects/lnotab_notes.txt for the
   "co_lnotab" format and how to decode it.

   バージョン 3.6 で変更: Line numbers can be decreasing. Before, they
   were always increasing.

dis.findlabels(code)

   Detect all offsets in the raw compiled bytecode string *code* which
   are jump targets, and return a list of these offsets.

dis.stack_effect(opcode, oparg=None, *, jump=None)

   *opcode* と引数 *oparg* がスタックに与える影響を計算します。

   If the code has a jump target and *jump* is "True",
   "stack_effect()" will return the stack effect of jumping.  If
   *jump* is "False", it will return the stack effect of not jumping.
   And if *jump* is "None" (default), it will return the maximal stack
   effect of both cases.

   バージョン 3.4 で追加.

   バージョン 3.8 で変更: Added *jump* parameter.


Python バイトコード命令
=======================

"get_instructions()" 関数と "Bytecode" クラスはバイトコード命令の詳細
を "Instruction" インスタンスの形で提供します:

class dis.Instruction

   バイトコード命令の詳細

   opcode

      以下の命令コードの値と 命令コードコレクション のバイトコードの値
      に対応する、命令の数値コードです。

   opname

      人間が読むための命令名

   arg

      (ある場合は) 命令の数値引数、無ければ "None"

   argval

      (もし分かっていれば) 解決された引数の値、そうでない場合は arg と
      同じもの

   argrepr

      人間が読むための命令引数の説明

   offset

      バイトコード列の中での命令の開始位置

   starts_line

      (ある場合は) この命令コードが始まる行、無ければ "None"

   is_jump_target

      他のコードからここへジャンプする場合は "True" 、そうでない場合は
      "False"

   バージョン 3.4 で追加.

現在 Python コンパイラは次のバイトコード命令を生成します。

**一般的な命令**

NOP

   なにもしないコード。バイトコードオプティマイザでプレースホルダとし
   て使われます。

POP_TOP

   スタックの先頭 (TOS) の要素を取り除きます。

ROT_TWO

   スタックの先頭の 2 つの要素を入れ替えます。

ROT_THREE

   スタックの二番目と三番目の要素の位置を 1 つ上げ、先頭を三番目へ下げ
   ます。

ROT_FOUR

   Lifts second, third and fourth stack items one position up, moves
   top down to position four.

   バージョン 3.8 で追加.

DUP_TOP

   スタックの先頭にある参照の複製を作ります。

   バージョン 3.2 で追加.

DUP_TOP_TWO

   スタックの先頭の2つの参照を、そのままの順番で複製します。

   バージョン 3.2 で追加.

**1オペランド命令**

1オペランド命令はスタックの先頭を取り出して操作を適用し、結果をスタッ
クへプッシュし戻します。

UNARY_POSITIVE

   "TOS = +TOS" を実行します。

UNARY_NEGATIVE

   "TOS = -TOS" を実行します。

UNARY_NOT

   "TOS = not TOS" を実行します。

UNARY_INVERT

   "TOS = ~TOS" を実行します。

GET_ITER

   "TOS = iter(TOS)" を実行します。

GET_YIELD_FROM_ITER

   "TOS" が *generator iterator* もしくは *coroutine* オブジェクトの場
   合は、そのままにしておきます。 そうでない場合は "TOS = iter(TOS)"
   を実行します。

   バージョン 3.5 で追加.

**2オペランド命令**

二項命令はスタックの先頭 (TOS) と先頭から二番目の要素をスタックから取
り除きます。 命令を実行し、スタックへ結果をプッシュし戻します。

BINARY_POWER

   "TOS = TOS1 ** TOS" を実行します。

BINARY_MULTIPLY

   "TOS = TOS1 * TOS" を実行します。

BINARY_MATRIX_MULTIPLY

   "TOS = TOS1 @ TOS" を実行します。

   バージョン 3.5 で追加.

BINARY_FLOOR_DIVIDE

   "TOS = TOS1 // TOS" を実行します。

BINARY_TRUE_DIVIDE

   "TOS = TOS1 / TOS" を実行します。

BINARY_MODULO

   "TOS = TOS1 % TOS" を実行します。

BINARY_ADD

   "TOS = TOS1 + TOS" を実行します。

BINARY_SUBTRACT

   "TOS = TOS1 - TOS" を実行します。

BINARY_SUBSCR

   "TOS = TOS1[TOS]" を実行します。

BINARY_LSHIFT

   "TOS = TOS1 << TOS" を実行します。

BINARY_RSHIFT

   "TOS = TOS1 >> TOS" を実行します。

BINARY_AND

   "TOS = TOS1 & TOS" を実行します。

BINARY_XOR

   "TOS = TOS1 ^ TOS" を実行します。

BINARY_OR

   "TOS = TOS1 | TOS" を実行します。

**インプレース (in-place) 命令**

インプレース命令は TOS と TOS1 を取り除いて結果をスタックへプッシュす
るという点で二項命令と似ています。 しかし、TOS1 がインプレース命令をサ
ポートしている場合には操作が直接 TOS1 に行われます。 また、操作結果の
TOS は (常に同じというわけではありませんが) 元の TOS1 と同じオブジェク
トになることが多いです。

INPLACE_POWER

   インプレースの "TOS = TOS1 ** TOS" を実行します。

INPLACE_MULTIPLY

   インプレースの "TOS = TOS1 * TOS" を実行します。

INPLACE_MATRIX_MULTIPLY

   インプレースの "TOS = TOS1 @ TOS" を実行します。

   バージョン 3.5 で追加.

INPLACE_FLOOR_DIVIDE

   インプレースの "TOS = TOS1 // TOS" を実行します。

INPLACE_TRUE_DIVIDE

   インプレースの "TOS = TOS1 / TOS" を実行します。

INPLACE_MODULO

   インプレースの "TOS = TOS1 % TOS" を実行します。

INPLACE_ADD

   インプレースの "TOS = TOS1 + TOS" を実行します。

INPLACE_SUBTRACT

   インプレースの "TOS = TOS1 - TOS" を実行します。

INPLACE_LSHIFT

   インプレースの "TOS = TOS1 << TOS" を実行します。

INPLACE_RSHIFT

   インプレースの "TOS = TOS1 >> TOS" を実行します。

INPLACE_AND

   インプレースの "TOS = TOS1 & TOS" を実行します。

INPLACE_XOR

   インプレースの "TOS = TOS1 ^ TOS" を実行します。

INPLACE_OR

   インプレースの "TOS = TOS1 | TOS" を実行します。

STORE_SUBSCR

   "TOS1[TOS] = TOS2" を実行します。

DELETE_SUBSCR

   "del TOS1[TOS]" を実行します。

**コルーチン命令コード**

GET_AWAITABLE

   "TOS = get_awaitable(TOS)" を実行します。 "get_awaitable(o)" は、
   "o" がコルーチンオブジェクトもしくは CO_ITERABLE_COROUTINE フラグの
   付いたジェネレータオブジェクトの場合に "o" を返し、そうでない場合は
   "o.__await__" を解決します。

   バージョン 3.5 で追加.

GET_AITER

   Implements "TOS = TOS.__aiter__()".

   バージョン 3.5 で追加.

   バージョン 3.7 で変更: Returning awaitable objects from "__aiter__"
   is no longer supported.

GET_ANEXT

   "PUSH(get_awaitable(TOS.__anext__()))" を実行します。
   "get_awaitable" の詳細については "GET_AWAITABLE" を参照してください
   。

   バージョン 3.5 で追加.

END_ASYNC_FOR

   Terminates an "async for" loop.  Handles an exception raised when
   awaiting a next item.  If TOS is "StopAsyncIteration" pop 7 values
   from the stack and restore the exception state using the second
   three of them.  Otherwise re-raise the exception using the three
   values from the stack.  An exception handler block is removed from
   the block stack.

   バージョン 3.8 で追加.

BEFORE_ASYNC_WITH

   スタックの先頭にあるオブジェクトの "__aenter__" と "__aexit__" を解
   決します。 "__aexit__" と "__aenter__()" の結果をスタックに積みます
   。

   バージョン 3.5 で追加.

SETUP_ASYNC_WITH

   新たなフレームオブジェクトを作成します。

   バージョン 3.5 で追加.

**その他の命令コード**

PRINT_EXPR

   対話モードのための式文を実行します。TOS はスタックから取り除かれ表
   示されます。 非対話モードにおいては、式文は "POP_TOP" で終了してい
   ます。

SET_ADD(i)

   "set.add(TOS1[-i], TOS)" を呼び出します。集合内包表記の実装に使われ
   ます。

LIST_APPEND(i)

   Calls "list.append(TOS1[-i], TOS)".  Used to implement list
   comprehensions.

MAP_ADD(i)

   Calls "dict.__setitem__(TOS1[-i], TOS1, TOS)".  Used to implement
   dict comprehensions.

   バージョン 3.1 で追加.

   バージョン 3.8 で変更: Map value is TOS and map key is TOS1.
   Before, those were reversed.

"SET_ADD", "LIST_APPEND", "MAP_ADD" は、追加した値または key/value ペ
アをスタックから取り除きますが、コンテナオブジェクトはループの次のイテ
レーションで利用できるようにスタックに残しておきます。

RETURN_VALUE

   関数の呼び出し元へ TOS を返します。

YIELD_VALUE

   TOS をポップし、それを *ジェネレータ* から yield します。

YIELD_FROM

   TOS をポップし、それを *generator* から取得したサブイテレーターとし
   て delegate します。

   バージョン 3.3 で追加.

SETUP_ANNOTATIONS

   Checks whether "__annotations__" is defined in "locals()", if not
   it is set up to an empty "dict". This opcode is only emitted if a
   class or module body contains *variable annotations* statically.

   バージョン 3.6 で追加.

IMPORT_STAR

   "'_'" で始まっていないすべてのシンボルをモジュール TOS から直接ロー
   カル名前空間へロードします。 モジュールはすべての名前をロードした後
   にポップされます。 この命令コードは "from module import *" を実行し
   ます。

POP_BLOCK

   Removes one block from the block stack.  Per frame, there is a
   stack of blocks, denoting "try" statements, and such.

POP_EXCEPT

   ブロックスタックからブロックを1つ取り除きます。 ポップされたブロッ
   クは、例外ハンドラに入ったときに暗黙的に生成された例外ハンドラのブ
   ロックでなければなりません。 フレームスタックから本質的でない値をポ
   ップするのに加えて、直前にポップした3つの値が例外状態を回復するのに
   使われます。

RERAISE

   Re-raises the exception currently on top of the stack.

   バージョン 3.9 で追加.

WITH_EXCEPT_START

   Calls the function in position 7 on the stack with the top three
   items on the stack as arguments. Used to implement the call
   "context_manager.__exit__(*exc_info())" when an exception has
   occurred in a "with" statement.

   バージョン 3.9 で追加.

LOAD_ASSERTION_ERROR

   Pushes "AssertionError" onto the stack.  Used by the "assert"
   statement.

   バージョン 3.9 で追加.

LOAD_BUILD_CLASS

   "builtins.__build_class__()" をスタックにプッシュします。 これはク
   ラスを構築するために、後で "CALL_FUNCTION" に呼ばれます。

SETUP_WITH(delta)

   This opcode performs several operations before a with block starts.
   First, it loads "__exit__()" from the context manager and pushes it
   onto the stack for later use by "WITH_EXCEPT_START".  Then,
   "__enter__()" is called, and a finally block pointing to *delta* is
   pushed.  Finally, the result of calling the "__enter__()" method is
   pushed onto the stack.  The next opcode will either ignore it
   ("POP_TOP"), or store it in (a) variable(s) ("STORE_FAST",
   "STORE_NAME", or "UNPACK_SEQUENCE").

   バージョン 3.2 で追加.

All of the following opcodes use their arguments.

STORE_NAME(namei)

   "name = TOS" を実行します。 *namei* はコードオブジェクトの属性
   "co_names" における *name* のインデックスです。 コンパイラは可能な
   らば "STORE_FAST" または "STORE_GLOBAL" を使おうとします。

DELETE_NAME(namei)

   "del name" を実行します。 *namei* はコードオブジェクトの "co_names"
   属性へのインデックスです。

UNPACK_SEQUENCE(count)

   TOS を *count* 個の個別の値にアンパックして、右から左の順にスタック
   に積みます。

UNPACK_EX(counts)

   星付きの対象ありの代入を実行します: TOS にあるイテラブルを個別の値
   にばらしますが、ばらした値の総数はイテラブルの要素数より小さくなる
   ことがあります: そのときは、値の1つはばらされずに残った要素からなる
   リストです。

   *counts* の下位バイトはそのリスト値より前にある値の個数で、
   *counts* の上位バイトはそれより後ろにある値の個数です。 そうしてで
   きた値は右から左の順でスタックに積まれます。

STORE_ATTR(namei)

   "TOS.name = TOS1" を実行します。 *namei* は "co_names" における名前
   のインデックスです。

DELETE_ATTR(namei)

   "del TOS.name" を実行します。 "co_names" へのインデックスとして
   *namei* を使います。

STORE_GLOBAL(namei)

   "STORE_NAME" と同じように動作しますが、 name をグローバルとして保存
   します。

DELETE_GLOBAL(namei)

   "DELETE_NAME" と同じように動作しますが、グローバルの name を削除し
   ます。

LOAD_CONST(consti)

   "co_consts[consti]" をスタックにプッシュします。

LOAD_NAME(namei)

   "co_names[namei]" に関連付けられた値をスタックにプッシュします。

BUILD_TUPLE(count)

   スタックから *count* 個の要素を消費してタプルを作り出し、できたタプ
   ルをスタックにプッシュします。

BUILD_LIST(count)

   "BUILD_TUPLE" と同じように動作しますが、この命令はリストを作り出し
   ます。

BUILD_SET(count)

   "BUILD_TUPLE" と同じように動作しますが、この命令は set を作り出しま
   す。

BUILD_MAP(count)

   Pushes a new dictionary object onto the stack.  Pops "2 * count"
   items so that the dictionary holds *count* entries: "{..., TOS3:
   TOS2, TOS1: TOS}".

   バージョン 3.5 で変更: The dictionary is created from stack items
   instead of creating an empty dictionary pre-sized to hold *count*
   items.

BUILD_CONST_KEY_MAP(count)

   The version of "BUILD_MAP" specialized for constant keys. Pops the
   top element on the stack which contains a tuple of keys, then
   starting from "TOS1", pops *count* values to form values in the
   built dictionary.

   バージョン 3.6 で追加.

BUILD_STRING(count)

   Concatenates *count* strings from the stack and pushes the
   resulting string onto the stack.

   バージョン 3.6 で追加.

LIST_TO_TUPLE

   Pops a list from the stack and pushes a tuple containing the same
   values.

   バージョン 3.9 で追加.

LIST_EXTEND(i)

   Calls "list.extend(TOS1[-i], TOS)".  Used to build lists.

   バージョン 3.9 で追加.

SET_UPDATE(i)

   Calls "set.update(TOS1[-i], TOS)".  Used to build sets.

   バージョン 3.9 で追加.

DICT_UPDATE(i)

   Calls "dict.update(TOS1[-i], TOS)".  Used to build dicts.

   バージョン 3.9 で追加.

DICT_MERGE

   Like "DICT_UPDATE" but raises an exception for duplicate keys.

   バージョン 3.9 で追加.

LOAD_ATTR(namei)

   TOS を "getattr(TOS, co_names[namei])" と入れ替えます。

COMPARE_OP(opname)

   ブール命令を実行します。命令名は "cmp_op[opname]" にあります。

IS_OP(invert)

   Performs "is" comparison, or "is not" if "invert" is 1.

   バージョン 3.9 で追加.

CONTAINS_OP(invert)

   Performs "in" comparison, or "not in" if "invert" is 1.

   バージョン 3.9 で追加.

IMPORT_NAME(namei)

   モジュール "co_names[namei]" をインポートします。 TOS と TOS1 がポ
   ップされ、 "__import__()" の *fromlist* と *level* 引数になります。
   モジュールオブジェクトはスタックへプッシュされます。現在の名前空間
   は影響されません: 適切な import 文のためには、後続の "STORE_FAST"
   命令が名前空間を変更します。

IMPORT_FROM(namei)

   TOS にあるモジュールから属性 "co_names[namei]" をロードします。作成
   されたオブジェクトはスタックにプッシュされ、後続の "STORE_FAST" 命
   令によって保存されます。

JUMP_FORWARD(delta)

   バイトコードカウンタを *delta* だけ増加させます。

POP_JUMP_IF_TRUE(target)

   TOS が真ならば、バイトコードカウンタを *target* に設定します。 TOS
   はポップされます。

   バージョン 3.1 で追加.

POP_JUMP_IF_FALSE(target)

   TOS が偽ならば、バイトコードカウンタを *target* に設定します。 TOS
   はポップされます。

   バージョン 3.1 で追加.

JUMP_IF_NOT_EXC_MATCH(target)

   Tests whether the second value on the stack is an exception
   matching TOS, and jumps if it is not. Pops two values from the
   stack.

   バージョン 3.9 で追加.

JUMP_IF_TRUE_OR_POP(target)

   TOS が真ならば、バイトコードカウンタを *target* に設定し、TOS は ス
   タックに残されます。そうでない (TOS が偽) なら、TOS はポップされま
   す。

   バージョン 3.1 で追加.

JUMP_IF_FALSE_OR_POP(target)

   TOS が偽ならば、バイトコードカウンタを *target* に設定し、TOS は ス
   タックに残されます。そうでない (TOS が真) なら、TOS はポップされま
   す。

   バージョン 3.1 で追加.

JUMP_ABSOLUTE(target)

   バイトコードカウンタを *target* に設定します。

FOR_ITER(delta)

   TOS is an *iterator*.  Call its "__next__()" method.  If this
   yields a new value, push it on the stack (leaving the iterator
   below it).  If the iterator indicates it is exhausted, TOS is
   popped, and the byte code counter is incremented by *delta*.

LOAD_GLOBAL(namei)

   "co_names[namei]" という名前のグローバルをスタック上にロードします
   。

SETUP_FINALLY(delta)

   Pushes a try block from a try-finally or try-except clause onto the
   block stack.  *delta* points to the finally block or the first
   except block.

LOAD_FAST(var_num)

   ローカルな "co_varnames[var_num]" への参照をスタックにプッシュしま
   す。

STORE_FAST(var_num)

   TOS をローカルな "co_varnames[var_num]" の中に保存します。

DELETE_FAST(var_num)

   ローカルな "co_varnames[var_num]" を削除します。

LOAD_CLOSURE(i)

   セルと自由変数の記憶領域のスロット *i* に含まれるセルへの参照をプッ
   シュします。 *i* が *co_cellvars* の長さより小さければ、変数の名前
   は "co_cellvars[i]" です。 そうでなければ "co_freevars[i -
   len(co_cellvars)]" です。

LOAD_DEREF(i)

   セルと自由変数の記憶領域のスロット *i* に含まれるセルをロードします
   。 セルが持つオブジェクトへの参照をスタックにプッシュします。

LOAD_CLASSDEREF(i)

   "LOAD_DEREF" とほぼ同じですが、セルを調べる前にまずローカルの辞書を
   確認します。 これはクラス本体に自由変数を読み込むために使います。

   バージョン 3.4 で追加.

STORE_DEREF(i)

   セルと自由変数の記憶領域のスロット *i* に含まれるセルへTOSを保存し
   ます。

DELETE_DEREF(i)

   セルと自由変数の記憶領域のスロット *i* にあるセルを空にします。
   "del" 文で使われます。

   バージョン 3.2 で追加.

RAISE_VARARGS(argc)

   Raises an exception using one of the 3 forms of the "raise"
   statement, depending on the value of *argc*:

   * 0: "raise" (re-raise previous exception)

   * 1: "raise TOS" (raise exception instance or type at "TOS")

   * 2: "raise TOS1 from TOS" (raise exception instance or type at
     "TOS1" with "__cause__" set to "TOS")

CALL_FUNCTION(argc)

   Calls a callable object with positional arguments. *argc* indicates
   the number of positional arguments. The top of the stack contains
   positional arguments, with the right-most argument on top.  Below
   the arguments is a callable object to call. "CALL_FUNCTION" pops
   all arguments and the callable object off the stack, calls the
   callable object with those arguments, and pushes the return value
   returned by the callable object.

   バージョン 3.6 で変更: This opcode is used only for calls with
   positional arguments.

CALL_FUNCTION_KW(argc)

   Calls a callable object with positional (if any) and keyword
   arguments. *argc* indicates the total number of positional and
   keyword arguments. The top element on the stack contains a tuple
   with the names of the keyword arguments, which must be strings.
   Below that are the values for the keyword arguments, in the order
   corresponding to the tuple. Below that are positional arguments,
   with the right-most parameter on top.  Below the arguments is a
   callable object to call. "CALL_FUNCTION_KW" pops all arguments and
   the callable object off the stack, calls the callable object with
   those arguments, and pushes the return value returned by the
   callable object.

   バージョン 3.6 で変更: Keyword arguments are packed in a tuple
   instead of a dictionary, *argc* indicates the total number of
   arguments.

CALL_FUNCTION_EX(flags)

   Calls a callable object with variable set of positional and keyword
   arguments.  If the lowest bit of *flags* is set, the top of the
   stack contains a mapping object containing additional keyword
   arguments. Before the callable is called, the mapping object and
   iterable object are each "unpacked" and their contents passed in as
   keyword and positional arguments respectively. "CALL_FUNCTION_EX"
   pops all arguments and the callable object off the stack, calls the
   callable object with those arguments, and pushes the return value
   returned by the callable object.

   バージョン 3.6 で追加.

LOAD_METHOD(namei)

   Loads a method named "co_names[namei]" from the TOS object. TOS is
   popped. This bytecode distinguishes two cases: if TOS has a method
   with the correct name, the bytecode pushes the unbound method and
   TOS. TOS will be used as the first argument ("self") by
   "CALL_METHOD" when calling the unbound method. Otherwise, "NULL"
   and the object return by the attribute lookup are pushed.

   バージョン 3.7 で追加.

CALL_METHOD(argc)

   Calls a method.  *argc* is the number of positional arguments.
   Keyword arguments are not supported.  This opcode is designed to be
   used with "LOAD_METHOD".  Positional arguments are on top of the
   stack. Below them, the two items described in "LOAD_METHOD" are on
   the stack (either "self" and an unbound method object or "NULL" and
   an arbitrary callable). All of them are popped and the return value
   is pushed.

   バージョン 3.7 で追加.

MAKE_FUNCTION(flags)

   Pushes a new function object on the stack.  From bottom to top, the
   consumed stack must consist of values if the argument carries a
   specified flag value

   * "0x01" a tuple of default values for positional-only and
     positional-or-keyword parameters in positional order

   * "0x02" a dictionary of keyword-only parameters' default values

   * "0x04" an annotation dictionary

   * "0x08" a tuple containing cells for free variables, making a
     closure

   * 関数に関連付けられたコード (TOS1の位置)

   * 関数の *qualified name* (TOSの位置)

BUILD_SLICE(argc)

   スライスオブジェクトをスタックにプッシュします。 *argc* は2あるいは
   3でなければなりません。 2 ならば "slice(TOS1, TOS)" がプッシュされ
   ます。 3 ならば "slice(TOS2, TOS1, TOS)" がプッシュされます。 これ
   以上の情報については、 "slice()" 組み込み関数を参照してください。

EXTENDED_ARG(ext)

   Prefixes any opcode which has an argument too big to fit into the
   default one byte. *ext* holds an additional byte which act as
   higher bits in the argument. For each opcode, at most three
   prefixal "EXTENDED_ARG" are allowed, forming an argument from two-
   byte to four-byte.

FORMAT_VALUE(flags)

   Used for implementing formatted literal strings (f-strings).  Pops
   an optional *fmt_spec* from the stack, then a required *value*.
   *flags* is interpreted as follows:

   * "(flags & 0x03) == 0x00": *value* is formatted as-is.

   * "(flags & 0x03) == 0x01": call "str()" on *value* before
     formatting it.

   * "(flags & 0x03) == 0x02": call "repr()" on *value* before
     formatting it.

   * "(flags & 0x03) == 0x03": call "ascii()" on *value* before
     formatting it.

   * "(flags & 0x04) == 0x04": pop *fmt_spec* from the stack and use
     it, else use an empty *fmt_spec*.

   Formatting is performed using "PyObject_Format()".  The result is
   pushed on the stack.

   バージョン 3.6 で追加.

HAVE_ARGUMENT

   This is not really an opcode.  It identifies the dividing line
   between opcodes which don't use their argument and those that do
   ("< HAVE_ARGUMENT" and ">= HAVE_ARGUMENT", respectively).

   バージョン 3.6 で変更: Now every instruction has an argument, but
   opcodes "< HAVE_ARGUMENT" ignore it. Before, only opcodes ">=
   HAVE_ARGUMENT" had an argument.


命令コードコレクション
======================

これらのコレクションは、自動でバイトコード命令を解析するために提供され
ています:

dis.opname

   命令コード名のリスト。 バイトコードをインデックスに使って参照できま
   す。

dis.opmap

   命令コード名をバイトコードに対応づける辞書。

dis.cmp_op

   すべての比較命令の名前のリスト。

dis.hasconst

   定数にアクセスするバイトコードのリスト。

dis.hasfree

   自由変数にアクセスするバイトコードのリスト (この文脈での '自由' と
   は、現在のスコープにある名前で内側のスコープから参照されているもの
   、もしくは外側のスコープにある名前で現在のスコープから参照している
   ものを指します。グローバルスコープや組み込みのスコープへの参照は含
   み *ません*)。

dis.hasname

   名前によって属性にアクセスするバイトコードのリスト。

dis.hasjrel

   相対ジャンプ先を持つバイトコードのリスト。

dis.hasjabs

   絶対ジャンプ先を持つバイトコードのリスト。

dis.haslocal

   ローカル変数にアクセスするバイトコードのリスト。

dis.hascompare

   ブール命令のバイトコードのリスト。
