class documentation

A bytecode VM that generates a cfg as it executes.

Exception VirtualMachineRecursionError Undocumented
Method __init__ Construct a TypegraphVirtualMachine.
Method binary_operator Undocumented
Method byte_ASYNC_GEN_WRAP Undocumented
Method byte_BEFORE_ASYNC_WITH Implementation of the BEFORE_ASYNC_WITH opcode.
Method byte_BEFORE_WITH Undocumented
Method byte_BEGIN_FINALLY Undocumented
Method byte_BINARY_ADD Undocumented
Method byte_BINARY_AND Undocumented
Method byte_BINARY_FLOOR_DIVIDE Undocumented
Method byte_BINARY_LSHIFT Undocumented
Method byte_BINARY_MATRIX_MULTIPLY Undocumented
Method byte_BINARY_MODULO Undocumented
Method byte_BINARY_MULTIPLY Undocumented
Method byte_BINARY_OP Undocumented
Method byte_BINARY_OR Undocumented
Method byte_BINARY_POWER Undocumented
Method byte_BINARY_RSHIFT Undocumented
Method byte_BINARY_SUBSCR Undocumented
Method byte_BINARY_SUBTRACT Undocumented
Method byte_BINARY_TRUE_DIVIDE Undocumented
Method byte_BINARY_XOR Undocumented
Method byte_BREAK_LOOP Undocumented
Method byte_BUILD_CONST_KEY_MAP Undocumented
Method byte_BUILD_LIST Undocumented
Method byte_BUILD_LIST_UNPACK Undocumented
Method byte_BUILD_MAP Build a dictionary.
Method byte_BUILD_MAP_UNPACK Undocumented
Method byte_BUILD_MAP_UNPACK_WITH_CALL Undocumented
Method byte_BUILD_SET Undocumented
Method byte_BUILD_SET_UNPACK Undocumented
Method byte_BUILD_SLICE Undocumented
Method byte_BUILD_STRING Undocumented
Method byte_BUILD_TUPLE Undocumented
Method byte_BUILD_TUPLE_UNPACK Undocumented
Method byte_BUILD_TUPLE_UNPACK_WITH_CALL Undocumented
Method byte_CACHE Undocumented
Method byte_CALL Undocumented
Method byte_CALL_FINALLY Undocumented
Method byte_CALL_FUNCTION Undocumented
Method byte_CALL_FUNCTION_EX Call a function.
Method byte_CALL_FUNCTION_KW Undocumented
Method byte_CALL_FUNCTION_VAR Undocumented
Method byte_CALL_FUNCTION_VAR_KW Undocumented
Method byte_CALL_METHOD Undocumented
Method byte_CHECK_EG_MATCH Undocumented
Method byte_CHECK_EXC_MATCH Undocumented
Method byte_COMPARE_OP Undocumented
Method byte_CONTAINS_OP Undocumented
Method byte_CONTINUE_LOOP Undocumented
Method byte_COPY Undocumented
Method byte_COPY_DICT_WITHOUT_KEYS Undocumented
Method byte_COPY_FREE_VARS Undocumented
Method byte_DELETE_ATTR Undocumented
Method byte_DELETE_DEREF Undocumented
Method byte_DELETE_FAST Undocumented
Method byte_DELETE_GLOBAL Undocumented
Method byte_DELETE_NAME Undocumented
Method byte_DELETE_SUBSCR Undocumented
Method byte_DICT_MERGE Undocumented
Method byte_DICT_UPDATE Pops top-of-stack and uses it to update the dict at stack[op.arg].
Method byte_DUP_TOP Undocumented
Method byte_DUP_TOP_TWO Undocumented
Method byte_END_ASYNC_FOR Undocumented
Method byte_END_FINALLY Implementation of the END_FINALLY opcode.
Method byte_FOR_ITER Undocumented
Method byte_FORMAT_VALUE Undocumented
Method byte_GEN_START Undocumented
Method byte_GET_AITER Implementation of the GET_AITER opcode.
Method byte_GET_ANEXT Implementation of the GET_ANEXT opcode.
Method byte_GET_AWAITABLE Implementation of the GET_AWAITABLE opcode.
Method byte_GET_ITER Get the iterator for an object.
Method byte_GET_LEN Undocumented
Method byte_GET_YIELD_FROM_ITER Implementation of the GET_YIELD_FROM_ITER opcode.
Method byte_IMPORT_FROM IMPORT_FROM is mostly like LOAD_ATTR but doesn't pop the container.
Method byte_IMPORT_NAME Import a single module.
Method byte_IMPORT_STAR Pops a module and stores all its contents in locals().
Method byte_INPLACE_ADD Undocumented
Method byte_INPLACE_AND Undocumented
Method byte_INPLACE_FLOOR_DIVIDE Undocumented
Method byte_INPLACE_LSHIFT Undocumented
Method byte_INPLACE_MATRIX_MULTIPLY Undocumented
Method byte_INPLACE_MODULO Undocumented
Method byte_INPLACE_MULTIPLY Undocumented
Method byte_INPLACE_OR Undocumented
Method byte_INPLACE_POWER Undocumented
Method byte_INPLACE_RSHIFT Undocumented
Method byte_INPLACE_SUBTRACT Undocumented
Method byte_INPLACE_TRUE_DIVIDE Undocumented
Method byte_INPLACE_XOR Undocumented
Method byte_IS_OP Undocumented
Method byte_JUMP_ABSOLUTE Undocumented
Method byte_JUMP_BACKWARD Undocumented
Method byte_JUMP_BACKWARD_NO_INTERRUPT Undocumented
Method byte_JUMP_FORWARD Undocumented
Method byte_JUMP_IF_FALSE Undocumented
Method byte_JUMP_IF_FALSE_OR_POP Undocumented
Method byte_JUMP_IF_NOT_EXC_MATCH Undocumented
Method byte_JUMP_IF_TRUE Undocumented
Method byte_JUMP_IF_TRUE_OR_POP Undocumented
Method byte_KW_NAMES Undocumented
Method byte_LIST_APPEND Undocumented
Method byte_LIST_EXTEND Pops top-of-stack and uses it to extend the list at stack[op.arg].
Method byte_LIST_TO_TUPLE Convert the list at the top of the stack to a tuple.
Method byte_LOAD_ASSERTION_ERROR Undocumented
Method byte_LOAD_ATTR Pop an object, and retrieve a named attribute from it.
Method byte_LOAD_BUILD_CLASS Undocumented
Method byte_LOAD_CLASSDEREF Retrieves a value out of either locals or a closure cell.
Method byte_LOAD_CLOSURE Retrieves a value out of a cell.
Method byte_LOAD_CONST Undocumented
Method byte_LOAD_DEREF Retrieves a value out of a cell.
Method byte_LOAD_FAST Load a local. Unlike LOAD_NAME, it doesn't fall back to globals.
Method byte_LOAD_FOLDED_CONST Undocumented
Method byte_LOAD_GLOBAL Load a global variable, or fall back to trying to load a builtin.
Method byte_LOAD_METHOD Implementation of the LOAD_METHOD opcode.
Method byte_LOAD_NAME Load a name. Can be a local, global, or builtin.
Method byte_MAKE_CELL Undocumented
Method byte_MAKE_CLOSURE Make a function that binds local variables.
Method byte_MAKE_FUNCTION Create a function and push it onto the stack.
Method byte_MAP_ADD Implements the MAP_ADD opcode.
Method byte_MATCH_CLASS Implementation of the MATCH_CLASS opcode.
Method byte_MATCH_KEYS Implementation of the MATCH_KEYS opcode.
Method byte_MATCH_MAPPING Undocumented
Method byte_MATCH_SEQUENCE Undocumented
Method byte_NOP Undocumented
Method byte_POP_BLOCK Undocumented
Method byte_POP_EXCEPT Undocumented
Method byte_POP_FINALLY Implements POP_FINALLY.
Method byte_POP_JUMP_BACKWARD_IF_FALSE Undocumented
Method byte_POP_JUMP_BACKWARD_IF_NONE Undocumented
Method byte_POP_JUMP_BACKWARD_IF_NOT_NONE Undocumented
Method byte_POP_JUMP_BACKWARD_IF_TRUE Undocumented
Method byte_POP_JUMP_FORWARD_IF_FALSE Undocumented
Method byte_POP_JUMP_FORWARD_IF_NONE Undocumented
Method byte_POP_JUMP_FORWARD_IF_NOT_NONE Undocumented
Method byte_POP_JUMP_FORWARD_IF_TRUE Undocumented
Method byte_POP_JUMP_IF_FALSE Undocumented
Method byte_POP_JUMP_IF_TRUE Undocumented
Method byte_POP_TOP Undocumented
Method byte_PRECALL Undocumented
Method byte_PREP_RERAISE_STAR Undocumented
Method byte_PRINT_EXPR Undocumented
Method byte_PUSH_EXC_INFO Undocumented
Method byte_PUSH_NULL Undocumented
Method byte_RAISE_VARARGS Raise an exception.
Method byte_RERAISE Undocumented
Method byte_RESUME Undocumented
Method byte_RETURN_GENERATOR Undocumented
Method byte_RETURN_VALUE Get and check the return value.
Method byte_ROT_FOUR Undocumented
Method byte_ROT_N Undocumented
Method byte_ROT_THREE Undocumented
Method byte_ROT_TWO Undocumented
Method byte_SEND Undocumented
Method byte_SET_ADD Undocumented
Method byte_SET_UPDATE Undocumented
Method byte_SETUP_ANNOTATIONS Sets up variable annotations in locals().
Method byte_SETUP_ASYNC_WITH Undocumented
Method byte_SETUP_EXCEPT Undocumented
Method byte_SETUP_FINALLY Implements the SETUP_FINALLY opcode.
Method byte_SETUP_LOOP Undocumented
Method byte_SETUP_WITH Starts a 'with' statement. Will push a block.
Method byte_STORE_ANNOTATION Implementation of the STORE_ANNOTATION opcode.
Method byte_STORE_ATTR Store an attribute.
Method byte_STORE_DEREF Stores a value in a closure cell.
Method byte_STORE_FAST Undocumented
Method byte_STORE_GLOBAL Undocumented
Method byte_STORE_NAME Undocumented
Method byte_STORE_SUBSCR Implement obj[subscr] = val.
Method byte_SWAP Undocumented
Method byte_UNARY_INVERT Undocumented
Method byte_UNARY_NEGATIVE Undocumented
Method byte_UNARY_NOT Implement the UNARY_NOT bytecode.
Method byte_UNARY_POSITIVE Undocumented
Method byte_UNPACK_EX Undocumented
Method byte_UNPACK_SEQUENCE Undocumented
Method byte_WITH_CLEANUP_FINISH Called to finish cleaning up a with block.
Method byte_WITH_CLEANUP_START Called to start cleaning up a with block. Calls the exit handlers etc.
Method byte_WITH_EXCEPT_START Undocumented
Method byte_YIELD_FROM Implementation of the YIELD_FROM opcode.
Method byte_YIELD_VALUE Yield a value from a generator.
Method call_function_from_stack Pop arguments for a function and call it.
Method call_function_with_state Call a function with the given state.
Method call_init Undocumented
Method call_with_fake_args Attempt to call the given function with made-up arguments.
Method compile_src Compile the given source code.
Method del_attr Delete an attribute.
Method del_subscr Undocumented
Method expand_bool_result Common functionality for 'is' and 'is not'.
Method flatten_late_annotation Undocumented
Method generate_late_annotations Undocumented
Method get_all_named_vars Undocumented
Method get_globals_dict Get a real python dict of the globals.
Method get_var_name Get the python variable name corresponding to a Variable.
Method import_module Import a module and return the module object or None.
Method init_class Undocumented
Method inplace_operator Undocumented
Method is_at_maximum_depth Undocumented
Method is_setup_except Check whether op is equivalent to a SETUP_EXCEPT opcode.
Method load_attr Try loading an attribute, and report errors.
Method load_attr_noerror Try loading an attribute, ignore errors.
Method load_builtin Undocumented
Method load_constant Undocumented
Method load_from Load an item out of locals, globals, or builtins.
Method load_global Undocumented
Method load_local Called when a local is loaded onto the stack.
Method load_special_builtin Undocumented
Method make_frame Create a new frame object, using the given args, globals and locals.
Method pop_frame Undocumented
Method pop_kwargs Retrieve a kwargs dictionary from the stack. Used by call_function.
Method pop_varargs Retrieve a varargs tuple from the stack. Used by call_function.
Method push_abstract_exception Undocumented
Method push_frame Undocumented
Method remaining_depth Undocumented
Method resume_frame Undocumented
Method run_bytecode Run the given bytecode.
Method run_frame Run a frame (typically belonging to a method).
Method run_instruction Run a single bytecode instruction.
Method run_program Run the code and return the CFG nodes.
Method set_var_name Undocumented
Method simple_stack Get a stack of simple frames.
Method stack Get a frame stack for the given function for error reporting.
Method store_attr Set an attribute on an object.
Method store_jump Undocumented
Method store_local Called when a local is written.
Method store_subscr Undocumented
Method trace_call Fired whenever we call a builtin using unknown parameters.
Method trace_classdef Undocumented
Method trace_functiondef Undocumented
Method trace_opcode Record trace data for other tools to use.
Method trace_unknown Fired whenever we create a variable containing 'Unknown'.
Method unary_operator Undocumented
Instance Variable annotated_locals Undocumented
Instance Variable ctx Undocumented
Instance Variable filename Undocumented
Instance Variable frame Undocumented
Instance Variable frames Undocumented
Instance Variable functions_type_params_check Undocumented
Instance Variable has_unknown_wildcard_imports Undocumented
Instance Variable late_annotations Undocumented
Instance Variable loaded_overlays Undocumented
Instance Variable local_ops Undocumented
Instance Variable opcode_traces Undocumented
Property current_annotated_locals Undocumented
Property current_line Undocumented
Property current_local_ops Undocumented
Property current_opcode Undocumented
Method _apply_annotation Applies the type annotation, if any, associated with this object.
Method _attribute_error_detection Undocumented
Method _call Undocumented
Method _check_return Undocumented
Method _check_test_assert Narrow the types of variables based on test assertions.
Method _cmp_in Implementation of CMP_IN/CMP_NOT_IN.
Method _cmp_is_always_supported Checks if the comparison should always succeed.
Method _cmp_rel Implementation of relational operators CMP_(LT|LE|EQ|NE|GE|GT).
Method _coerce_to_bool Coerce the values in a variable to bools.
Method _compare_op Pops and compares the top two stack values and pushes a boolean.
Method _convert_kw_defaults Undocumented
Method _data_is_none Undocumented
Method _del_name Called when a local or global is deleted.
Method _delete_item Undocumented
Method _filter_none_and_paste_bindings Paste the bindings into var, filtering out false positives on None.
Method _get_aiter Get an async iterator from an object.
Method _get_extra_closure_args Get closure annotations and defaults from the stack.
Method _get_extra_function_args Get function annotations and defaults from the stack.
Method _get_iter Get an iterator from a sequence.
Method _get_literal_sequence Helper function for _unpack_sequence.
Method _get_type_of_attr_to_store Grabs the __annotations__ dict, if any, with the attribute type.
Method _has_strict_none_origins Whether the binding has any possible origins, with None filtering.
Method _import_module Import the module and return the module object.
Method _instantiate_exception Instantiate an exception type.
Method _is_classmethod_cls_arg True if var is the first arg of a class method in the current frame.
Method _is_private Undocumented
Method _load_annotation Undocumented
Method _maybe_load_overlay Check if a module path is in the overlay dictionary.
Method _name_error_or_late_annotation Returns a late annotation or returns Any and logs a name error.
Method _narrow Narrow a variable by removing bindings that do not satisfy pred.
Method _pop_and_store Pop a value off the stack and store it in a variable.
Method _process_annotations Process any type annotations in the named value.
Method _record_annotation Undocumented
Method _record_annotation_dict_store Record a store_subscr to an __annotations__ dict.
Method _record_local Record a type annotation on a local variable.
Method _replace_abstract_exception Replace unknowns added by push_abstract_exception with precise values.
Method _restructure_tuple Collapse the middle part of a tuple into a List variable.
Method _retrieve_attr Load an attribute from an object.
Method _revert_state_to Undocumented
Method _set_frame_return Undocumented
Method _set_type_from_assert_isinstance Undocumented
Method _setup_except Sets up an except block.
Method _store_new_var_in_local Assign a new var to a variable in locals.
Method _store_value Store 'value' under 'name'.
Method _suppress_opcode_tracing Undocumented
Method _unpack_sequence Pops a tuple (or other iterable) and pushes it onto the VM's stack.
Method _update_annotations_dict Undocumented
Method _var_is_none Undocumented
Method _with_cleanup_start Implements WITH_CLEANUP_START before Python 3.8.
Method _with_cleanup_start_3_8 Implements WITH_CLEANUP_START in Python 3.8+.
Instance Variable _analyzing Undocumented
Instance Variable _branch_tracker Undocumented
Instance Variable _director Undocumented
Instance Variable _importing Undocumented
Instance Variable _late_annotations_stack Undocumented
Instance Variable _maximum_depth Undocumented
Instance Variable _trace_opcodes Undocumented
Instance Variable _var_names Undocumented
def __init__(self, ctx): (source)

Construct a TypegraphVirtualMachine.

def binary_operator(self, state, name, report_errors=True): (source)

Undocumented

def byte_ASYNC_GEN_WRAP(self, state, op): (source)

Undocumented

def byte_BEFORE_ASYNC_WITH(self, state, op): (source)

Implementation of the BEFORE_ASYNC_WITH opcode.

def byte_BEFORE_WITH(self, state, op): (source)

Undocumented

def byte_BEGIN_FINALLY(self, state, op): (source)

Undocumented

def byte_BINARY_ADD(self, state, op): (source)

Undocumented

def byte_BINARY_AND(self, state, op): (source)

Undocumented

def byte_BINARY_FLOOR_DIVIDE(self, state, op): (source)

Undocumented

def byte_BINARY_LSHIFT(self, state, op): (source)

Undocumented

def byte_BINARY_MATRIX_MULTIPLY(self, state, op): (source)

Undocumented

def byte_BINARY_MODULO(self, state, op): (source)

Undocumented

def byte_BINARY_MULTIPLY(self, state, op): (source)

Undocumented

def byte_BINARY_OP(self, state, op): (source)

Undocumented

def byte_BINARY_OR(self, state, op): (source)

Undocumented

def byte_BINARY_POWER(self, state, op): (source)

Undocumented

def byte_BINARY_RSHIFT(self, state, op): (source)

Undocumented

def byte_BINARY_SUBSCR(self, state, op): (source)

Undocumented

def byte_BINARY_SUBTRACT(self, state, op): (source)

Undocumented

def byte_BINARY_TRUE_DIVIDE(self, state, op): (source)

Undocumented

def byte_BINARY_XOR(self, state, op): (source)

Undocumented

def byte_BREAK_LOOP(self, state, op): (source)

Undocumented

def byte_BUILD_CONST_KEY_MAP(self, state, op): (source)

Undocumented

def byte_BUILD_LIST(self, state, op): (source)

Undocumented

def byte_BUILD_LIST_UNPACK(self, state, op): (source)

Undocumented

def byte_BUILD_MAP(self, state, op): (source)

Build a dictionary.

def byte_BUILD_MAP_UNPACK(self, state, op): (source)

Undocumented

def byte_BUILD_MAP_UNPACK_WITH_CALL(self, state, op): (source)

Undocumented

def byte_BUILD_SET(self, state, op): (source)

Undocumented

def byte_BUILD_SET_UNPACK(self, state, op): (source)

Undocumented

def byte_BUILD_SLICE(self, state, op): (source)

Undocumented

def byte_BUILD_STRING(self, state, op): (source)

Undocumented

def byte_BUILD_TUPLE(self, state, op): (source)

Undocumented

def byte_BUILD_TUPLE_UNPACK(self, state, op): (source)

Undocumented

def byte_BUILD_TUPLE_UNPACK_WITH_CALL(self, state, op): (source)

Undocumented

def byte_CACHE(self, state, op): (source)

Undocumented

def byte_CALL(self, state, op): (source)

Undocumented

def byte_CALL_FINALLY(self, state, op): (source)

Undocumented

def byte_CALL_FUNCTION(self, state, op): (source)

Undocumented

def byte_CALL_FUNCTION_EX(self, state, op): (source)

Call a function.

def byte_CALL_FUNCTION_KW(self, state, op): (source)

Undocumented

def byte_CALL_FUNCTION_VAR(self, state, op): (source)

Undocumented

def byte_CALL_FUNCTION_VAR_KW(self, state, op): (source)

Undocumented

def byte_CALL_METHOD(self, state, op): (source)

Undocumented

def byte_CHECK_EG_MATCH(self, state, op): (source)

Undocumented

def byte_CHECK_EXC_MATCH(self, state, op): (source)

Undocumented

def byte_COMPARE_OP(self, state, op): (source)

Undocumented

def byte_CONTAINS_OP(self, state, op): (source)

Undocumented

def byte_CONTINUE_LOOP(self, state, op): (source)

Undocumented

def byte_COPY(self, state, op): (source)

Undocumented

def byte_COPY_DICT_WITHOUT_KEYS(self, state, op): (source)

Undocumented

def byte_COPY_FREE_VARS(self, state, op): (source)

Undocumented

def byte_DELETE_ATTR(self, state, op): (source)

Undocumented

def byte_DELETE_DEREF(self, state, op): (source)

Undocumented

def byte_DELETE_FAST(self, state, op): (source)

Undocumented

def byte_DELETE_GLOBAL(self, state, op): (source)

Undocumented

def byte_DELETE_NAME(self, state, op): (source)

Undocumented

def byte_DELETE_SUBSCR(self, state, op): (source)

Undocumented

def byte_DICT_MERGE(self, state, op): (source)

Undocumented

def byte_DICT_UPDATE(self, state, op): (source)

Pops top-of-stack and uses it to update the dict at stack[op.arg].

def byte_DUP_TOP(self, state, op): (source)

Undocumented

def byte_DUP_TOP_TWO(self, state, op): (source)

Undocumented

def byte_END_ASYNC_FOR(self, state, op): (source)

Undocumented

def byte_END_FINALLY(self, state, op): (source)

Implementation of the END_FINALLY opcode.

def byte_FOR_ITER(self, state, op): (source)

Undocumented

def byte_FORMAT_VALUE(self, state, op): (source)

Undocumented

def byte_GEN_START(self, state, op): (source)

Undocumented

def byte_GET_AITER(self, state, op): (source)

Implementation of the GET_AITER opcode.

def byte_GET_ANEXT(self, state, op): (source)

Implementation of the GET_ANEXT opcode.

def byte_GET_AWAITABLE(self, state, op): (source)

Implementation of the GET_AWAITABLE opcode.

def byte_GET_ITER(self, state, op): (source)

Get the iterator for an object.

def byte_GET_LEN(self, state, op): (source)

Undocumented

def byte_GET_YIELD_FROM_ITER(self, state, op): (source)

Implementation of the GET_YIELD_FROM_ITER opcode.

def byte_IMPORT_FROM(self, state, op): (source)

IMPORT_FROM is mostly like LOAD_ATTR but doesn't pop the container.

def byte_IMPORT_NAME(self, state, op): (source)

Import a single module.

def byte_IMPORT_STAR(self, state, op): (source)

Pops a module and stores all its contents in locals().

def byte_INPLACE_ADD(self, state, op): (source)

Undocumented

def byte_INPLACE_AND(self, state, op): (source)

Undocumented

def byte_INPLACE_FLOOR_DIVIDE(self, state, op): (source)

Undocumented

def byte_INPLACE_LSHIFT(self, state, op): (source)

Undocumented

def byte_INPLACE_MATRIX_MULTIPLY(self, state, op): (source)

Undocumented

def byte_INPLACE_MODULO(self, state, op): (source)

Undocumented

def byte_INPLACE_MULTIPLY(self, state, op): (source)

Undocumented

def byte_INPLACE_OR(self, state, op): (source)

Undocumented

def byte_INPLACE_POWER(self, state, op): (source)

Undocumented

def byte_INPLACE_RSHIFT(self, state, op): (source)

Undocumented

def byte_INPLACE_SUBTRACT(self, state, op): (source)

Undocumented

def byte_INPLACE_TRUE_DIVIDE(self, state, op): (source)

Undocumented

def byte_INPLACE_XOR(self, state, op): (source)

Undocumented

def byte_IS_OP(self, state, op): (source)

Undocumented

def byte_JUMP_ABSOLUTE(self, state, op): (source)

Undocumented

def byte_JUMP_BACKWARD(self, state, op): (source)

Undocumented

def byte_JUMP_BACKWARD_NO_INTERRUPT(self, state, op): (source)

Undocumented

def byte_JUMP_FORWARD(self, state, op): (source)

Undocumented

def byte_JUMP_IF_FALSE(self, state, op): (source)

Undocumented

def byte_JUMP_IF_FALSE_OR_POP(self, state, op): (source)

Undocumented

def byte_JUMP_IF_NOT_EXC_MATCH(self, state, op): (source)

Undocumented

def byte_JUMP_IF_TRUE(self, state, op): (source)

Undocumented

def byte_JUMP_IF_TRUE_OR_POP(self, state, op): (source)

Undocumented

def byte_KW_NAMES(self, state, op): (source)

Undocumented

def byte_LIST_APPEND(self, state, op): (source)

Undocumented

def byte_LIST_EXTEND(self, state, op): (source)

Pops top-of-stack and uses it to extend the list at stack[op.arg].

def byte_LIST_TO_TUPLE(self, state, op): (source)

Convert the list at the top of the stack to a tuple.

def byte_LOAD_ASSERTION_ERROR(self, state, op): (source)

Undocumented

def byte_LOAD_ATTR(self, state, op): (source)

Pop an object, and retrieve a named attribute from it.

def byte_LOAD_BUILD_CLASS(self, state, op): (source)

Undocumented

def byte_LOAD_CLASSDEREF(self, state, op): (source)

Retrieves a value out of either locals or a closure cell.

def byte_LOAD_CLOSURE(self, state, op): (source)

Retrieves a value out of a cell.

def byte_LOAD_CONST(self, state, op): (source)

Undocumented

def byte_LOAD_DEREF(self, state, op): (source)

Retrieves a value out of a cell.

def byte_LOAD_FAST(self, state, op): (source)

Load a local. Unlike LOAD_NAME, it doesn't fall back to globals.

def byte_LOAD_FOLDED_CONST(self, state, op): (source)

Undocumented

def byte_LOAD_GLOBAL(self, state, op): (source)

Load a global variable, or fall back to trying to load a builtin.

def byte_LOAD_METHOD(self, state, op): (source)

Implementation of the LOAD_METHOD opcode.

def byte_LOAD_NAME(self, state, op): (source)

Load a name. Can be a local, global, or builtin.

def byte_MAKE_CELL(self, state, op): (source)

Undocumented

def byte_MAKE_CLOSURE(self, state, op): (source)

Make a function that binds local variables.

def byte_MAKE_FUNCTION(self, state, op): (source)

Create a function and push it onto the stack.

def byte_MAP_ADD(self, state, op): (source)

Implements the MAP_ADD opcode.

def byte_MATCH_CLASS(self, state, op): (source)

Implementation of the MATCH_CLASS opcode.

def byte_MATCH_KEYS(self, state, op): (source)

Implementation of the MATCH_KEYS opcode.

def byte_MATCH_MAPPING(self, state, op): (source)

Undocumented

def byte_MATCH_SEQUENCE(self, state, op): (source)

Undocumented

def byte_NOP(self, state, op): (source)

Undocumented

def byte_POP_BLOCK(self, state, op): (source)

Undocumented

def byte_POP_EXCEPT(self, state, op): (source)

