Add lifetime to Caches.
This commit is contained in:
parent
e4d492c727
commit
07d3dd6882
@ -2,9 +2,9 @@
|
||||
|
||||
use crate::func::CallableFunction;
|
||||
use crate::{Identifier, StaticVec};
|
||||
use std::collections::BTreeMap;
|
||||
#[cfg(feature = "no_std")]
|
||||
use std::prelude::v1::*;
|
||||
use std::{collections::BTreeMap, marker::PhantomData};
|
||||
|
||||
/// _(internals)_ An entry in a function resolution cache.
|
||||
/// Exported under the `internals` feature only.
|
||||
@ -29,14 +29,14 @@ pub type FnResolutionCache = BTreeMap<u64, Option<FnResolutionCacheEntry>>;
|
||||
/// The following caches are contained inside this type:
|
||||
/// * A stack of [function resolution caches][FnResolutionCache]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Caches(StaticVec<FnResolutionCache>);
|
||||
pub struct Caches<'a>(StaticVec<FnResolutionCache>, PhantomData<&'a ()>);
|
||||
|
||||
impl Caches {
|
||||
impl Caches<'_> {
|
||||
/// Create an empty [`Caches`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
Self(StaticVec::new_const())
|
||||
Self(StaticVec::new_const(), PhantomData)
|
||||
}
|
||||
/// Get the number of function resolution cache(s) in the stack.
|
||||
#[inline(always)]
|
||||
|
@ -7,7 +7,7 @@ use std::prelude::v1::*;
|
||||
|
||||
/// Context of a script evaluation process.
|
||||
#[derive(Debug)]
|
||||
pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> {
|
||||
pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> {
|
||||
/// The current [`Engine`].
|
||||
engine: &'a Engine,
|
||||
/// The current [`Scope`].
|
||||
@ -15,7 +15,7 @@ pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> {
|
||||
/// The current [`GlobalRuntimeState`].
|
||||
global: &'g mut GlobalRuntimeState<'pg>,
|
||||
/// The current [caches][Caches], if available.
|
||||
caches: Option<&'c mut Caches>,
|
||||
caches: Option<&'c mut Caches<'pc>>,
|
||||
/// The current stack of imported [modules][Module].
|
||||
lib: &'a [&'a Module],
|
||||
/// The current bound `this` pointer, if any.
|
||||
@ -24,7 +24,7 @@ pub struct EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> {
|
||||
level: usize,
|
||||
}
|
||||
|
||||
impl<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> {
|
||||
impl<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 'pc, 't, 'pt> {
|
||||
/// Create a new [`EvalContext`].
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
@ -32,7 +32,7 @@ impl<'a, 's, 'ps, 'g, 'pg, 'c, 't, 'pt> EvalContext<'a, 's, 'ps, 'g, 'pg, 'c, 't
|
||||
engine: &'a Engine,
|
||||
scope: &'s mut Scope<'ps>,
|
||||
global: &'g mut GlobalRuntimeState<'pg>,
|
||||
caches: Option<&'c mut Caches>,
|
||||
caches: Option<&'c mut Caches<'pc>>,
|
||||
lib: &'a [&'a Module],
|
||||
this_ptr: &'t mut Option<&'pt mut Dynamic>,
|
||||
level: usize,
|
||||
|
@ -55,7 +55,7 @@ struct OptimizerState<'a> {
|
||||
/// The global runtime state.
|
||||
global: GlobalRuntimeState<'a>,
|
||||
/// Function resolution caches.
|
||||
caches: Caches,
|
||||
caches: Caches<'a>,
|
||||
/// [Module][crate::Module] containing script-defined functions.
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
lib: &'a [&'a crate::Module],
|
||||
|
Loading…
Reference in New Issue
Block a user