Refactor frontend/middleware types (#194)
* unify fe/be NativeOp and NativePred * remove Origin in favour of PodId * Combine string and hash in Key * use middleware::AnchoredKey in frontend * merge frontend/middleware types * refactor custom predicates * clean up a bit * fix middleware custom tests * clean up * clean up 2 * add acronyms in typos list
This commit is contained in:
parent
9e860ef262
commit
c232c8dae5
33 changed files with 1985 additions and 2800 deletions
|
|
@ -1,13 +1,13 @@
|
|||
use std::fmt;
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
// use serde::{Deserialize, Serialize};
|
||||
use crate::middleware::{
|
||||
self, AnchoredKey, NativePredicate, Params, Predicate, StatementArg, ToFields,
|
||||
self, NativePredicate, Params, Predicate, StatementArg, ToFields, WildcardValue,
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Statement(pub Predicate, pub Vec<StatementArg>);
|
||||
|
||||
impl Statement {
|
||||
|
|
@ -81,15 +81,15 @@ impl TryFrom<Statement> for middleware::Statement {
|
|||
_ => Err(anyhow!("Ill-formed statement expression {:?}", s))?,
|
||||
},
|
||||
Predicate::Custom(cpr) => {
|
||||
let aks: Vec<AnchoredKey> = proper_args
|
||||
let vs: Vec<WildcardValue> = proper_args
|
||||
.into_iter()
|
||||
.filter_map(|arg| match arg {
|
||||
SA::None => None,
|
||||
SA::Key(ak) => Some(ak),
|
||||
SA::Literal(_) => unreachable!(),
|
||||
SA::WildcardLiteral(v) => Some(v),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.collect();
|
||||
S::Custom(cpr, aks)
|
||||
S::Custom(cpr, vs)
|
||||
}
|
||||
Predicate::BatchSelf(_) => {
|
||||
unreachable!()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue