use std::fmt::Debug;
use allocative::Allocative;
use starlark_derive::NoSerialize;
use starlark_derive::StarlarkPagablePanic;
use starlark_derive::starlark_value;
use crate as starlark;
use crate::any::ProvidesStaticType;
use crate::eval::runtime::profile::instant::ProfilerInstant;
use crate::typing::HasTyVTable;
use crate::values::StarlarkValue;
use crate::values::Trace;
use crate::values::Value;
pub(crate) trait MaybeDrop: Debug + Sync + Send + Allocative + 'static {}
#[derive(ProvidesStaticType, Debug, Trace, Allocative)]
pub(crate) struct NeedsDrop;
impl Drop for NeedsDrop {
fn drop(&mut self) {
}
}
#[derive(ProvidesStaticType, Debug, Trace, Allocative)]
pub(crate) struct NoDrop;
impl MaybeDrop for NeedsDrop {}
impl MaybeDrop for NoDrop {}
#[derive(
Trace,
Debug,
derive_more::Display,
ProvidesStaticType,
NoSerialize,
Allocative
)]
#[display("CallEnter")]
pub(crate) struct CallEnter<'v, D: MaybeDrop + 'static> {
pub(crate) function: Value<'v>,
pub(crate) time: ProfilerInstant,
pub(crate) maybe_drop: D,
}
#[starlark_value(type = "call_enter", skip_pagable)]
impl<'v, D: MaybeDrop + Trace<'v> + 'v> StarlarkValue<'v> for CallEnter<'v, D>
where
Self: HasTyVTable,
{
type Canonical = Self;
}
crate::register_ty_starlark_value!(CallEnter<'_, NeedsDrop>);
crate::register_ty_starlark_value!(CallEnter<'_, NoDrop>);
#[derive(
Debug,
derive_more::Display,
ProvidesStaticType,
NoSerialize,
Allocative,
StarlarkPagablePanic
)]
#[display("CallExit")]
pub(crate) struct CallExit<D: MaybeDrop + 'static> {
pub(crate) time: ProfilerInstant,
pub(crate) maybe_drop: D,
}
#[starlark_value(type = "call_exit", skip_pagable)]
impl<'v, D: MaybeDrop> StarlarkValue<'v> for CallExit<D>
where
Self: HasTyVTable,
{
type Canonical = Self;
}
crate::register_avalue_simple_frozen!(CallExit<NeedsDrop>);
crate::register_avalue_simple_frozen!(CallExit<NoDrop>);