PythonHIR

Enum PythonHIR 

Source
pub enum PythonHIR {
Show 16 variants Module { name: String, body: Vec<PythonHIR>, meta: Metadata, }, Function { id: NodeId, name: String, params: Vec<Parameter>, return_type: Option<Type>, body: Vec<PythonHIR>, decorators: Vec<String>, visibility: Visibility, meta: Metadata, }, Class { id: NodeId, name: String, bases: Vec<String>, body: Vec<PythonHIR>, decorators: Vec<String>, meta: Metadata, }, Call { id: NodeId, callee: Box<PythonHIR>, args: Vec<PythonHIR>, kwargs: Vec<(String, PythonHIR)>, inferred_type: Option<Type>, meta: Metadata, }, Variable { id: NodeId, name: String, inferred_type: Option<Type>, meta: Metadata, }, Assign { id: NodeId, target: String, value: Box<PythonHIR>, type_annotation: Option<Type>, meta: Metadata, }, Return { id: NodeId, value: Option<Box<PythonHIR>>, meta: Metadata, }, If { id: NodeId, condition: Box<PythonHIR>, then_branch: Vec<PythonHIR>, else_branch: Vec<PythonHIR>, meta: Metadata, }, For { id: NodeId, target: String, iter: Box<PythonHIR>, body: Vec<PythonHIR>, orelse: Vec<PythonHIR>, meta: Metadata, }, While { id: NodeId, condition: Box<PythonHIR>, body: Vec<PythonHIR>, orelse: Vec<PythonHIR>, meta: Metadata, }, BinOp { id: NodeId, op: BinOp, left: Box<PythonHIR>, right: Box<PythonHIR>, inferred_type: Option<Type>, meta: Metadata, }, UnaryOp { id: NodeId, op: UnaryOp, operand: Box<PythonHIR>, inferred_type: Option<Type>, meta: Metadata, }, Literal { id: NodeId, value: Literal, meta: Metadata, }, ListComp { id: NodeId, element: Box<PythonHIR>, generators: Vec<Comprehension>, meta: Metadata, }, Attribute { id: NodeId, object: Box<PythonHIR>, attr: String, inferred_type: Option<Type>, meta: Metadata, }, Subscript { id: NodeId, object: Box<PythonHIR>, index: Box<PythonHIR>, inferred_type: Option<Type>, meta: Metadata, },
}
Expand description

Python HIR node

Variants§

§

Module

Module (top-level)

Fields

§name: String

Module name

§body: Vec<PythonHIR>

Module body

§meta: Metadata

Metadata

§

Function

Function definition

Fields

§id: NodeId

Node ID

§name: String

Function name

§params: Vec<Parameter>

Parameters

§return_type: Option<Type>

Return type annotation

§body: Vec<PythonHIR>

Function body

§decorators: Vec<String>

Decorators

§visibility: Visibility

Visibility

§meta: Metadata

Metadata

§

Class

Class definition

Fields

§id: NodeId

Node ID

§name: String

Class name

§bases: Vec<String>

Base classes

§body: Vec<PythonHIR>

Class body

§decorators: Vec<String>

Decorators

§meta: Metadata

Metadata

§

Call

Function call

Fields

§id: NodeId

Node ID

§callee: Box<PythonHIR>

Function being called

§args: Vec<PythonHIR>

Arguments

§kwargs: Vec<(String, PythonHIR)>

Keyword arguments

§inferred_type: Option<Type>

Inferred type

§meta: Metadata

Metadata

§

Variable

Variable reference

Fields

§id: NodeId

Node ID

§name: String

Variable name

§inferred_type: Option<Type>

Inferred type

§meta: Metadata

Metadata

§

Assign

Assignment

Fields

§id: NodeId

Node ID

§target: String

Target variable

§value: Box<PythonHIR>

Value being assigned

§type_annotation: Option<Type>

Type annotation

§meta: Metadata

Metadata

§

Return

Return statement

Fields

§id: NodeId

Node ID

§value: Option<Box<PythonHIR>>

Return value

§meta: Metadata

Metadata

§

If

If statement

Fields

§id: NodeId

Node ID

§condition: Box<PythonHIR>

Condition

§then_branch: Vec<PythonHIR>

Then branch

§else_branch: Vec<PythonHIR>

Else branch

§meta: Metadata

Metadata

§

For

For loop

Fields

§id: NodeId

Node ID

§target: String

Loop variable

§iter: Box<PythonHIR>

Iterable

§body: Vec<PythonHIR>

Loop body

§orelse: Vec<PythonHIR>

Else clause

§meta: Metadata

Metadata

§

While

While loop

Fields

§id: NodeId

Node ID

§condition: Box<PythonHIR>

Condition

§body: Vec<PythonHIR>

Loop body

§orelse: Vec<PythonHIR>

Else clause

§meta: Metadata

Metadata

§

BinOp

Binary operation

Fields

§id: NodeId

Node ID

§op: BinOp

Operator

§left: Box<PythonHIR>

Left operand

§right: Box<PythonHIR>

Right operand

§inferred_type: Option<Type>

Inferred type

§meta: Metadata

Metadata

§

UnaryOp

Unary operation

Fields

§id: NodeId

Node ID

§op: UnaryOp

Operator

§operand: Box<PythonHIR>

Operand

§inferred_type: Option<Type>

Inferred type

§meta: Metadata

Metadata

§

Literal

Literal value

Fields

§id: NodeId

Node ID

§value: Literal

Literal value

§meta: Metadata

Metadata

§

ListComp

List comprehension

Fields

§id: NodeId

Node ID

§element: Box<PythonHIR>

Element expression

§generators: Vec<Comprehension>

Generators

§meta: Metadata

Metadata

§

Attribute

Attribute access (obj.attr)

Fields

§id: NodeId

Node ID

§object: Box<PythonHIR>

Object

§attr: String

Attribute name

§inferred_type: Option<Type>

Inferred type

§meta: Metadata

Metadata

§

Subscript

Subscript (obj[index])

Fields

§id: NodeId

Node ID

§object: Box<PythonHIR>

Object

§index: Box<PythonHIR>

Index

§inferred_type: Option<Type>

Inferred type

§meta: Metadata

Metadata

Implementations§

Source§

impl PythonHIR

Source

pub const fn id(&self) -> Option<NodeId>

Get the node ID if present

Source

pub const fn metadata(&self) -> &Metadata

Get the metadata

Trait Implementations§

Source§

impl Clone for PythonHIR

Source§

fn clone(&self) -> PythonHIR

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PythonHIR

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PythonHIR

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PythonHIR

Source§

fn eq(&self, other: &PythonHIR) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PythonHIR

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PythonHIR

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,