class VirtualMachine: (source)
Known subclasses: pytype.tracer_vm.CallTracer
, pytype.vm_test.TraceVM
A bytecode VM that generates a cfg as it executes.
Exception |
|
Undocumented |
Method | __init__ |
Construct a TypegraphVirtualMachine. |
Method | binary |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Implementation of the BEFORE_ASYNC_WITH opcode. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Build a dictionary. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Call a function. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Pops top-of-stack and uses it to update the dict at stack[op.arg]. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Implementation of the END_FINALLY opcode. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Implementation of the GET_AITER opcode. |
Method | byte_ |
Implementation of the GET_ANEXT opcode. |
Method | byte_ |
Implementation of the GET_AWAITABLE opcode. |
Method | byte_ |
Get the iterator for an object. |
Method | byte_ |
Undocumented |
Method | byte_ |
Implementation of the GET_YIELD_FROM_ITER opcode. |
Method | byte_ |
IMPORT_FROM is mostly like LOAD_ATTR but doesn't pop the container. |
Method | byte_ |
Import a single module. |
Method | byte_ |
Pops a module and stores all its contents in locals(). |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Pops top-of-stack and uses it to extend the list at stack[op.arg]. |
Method | byte_ |
Convert the list at the top of the stack to a tuple. |
Method | byte_ |
Undocumented |
Method | byte_ |
Pop an object, and retrieve a named attribute from it. |
Method | byte_ |
Undocumented |
Method | byte_ |
Retrieves a value out of either locals or a closure cell. |
Method | byte_ |
Retrieves a value out of a cell. |
Method | byte_ |
Undocumented |
Method | byte_ |
Retrieves a value out of a cell. |
Method | byte_ |
Load a local. Unlike LOAD_NAME, it doesn't fall back to globals. |
Method | byte_ |
Undocumented |
Method | byte_ |
Load a global variable, or fall back to trying to load a builtin. |
Method | byte_ |
Implementation of the LOAD_METHOD opcode. |
Method | byte_ |
Load a name. Can be a local, global, or builtin. |
Method | byte_ |
Undocumented |
Method | byte_ |
Make a function that binds local variables. |
Method | byte_ |
Create a function and push it onto the stack. |
Method | byte_ |
Implements the MAP_ADD opcode. |
Method | byte_ |
Implementation of the MATCH_CLASS opcode. |
Method | byte_ |
Implementation of the MATCH_KEYS opcode. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Implements POP_FINALLY. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Raise an exception. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Get and check the return value. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Sets up variable annotations in locals(). |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Implements the SETUP_FINALLY opcode. |
Method | byte_ |
Undocumented |
Method | byte_ |
Starts a 'with' statement. Will push a block. |
Method | byte_ |
Implementation of the STORE_ANNOTATION opcode. |
Method | byte_ |
Store an attribute. |
Method | byte_ |
Stores a value in a closure cell. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Implement obj[subscr] = val. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Implement the UNARY_NOT bytecode. |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Undocumented |
Method | byte_ |
Called to finish cleaning up a with block. |
Method | byte_ |
Called to start cleaning up a with block. Calls the exit handlers etc. |
Method | byte_ |
Undocumented |
Method | byte_ |
Implementation of the YIELD_FROM opcode. |
Method | byte_ |
Yield a value from a generator. |
Method | call |
Pop arguments for a function and call it. |
Method | call |
Call a function with the given state. |
Method | call |
Undocumented |
Method | call |
Attempt to call the given function with made-up arguments. |
Method | compile |
Compile the given source code. |
Method | del |
Delete an attribute. |
Method | del |
Undocumented |
Method | expand |
Common functionality for 'is' and 'is not'. |
Method | flatten |
Undocumented |
Method | generate |
Undocumented |
Method | get |
Undocumented |
Method | get |
Get a real python dict of the globals. |
Method | get |
Get the python variable name corresponding to a Variable. |
Method | import |
Import a module and return the module object or None. |
Method | init |
Undocumented |
Method | inplace |
Undocumented |
Method | is |
Undocumented |
Method | is |
Check whether op is equivalent to a SETUP_EXCEPT opcode. |
Method | load |
Try loading an attribute, and report errors. |
Method | load |
Try loading an attribute, ignore errors. |
Method | load |
Undocumented |
Method | load |
Undocumented |
Method | load |
Load an item out of locals, globals, or builtins. |
Method | load |
Undocumented |
Method | load |
Called when a local is loaded onto the stack. |
Method | load |
Undocumented |
Method | make |
Create a new frame object, using the given args, globals and locals. |
Method | pop |
Undocumented |
Method | pop |
Retrieve a kwargs dictionary from the stack. Used by call_function. |
Method | pop |
Retrieve a varargs tuple from the stack. Used by call_function. |
Method | push |
Undocumented |
Method | push |
Undocumented |
Method | remaining |
Undocumented |
Method | resume |
Undocumented |
Method | run |
Run the given bytecode. |
Method | run |
Run a frame (typically belonging to a method). |
Method | run |
Run a single bytecode instruction. |
Method | run |
Run the code and return the CFG nodes. |
Method | set |
Undocumented |
Method | simple |
Get a stack of simple frames. |
Method | stack |
Get a frame stack for the given function for error reporting. |
Method | store |
Set an attribute on an object. |
Method | store |
Undocumented |
Method | store |
Called when a local is written. |
Method | store |
Undocumented |
Method | trace |
Fired whenever we call a builtin using unknown parameters. |
Method | trace |
Undocumented |
Method | trace |
Undocumented |
Method | trace |
Record trace data for other tools to use. |
Method | trace |
Fired whenever we create a variable containing 'Unknown'. |
Method | unary |
Undocumented |
Instance Variable | annotated |
Undocumented |
Instance Variable | ctx |
Undocumented |
Instance Variable | filename |
Undocumented |
Instance Variable | frame |
Undocumented |
Instance Variable | frames |
Undocumented |
Instance Variable | functions |
Undocumented |
Instance Variable | has |
Undocumented |
Instance Variable | late |
Undocumented |
Instance Variable | loaded |
Undocumented |
Instance Variable | local |
Undocumented |
Instance Variable | opcode |
Undocumented |
Property | current |
Undocumented |
Property | current |
Undocumented |
Property | current |
Undocumented |
Property | current |
Undocumented |
Method | _apply |
Applies the type annotation, if any, associated with this object. |
Method | _attribute |
Undocumented |
Method | _call |
Undocumented |
Method | _check |
Undocumented |
Method | _check |
Narrow the types of variables based on test assertions. |
Method | _cmp |
Implementation of CMP_IN/CMP_NOT_IN. |
Method | _cmp |
Checks if the comparison should always succeed. |
Method | _cmp |
Implementation of relational operators CMP_(LT|LE|EQ|NE|GE|GT). |
Method | _coerce |
Coerce the values in a variable to bools. |
Method | _compare |
Pops and compares the top two stack values and pushes a boolean. |
Method | _convert |
Undocumented |
Method | _data |
Undocumented |
Method | _del |
Called when a local or global is deleted. |
Method | _delete |
Undocumented |
Method | _filter |
Paste the bindings into var, filtering out false positives on None. |
Method | _get |
Get an async iterator from an object. |
Method | _get |
Get closure annotations and defaults from the stack. |
Method | _get |
Get function annotations and defaults from the stack. |
Method | _get |
Get an iterator from a sequence. |
Method | _get |
Helper function for _unpack_sequence. |
Method | _get |
Grabs the __annotations__ dict, if any, with the attribute type. |
Method | _has |
Whether the binding has any possible origins, with None filtering. |
Method | _import |
Import the module and return the module object. |
Method | _instantiate |
Instantiate an exception type. |
Method | _is |
True if var is the first arg of a class method in the current frame. |
Method | _is |
Undocumented |
Method | _load |
Undocumented |
Method | _maybe |
Check if a module path is in the overlay dictionary. |
Method | _name |
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 |
Pop a value off the stack and store it in a variable. |
Method | _process |
Process any type annotations in the named value. |
Method | _record |
Undocumented |
Method | _record |
Record a store_subscr to an __annotations__ dict. |
Method | _record |
Record a type annotation on a local variable. |
Method | _replace |
Replace unknowns added by push_abstract_exception with precise values. |
Method | _restructure |
Collapse the middle part of a tuple into a List variable. |
Method | _retrieve |
Load an attribute from an object. |
Method | _revert |
Undocumented |
Method | _set |
Undocumented |
Method | _set |
Undocumented |
Method | _setup |
Sets up an except block. |
Method | _store |
Assign a new var to a variable in locals. |
Method | _store |
Store 'value' under 'name'. |
Method | _suppress |
Undocumented |
Method | _unpack |
Pops a tuple (or other iterable) and pushes it onto the VM's stack. |
Method | _update |
Undocumented |
Method | _var |
Undocumented |
Method | _with |
Implements WITH_CLEANUP_START before Python 3.8. |
Method | _with |
Implements WITH_CLEANUP_START in Python 3.8+. |
Instance Variable | _analyzing |
Undocumented |
Instance Variable | _branch |
Undocumented |
Instance Variable | _director |
Undocumented |
Instance Variable | _importing |
Undocumented |
Instance Variable | _late |
Undocumented |
Instance Variable | _maximum |
Undocumented |
Instance Variable | _trace |
Undocumented |
Instance Variable | _var |
Undocumented |
pytype.tracer_vm.CallTracer
, pytype.vm_test.TraceVM
Construct a TypegraphVirtualMachine.
Call a function with the given state.
pytype.tracer_vm.CallTracer
Attempt to call the given function with made-up arguments.
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.
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)
Create a new frame object, using the given args, globals and locals.
opcodes.Opcode
, state: frame_state.FrameState
) -> frame_state.FrameState
:
(source)
¶
pytype.vm_test.TraceVM
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.
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.
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.
frame_state.FrameState
, obj: cfg.Variable
, attr: str
, value: cfg.Variable
) -> frame_state.FrameState
:
(source)
¶
Set an attribute on an object.
pytype.tracer_vm.CallTracer
Fired whenever we call a builtin using unknown parameters.
List[ Tuple[ Optional[ opcodes.Opcode], Any, Tuple[ Optional[ List[ abstract.BaseValue]], ...]]]
=
(source)
¶
Undocumented
Tuple[ frame_state.FrameState, cfg.Variable]
:
(source)
¶
Undocumented
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.
Paste the bindings into var, filtering out false positives on None.
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.
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.
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.
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).
cfg.CFGNode
, obj: cfg.Variable
, attr: str
) -> Tuple[ cfg.CFGNode, Optional[ cfg.Variable], List[ cfg.Binding]]
:
(source)
¶
Load an attribute from an object.
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.
Undocumented