Skip to main content

datex_core/values/value/
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::value::{Value, value_classification::ValueTag},
8};
9
10impl Classification for Value {
11    fn entity_type(
12        &self,
13        cache: &mut SharedReferencesCache,
14    ) -> Option<EntityType> {
15        match self {
16            Value::Core(core_value) => core_value.entity_type(cache),
17            Value::Native(custom_value) => custom_value.entity_type(cache),
18        }
19    }
20
21    fn entity_type_address(&self) -> Option<PointerAddress> {
22        match self {
23            Value::Core(core_value) => core_value.entity_type_address(),
24            Value::Native(custom_value) => custom_value.entity_type_address(),
25        }
26    }
27
28    fn tag(&self) -> Option<ValueTag> {
29        match self {
30            Value::Core(core_value) => core_value.tag(),
31            Value::Native(custom_value) => custom_value.tag(),
32        }
33    }
34
35    fn impls(&self) -> Vec<PointerAddress> {
36        match self {
37            Value::Core(core_value) => core_value.impls(),
38            Value::Native(custom_value) => custom_value.impls(),
39        }
40    }
41}