use crate::{
prelude::*,
runtime::{
execution::ExecutionError,
pointer_address_provider::SelfOwnedPointerAddressProvider,
},
shared_values::{
OwnedSharedContainer, SelfOwnedSharedContainer, SharedContainer,
SharedContainerMutability,
base_shared_value_container::BaseSharedValueContainer,
},
values::{
value::{
Value,
value_classification::{ValueClassification, ValueTag},
},
value_container::ValueContainer,
},
};
#[allow(unused)]
pub fn create_tagged_value_container(
value_container: ValueContainer,
tag: String,
) -> Result<ValueContainer, ExecutionError> {
match value_container {
ValueContainer::Local(Value::Core(mut value)) => {
value.classification =
ValueClassification::new_with_tag(ValueTag {
name: tag,
is_empty: false,
});
Ok(ValueContainer::Local(Value::Core(value)))
}
_ => Err(ExecutionError::ExpectedLocalValue),
}
}
pub fn create_owned_shared_container(
value: ValueContainer,
mutability: SharedContainerMutability,
provider: &mut SelfOwnedPointerAddressProvider,
) -> ValueContainer {
let shared_container = SharedContainer::Owned(
OwnedSharedContainer::new_from_self_owned_container(
SelfOwnedSharedContainer::new(
BaseSharedValueContainer::new_with_inferred_allowed_type(
value, mutability,
),
provider,
),
),
);
ValueContainer::Shared(shared_container)
}