Undocumented

def byte_POP_FINALLY(self, state, op): (source)

Implements POP_FINALLY.

def byte_POP_JUMP_BACKWARD_IF_FALSE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_BACKWARD_IF_NONE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_BACKWARD_IF_NOT_NONE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_BACKWARD_IF_TRUE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_FORWARD_IF_FALSE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_FORWARD_IF_NONE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_FORWARD_IF_NOT_NONE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_FORWARD_IF_TRUE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_IF_FALSE(self, state, op): (source)

Undocumented

def byte_POP_JUMP_IF_TRUE(self, state, op): (source)

Undocumented

def byte_POP_TOP(self, state, op): (source)

Undocumented

def byte_PRECALL(self, state, op): (source)

Undocumented

def byte_PREP_RERAISE_STAR(self, state, op): (source)

Undocumented

def byte_PRINT_EXPR(self, state, op): (source)

Undocumented

def byte_PUSH_EXC_INFO(self, state, op): (source)

Undocumented

def byte_PUSH_NULL(self, state, op): (source)

Undocumented

def byte_RAISE_VARARGS(self, state, op): (source)

Raise an exception.

def byte_RERAISE(self, state, op): (source)

Undocumented

def byte_RESUME(self, state, op): (source)

Undocumented

def byte_RETURN_GENERATOR(self, state, op): (source)

Undocumented

def byte_RETURN_VALUE(self, state, op): (source)

Get and check the return value.

def byte_ROT_FOUR(self, state, op): (source)

Undocumented

def byte_ROT_N(self, state, op): (source)

Undocumented

def byte_ROT_THREE(self, state, op): (source)

Undocumented

def byte_ROT_TWO(self, state, op): (source)

Undocumented

def byte_SEND(self, state, op): (source)

Undocumented

def byte_SET_ADD(self, state, op): (source)

Undocumented

def byte_SET_UPDATE(self, state, op): (source)

Undocumented

def byte_SETUP_ANNOTATIONS(self, state, op): (source)

Sets up variable annotations in locals().

def byte_SETUP_ASYNC_WITH(self, state, op): (source)

Undocumented

def byte_SETUP_EXCEPT(self, state, op): (source)

Undocumented

def byte_SETUP_FINALLY(self, state, op): (source)

Implements the SETUP_FINALLY opcode.

def byte_SETUP_LOOP(self, state, op): (source)

Undocumented

def byte_SETUP_WITH(self, state, op): (source)

Starts a 'with' statement. Will push a block.

def byte_STORE_ANNOTATION(self, state, op): (source)

Implementation of the STORE_ANNOTATION opcode.

def byte_STORE_ATTR(self, state, op): (source)

Store an attribute.

def byte_STORE_DEREF(self, state, op): (source)

Stores a value in a closure cell.

def byte_STORE_FAST(self, state, op): (source)

Undocumented

def byte_STORE_GLOBAL(self, state, op): (source)

Undocumented

def byte_STORE_NAME(self, state, op): (source)

Undocumented

def byte_STORE_SUBSCR(self, state, op): (source)

Implement obj[subscr] = val.

def byte_SWAP(self, state, op): (source)

Undocumented

def byte_UNARY_INVERT(self, state, op): (source)

Undocumented

def byte_UNARY_NEGATIVE(self, state, op): (source)

Undocumented

def byte_UNARY_NOT(self, state, op): (source)

Implement the UNARY_NOT bytecode.

def byte_UNARY_POSITIVE(self, state, op): (source)

Undocumented

def byte_UNPACK_EX(self, state, op): (source)

Undocumented

def byte_UNPACK_SEQUENCE(self, state, op): (source)

Undocumented

def byte_WITH_CLEANUP_FINISH(self, state, op): (source)

Called to finish cleaning up a with block.

def byte_WITH_CLEANUP_START(self, state, op): (source)

Called to start cleaning up a with block. Calls the exit handlers etc.

def byte_WITH_EXCEPT_START(self, state, op): (source)

Undocumented

def byte_YIELD_FROM(self, state, op): (source)

Implementation of the YIELD_FROM opcode.

def byte_YIELD_VALUE(self, state, op): (source)

Yield a value from a generator.

def call_function_from_stack(self, state, num, starargs, starstarargs): (source)

Pop arguments for a function and call it.

def call_function_with_state(self, state, funcv, posargs, namedargs=None, starargs=None, starstarargs=None, fallback_to_unsolvable=True): (source)

Call a function with the given state.

def call_init(self, node, unused_instance): (source)

Undocumented

def call_with_fake_args(self, node0, funcv): (source)

Attempt to call the given function with made-up arguments.

def compile_src(self, src, filename=None, mode='exec'): (source)

Compile the given source code.

def del_attr(self, state, obj, attr): (source)

Delete an attribute.

def del_subscr(self, state, obj, subscr): (source)

Undocumented

def expand_bool_result(self, node, left, right, name, maybe_predicate): (source)

Common functionality for 'is' and 'is not'.

def flatten_late_annotation(self, node, annot, f_globals): (source)

Undocumented

@contextlib.contextmanager
def generate_late_annotations(self, stack): (source)

Undocumented

def get_all_named_vars(self): (source)

Undocumented

def get_globals_dict(self): (source)

Get a real python dict of the globals.

def get_var_name(self, var): (source)

Get the python variable name corresponding to a Variable.

def import_module(self, name, full_name, level): (source)

Import a module and return the module object or None.

def init_class(self, node, cls, container=None, extra_key=None): (source)

Undocumented

def inplace_operator(self, state, name): (source)

Undocumented

def is_at_maximum_depth(self): (source)

Undocumented

def is_setup_except(self, op): (source)

