air_mir/ir/nodes/roots/
function.rs1use crate::ir::{Builder, Link, Node, Op, Owner, Parent, Root, Singleton};
2use miden_diagnostics::{SourceSpan, Spanned};
3
4#[derive(Default, Clone, PartialEq, Eq, Debug, Hash, Builder, Spanned)]
6#[enum_wrapper(Root)]
7pub struct Function {
8 pub parameters: Vec<Link<Op>>,
10 pub return_type: Link<Op>,
12 pub body: Link<Vec<Link<Op>>>,
14 pub _node: Singleton<Node>,
15 pub _owner: Singleton<Owner>,
16 #[span]
17 pub span: SourceSpan,
18}
19
20impl Function {
21 pub fn create(
22 parameters: Vec<Link<Op>>,
23 return_type: Link<Op>,
24 body: Vec<Link<Op>>,
25 span: SourceSpan,
26 ) -> Link<Root> {
27 Root::Function(Self {
28 parameters,
29 return_type,
30 body: Link::new(body),
31 span,
32 ..Default::default()
33 })
34 .into()
35 }
36}
37
38impl Parent for Function {
39 type Child = Op;
40 fn children(&self) -> Link<Vec<Link<Self::Child>>> {
41 self.body.clone()
42 }
43}