Add some runtime types
This commit is contained in:
parent
045dc8fed8
commit
9ea57aa461
|
@ -5,6 +5,7 @@ use crate::{
|
||||||
|
|
||||||
pub mod cost_model;
|
pub mod cost_model;
|
||||||
mod error;
|
mod error;
|
||||||
|
mod runtime;
|
||||||
|
|
||||||
use cost_model::{ExBudget, MachineCosts, StepKind};
|
use cost_model::{ExBudget, MachineCosts, StepKind};
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
use super::cost_model::{CostingFun, ExBudget};
|
||||||
|
|
||||||
|
enum RuntimeScheme {
|
||||||
|
RuntimeSchemeResult,
|
||||||
|
RuntimeSchemeArrow(usize),
|
||||||
|
RuntimeSchemeAll(usize),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(std::cmp::PartialEq)]
|
||||||
|
enum EvalMode {
|
||||||
|
Immediate,
|
||||||
|
Deferred,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct BuiltinRuntimeOptions<T, G> {
|
||||||
|
runtime_scheme: Vec<RuntimeScheme>,
|
||||||
|
immediate_eval: T,
|
||||||
|
deferred_eval: T,
|
||||||
|
budget: fn(CostingFun<G>) -> fn(Vec<u32>) -> ExBudget,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct BuiltinRuntime<T> {
|
||||||
|
runtime_scheme: Vec<RuntimeScheme>,
|
||||||
|
runtime_denotation: T,
|
||||||
|
budget: fn(Vec<u32>) -> ExBudget,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> BuiltinRuntime<T> {
|
||||||
|
fn from_builtin_runtime_options<G>(
|
||||||
|
eval_mode: EvalMode,
|
||||||
|
cost: CostingFun<G>,
|
||||||
|
runtime_options: BuiltinRuntimeOptions<T, G>,
|
||||||
|
) -> BuiltinRuntime<T> {
|
||||||
|
BuiltinRuntime {
|
||||||
|
runtime_scheme: runtime_options.runtime_scheme,
|
||||||
|
runtime_denotation: if eval_mode == EvalMode::Immediate {
|
||||||
|
runtime_options.immediate_eval
|
||||||
|
} else {
|
||||||
|
runtime_options.deferred_eval
|
||||||
|
},
|
||||||
|
budget: (runtime_options.budget)(cost),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue