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 std::sync::Arc;
use glsl_lang::ast::*;
use crate::transform::template::TemplateDefinition;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FnRef<'a> {
pub prototype: &'a FunctionPrototype,
pub statement: &'a CompoundStatement,
}
impl glsl_lang::ast::NodeContent for FnRef<'_> {}
#[derive(Debug, Clone)]
pub enum FnHandle<'a> {
Owned(Arc<TemplateDefinition>),
Borrowed(Node<FnRef<'a>>),
}
impl From<Arc<TemplateDefinition>> for FnHandle<'_> {
fn from(td: Arc<TemplateDefinition>) -> Self {
Self::Owned(td)
}
}
impl<'a> From<Node<FnRef<'a>>> for FnHandle<'a> {
fn from(r: Node<FnRef<'a>>) -> Self {
Self::Borrowed(r)
}
}
impl<'a> FnHandle<'a> {
pub fn fn_ref(&self) -> Node<FnRef> {
match self {
Self::Owned(r) => r.fn_ref(),
Self::Borrowed(r) => *r,
}
}
}