Gcx

Struct Gcx 

Source
pub struct Gcx<'gcx>(/* private fields */);
Expand description

Reference to the global context.

Implementations§

Source§

impl<'gcx> Gcx<'gcx>

Source

pub fn contract_abi<'a>(self, id: ContractId) -> Vec<AbiItem<'a>>

Returns the ABI of the given contract.

Reference: https://docs.soliditylang.org/en/develop/abi-spec.html

Source§

impl<'gcx> Gcx<'gcx>

Source

pub fn stage(&self) -> Option<CompilerStage>

Returns the current compiler stage.

Source

pub fn dcx(self) -> &'gcx DiagCtxt

Returns the diagnostics context.

Source

pub fn arena(self) -> &'gcx Arena

Source

pub fn bump(self) -> &'gcx Bump

Source

pub fn alloc<T>(self, value: T) -> &'gcx T

Source

pub fn mk_ty(self, kind: TyKind<'gcx>) -> Ty<'gcx>

Source

pub fn mk_tys(self, tys: &[Ty<'gcx>]) -> &'gcx [Ty<'gcx>]

Source

pub fn mk_ty_iter(self, tys: impl Iterator<Item = Ty<'gcx>>) -> &'gcx [Ty<'gcx>]

Source

pub fn mk_ty_string_literal(self, s: &[u8]) -> Ty<'gcx>

Source

pub fn mk_ty_int_literal(self, size: TypeSize) -> Ty<'gcx>

Source

pub fn mk_ty_fn_ptr(self, ptr: TyFnPtr<'gcx>) -> Ty<'gcx>

Source

pub fn mk_ty_fn( self, parameters: &[Ty<'gcx>], state_mutability: StateMutability, visibility: Visibility, returns: &[Ty<'gcx>], ) -> Ty<'gcx>

Source

pub fn mk_ty_err(self, guar: ErrorGuaranteed) -> Ty<'gcx>

Source

pub fn get_file(self, name: impl Into<FileName>) -> Option<Arc<SourceFile>>

Returns the source file with the given path, if it exists.

Source

pub fn get_ast_source( self, name: impl Into<FileName>, ) -> Option<(SourceId, &'gcx Source<'gcx>)>

Returns the AST source at the given path, if it exists.

Source

pub fn get_hir_source( self, name: impl Into<FileName>, ) -> Option<(SourceId, &'gcx Source<'gcx>)>

Returns the HIR source at the given path, if it exists.

Source

pub fn item_name(self, id: impl Into<ItemId>) -> Ident

Returns the name of the given item.

§Panics

Panics if the item has no name, such as unnamed function parameters.

Source

pub fn item_canonical_name(self, id: impl Into<ItemId>) -> impl Display

Returns the canonical name of the given item.

This is the name of the item prefixed by the name of the contract it belongs to.

Source

pub fn contract_fully_qualified_name( self, id: ContractId, ) -> impl Display + use<'gcx>

Returns the fully qualified name of the contract.

Source

pub fn item_fields( self, id: impl Into<ItemId>, ) -> impl Iterator<Item = (Ty<'gcx>, VariableId)>

Returns an iterator over the fields of the given item.

Accepts structs, functions, errors, and events.

Source

pub fn item_parameters(self, id: impl Into<ItemId>) -> &'gcx [VariableId]

Returns the parameter variable declarations of the given function-like item.

Also accepts structs.

§Panics

Panics if the item is not a function-like item or a struct.

Source

pub fn item_parameters_opt( self, id: impl Into<ItemId>, ) -> Option<&'gcx [VariableId]>

Returns the parameter variable declarations of the given function-like item.

Also accepts structs.

Source

pub fn item_parameter_types(self, id: impl Into<ItemId>) -> &'gcx [Ty<'gcx>]

Returns the return variable declarations of the given function-like item.

§Panics

Panics if the item is not a function-like item.

Source

pub fn item_parameter_types_opt( self, id: impl Into<ItemId>, ) -> Option<&'gcx [Ty<'gcx>]>

Returns the return variable declarations of the given function-like item.

§Panics

Panics if the item is not a function-like item.

Source

pub fn item_name_opt(self, id: impl Into<ItemId>) -> Option<Ident>

Returns the name of the given item.

Source

pub fn item_span(self, id: impl Into<ItemId>) -> Span

Returns the span of the given item.

Source

pub fn function_selector(self, id: impl Into<ItemId>) -> FixedBytes<4>

Returns the 4-byte selector of the given item. Only accepts functions and errors.

§Panics

Panics if the item is not a function or error.

Source

pub fn event_selector(self, id: EventId) -> FixedBytes<32>

Returns the 32-byte selector of the given event.

Source

pub fn type_of_hir_ty(self, ty: &Type<'_>) -> Ty<'gcx>

Computes the Ty of the given hir::Type. Not cached.

Source

pub fn type_of_res(self, res: Res) -> Ty<'gcx>

Returns the type of the given hir::Res.

Source§

impl<'gcx> Gcx<'gcx>

Source

pub fn interface_id(self, id: ContractId) -> FixedBytes<4>

Returns the ERC-165 interface ID of the given contract.

This is the XOR of the selectors of all function selectors in the interface.

The solc implementation excludes inheritance: https://github.com/argotorg/solidity/blob/ad2644c52b3afbe80801322c5fe44edb59383500/libsolidity/ast/AST.cpp#L310-L316

See ERC-165 for more details.

Source

pub fn interface_functions(self, id: ContractId) -> InterfaceFunctions<'gcx>

Returns all the exported functions of the given contract.

The contract doesn’t have to be an interface.

Source

pub fn item_signature(self, id: ItemId) -> &'gcx str

Returns the ABI signature of the given item. Only accepts functions, errors, and events.

Source

pub fn type_of_item(self, id: ItemId) -> Ty<'gcx>

Returns the type of the given item.

Source

pub fn struct_field_types(self, id: StructId) -> &'gcx [Ty<'gcx>]

Returns the types of the fields of the given struct.

Source

pub fn struct_recursiveness(self, id: StructId) -> Recursiveness

Returns the recursiveness of the given struct.

Source

pub fn members_of(self, ty: Ty<'gcx>) -> &'gcx [Member<'gcx>]

Returns the members of the given type.

Trait Implementations§

Source§

impl<'gcx> Clone for Gcx<'gcx>

Source§

fn clone(&self) -> Gcx<'gcx>

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<'gcx> Debug for Gcx<'gcx>

Source§

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

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

impl<'gcx> Deref for Gcx<'gcx>

Source§

type Target = &'gcx GlobalCtxt<'gcx>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Gcx<'gcx> as Deref>::Target

Dereferences the value.
Source§

impl<'gcx> Copy for Gcx<'gcx>

Auto Trait Implementations§

§

impl<'gcx> Freeze for Gcx<'gcx>

§

impl<'gcx> !RefUnwindSafe for Gcx<'gcx>

§

impl<'gcx> Send for Gcx<'gcx>

§

impl<'gcx> Sync for Gcx<'gcx>

§

impl<'gcx> Unpin for Gcx<'gcx>

§

impl<'gcx> !UnwindSafe for Gcx<'gcx>

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, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more