Pre: Handle SrcVar.
This commit is contained in:
parent
a10c6fc67a
commit
08534a1a3a
2 changed files with 40 additions and 14 deletions
|
@ -50,7 +50,7 @@ impl ConjoiningClauses {
|
||||||
},
|
},
|
||||||
// Can't be an entid.
|
// Can't be an entid.
|
||||||
EntidOrInteger(i) => Ok(QueryValue::TypedValue(TypedValue::Long(i))),
|
EntidOrInteger(i) => Ok(QueryValue::TypedValue(TypedValue::Long(i))),
|
||||||
Ident(_) |
|
IdentOrKeyword(_) |
|
||||||
SrcVar(_) |
|
SrcVar(_) |
|
||||||
Constant(NonIntegerConstant::Boolean(_)) |
|
Constant(NonIntegerConstant::Boolean(_)) |
|
||||||
Constant(NonIntegerConstant::Text(_)) |
|
Constant(NonIntegerConstant::Text(_)) |
|
||||||
|
@ -78,7 +78,7 @@ impl ConjoiningClauses {
|
||||||
.ok_or_else(|| Error::from_kind(ErrorKind::UnboundVariable(var.name())))
|
.ok_or_else(|| Error::from_kind(ErrorKind::UnboundVariable(var.name())))
|
||||||
},
|
},
|
||||||
EntidOrInteger(i) => Ok(QueryValue::PrimitiveLong(i)),
|
EntidOrInteger(i) => Ok(QueryValue::PrimitiveLong(i)),
|
||||||
Ident(_) => unimplemented!(), // TODO
|
IdentOrKeyword(_) => unimplemented!(), // TODO
|
||||||
Constant(NonIntegerConstant::Boolean(val)) => Ok(QueryValue::TypedValue(TypedValue::Boolean(val))),
|
Constant(NonIntegerConstant::Boolean(val)) => Ok(QueryValue::TypedValue(TypedValue::Boolean(val))),
|
||||||
Constant(NonIntegerConstant::Float(f)) => Ok(QueryValue::TypedValue(TypedValue::Double(f))),
|
Constant(NonIntegerConstant::Float(f)) => Ok(QueryValue::TypedValue(TypedValue::Double(f))),
|
||||||
Constant(NonIntegerConstant::Text(s)) => Ok(QueryValue::TypedValue(TypedValue::typed_string(s.as_str()))),
|
Constant(NonIntegerConstant::Text(s)) => Ok(QueryValue::TypedValue(TypedValue::typed_string(s.as_str()))),
|
||||||
|
|
|
@ -174,7 +174,11 @@ impl FromValue<SrcVar> for SrcVar {
|
||||||
impl SrcVar {
|
impl SrcVar {
|
||||||
pub fn from_symbol(sym: &PlainSymbol) -> Option<SrcVar> {
|
pub fn from_symbol(sym: &PlainSymbol) -> Option<SrcVar> {
|
||||||
if sym.is_src_symbol() {
|
if sym.is_src_symbol() {
|
||||||
Some(SrcVar::NamedSrc(sym.plain_name().to_string()))
|
if sym.0 == "$" {
|
||||||
|
Some(SrcVar::DefaultSrc)
|
||||||
|
} else {
|
||||||
|
Some(SrcVar::NamedSrc(sym.plain_name().to_string()))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -210,22 +214,44 @@ pub enum FnArg {
|
||||||
Variable(Variable),
|
Variable(Variable),
|
||||||
SrcVar(SrcVar),
|
SrcVar(SrcVar),
|
||||||
EntidOrInteger(i64),
|
EntidOrInteger(i64),
|
||||||
Ident(NamespacedKeyword),
|
IdentOrKeyword(NamespacedKeyword),
|
||||||
Constant(NonIntegerConstant),
|
Constant(NonIntegerConstant),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromValue<FnArg> for FnArg {
|
impl FromValue<FnArg> for FnArg {
|
||||||
fn from_value(v: &edn::ValueAndSpan) -> Option<FnArg> {
|
fn from_value(v: &edn::ValueAndSpan) -> Option<FnArg> {
|
||||||
// TODO: support SrcVars.
|
use edn::SpannedValue::*;
|
||||||
Variable::from_value(v)
|
match v.inner {
|
||||||
.and_then(|v| Some(FnArg::Variable(v)))
|
Integer(x) =>
|
||||||
.or_else(|| {
|
Some(FnArg::EntidOrInteger(x)),
|
||||||
println!("from_value {}", v.inner);
|
PlainSymbol(ref x) if x.is_src_symbol() =>
|
||||||
match v.inner {
|
SrcVar::from_symbol(x).map(FnArg::SrcVar),
|
||||||
edn::SpannedValue::Integer(i) => Some(FnArg::EntidOrInteger(i)),
|
PlainSymbol(ref x) if x.is_var_symbol() =>
|
||||||
edn::SpannedValue::Float(f) => Some(FnArg::Constant(NonIntegerConstant::Float(f))),
|
Variable::from_symbol(x).map(FnArg::Variable),
|
||||||
_ => unimplemented!(),
|
PlainSymbol(_) => None,
|
||||||
}})
|
NamespacedKeyword(ref x) =>
|
||||||
|
Some(FnArg::IdentOrKeyword(x.clone())),
|
||||||
|
Instant(x) =>
|
||||||
|
Some(FnArg::Constant(NonIntegerConstant::Instant(x))),
|
||||||
|
Uuid(x) =>
|
||||||
|
Some(FnArg::Constant(NonIntegerConstant::Uuid(x))),
|
||||||
|
Boolean(x) =>
|
||||||
|
Some(FnArg::Constant(NonIntegerConstant::Boolean(x))),
|
||||||
|
Float(x) =>
|
||||||
|
Some(FnArg::Constant(NonIntegerConstant::Float(x))),
|
||||||
|
BigInteger(ref x) =>
|
||||||
|
Some(FnArg::Constant(NonIntegerConstant::BigInteger(x.clone()))),
|
||||||
|
Text(ref x) =>
|
||||||
|
// TODO: intern strings. #398.
|
||||||
|
Some(FnArg::Constant(NonIntegerConstant::Text(Rc::new(x.clone())))),
|
||||||
|
Nil |
|
||||||
|
NamespacedSymbol(_) |
|
||||||
|
Keyword(_) |
|
||||||
|
Vector(_) |
|
||||||
|
List(_) |
|
||||||
|
Set(_) |
|
||||||
|
Map(_) => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue