summaryrefslogtreecommitdiff
path: root/dhall_generator/src
diff options
context:
space:
mode:
authorNadrieril2019-03-31 19:08:08 +0200
committerNadrieril2019-03-31 19:08:08 +0200
commit7374d0524ccd53b256107667b213597c05720d2d (patch)
tree69dc0e324ffbe3ecf928c62f4e900000f11c5386 /dhall_generator/src
parentbfe3f7f75570540fa184a133653d16e86f22667a (diff)
Move recursion out of Expr
Diffstat (limited to 'dhall_generator/src')
-rw-r--r--dhall_generator/src/dhall_expr.rs36
-rw-r--r--dhall_generator/src/dhall_type.rs4
2 files changed, 20 insertions, 20 deletions
diff --git a/dhall_generator/src/dhall_expr.rs b/dhall_generator/src/dhall_expr.rs
index e2187d6..c4b15e8 100644
--- a/dhall_generator/src/dhall_expr.rs
+++ b/dhall_generator/src/dhall_expr.rs
@@ -21,7 +21,7 @@ fn dhall_to_tokenstream(
expr: &DhallExpr,
ctx: &Context<Label, ()>,
) -> TokenStream {
- use dhall_core::Expr::*;
+ use dhall_core::ExprF::*;
match expr.as_ref() {
Var(_) => {
let v = dhall_to_tokenstream_bx(expr, ctx);
@@ -31,66 +31,66 @@ fn dhall_to_tokenstream(
let t = dhall_to_tokenstream_bx(t, ctx);
let b = dhall_to_tokenstream_bx(b, &ctx.insert(x.clone(), ()));
let x = label_to_tokenstream(x);
- quote! { dhall_core::Expr::Pi(#x, #t, #b) }
+ quote! { dhall_core::ExprF::Pi(#x, #t, #b) }
}
Lam(x, t, b) => {
let t = dhall_to_tokenstream_bx(t, ctx);
let b = dhall_to_tokenstream_bx(b, &ctx.insert(x.clone(), ()));
let x = label_to_tokenstream(x);
- quote! { dhall_core::Expr::Lam(#x, #t, #b) }
+ quote! { dhall_core::ExprF::Lam(#x, #t, #b) }
}
App(f, a) => {
let f = dhall_to_tokenstream_bx(f, ctx);
let a = vec_to_tokenstream(a, ctx);
- quote! { dhall_core::Expr::App(#f, #a) }
+ quote! { dhall_core::ExprF::App(#f, #a) }
}
Const(c) => {
let c = const_to_tokenstream(*c);
- quote! { dhall_core::Expr::Const(#c) }
+ quote! { dhall_core::ExprF::Const(#c) }
}
Builtin(b) => {
let b = builtin_to_tokenstream(*b);
- quote! { dhall_core::Expr::Builtin(#b) }
+ quote! { dhall_core::ExprF::Builtin(#b) }
}
BinOp(o, a, b) => {
let o = binop_to_tokenstream(*o);
let a = dhall_to_tokenstream_bx(a, ctx);
let b = dhall_to_tokenstream_bx(b, ctx);
- quote! { dhall_core::Expr::BinOp(#o, #a, #b) }
+ quote! { dhall_core::ExprF::BinOp(#o, #a, #b) }
}
NaturalLit(n) => {
- quote! { dhall_core::Expr::NaturalLit(#n) }
+ quote! { dhall_core::ExprF::NaturalLit(#n) }
}
BoolLit(b) => {
- quote! { dhall_core::Expr::BoolLit(#b) }
+ quote! { dhall_core::ExprF::BoolLit(#b) }
}
EmptyOptionalLit(x) => {
let x = dhall_to_tokenstream_bx(x, ctx);
- quote! { dhall_core::Expr::EmptyOptionalLit(#x) }
+ quote! { dhall_core::ExprF::EmptyOptionalLit(#x) }
}
NEOptionalLit(x) => {
let x = dhall_to_tokenstream_bx(x, ctx);
- quote! { dhall_core::Expr::NEOptionalLit(#x) }
+ quote! { dhall_core::ExprF::NEOptionalLit(#x) }
}
EmptyListLit(t) => {
let t = dhall_to_tokenstream_bx(t, ctx);
- quote! { dhall_core::Expr::EmptyListLit(#t) }
+ quote! { dhall_core::ExprF::EmptyListLit(#t) }
}
NEListLit(es) => {
let es = vec_to_tokenstream(es, ctx);
- quote! { dhall_core::Expr::NEListLit(#es) }
+ quote! { dhall_core::ExprF::NEListLit(#es) }
}
RecordType(m) => {
let m = map_to_tokenstream(m, ctx);
- quote! { dhall_core::Expr::RecordType(#m) }
+ quote! { dhall_core::ExprF::RecordType(#m) }
}
RecordLit(m) => {
let m = map_to_tokenstream(m, ctx);
- quote! { dhall_core::Expr::RecordLit(#m) }
+ quote! { dhall_core::ExprF::RecordLit(#m) }
}
UnionType(m) => {
let m = map_to_tokenstream(m, ctx);
- quote! { dhall_core::Expr::UnionType(#m) }
+ quote! { dhall_core::ExprF::UnionType(#m) }
}
e => unimplemented!("{:?}", e),
}
@@ -101,7 +101,7 @@ fn dhall_to_tokenstream_bx(
expr: &DhallExpr,
ctx: &Context<Label, ()>,
) -> TokenStream {
- use dhall_core::Expr::*;
+ use dhall_core::ExprF::*;
match expr.as_ref() {
Var(V(s, n)) => {
match ctx.lookup(&s, *n) {
@@ -109,7 +109,7 @@ fn dhall_to_tokenstream_bx(
Some(()) => {
let s: String = s.into();
let var = quote! { dhall_core::V(#s.into(), #n) };
- bx(quote! { dhall_core::Expr::Var(#var) })
+ bx(quote! { dhall_core::ExprF::Var(#var) })
}
// Free variable; interpolates as a rust variable
None => {
diff --git a/dhall_generator/src/dhall_type.rs b/dhall_generator/src/dhall_type.rs
index 270c27c..876d261 100644
--- a/dhall_generator/src/dhall_type.rs
+++ b/dhall_generator/src/dhall_type.rs
@@ -48,7 +48,7 @@ pub fn derive_for_struct(
);
}
});
- Ok(quote! { dhall_core::rc(dhall_core::Expr::RecordType({
+ Ok(quote! { dhall_core::rc(dhall_core::ExprF::RecordType({
use std::collections::BTreeMap;
let mut m = BTreeMap::new();
#(#fields)*
@@ -101,7 +101,7 @@ pub fn derive_for_enum(
})
.collect::<Result<Vec<_>, Error>>()?;
- Ok(quote! { dhall_core::rc(dhall_core::Expr::UnionType({
+ Ok(quote! { dhall_core::rc(dhall_core::ExprF::UnionType({
use std::collections::BTreeMap;
let mut m = BTreeMap::new();
#(#variants)*