1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::{
decl_engine::DeclRef, engine_threading::*, language::parsed, transform, type_system::*,
};
use std::hash::{Hash, Hasher};
use sway_types::{Ident, Span, Spanned};
#[derive(Clone, Debug)]
pub struct TyAbiDeclaration {
pub name: Ident,
pub interface_surface: Vec<DeclRef>,
pub supertraits: Vec<parsed::Supertrait>,
pub methods: Vec<DeclRef>,
pub span: Span,
pub attributes: transform::AttributesMap,
}
impl EqWithEngines for TyAbiDeclaration {}
impl PartialEqWithEngines for TyAbiDeclaration {
fn eq(&self, other: &Self, engines: Engines<'_>) -> bool {
self.name == other.name
&& self.interface_surface.eq(&other.interface_surface, engines)
&& self.methods.eq(&other.methods, engines)
}
}
impl HashWithEngines for TyAbiDeclaration {
fn hash<H: Hasher>(&self, state: &mut H, engines: Engines<'_>) {
let TyAbiDeclaration {
name,
interface_surface,
methods,
supertraits,
attributes: _,
span: _,
} = self;
name.hash(state);
interface_surface.hash(state, engines);
methods.hash(state, engines);
supertraits.hash(state, engines);
}
}
impl CreateTypeId for TyAbiDeclaration {
fn create_type_id(&self, engines: Engines<'_>) -> TypeId {
let type_engine = engines.te();
let decl_engine = engines.de();
let ty = TypeInfo::ContractCaller {
abi_name: AbiName::Known(self.name.clone().into()),
address: None,
};
type_engine.insert(decl_engine, ty)
}
}
impl Spanned for TyAbiDeclaration {
fn span(&self) -> Span {
self.span.clone()
}
}