use super::call::*;
use {kutil::std::immutable::*, ordered_float::*, std::collections::*};
#[derive(Clone, Debug, Default)]
pub enum Expression {
#[default]
Undefined,
Null,
Integer(i64),
UnsignedInteger(u64),
Float(OrderedFloat<f64>),
Boolean(bool),
Text(ByteString),
Blob(Bytes),
List(Vec<Expression>),
Map(BTreeMap<Expression, Expression>),
Custom(ByteString, Box<Expression>),
Call(Call),
}
impl Expression {
pub fn is_literal(&self) -> bool {
match self {
Expression::List(list) => {
for item in list {
if !item.is_literal() {
return false;
}
}
true
}
Expression::Map(map) => {
for (key, value) in map {
if !key.is_literal() {
return false;
}
if !value.is_literal() {
return false;
}
}
true
}
Expression::Custom(_kind, inner) => inner.is_literal(),
Expression::Call(call) => matches!(call.kind, CallKind::Lazy),
_ => true,
}
}
}