Skip to main content

InferredType

Enum InferredType 

Source
pub enum InferredType {
Show 26 variants IntLiteral, UIntLiteral, FloatLiteral, CharLiteral, StringLiteral, SymbolLookup { name: InternedStr, resolved_type: Box<TypeRepr>, }, ThxDefault, BinaryOp { op: BinOp, result_type: Box<TypeRepr>, }, UnaryArithmetic { inner_type: Box<TypeRepr>, }, LogicalNot, AddressOf { inner_type: Box<TypeRepr>, }, Dereference { pointer_type: Box<TypeRepr>, }, IncDec { inner_type: Box<TypeRepr>, }, MemberAccess { base_type: String, member: InternedStr, field_type: Option<Box<TypeRepr>>, }, PtrMemberAccess { base_type: String, member: InternedStr, field_type: Option<Box<TypeRepr>>, used_consistent_type: bool, }, ArraySubscript { base_type: Box<TypeRepr>, element_type: Box<TypeRepr>, }, Conditional { then_type: Box<TypeRepr>, else_type: Box<TypeRepr>, result_type: Box<TypeRepr>, }, Comma { rhs_type: Box<TypeRepr>, }, Assignment { lhs_type: Box<TypeRepr>, }, Cast { target_type: Box<TypeRepr>, }, Sizeof, Alignof, CompoundLiteral { type_name: Box<TypeRepr>, }, StmtExpr { last_expr_type: Option<Box<TypeRepr>>, }, Assert, FunctionReturn { func_name: InternedStr, },
}
Expand description

推論で導出された型

Variants§

§

IntLiteral

整数リテラル (42, 0x1F, etc.)

§

UIntLiteral

符号なし整数リテラル (42u, etc.)

§

FloatLiteral

浮動小数点リテラル (3.14, etc.)

§

CharLiteral

文字リテラル (‘a’)

§

StringLiteral

文字列リテラル (“hello”)

§

SymbolLookup

シンボルテーブルからの参照

Fields

§resolved_type: Box<TypeRepr>

解決された型

§

ThxDefault

THX (my_perl) のデフォルト型

§

BinaryOp

二項演算の結果

Fields

§result_type: Box<TypeRepr>

左右オペランドの型から計算された結果型

§

UnaryArithmetic

単項演算 (+, -, ~)

Fields

§inner_type: Box<TypeRepr>

内部式の型をそのまま継承

§

LogicalNot

論理否定 (!) - 常に int

§

AddressOf

アドレス取得 (&x)

Fields

§inner_type: Box<TypeRepr>
§

Dereference

間接参照 (*p)

Fields

§pointer_type: Box<TypeRepr>
§

IncDec

インクリメント/デクリメント (++, –)

Fields

§inner_type: Box<TypeRepr>
§

MemberAccess

直接メンバーアクセス (expr.member)

Fields

§base_type: String
§field_type: Option<Box<TypeRepr>>

解決されたフィールド型

§

PtrMemberAccess

ポインタメンバーアクセス (expr->member)

Fields

§base_type: String
§field_type: Option<Box<TypeRepr>>

解決されたフィールド型

§used_consistent_type: bool

一致型を使用した場合(ベース型が不明時)

§

ArraySubscript

配列添字 (arr[i])

Fields

§base_type: Box<TypeRepr>
§element_type: Box<TypeRepr>

要素型

§

Conditional

条件演算子 (cond ? then : else)

Fields

§then_type: Box<TypeRepr>
§else_type: Box<TypeRepr>
§result_type: Box<TypeRepr>

計算された共通型

§

Comma

コンマ式 (a, b)

Fields

§rhs_type: Box<TypeRepr>

右辺の型

§

Assignment

代入式 (a = b)

Fields

§lhs_type: Box<TypeRepr>

左辺の型

§

Cast

キャスト式 ((type)expr)

Fields

§target_type: Box<TypeRepr>
§

Sizeof

sizeof 式/型 - 常に unsigned long

§

Alignof

alignof - 常に unsigned long

§

CompoundLiteral

複合リテラル ((type){…})

Fields

§type_name: Box<TypeRepr>
§

StmtExpr

文式 ({ … })

Fields

§last_expr_type: Option<Box<TypeRepr>>

最後の式の型

§

Assert

アサーション - 常に void

§

FunctionReturn

関数呼び出しの戻り値(RustBindings/Apidoc から取得できなかった場合)

Fields

§func_name: InternedStr

Implementations§

Source§

impl InferredType

Source

pub fn resolved_type(&self) -> Option<&TypeRepr>

Inferred ラッパーを解決して内側の TypeRepr を返す

各 InferredType バリアントが保持する「結果の型」を取得する。 pointee_name() / type_name() から再帰的に呼ばれる。

Source§

impl InferredType

Source

pub fn to_display_string(&self, interner: &StringInterner) -> String

表示用文字列に変換

Source

pub fn to_rust_string(&self, interner: &StringInterner) -> String

Rust コード生成用の型文字列に変換

Trait Implementations§

Source§

impl Clone for InferredType

Source§

fn clone(&self) -> InferredType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for InferredType

Source§

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

Formats the value using the given formatter. Read more

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.