Generate an object call for a python function given during compilation time
Returns whether the given node is a Name
Set a type and simple typed variable on a node
Clone a CloneableNode. This allows the node’s sub-expressions to be re-used without re-evaluating them.
The CloneableNode must be evaluated before the CloneNode is evaluated!
Create a node that can be cloned. This allows sub-expressions to be re-used without re-evaluating them.
Node that is an expression.
Node that allows an expression to execute a bunch of statements first.
This code is a wrapper function callable from Python using NumbaFunction (see numba/numbafunction.c):
It unpacks the tuple to native types, calls the wrapped function, and coerces the return type back to an object.
Bases: _ast.Name, numba.nodes.basenodes.ExprNode
Superclass for Numba AST nodes
with nopython: ...
with python: ...
Inject a low-level macro in the function at the call site.
Low-level macros are Python functions that take a FunctionCache instance, a LLVM builder instance, and a set of arguments, construct LLVM code, and return some kind of LLVM value result. The passed signature should reflect the Numba types of the expected input parameters, and the type of the resulting value (this does not restrict polymorphism at the LLVM type level in the macro expansion function).
For calling an external llvm function where you only have the signature and the function name.
Call an llvm intrinsic function
Low level call a libc math function
Call a function which is given as a node
Node that has control flow basic blocks.
Bases: _ast.For, numba.nodes.cfnodes.FlowNode
A for loop node. Has the basic block attributes from FlowNode
Bases: _ast.If, numba.nodes.cfnodes.FlowNode
An if statement node. Has the basic block attributes from FlowNode
Evaluate a statement or expression in a new LLVM basic block.
Wraps an ast.Name() to indicate that the result may be unused.
Bases: _ast.While, numba.nodes.cfnodes.FlowNode
A while loop node. Has the basic block attributes from FlowNode
Remove all control flow basic blocks from the CFG given a FlowNode and the CFG. Also removes Name references from cf_references.
Implements ‘lhs if cond_left <op> cond_right else rhs’
Merge CFG blocks into the AST. E.g.
While(test=ControlBlock(0, body=[x]), body=ControlBlock(1, body=[y]))
Call to closure or inner function.
Inner functions or closures.
When coerced to an object, a wrapper PyMethodDef gets created, and at call time a function is dynamically created with the closure scope.
- AST FunctionDef of the function
- Outer Python function (or None!)
Load the closure scope for the function or NULL
Explicit cast by user, e.g. double(value)
Coerce objects to native values
Coerce native values to objects
Coerce a node to a different type
Numpy array attributes, such as ‘data’, get rewritten to direct accesses. Since they are being coerced back to objects, use a generic attribute access instead.
dst_type is always the same as type, and ‘type’ is kept consistent with Variable.type
Coerce to the type of the given variable. The type of the variable may change in the meantime (e.g. may be promoted or demoted).
Coerces a variable of some type to another type for a phi node in a successor block.
Wrap a constant.
Check for an exception.
badval: if this value is returned, propagate an error goodval: if this value is not returned, propagate an error
If exc_type, exc_msg and optionally exc_args are given, an error is raised instead of propagating it.
See RaiseNode for the exc_* arguments.
Propagate an exception (jump to the error label). This is resolved at code generation time and can be generated at any moment.
Check for a set Python exception using PyErr_Occurred().
Can be set any time after type inference. This node is resolved during late specialization.
Raise an exception.
exception_type: The Python exception type
- exc_type: The Python exception as an AST node
- May be passed in as a Python exception type
- exc_msg: The message to print as an AST node
- May be passed in as a string
- exc_args: If given, must be an list of AST nodes representing the
- arguments to PyErr_Format (matching the format specifiers at runtime in exc_msg)
Create an extension type attribute node if the attribute is known to exist (and isn’t being inferred)
alias of UserNode
Allow annotating AST nodes with some metadata, and querying for that metadata.
Allocate a new array with data.
Allocate a new array given the attributes.
Low-level specialized equivalent of ArrayNewNode
Load the shape values from an ndarray
Load the stride values from an ndarray
Refer to a Python object in the llvm code.
Coerce a node to a temporary which is reference counted.
Dereference a pointer
Bitcast objects to void *
Struct and complex nodes.
Structs are allocated on the stack, and not mutated as values. This is because mutations are attribute or index assignments, which are not recognized as variable assignments. Hence mutation cannot propagate new values. So we mutate what we have on the stack.
Tells the type inferencer that the node is actually a valid struct that we can mutate. For instance
func().a = 2
is wrong if func() returns a struct by value. So we only allow references like struct.a = 2 and array[i].a = 2.
Create a temporary to store values in. Does not perform reference counting.
TBAA metadata node unique to this temporary. This is valid since one cannot take the address of a temporary.
Node that users can subclass and insert in the AST without using mixins to provide user-specified functionality.
Generate code for this node.
Must return an LLVM Value.
Infer the type of this node and set it self.type.
The return value will replace this node in the AST.
Just before code generation. Useful to rewrite this node in terms of other existing fundamental operations.
Implementing this method is optional.