sway_core/language/parsed/declaration/
abi.rs1use crate::{
2 decl_engine::parsed_id::ParsedDeclId,
3 engine_threading::{EqWithEngines, PartialEqWithEngines, PartialEqWithEnginesContext},
4 transform,
5};
6
7use super::{FunctionDeclaration, Supertrait, TraitItem};
8
9use sway_types::{ident::Ident, span::Span, Named, Spanned};
10
11#[derive(Debug, Clone)]
14pub struct AbiDeclaration {
15 pub name: Ident,
17 pub interface_surface: Vec<TraitItem>,
19 pub supertraits: Vec<Supertrait>,
20 pub methods: Vec<ParsedDeclId<FunctionDeclaration>>,
22 pub(crate) span: Span,
23 pub attributes: transform::AttributesMap,
24}
25
26impl EqWithEngines for AbiDeclaration {}
27impl PartialEqWithEngines for AbiDeclaration {
28 fn eq(&self, other: &Self, ctx: &PartialEqWithEnginesContext) -> bool {
29 self.name == other.name
30 && self.interface_surface.eq(&other.interface_surface, ctx)
31 && self.supertraits.eq(&other.supertraits, ctx)
32 && PartialEqWithEngines::eq(&self.methods, &other.methods, ctx)
33 && self.span == other.span
34 && self.attributes == other.attributes
35 }
36}
37
38impl Named for AbiDeclaration {
39 fn name(&self) -> &sway_types::BaseIdent {
40 &self.name
41 }
42}
43
44impl Spanned for AbiDeclaration {
45 fn span(&self) -> sway_types::Span {
46 self.span.clone()
47 }
48}