Diffstat (limited to 'src/walk/walkers/core/struct.rs')
-rw-r--r--src/walk/walkers/core/struct.rs833
1 files changed, 423 insertions, 410 deletions
diff --git a/src/walk/walkers/core/struct.rs b/src/walk/walkers/core/struct.rs
index ac4a784..283db72 100644
--- a/src/walk/walkers/core/struct.rs
+++ b/src/walk/walkers/core/struct.rs
@@ -1,29 +1,27 @@
use core::any::TypeId;
use effectful::{
- bound::{Dynamic, IsSend, IsSync},
+ bound::Dynamic,
effective::Effective,
environment::{DynBind, Environment, NativeForm},
+ higher_ranked::{for_lt, Rank1, WithLt},
SendSync,
};
use crate::{
- any::{AnyTrait, BorrowedStatic, BorrowedStaticHrt, OwnedStatic, StaticType},
- any_trait,
+ any::{type_name, AnyTrait, BorrowedStatic, OwnedStatic},
hkt::Marker,
- never::Never,
protocol::{
visitor::{
request_hint, tags, visit_sequence, visit_tag, visit_value, EffectiveVisitExt as _,
- Recoverable, RecoverableKnown, RecoverableProto, RecoverableScope, Sequence,
- SequenceKnown, SequenceProto, SequenceScope, Tag, TagConst, TagDyn, TagError, TagKnown,
- TagProto, Value, ValueKnown, ValueProto, VisitResult,
+ Recoverable, RecoverableScope, Sequence, SequenceHint, SequenceKnown, SequenceScope,
+ Tag, TagConst, TagDyn, TagError, TagHint, TagKnown, Value, ValueKnown, VisitResult,
},
- walker::hint::{DynVisitorWith, Hint, HintMeta, HintProto, MetaHint, MetaKnown},
+ walker::hint::{DynVisitorWith, Hint, HintMeta},
DynVisitor, DynWalker,
},
- DynWalkerAdapter, Flow, Status, TAG_FIELD_NAMES, TAG_MAP, TAG_STRUCT, TAG_TYPE_ID,
- TAG_TYPE_NAME,
+ walk::DynWalkerAdapter,
+ Flow, Never, Status,
};
use super::{noop::NoopWalker, value::ValueWalker};
@@ -124,7 +122,7 @@ impl<'ctx, I, S, E, M> crate::Walker<'ctx, E> for StructWalker<'ctx, I, S, M, E>
where
E: Environment,
I: StructTypeInfo<'ctx, M, E, S = S>,
- Self: AnyTrait<'ctx, E> + RecoverableScope<'ctx, E>,
+ Self: AnyTrait<'ctx> + RecoverableScope<'ctx, E>,
{
type Error = StructWalkError<I::FieldError>;
type Output = ();
@@ -164,69 +162,42 @@ where
}
}
-any_trait! {
- impl['ctx, I, M][E] StructWalker<'ctx, I, StaticType, M, E> = [
- HintProto<RecoverableProto<E>>,
- HintProto<SequenceProto<E>>,
- HintProto<ValueProto<BorrowedStaticHrt<I::T>, E>>,
- HintProto<TagProto<TagDyn, E>>,
- HintProto<TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>,
- HintProto<TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>,
- HintProto<TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>,
- HintProto<TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>,
- HintProto<TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
- ] where
- E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = StaticType>,
- M: 'ctx,
- I::T: 'static,
- Dynamic<&'ctx I::T>: DynBind<E>,
- Dynamic<BorrowedStatic<'ctx, I::T>>: DynBind<E>,
- for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, I::T>>: DynBind<E>,
- Dynamic<TypeId>: DynBind<E>,
- Dynamic<OwnedStatic<TypeId>>: DynBind<E>,
-}
+pub enum StaticType {}
-impl<'ctx, I, S, M, E> Hint<'ctx, RecoverableProto<E>> for StructWalker<'ctx, I, S, M, E>
+impl<'ctx, I, M, E> AnyTrait<'ctx> for StructWalker<'ctx, I, StaticType, M, E>
where
E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = S>,
- Self: AnyTrait<'ctx, E> + RecoverableScope<'ctx, E>,
+ I: StructTypeInfo<'ctx, M, E, S = StaticType>,
+ M: 'ctx,
+ I::T: 'static,
+ Dynamic<&'ctx I::T>: DynBind<E>,
+ Dynamic<BorrowedStatic<'ctx, I::T>>: DynBind<E>,
+ for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, I::T>>: DynBind<E>,
+ Dynamic<TypeId>: DynBind<E>,
+ Dynamic<OwnedStatic<TypeId>>: DynBind<E>,
{
- #[inline(always)]
- fn hint<'this, 'visitor, 'hint, 'e>(
- &'this mut self,
- _visitor: DynVisitorWith<'visitor, 'ctx, RecoverableProto<E>>,
- _hint: MetaHint<'hint, 'ctx, RecoverableProto<E>>,
- ) -> NativeForm<'e, VisitResult, E>
- where
- 'ctx: 'this + 'visitor + 'hint + 'e,
- {
- todo!()
- // E::map(
- // visit_recoverable::<E>(visitor, self),
- // |status| match status {
- // VisitResult::Skipped(_) => Flow::Continue,
- // VisitResult::Control(flow) => flow,
- // },
- // )
- }
-
- #[inline(always)]
- fn known<'a>(
- &'a mut self,
- _hint: &'a <RecoverableProto<E> as HintMeta>::Hint,
- ) -> NativeForm<'a, Result<MetaKnown<'a, 'ctx, RecoverableProto<E>>, ()>, E> {
- E::value(Ok(RecoverableKnown)).cast()
- }
}
-impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>
+// any_trait! {
+// impl['ctx, I, M][E] StructWalker<'ctx, I, StaticType, M, E> = [
+// HintProto<RecoverableProto<E>>,
+// HintProto<SequenceProto<E>>,
+// HintProto<ValueProto<BorrowedStaticHrt<I::T>, E>>,
+// HintProto<TagProto<TagDyn, E>>,
+// HintProto<TagProto<tags::TypeId, E>>,
+// HintProto<TagProto<tags::Struct, E>>,
+// HintProto<TagProto<tags::Map, E>>,
+// HintProto<TagProto<tags::TypeName, E>>,
+// HintProto<TagProto<tags::FieldNames, E>>,
+// ] where
+// }
+
+impl<'ctx, I, S, M, E> Hint<'ctx, type_name::Raised<'static, 'ctx, dyn Recoverable<'ctx, E>>>
for StructWalker<'ctx, I, S, M, E>
where
- Self: DynBind<E>,
E: Environment,
I: StructTypeInfo<'ctx, M, E, S = S>,
+ Self: AnyTrait<'ctx> + RecoverableScope<'ctx, E>,
{
#[inline(always)]
fn hint<'this, 'visitor, 'hint, 'e>(
@@ -234,144 +205,391 @@ where
_visitor: DynVisitorWith<
'visitor,
'ctx,
- TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>,
+ type_name::Raised<'static, 'ctx, dyn Recoverable<'ctx, E>>,
>,
- _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
- ) -> NativeForm<'e, VisitResult, E>
- where
- 'ctx: 'this + 'visitor + 'hint + 'e,
- {
- todo!()
- // E::map(
- // visit_tag::<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E, _>(
- // TagConst,
- // visitor,
- // StaticSliceWalker::<_, ValueWalker<&'static str>>::new(I::FIELDS),
- // ),
- // |status| match status {
- // Err(err) => {
- // self.error = Some(StructWalkErrorKind::FieldTag(err));
- // Flow::Err
- // }
- // Ok(VisitResult::Skipped(_)) => Flow::Continue,
- // Ok(VisitResult::Control(flow)) => flow,
- // },
- // )
- }
-
- #[inline(always)]
- fn known<'a>(
- &'a mut self,
- _hint: &'a MetaHint<'a, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>,
- ) -> NativeForm<
- 'a,
- Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>>, ()>,
- E,
- > {
- E::value(Ok(TagKnown {
- kind_available: Some(true),
- }))
- .cast()
- }
-}
-
-impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>
- for StructWalker<'ctx, I, S, M, E>
-where
- Self: DynBind<E>,
- E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = S>,
-{
- #[inline(always)]
- fn hint<'this, 'visitor, 'hint, 'e>(
- &'this mut self,
- _visitor: DynVisitorWith<'visitor, 'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>,
- _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>,
+ _hint: (),
) -> NativeForm<'e, VisitResult, E>
where
'ctx: 'this + 'visitor + 'hint + 'e,
{
todo!()
// E::map(
- // visit_tag::<TagConst<{ TAG_TYPE_NAME.to_int() }>, E, _>(
- // TagConst,
- // visitor,
- // ValueWalker::new(I::NAME),
- // ),
+ // visit_recoverable::<E>(visitor, self),
// |status| match status {
- // Err(err) => {
- // self.error = Some(StructWalkErrorKind::Tag(err));
- // Flow::Err
- // }
- // Ok(VisitResult::Skipped(_)) => Flow::Continue,
- // Ok(VisitResult::Control(flow)) => flow,
+ // VisitResult::Skipped(_) => Flow::Continue,
+ // VisitResult::Control(flow) => flow,
// },
// )
}
- #[inline(always)]
fn known<'a>(
&'a mut self,
- _hint: &'a <TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E> as HintMeta>::Hint,
- ) -> NativeForm<
- 'a,
- Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>, ()>,
- E,
- > {
- E::value(Ok(TagKnown {
- kind_available: Some(true),
- }))
- .cast()
- }
-}
-
-impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>
- for StructWalker<'ctx, I, S, M, E>
-where
- Self: DynBind<E>,
- E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = S>,
-{
- #[inline(always)]
- fn hint<'this, 'visitor, 'hint, 'e>(
- &'this mut self,
- _visitor: DynVisitorWith<'visitor, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>,
- _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>,
- ) -> NativeForm<'e, VisitResult, E>
+ hint: &'a WithLt<'a, Rank1<()>>,
+ ) -> NativeForm<'a, Result<WithLt<'a, Rank1<()>>, ()>, E>
where
- 'ctx: 'this + 'visitor + 'hint + 'e,
+ WithLt<'a, Rank1<()>>: DynBind<E>,
{
- todo!()
- // E::map(
- // visit_tag::<TagConst<{ TAG_MAP.to_int() }>, E, _>(TagConst, visitor, NoopWalker::new()),
- // |status| match status {
- // Err(err) => {
- // self.error = Some(StructWalkErrorKind::Tag(err));
- // Flow::Err
- // }
- // Ok(VisitResult::Skipped(_)) => Flow::Continue,
- // Ok(VisitResult::Control(flow)) => flow,
- // },
- // )
- }
-
- #[inline(always)]
- fn known<'a>(
- &'a mut self,
- _hint: &'a <TagProto<TagConst<{ TAG_MAP.to_int() }>, E> as HintMeta>::Hint,
- ) -> NativeForm<
- 'a,
- Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>, ()>,
- E,
- > {
- E::value(Ok(TagKnown {
- kind_available: Some(true),
- }))
- .cast()
+ E::value(Ok(())).cast()
}
}
-impl<'ctx, I, S, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>
+// impl<'c, 'ctx: 'c, I, S, M, E> Hint<'ctx, dyn Tag<'ctx, tags::FieldNames, E> + 'c>
+// for StructWalker<'ctx, I, S, M, E>
+// where
+// Self: DynBind<E>,
+// E: Environment,
+// I: StructTypeInfo<'ctx, M, E, S = S>,
+// {
+// #[inline(always)]
+// fn hint<'this, 'visitor, 'hint, 'e>(
+// &'this mut self,
+// _visitor: DynVisitorWith<
+// 'visitor,
+// 'ctx,
+// dyn Tag<'ctx, tags::FieldNames, E> + 'c,
+// >,
+// _hint: TagHint<tags::FieldNames>,
+// ) -> NativeForm<'e, VisitResult, E>
+// where
+// 'ctx: 'this + 'visitor + 'hint + 'e,
+// {
+// todo!()
+// // E::map(
+// // visit_tag::<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E, _>(
+// // TagConst,
+// // visitor,
+// // StaticSliceWalker::<_, ValueWalker<&'static str>>::new(I::FIELDS),
+// // ),
+// // |status| match status {
+// // Err(err) => {
+// // self.error = Some(StructWalkErrorKind::FieldTag(err));
+// // Flow::Err
+// // }
+// // Ok(VisitResult::Skipped(_)) => Flow::Continue,
+// // Ok(VisitResult::Control(flow)) => flow,
+// // },
+// // )
+// }
+//
+// #[inline(always)]
+// fn known<'a>(
+// &'a mut self,
+// hint: &'a WithLt<'a, Rank1<()>>,
+// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// where
+// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
+// {
+// E::value(Ok(TagKnown {
+// kind_available: Some(true),
+// }))
+// .cast()
+// }
+// }
+//
+// impl<'c, 'ctx: 'c, I, S, M, E> Hint<'ctx, dyn Tag<'ctx, tags::TypeName, E> + 'c>
+// for StructWalker<'ctx, I, S, M, E>
+// where
+// Self: DynBind<E>,
+// E: Environment,
+// I: StructTypeInfo<'ctx, M, E, S = S>,
+// {
+// #[inline(always)]
+// fn hint<'this, 'visitor, 'hint, 'e>(
+// &'this mut self,
+// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::TypeName, E> + 'c>,
+// _hint: TagHint<tags::TypeName>,
+// ) -> NativeForm<'e, VisitResult, E>
+// where
+// 'ctx: 'this + 'visitor + 'hint + 'e,
+// {
+// todo!()
+// // E::map(
+// // visit_tag::<TagConst<{ TAG_TYPE_NAME.to_int() }>, E, _>(
+// // TagConst,
+// // visitor,
+// // ValueWalker::new(I::NAME),
+// // ),
+// // |status| match status {
+// // Err(err) => {
+// // self.error = Some(StructWalkErrorKind::Tag(err));
+// // Flow::Err
+// // }
+// // Ok(VisitResult::Skipped(_)) => Flow::Continue,
+// // Ok(VisitResult::Control(flow)) => flow,
+// // },
+// // )
+// }
+//
+// #[inline(always)]
+// fn known<'a>(
+// &'a mut self,
+// hint: &'a WithLt<'a, Rank1<()>>,
+// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// where
+// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
+// {
+// E::value(Ok(TagKnown {
+// kind_available: Some(true),
+// }))
+// .cast()
+// }
+// }
+//
+// impl<'c, 'ctx: 'c, I, S, M, E> Hint<'ctx, dyn Tag<'ctx, tags::Map, E> + 'c>
+// for StructWalker<'ctx, I, S, M, E>
+// where
+// Self: DynBind<E>,
+// E: Environment,
+// I: StructTypeInfo<'ctx, M, E, S = S>,
+// {
+// #[inline(always)]
+// fn hint<'this, 'visitor, 'hint, 'e>(
+// &'this mut self,
+// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::Map, E> + 'c>,
+// _hint: TagHint<tags::Map>,
+// ) -> NativeForm<'e, VisitResult, E>
+// where
+// 'ctx: 'this + 'visitor + 'hint + 'e,
+// {
+// todo!()
+// // E::map(
+// // visit_tag::<TagConst<{ TAG_MAP.to_int() }>, E, _>(TagConst, visitor, NoopWalker::new()),
+// // |status| match status {
+// // Err(err) => {
+// // self.error = Some(StructWalkErrorKind::Tag(err));
+// // Flow::Err
+// // }
+// // Ok(VisitResult::Skipped(_)) => Flow::Continue,
+// // Ok(VisitResult::Control(flow)) => flow,
+// // },
+// // )
+// }
+//
+// #[inline(always)]
+// fn known<'a>(
+// &'a mut self,
+// hint: &'a WithLt<'a, Rank1<()>>,
+// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// where
+// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
+// {
+// E::value(Ok(TagKnown {
+// kind_available: Some(true),
+// }))
+// .cast()
+// }
+// }
+//
+// impl<'c, 'ctx: 'c, I, S, M, E> Hint<'ctx, dyn Tag<'ctx, tags::Struct, E> + 'c>
+// for StructWalker<'ctx, I, S, M, E>
+// where
+// Self: DynBind<E>,
+// E: Environment,
+// I: StructTypeInfo<'ctx, M, E, S = S>,
+// {
+// #[inline(always)]
+// fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+// &'this mut self,
+// visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::Struct, E> + 'c>,
+// _hint: TagHint<tags::Struct>,
+// ) -> NativeForm<'e, VisitResult, E>
+// where
+// 'ctx: 'this + 'visitor + 'hint + 'e,
+// {
+// E::with(
+// (visitor, DynWalkerAdapter::new(NoopWalker::new())),
+// |(visitor, noop_walker)| {
+// visitor
+// .as_known()
+// .visit(TagConst, noop_walker)
+// .map((), |_, status| {
+// VisitResult::Control(status.to_flow().unwrap_or(Flow::Continue))
+// })
+// .cast()
+// },
+// )
+// .map((), |_, (_, x)| x)
+// .cast()
+// }
+//
+// #[inline(always)]
+// fn known<'a>(
+// &'a mut self,
+// hint: &'a WithLt<'a, Rank1<()>>,
+// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// where
+// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
+// {
+// E::value(Ok(TagKnown {
+// kind_available: Some(true),
+// }))
+// .cast()
+// }
+// }
+//
+// impl<'c, 'ctx: 'c, I, M, E> Hint<'ctx, dyn Tag<'ctx, tags::TypeId, E> + 'c>
+// for StructWalker<'ctx, I, StaticType, M, E>
+// where
+// Self: DynBind<E>,
+// E: Environment,
+// I: StructTypeInfo<'ctx, M, E, S = StaticType>,
+// I::T: 'static,
+// {
+// #[inline(always)]
+// fn hint<'this, 'visitor, 'hint, 'e>(
+// &'this mut self,
+// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, tags::TypeId, E> + 'c>,
+// _hint: TagHint<tags::TypeId>,
+// ) -> NativeForm<'e, VisitResult, E>
+// where
+// 'ctx: 'this + 'visitor + 'hint + 'e,
+// {
+// todo!()
+// // E::map(
+// // visit_tag::<TagConst<{ TAG_TYPE_ID.to_int() }>, E, _>(
+// // TagConst,
+// // visitor,
+// // ValueWalker::new(TypeId::of::<I::T>()),
+// // ),
+// // |status| match status {
+// // Err(err) => {
+// // self.error = Some(StructWalkErrorKind::Tag(err));
+// // Flow::Err
+// // }
+// // Ok(VisitResult::Skipped(_)) => Flow::Continue,
+// // Ok(VisitResult::Control(flow)) => flow,
+// // },
+// // )
+// }
+//
+// #[inline(always)]
+// fn known<'a>(
+// &'a mut self,
+// hint: &'a WithLt<'a, Rank1<()>>,
+// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// where
+// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
+// {
+// E::value(Ok(TagKnown {
+// kind_available: Some(true),
+// }))
+// .cast()
+// }
+// }
+//
+// impl<'c, 'ctx: 'c, I, M, E> Hint<'ctx, dyn Tag<'ctx, TagDyn, E> + 'c> for StructWalker<'ctx, I, StaticType, M, E>
+// where
+// Self: DynBind<E>,
+// E: Environment,
+// I: StructTypeInfo<'ctx, M, E, S = StaticType>,
+// I::T: 'static,
+// {
+// #[inline(always)]
+// fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
+// &'this mut self,
+// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Tag<'ctx, TagDyn, E> + 'c>,
+// _hint: TagHint<TagDyn>,
+// ) -> NativeForm<'e, VisitResult, E>
+// where
+// 'ctx: 'this + 'visitor + 'hint + 'e,
+// {
+// todo!()
+// // match hint.kind.0 {
+// // crate::TAG_TYPE_ID => {
+// // Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>::hint(
+// // self,
+// // visitor,
+// // TagHint { kind: TagConst },
+// // )
+// // }
+// // crate::TAG_STRUCT => {
+// // Hint::<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>::hint(
+// // self,
+// // visitor,
+// // TagHint { kind: TagConst },
+// // )
+// // }
+// // crate::TAG_MAP => Hint::<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>::hint(
+// // self,
+// // visitor,
+// // TagHint { kind: TagConst },
+// // ),
+// // crate::TAG_TYPE_NAME => {
+// // Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>::hint(
+// // self,
+// // visitor,
+// // TagHint { kind: TagConst },
+// // )
+// // }
+// // crate::TAG_FIELD_NAMES => Hint::<
+// // 'ctx,
+// // TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>,
+// // >::hint(self, visitor, TagHint { kind: TagConst }),
+// // _ => E::ready(Flow::Continue),
+// // }
+// }
+//
+// #[inline(always)]
+// fn known<'a>(
+// &'a mut self,
+// hint: &'a WithLt<'a, Rank1<TagHint<TagDyn>>>,
+// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<TagKnown>>, ()>, Protocol::Env>
+// where
+// WithLt<'a, Rank1<TagKnown>>: DynBind<Protocol::Env>
+// {
+// E::value(match hint.kind {
+// TagDyn(tags::TypeId::VALUE) | TagDyn(tags::Struct::VALUE) => Ok(TagKnown {
+// kind_available: Some(true),
+// }),
+// _ => Ok(TagKnown {
+// kind_available: Some(false),
+// }),
+// })
+// .cast()
+// }
+// }
+//
+// impl<'x, 'ctx: 'x, I, M, E> Hint<'ctx, dyn Value<'ctx, BorrowedStatic<'ctx, I::T>, E> + 'x>
+// for StructWalker<'ctx, I, StaticType, M, E>
+// where
+// E: Environment,
+// I: StructTypeInfo<'ctx, M, E, S = StaticType>,
+// I::T: 'static,
+// for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, I::T>>: DynBind<E>,
+// Dynamic<&'ctx I::T>: DynBind<E>,
+// {
+// #[inline(always)]
+// fn hint<'this, 'visitor, 'hint, 'e>(
+// &'this mut self,
+// _visitor: DynVisitorWith<'visitor, 'ctx, dyn Value<'ctx, BorrowedStatic<'ctx, I::T>, E> + 'x>,
+// _hint: (),
+// ) -> NativeForm<'e, VisitResult, E>
+// where
+// 'ctx: 'this + 'visitor + 'hint + 'e,
+// {
+// todo!()
+// // E::map(
+// // visit_value::<_, E>(visitor, BorrowedStatic(self.value)),
+// // |status| match status {
+// // VisitResult::Skipped(_) => Flow::Continue,
+// // VisitResult::Control(flow) => flow,
+// // },
+// // )
+// }
+//
+// #[inline(always)]
+// fn known<'a>(
+// &'a mut self,
+// hint: &'a WithLt<'a, Rank1<()>>,
+// ) -> NativeForm<'a, Result<WithLt<'a, Rank1<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>>>, ()>, Protocol::Env>
+// where
+// WithLt<'a, Rank1<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>>>: DynBind<Protocol::Env>
+// {
+// E::value(Ok(ValueKnown { preview: None })).cast()
+// }
+// }
+
+impl<'ctx, I, S, M: 'ctx, E> Hint<'ctx, type_name::Raised<'static, 'ctx, dyn Sequence<'ctx, E>>>
for StructWalker<'ctx, I, S, M, E>
where
Self: DynBind<E>,
@@ -379,215 +597,15 @@ where
I: StructTypeInfo<'ctx, M, E, S = S>,
{
#[inline(always)]
- fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
- &'this mut self,
- visitor: DynVisitorWith<'visitor, 'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>,
- _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>,
- ) -> NativeForm<'e, VisitResult, E>
- where
- 'ctx: 'this + 'visitor + 'hint + 'e,
- {
- E::with(
- (visitor, DynWalkerAdapter::new(NoopWalker::new())),
- |(visitor, noop_walker)| {
- visitor
- .as_known()
- .visit(TagConst, noop_walker)
- .map((), |_, status| {
- VisitResult::Control(status.to_flow().unwrap_or(Flow::Continue))
- })
- .cast()
- },
- )
- .map((), |_, (_, x)| x)
- .cast()
- }
-
- #[inline(always)]
- fn known<'a>(
- &'a mut self,
- _hint: &'a <TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E> as HintMeta>::Hint,
- ) -> NativeForm<
- 'a,
- Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>, ()>,
- E,
- > {
- E::value(Ok(TagKnown {
- kind_available: Some(true),
- }))
- .cast()
- }
-}
-
-impl<'ctx, I, M, E> Hint<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>
- for StructWalker<'ctx, I, StaticType, M, E>
-where
- Self: DynBind<E>,
- E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = StaticType>,
- I::T: 'static,
-{
- #[inline(always)]
- fn hint<'this, 'visitor, 'hint, 'e>(
- &'this mut self,
- _visitor: DynVisitorWith<'visitor, 'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>,
- _hint: MetaHint<'hint, 'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>,
- ) -> NativeForm<'e, VisitResult, E>
- where
- 'ctx: 'this + 'visitor + 'hint + 'e,
- {
- todo!()
- // E::map(
- // visit_tag::<TagConst<{ TAG_TYPE_ID.to_int() }>, E, _>(
- // TagConst,
- // visitor,
- // ValueWalker::new(TypeId::of::<I::T>()),
- // ),
- // |status| match status {
- // Err(err) => {
- // self.error = Some(StructWalkErrorKind::Tag(err));
- // Flow::Err
- // }
- // Ok(VisitResult::Skipped(_)) => Flow::Continue,
- // Ok(VisitResult::Control(flow)) => flow,
- // },
- // )
- }
-
- #[inline(always)]
- fn known<'a>(
- &'a mut self,
- _hint: &'a <TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E> as HintMeta>::Hint,
- ) -> NativeForm<
- 'a,
- Result<MetaKnown<'a, 'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>, ()>,
- E,
- > {
- E::value(Ok(TagKnown {
- kind_available: Some(true),
- }))
- .cast()
- }
-}
-
-impl<'ctx, I, M, E> Hint<'ctx, TagProto<TagDyn, E>> for StructWalker<'ctx, I, StaticType, M, E>
-where
- Self: DynBind<E>,
- E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = StaticType>,
- I::T: 'static,
-{
- #[inline(always)]
- fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
- &'this mut self,
- _visitor: DynVisitorWith<'visitor, 'ctx, TagProto<TagDyn, E>>,
- _hint: MetaHint<'hint, 'ctx, TagProto<TagDyn, E>>,
- ) -> NativeForm<'e, VisitResult, E>
- where
- 'ctx: 'this + 'visitor + 'hint + 'e,
- {
- todo!()
- // match hint.kind.0 {
- // crate::TAG_TYPE_ID => {
- // Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_ID.to_int() }>, E>>::hint(
- // self,
- // visitor,
- // TagHint { kind: TagConst },
- // )
- // }
- // crate::TAG_STRUCT => {
- // Hint::<'ctx, TagProto<TagConst<{ TAG_STRUCT.to_int() }>, E>>::hint(
- // self,
- // visitor,
- // TagHint { kind: TagConst },
- // )
- // }
- // crate::TAG_MAP => Hint::<'ctx, TagProto<TagConst<{ TAG_MAP.to_int() }>, E>>::hint(
- // self,
- // visitor,
- // TagHint { kind: TagConst },
- // ),
- // crate::TAG_TYPE_NAME => {
- // Hint::<'ctx, TagProto<TagConst<{ TAG_TYPE_NAME.to_int() }>, E>>::hint(
- // self,
- // visitor,
- // TagHint { kind: TagConst },
- // )
- // }
- // crate::TAG_FIELD_NAMES => Hint::<
- // 'ctx,
- // TagProto<TagConst<{ TAG_FIELD_NAMES.to_int() }>, E>,
- // >::hint(self, visitor, TagHint { kind: TagConst }),
- // _ => E::ready(Flow::Continue),
- // }
- }
-
- #[inline(always)]
- fn known<'a>(
- &'a mut self,
- hint: &'a <TagProto<TagDyn, E> as HintMeta>::Hint,
- ) -> NativeForm<'a, Result<MetaKnown<'a, 'ctx, TagProto<TagDyn, E>>, ()>, E> {
- E::value(match hint.kind {
- TagDyn(crate::TAG_TYPE_ID) | TagDyn(crate::TAG_STRUCT) => Ok(TagKnown {
- kind_available: Some(true),
- }),
- _ => Ok(TagKnown {
- kind_available: Some(false),
- }),
- })
- .cast()
- }
-}
-
-impl<'ctx, I, M, E> Hint<'ctx, ValueProto<BorrowedStaticHrt<I::T>, E>>
- for StructWalker<'ctx, I, StaticType, M, E>
-where
- E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = StaticType>,
- I::T: 'static,
- for<'a, 'b> Dynamic<&'a BorrowedStatic<'b, I::T>>: DynBind<E>,
- Dynamic<&'ctx I::T>: DynBind<E>,
-{
- #[inline(always)]
- fn hint<'this, 'visitor, 'hint, 'e>(
- &'this mut self,
- _visitor: DynVisitorWith<'visitor, 'ctx, ValueProto<BorrowedStaticHrt<I::T>, E>>,
- _hint: MetaHint<'hint, 'ctx, ValueProto<BorrowedStaticHrt<I::T>, E>>,
- ) -> NativeForm<'e, VisitResult, E>
- where
- 'ctx: 'this + 'visitor + 'hint + 'e,
- {
- todo!()
- // E::map(
- // visit_value::<_, E>(visitor, BorrowedStatic(self.value)),
- // |status| match status {
- // VisitResult::Skipped(_) => Flow::Continue,
- // VisitResult::Control(flow) => flow,
- // },
- // )
- }
-
- #[inline(always)]
- fn known<'a>(
- &'a mut self,
- _hint: &'a (),
- ) -> NativeForm<'a, Result<ValueKnown<'a, BorrowedStatic<'ctx, I::T>>, ()>, E> {
- E::value(Ok(ValueKnown { preview: None })).cast()
- }
-}
-
-impl<'ctx, I, S, M: 'ctx, E> Hint<'ctx, SequenceProto<E>> for StructWalker<'ctx, I, S, M, E>
-where
- Self: DynBind<E>,
- E: Environment,
- I: StructTypeInfo<'ctx, M, E, S = S>,
-{
- #[inline(always)]
fn hint<'this: 'e, 'visitor: 'e, 'hint: 'e, 'e>(
&'this mut self,
- visitor: DynVisitorWith<'visitor, 'ctx, SequenceProto<E>>,
- _hint: MetaHint<'hint, 'ctx, SequenceProto<E>>,
+ visitor: DynVisitorWith<
+ 'visitor,
+ 'ctx,
+ type_name::Raised<'static, 'ctx, dyn Sequence<'ctx, E>>,
+ >,
+ _hint: SequenceHint,
) -> NativeForm<'e, VisitResult, E>
where
'ctx: 'this + 'visitor + 'hint + 'e,
@@ -612,8 +630,11 @@ where
#[inline(always)]
fn known<'a>(
&'a mut self,
- _hint: &'a <SequenceProto<E> as HintMeta>::Hint,
- ) -> NativeForm<'a, Result<MetaKnown<'a, 'ctx, SequenceProto<E>>, ()>, E> {
+ hint: &'a WithLt<'a, Rank1<SequenceHint>>,
+ ) -> NativeForm<'a, Result<WithLt<'a, Rank1<SequenceKnown>>, ()>, E>
+ where
+ WithLt<'a, Rank1<SequenceKnown>>: DynBind<E>,
+ {
let len = I::FIELDS.len();
E::value(Ok(SequenceKnown {
@@ -709,7 +730,7 @@ where
})
.cast::<()>()
.if_not_finished((), |_, (this, visitor)| {
- visit_tag::<TagConst<{ TAG_TYPE_ID.to_int() }>, E, _>(
+ visit_tag::<tags::TypeId, E, _>(
TagConst,
visitor.cast(),
ValueWalker::new(TypeId::of::<I::T>()),
@@ -721,27 +742,19 @@ where
})
.cast::<()>()
.if_not_finished((), |_, (this, visitor)| {
- visit_tag::<TagConst<{ TAG_STRUCT.to_int() }>, E, _>(
- TagConst,
- visitor.cast(),
- NoopWalker::new(),
- )
- .map(this, |this, result| {
- this.record_tag_error(result).unit_skipped()
- })
- .cast()
+ visit_tag::<tags::Struct, E, _>(TagConst, visitor.cast(), NoopWalker::new())
+ .map(this, |this, result| {
+ this.record_tag_error(result).unit_skipped()
+ })
+ .cast()
})
.cast::<()>()
.if_skipped((), |_, (this, visitor)| {
- visit_tag::<TagConst<{ TAG_MAP.to_int() }>, E, _>(
- TagConst,
- visitor.cast(),
- NoopWalker::new(),
- )
- .map(this, |this, result| {
- this.record_tag_error(result).unit_skipped()
- })
- .cast()
+ visit_tag::<tags::Map, E, _>(TagConst, visitor.cast(), NoopWalker::new())
+ .map(this, |this, result| {
+ this.record_tag_error(result).unit_skipped()
+ })
+ .cast()
})
.cast::<()>()
.if_not_finished((), |_, (this, visitor)| {