rstd::external_points

This commit is contained in:
AF 2023-07-29 10:30:43 +00:00
parent c595be270c
commit 79f1fadf0a
3 changed files with 23 additions and 17 deletions

View File

@ -3,6 +3,7 @@
pub mod atomic; pub mod atomic;
pub mod cast; pub mod cast;
pub mod collections; pub mod collections;
mod external_points;
pub mod inject; pub mod inject;
pub mod inlining; pub mod inlining;
mod local_origin; mod local_origin;

View File

@ -2,6 +2,7 @@
use crate::func::{context::*, controlflow::ControlFlow}; use crate::func::{context::*, controlflow::ControlFlow};
use crate::rcore::*; use crate::rcore::*;
use crate::rstd::external_points::*;
use crate::rstd::{inlining::*, nullable::*, point::*, *}; use crate::rstd::{inlining::*, nullable::*, point::*, *};
/// Node containing a (nullable) reference to the next node and an element. /// Node containing a (nullable) reference to the next node and an element.
@ -35,10 +36,6 @@ impl<'a, Ctx: Context<'a>, A: StackCompatible<'a, Ctx>> Serializable for StackNo
} }
} }
pub trait ExternalPoints<'a, Ctx: Context<'a>, T: MentionableBase<'a, Ctx>> {
fn ex_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>);
}
pub trait StackCompatible<'a, Ctx: Context<'a>>: pub trait StackCompatible<'a, Ctx: Context<'a>>:
Mentionable<'a, Ctx> + ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>> Mentionable<'a, Ctx> + ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>>
{ {
@ -52,21 +49,17 @@ impl<
{ {
} }
pub trait ExternalPointsProxy<'a, Ctx: Context<'a>, T>: FactoryProxy<'a, Ctx>
where
Self::F: Factory<'a, Ctx>,
{
fn exp_points_typed(stack: &T, points: &mut impl PointsVisitor<'a, Ctx>);
}
impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>> impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> ExternalPoints<'a, Ctx, Stack<'a, Ctx, Self>>
for A for A
where where
<Fctr<'a, Ctx, A> as WithParseMode>::WithMode: <Fctr<'a, Ctx, A> as WithParseMode>::WithMode:
ExternalPointsProxy<'a, Ctx, Stack<'a, Ctx, A>, F = Fctr<'a, Ctx, A>>, ExternalPointsProxy<'a, Ctx, Stack<'a, Ctx, A>, F = Fctr<'a, Ctx, A>>,
{ {
fn ex_points_typed(stack: &Stack<'a, Ctx, Self>, points: &mut impl PointsVisitor<'a, Ctx>) { fn ex_points_typed(
<<Fctr<'a, Ctx, A> as WithParseMode>::WithMode as ExternalPointsProxy<'a, Ctx, _>>::exp_points_typed(stack, points) mentionable: &Stack<'a, Ctx, Self>,
points: &mut impl PointsVisitor<'a, Ctx>,
) {
<<Fctr<'a, Ctx, A> as WithParseMode>::WithMode as ExternalPointsProxy<'a, Ctx, _>>::exp_points_typed(mentionable, points)
} }
} }
@ -76,10 +69,10 @@ where
F::Mtbl: MentionableTop<'a, Ctx>, F::Mtbl: MentionableTop<'a, Ctx>,
{ {
fn exp_points_typed( fn exp_points_typed(
stack: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>, mentionable: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>,
points: &mut impl PointsVisitor<'a, Ctx>, points: &mut impl PointsVisitor<'a, Ctx>,
) { ) {
stack.points_typed(points) mentionable.points_typed(points)
} }
} }
@ -89,10 +82,10 @@ where
F::Mtbl: MentionableTop<'a, Ctx>, F::Mtbl: MentionableTop<'a, Ctx>,
{ {
fn exp_points_typed( fn exp_points_typed(
stack: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>, mentionable: &Stack<'a, Ctx, Mtbl<'a, Ctx, Self::F>>,
points: &mut impl PointsVisitor<'a, Ctx>, points: &mut impl PointsVisitor<'a, Ctx>,
) { ) {
stack.points_typed(points) mentionable.points_typed(points)
} }
} }

View File

@ -0,0 +1,12 @@
use crate::rcore::*;
pub trait ExternalPoints<'a, Ctx: Context<'a>, T: MentionableBase<'a, Ctx>> {
fn ex_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>);
}
pub trait ExternalPointsProxy<'a, Ctx: Context<'a>, T>: FactoryProxy<'a, Ctx>
where
Self::F: Factory<'a, Ctx>,
{
fn exp_points_typed(mentionable: &T, points: &mut impl PointsVisitor<'a, Ctx>);
}