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
use crate::{
engine_threading::*,
language::{parsed::*, *},
transform::{self, AttributeKind},
type_system::*,
};
use sway_types::{ident::Ident, span::Span};
#[derive(Debug, Clone)]
pub struct FunctionDeclaration {
pub purity: Purity,
pub attributes: transform::AttributesMap,
pub name: Ident,
pub visibility: Visibility,
pub body: CodeBlock,
pub parameters: Vec<FunctionParameter>,
pub span: Span,
pub return_type: TypeArgument,
pub type_parameters: Vec<TypeParameter>,
}
#[derive(Debug, Clone)]
pub struct FunctionParameter {
pub name: Ident,
pub is_reference: bool,
pub is_mutable: bool,
pub mutability_span: Span,
pub type_argument: TypeArgument,
}
impl EqWithEngines for FunctionParameter {}
impl PartialEqWithEngines for FunctionParameter {
fn eq(&self, other: &Self, engines: Engines<'_>) -> bool {
self.name == other.name
&& self.is_reference == other.is_reference
&& self.is_mutable == other.is_mutable
&& self.mutability_span == other.mutability_span
&& self.type_argument.eq(&other.type_argument, engines)
}
}
impl FunctionDeclaration {
pub(crate) fn is_test(&self) -> bool {
self.attributes
.keys()
.any(|k| matches!(k, AttributeKind::Test))
}
}