sway_core/language/ty/declaration/
abi.rsuse crate::{
engine_threading::*,
language::parsed::{self, AbiDeclaration},
transform,
type_system::*,
};
use std::hash::{Hash, Hasher};
use sway_types::{Ident, Named, Span, Spanned};
use super::{TyDeclParsedType, TyTraitInterfaceItem, TyTraitItem};
#[derive(Clone, Debug)]
pub struct TyAbiDecl {
pub name: Ident,
pub interface_surface: Vec<TyTraitInterfaceItem>,
pub supertraits: Vec<parsed::Supertrait>,
pub items: Vec<TyTraitItem>,
pub span: Span,
pub attributes: transform::AttributesMap,
}
impl TyDeclParsedType for TyAbiDecl {
type ParsedType = AbiDeclaration;
}
impl EqWithEngines for TyAbiDecl {}
impl PartialEqWithEngines for TyAbiDecl {
fn eq(&self, other: &Self, ctx: &PartialEqWithEnginesContext) -> bool {
let TyAbiDecl {
name: ln,
interface_surface: lis,
supertraits: ls,
items: li,
attributes: _,
span: _,
} = self;
let TyAbiDecl {
name: rn,
interface_surface: ris,
supertraits: rs,
items: ri,
attributes: _,
span: _,
} = other;
ln == rn && lis.eq(ris, ctx) && li.eq(ri, ctx) && ls.eq(rs, ctx)
}
}
impl HashWithEngines for TyAbiDecl {
fn hash<H: Hasher>(&self, state: &mut H, engines: &Engines) {
let TyAbiDecl {
name,
interface_surface,
items,
supertraits,
attributes: _,
span: _,
} = self;
name.hash(state);
interface_surface.hash(state, engines);
items.hash(state, engines);
supertraits.hash(state, engines);
}
}
impl CreateTypeId for TyAbiDecl {
fn create_type_id(&self, engines: &Engines) -> TypeId {
engines
.te()
.new_contract_caller(engines, AbiName::Known(self.name.clone().into()), None)
}
}
impl Spanned for TyAbiDecl {
fn span(&self) -> Span {
self.span.clone()
}
}
impl Named for TyAbiDecl {
fn name(&self) -> &Ident {
&self.name
}
}