From 922199ab322efa7b62bf4698cf5ed9e2d7a378c0 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 7 Dec 2020 15:24:36 +0000 Subject: Unify `skip_resolve_expr` with normal resolution --- dhall/src/lib.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'dhall/src/lib.rs') diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 7f77334..c27b633 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -58,6 +58,11 @@ pub struct ToExprOptions { } impl Parsed { + /// Construct from an `Expr`. This `Expr` will have imports disabled. + pub fn from_expr_without_imports(e: Expr) -> Self { + Parsed(e, ImportLocation::dhall_code_without_imports()) + } + pub fn parse_file(f: &Path) -> Result { parse::parse_file(f) } @@ -78,8 +83,11 @@ impl Parsed { pub fn resolve<'cx>(self, cx: Ctxt<'cx>) -> Result, Error> { resolve::resolve(cx, self) } - pub fn skip_resolve<'cx>(self) -> Result, Error> { - resolve::skip_resolve(self) + pub fn skip_resolve<'cx>( + self, + cx: Ctxt<'cx>, + ) -> Result, Error> { + resolve::skip_resolve(cx, self) } /// Converts a value back to the corresponding AST expression. @@ -122,6 +130,9 @@ impl<'cx> Typed<'cx> { self.hir.to_expr(cx, ToExprOptions { alpha: false }) } + pub fn as_hir(&self) -> &Hir<'cx> { + &self.hir + } pub fn ty(&self) -> &Type<'cx> { &self.ty } -- cgit v1.2.3