Skip to main content

datex_core/values/value_container/
classification.rs

1use crate::{
2    prelude::*,
3    runtime::cache::shared_references_cache::SharedReferencesCache,
4    shared_values::PointerAddress,
5    traits::classification::Classification,
6    types::entity_type::EntityType,
7    values::{
8        value::value_classification::ValueTag, value_container::ValueContainer,
9    },
10};
11
12impl Classification for ValueContainer {
13    fn entity_type(
14        &self,
15        cache: &mut SharedReferencesCache,
16    ) -> Option<EntityType> {
17        match self {
18            ValueContainer::Local(value) => {
19                Classification::entity_type(value, cache)
20            }
21            ValueContainer::Shared(_shared) => None,
22        }
23    }
24
25    fn entity_type_address(&self) -> Option<PointerAddress> {
26        match self {
27            ValueContainer::Local(value) => {
28                Classification::entity_type_address(value)
29            }
30            ValueContainer::Shared(_shared) => None,
31        }
32    }
33
34    fn tag(&self) -> Option<ValueTag> {
35        match self {
36            ValueContainer::Local(value) => Classification::tag(value),
37            ValueContainer::Shared(_shared) => None,
38        }
39    }
40
41    fn impls(&self) -> Vec<PointerAddress> {
42        match self {
43            ValueContainer::Local(value) => Classification::impls(value),
44            ValueContainer::Shared(_shared) => Vec::new(),
45        }
46    }
47}