class InterpreterFunction(_function_base.SignedFunction): (source)
An abstract value representing a user-defined function. Attributes: name: Function name. Might just be something like "<lambda>". code: A code object. closure: Tuple of cells (cfg.Variable) containing the free variables this closure binds to. ctx: context.Context instance.
Class Method | make |
Get an InterpreterFunction. |
Method | __init__ |
Initialize a SimpleValue. |
Method | argcount |
Returns the minimum number of arguments needed for a call. |
Method | call |
Call this abstract value with the given arguments. |
Method | get |
Get this function's call records. |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | get |
Undocumented |
Method | has |
Undocumented |
Method | has |
Return True if this is a function and has a **kwargs parameter. |
Method | has |
Return True if this is a function and has a *args parameter. |
Method | is |
Undocumented |
Method | iter |
Loop through signatures, setting each as the primary one in turn. |
Method | match |
Check whether the given arguments can match the function signature. |
Method | property |
Bind this value to the given self or cls. |
Method | record |
Turn on recording of function calls. Used by analyze.py. |
Method | signature |
Get the functions that describe this function's signature. |
Instance Variable | bound |
Undocumented |
Instance Variable | closure |
Undocumented |
Instance Variable | code |
Undocumented |
Instance Variable | def |
Undocumented |
Instance Variable | defaults |
Undocumented |
Instance Variable | doc |
Undocumented |
Instance Variable | f |
Undocumented |
Instance Variable | f |
Undocumented |
Instance Variable | has |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | kw |
Undocumented |
Instance Variable | last |
Undocumented |
Instance Variable | nonstararg |
Undocumented |
Instance Variable | posonlyarg |
Undocumented |
Method | _build |
Build a function.Signature object representing this function. |
Method | _check |
Validate function signature. |
Method | _find |
Undocumented |
Method | _fix |
Adjust argument types for a contextmanager's __exit__ method. |
Method | _handle |
Undocumented |
Method | _hash |
Undocumented |
Method | _inner |
Check if the function and its nested class use same type parameter. |
Method | _paramspec |
Undocumented |
Method | _set |
Undocumented |
Method | _update |
Undocumented |
Class Variable | _function |
Undocumented |
Instance Variable | _call |
Undocumented |
Instance Variable | _call |
Undocumented |
Instance Variable | _overloads |
Undocumented |
Instance Variable | _store |
Undocumented |
Inherited from SignedFunction
:
Method | match |
Calls match_args() and _map_args(). |
Method | set |
Attempts to set default arguments of a function. |
Method | set |
Set the annotation for `self` in a class. |
Instance Variable | signature |
Undocumented |
Method | _check |
Undocumented |
Method | _map |
Map call args to function args. |
Method | _match |
Undocumented |
Method | _mutations |
Undocumented |
Instance Variable | _has |
Undocumented |
Inherited from Function
(via SignedFunction
):
Method | __repr__ |
Undocumented |
Instance Variable | cls |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Method | _extract |
Extracts defaults from a Variable, used by set_function_defaults. |
Method | _get |
Get the python variable name of a pytype Variable. |
Inherited from SimpleValue
(via SignedFunction
, Function
):
Method | cls |
Undocumented |
Method | get |
Undocumented |
Method | get |
Get a cfg.Variable of the instance's values for the type parameter. |
Method | get |
Build a key from the information used to perform type matching. |
Method | has |
Check if the key is in `instance_type_parameters`. |
Method | instantiate |
Create an instance of self. |
Method | maybe |
Undocumented |
Method | merge |
Set the value of a type parameter. |
Method | set |
Set the __class__ of an instance, for code that does "x.__class__ = y. |
Method | update |
Undocumented |
Instance Variable | members |
Undocumented |
Property | instance |
Undocumented |
Property | maybe |
Undocumented |
Method | _call |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _unique |
Get unique parameter subtypes as variables. |
Instance Variable | _cached |
Undocumented |
Instance Variable | _cls |
Undocumented |
Instance Variable | _fullhash |
Undocumented |
Instance Variable | _instance |
Undocumented |
Instance Variable | _maybe |
Undocumented |
Instance Variable | _type |
Undocumented |
Inherited from BaseValue
(via SignedFunction
, Function
, SimpleValue
):
Method | compute |
Undocumented |
Method | default |
Undocumented |
Method | get |
Undocumented |
Method | get |
Gets a default type key. See get_type_key. |
Method | get |
Get the class's type for the type parameter. |
Method | get |
Get the type an instance of us would have. |
Method | get |
Get this value's __new__ method, if it isn't object.__new__. |
Method | get |
Fetch a special attribute (e.g., __get__, __iter__). |
Method | init |
Allow metaprogramming via __init_subclass__. |
Method | is |
Undocumented |
Method | module |
Undocumented |
Method | official |
Undocumented |
Method | register |
Treating self as a class definition, register an instance of it. |
Method | should |
Undocumented |
Method | to |
Undocumented |
Method | to |
Undocumented |
Method | to |
Get a PyTD definition for this object. |
Method | to |
Get a PyTD type representing this object, as seen at a node. |
Method | to |
Build a variable out of this abstract value. |
Method | unique |
Get unique parameter subtypes as bindings. |
Method | update |
Update the official name. |
Class Variable | formal |
Undocumented |
Instance Variable | final |
Undocumented |
Instance Variable | from |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | mro |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | slots |
Undocumented |
Property | all |
Undocumented |
Property | full |
Undocumented |
Property | module |
Undocumented |
Property | official |
Undocumented |
Property | template |
Undocumented |
Instance Variable | _all |
Undocumented |
Instance Variable | _instance |
Undocumented |
Instance Variable | _module |
Undocumented |
Instance Variable | _official |
Undocumented |
Instance Variable | _template |
Undocumented |
Inherited from ContextWeakrefMixin
(via SignedFunction
, Function
, SimpleValue
, BaseValue
):
Class Variable | __slots__ |
Undocumented |
Instance Variable | ctx |
Undocumented |
Property | ctx |
Undocumented |
def make(cls, name, *, def_opcode, code, f_locals, f_globals, defaults, kw_defaults, closure, annotations, ctx): (source) ¶
Get an InterpreterFunction. Things like anonymous functions and generator expressions are created every time the corresponding code executes. Caching them makes it easier to detect when the environment hasn't changed and a function call can be optimized away. Arguments: name: Function name. def_opcode: The opcode for the def statement code: A code object. f_locals: The locals used for name resolution. f_globals: The globals used for name resolution. defaults: Default arguments. kw_defaults: Default arguments for kwonly parameters. closure: The free variables this closure binds to. annotations: Function annotations. Dict of name -> BaseValue. ctx: context.Context instance. Returns: An InterpreterFunction.
Initialize a SimpleValue. Args: name: Name of this value. For debugging and error reporting. ctx: The abstract context.
Call this abstract value with the given arguments. The posargs and namedargs arguments may be modified by this function. Args: node: The CFGNode calling this function func: The cfg.Binding containing this function. args: Arguments for the call. alias_map: A datatypes.UnionFind, which stores all the type renaming information, mapping of type parameter name to its representative. Returns: A tuple (cfg.Node, cfg.Variable). The CFGNode corresponds to the function's "return" statement(s). Raises: function.FailedFunctionCall Make the call as required by this specific kind of atomic value, and make sure to annotate the results correctly with the origins (val and also other values appearing in the arguments).
Bind this value to the given self or cls. This function is similar to __get__ except at the abstract level. This does not trigger any code execution inside the VM. See __get__ for more details. Args: callself: The Variable that should be passed as self or cls when the call is made. We only need one of self or cls, so having them share a parameter prevents accidentally passing in both. is_class: Whether callself is self or cls. Should be cls only when we want to directly pass in a class to bind a class method to, rather than passing in an instance and calling get_class(). Returns: Another abstract value that should be returned in place of this one. The default implementation returns self, so this can always be called safely.