Check whether op is equivalent to a SETUP_EXCEPT opcode.

def load_attr(self, state, obj, attr): (source)

Try loading an attribute, and report errors.

def load_attr_noerror(self, state, obj, attr): (source)

Try loading an attribute, ignore errors.

def load_builtin(self, state, name): (source)

Undocumented

def load_constant(self, state, op, raw_const): (source)

Undocumented

def load_from(self, state: frame_state.FrameState, store: abstract.LazyConcreteDict, name: str, discard_concrete_values: bool = False) -> Tuple[frame_state.FrameState, cfg.Variable]: (source)

Load an item out of locals, globals, or builtins.

def load_global(self, state, name): (source)

Undocumented

def load_local(self, state, name): (source)

Called when a local is loaded onto the stack. Uses the name to retrieve the value from the current locals(). Args: state: The current VM state. name: Name of the local Returns: A tuple of the state and the value (cfg.Variable)

def load_special_builtin(self, name): (source)

Undocumented

def make_frame(self, node, code, f_globals, f_locals, callargs=None, closure=None, new_locals=False, func=None, first_arg=None, substs=()): (source)

Create a new frame object, using the given args, globals and locals.

def pop_frame(self, frame): (source)

Undocumented

def pop_kwargs(self, state): (source)

Retrieve a kwargs dictionary from the stack. Used by call_function.

def pop_varargs(self, state): (source)

Retrieve a varargs tuple from the stack. Used by call_function.

def push_abstract_exception(self, state): (source)

Undocumented

def push_frame(self, frame): (source)

Undocumented

def remaining_depth(self): (source)

Undocumented

def resume_frame(self, node, frame): (source)

Undocumented

def run_bytecode(self, node, code, f_globals=None, f_locals=None): (source)

Run the given bytecode.

def run_frame(self, frame, node, annotated_locals=None): (source)

Run a frame (typically belonging to a method).

Run a single bytecode instruction. Args: op: An opcode. state: The state just before running this instruction. Returns: The state right after this instruction that should roll over to the subsequent instruction. If this opcode aborts this function (e.g. through a 'raise'), then the state's "why" attribute is set to the abort reason. Raises: VirtualMachineError: if a fatal error occurs.

def run_program(self, src, filename, maximum_depth): (source)

Run the code and return the CFG nodes. Args: src: The program source code. filename: The filename the source is from. maximum_depth: Maximum depth to follow call chains. Returns: A tuple (CFGNode, set) containing the last CFGNode of the program as well as all the top-level names defined by it.

def set_var_name(self, var, name): (source)

Undocumented

def simple_stack(self, opcode=None): (source)

Get a stack of simple frames. Args: opcode: Optionally, an opcode to create a stack for. Returns: If an opcode is provided, a stack with a single frame at that opcode. Otherwise, the VM's current stack converted to simple frames.

def stack(self, func): (source)

Get a frame stack for the given function for error reporting.

def store_attr(self, state: frame_state.FrameState, obj: cfg.Variable, attr: str, value: cfg.Variable) -> frame_state.FrameState: (source)

Set an attribute on an object.

def store_jump(self, target, state): (source)

Undocumented

def store_local(self, state, name, value): (source)

Called when a local is written.

def store_subscr(self, state, obj, key, val): (source)

Undocumented

def trace_call(self, *args): (source)

Fired whenever we call a builtin using unknown parameters.

def trace_classdef(self, *args): (source)

Undocumented

def trace_functiondef(self, *args): (source)

Undocumented

def trace_opcode(self, op, symbol, val): (source)

Record trace data for other tools to use.

def trace_unknown(self, *args): (source)

Fired whenever we create a variable containing 'Unknown'.

def unary_operator(self, state, name): (source)

Undocumented

Undocumented

Undocumented

filename = (source)

Undocumented

Undocumented

Undocumented

has_unknown_wildcard_imports: bool = (source)

Undocumented

late_annotations = (source)

Undocumented

Undocumented

Undocumented

@property
current_annotated_locals = (source)

Undocumented

Undocumented

@property
current_local_ops = (source)

Undocumented

Undocumented

def _apply_annotation(self, state, op, name, orig_val, annotations_dict, check_types): (source)

Applies the type annotation, if any, associated with this object.

def _attribute_error_detection(self, state, attr, errors): (source)

Undocumented

def _call(self, state, obj, method_name, args) -> Tuple[frame_state.FrameState, cfg.Variable]: (source)

Undocumented

def _check_return(self, node, actual, formal): (source)

Undocumented

def _check_test_assert(self, state, func, args): (source)

Narrow the types of variables based on test assertions.

def _cmp_in(self, state, item, seq, true_val=True): (source)

Implementation of CMP_IN/CMP_NOT_IN.

def _cmp_is_always_supported(self, op_arg): (source)

Checks if the comparison should always succeed.

def _cmp_rel(self, state, op_name, x, y): (source)

Implementation of relational operators CMP_(LT|LE|EQ|NE|GE|GT). Args: state: Initial FrameState. op_name: An operator name, e.g., "EQ". x: A variable of the lhs value. y: A variable of the rhs value. Returns: A tuple of the new FrameState and the return variable.

def _coerce_to_bool(self, node, var, true_val=True): (source)

Coerce the values in a variable to bools.

def _compare_op(self, state, op_arg, op): (source)

Pops and compares the top two stack values and pushes a boolean.

def _convert_kw_defaults(self, values): (source)

Undocumented

def _data_is_none(self, x: abstract.BaseValue) -> bool: (source)

Undocumented

def _del_name(self, op, state, name, local): (source)

Called when a local or global is deleted.

def _delete_item(self, state, obj, arg): (source)

Undocumented

def _filter_none_and_paste_bindings(self, node, bindings, var, discard_concrete_values=False): (source)

Paste the bindings into var, filtering out false positives on None.

def _get_aiter(self, state, obj): (source)

Get an async iterator from an object.

def _get_extra_closure_args(self, state, arg): (source)

Get closure annotations and defaults from the stack.

def _get_extra_function_args(self, state, arg): (source)

Get function annotations and defaults from the stack.

def _get_iter(self, state, seq, report_errors=True): (source)

Get an iterator from a sequence.

def _get_literal_sequence(self, data): (source)

Helper function for _unpack_sequence.

def _get_type_of_attr_to_store(self, node, op, obj, name): (source)

Grabs the __annotations__ dict, if any, with the attribute type.

def _has_strict_none_origins(self, binding): (source)

Whether the binding has any possible origins, with None filtering. Determines whether the binding has any possibly visible origins at the current node once we've filtered out false positives on None. The caller still must call HasCombination() to find out whether these origins are actually reachable. Args: binding: A cfg.Binding. Returns: True if there are possibly visible origins, else False.

@functools.lru_cache(maxsize=None)
def _import_module(self, name, level): (source)

Import the module and return the module object. Args: name: Name of the module. E.g. "sys". level: Specifies whether to use absolute or relative imports. -1: (Python <= 3.1) "Normal" import. Try both relative and absolute. 0: Absolute import. 1: "from . import abc" 2: "from .. import abc" etc. Returns: An instance of abstract.Module or None if we couldn't find the module.

def _instantiate_exception(self, node, exc_type): (source)

Instantiate an exception type. Args: node: The current node. exc_type: A cfg.Variable of the exception type. Returns: A tuple of a cfg.Variable of the instantiated type and a list of the flattened exception types in the data of exc_type. None takes the place of invalid types.

def _is_classmethod_cls_arg(self, var): (source)

True if var is the first arg of a class method in the current frame.

def _is_private(self, name): (source)

Undocumented

def _load_annotation(self, node, name, store): (source)

Undocumented

def _maybe_load_overlay(self, name): (source)

Check if a module path is in the overlay dictionary.

def _name_error_or_late_annotation(self, state, name): (source)

Returns a late annotation or returns Any and logs a name error.

def _narrow(self, state, var, pred): (source)

Narrow a variable by removing bindings that do not satisfy pred.

def _pop_and_store(self, state, op, name, local): (source)

Pop a value off the stack and store it in a variable.

def _process_annotations(self, node, name, value): (source)

Process any type annotations in the named value.

def _record_annotation(self, node, op, name, typ): (source)

Undocumented

def _record_annotation_dict_store(self, state, obj, subscr, val, op): (source)

Record a store_subscr to an __annotations__ dict.

def _record_local(self, node, op, name, typ, orig_val=None, final=None): (source)

Record a type annotation on a local variable. This method records three types of local operations: - An annotation, e.g., `x: int`. In this case, `typ` is PyTDClass(int) and `orig_val` is None. - An assignment, e.g., `x = 0`. In this case, `typ` is None and `orig_val` is Instance(int). - An annotated assignment, e.g., `x: int = None`. In this case, `typ` is PyTDClass(int) and `orig_val` is Instance(None). Args: node: The current node. op: The current opcode. name: The variable name. typ: The annotation. orig_val: The original value, if any. final: Whether the annotation is tagged Final (None to preserve any existing Final tag when updating an existing annotation).

def _replace_abstract_exception(self, state, exc_type): (source)

Replace unknowns added by push_abstract_exception with precise values.

def _restructure_tuple(self, state, tup, pre, post): (source)

Collapse the middle part of a tuple into a List variable.

def _retrieve_attr(self, node: cfg.CFGNode, obj: cfg.Variable, attr: str) -> Tuple[cfg.CFGNode, Optional[cfg.Variable], List[cfg.Binding]]: (source)

Load an attribute from an object.

def _revert_state_to(self, state, name): (source)

Undocumented

def _set_frame_return(self, node, frame, var): (source)

Undocumented

def _set_type_from_assert_isinstance(self, state, var, class_spec): (source)

Undocumented

def _setup_except(self, state, op): (source)

Sets up an except block.

def _store_new_var_in_local(self, state, var, new_var): (source)

Assign a new var to a variable in locals.

def _store_value(self, state, name, value, local): (source)

Store 'value' under 'name'.

@contextlib.contextmanager
def _suppress_opcode_tracing(self): (source)

Undocumented

def _unpack_sequence(self, state, n_before, n_after=-1): (source)

Pops a tuple (or other iterable) and pushes it onto the VM's stack. Supports destructuring assignment with potentially a single list variable that slurps up the remaining elements: 1. a, b, c = ... # UNPACK_SEQUENCE 2. a, *b, c = ... # UNPACK_EX Args: state: The current VM state n_before: Number of elements before the list (n_elements for case 1) n_after: Number of elements after the list (-1 for case 1) Returns: The new state.

def _update_annotations_dict(self, node, op, name, typ, orig_val, annotations_dict, final=None): (source)

Undocumented

def _var_is_none(self, v: cfg.Variable) -> bool: (source)

Undocumented

def _with_cleanup_start(self, state, op): (source)

Implements WITH_CLEANUP_START before Python 3.8.

def _with_cleanup_start_3_8(self, state, op): (source)

Implements WITH_CLEANUP_START in Python 3.8+.

_analyzing: bool = (source)

Undocumented

_branch_tracker = (source)

Undocumented

_director = (source)

Undocumented

_importing = (source)

Undocumented

_late_annotations_stack = (source)

Undocumented

_maximum_depth = (source)

Undocumented

_trace_opcodes: bool = (source)

Undocumented

_var_names: dict = (source)

Undocumented