use vize_l0::{Span, String};
use crate::expr::{ExprRef, OpaqueReason};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Expr {
Js {
source: String,
span: Span,
},
Foreign {
dialect: String,
source: String,
span: Span,
},
Opaque {
reason: OpaqueReason,
source: String,
span: Span,
},
Filter {
source: String,
span: Span,
},
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ForBinding {
pub source: Expr,
pub value: Expr,
pub key: Option<Expr>,
pub index: Option<Expr>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Contract {
pub read: Expr,
pub write: Expr,
}
pub(in crate::dump) fn own_expr(expr: &ExprRef<'_>) -> Expr {
match expr {
ExprRef::Js(js) => Expr::Js {
source: String::from(js.source),
span: js.span,
},
ExprRef::Foreign(foreign) => Expr::Foreign {
dialect: String::from(foreign.dialect),
source: String::from(foreign.source),
span: foreign.span,
},
ExprRef::Opaque(opaque) => Expr::Opaque {
reason: opaque.reason,
source: String::from(opaque.source),
span: opaque.span,
},
ExprRef::Filter(filter) => Expr::Filter {
source: String::from(filter.source),
span: filter.span,
},
}
}