difftreelog
refactor drop default args parser
in: master
2 files changed
crates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth191920pub mod builtin;20pub mod builtin;21mod native;21mod native;22mod parse;23pub(crate) mod prepared;22pub(crate) mod prepared;242325pub use jrsonnet_ir::function::*;24pub use jrsonnet_ir::function::*;crates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/parse.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-use std::rc::Rc;
-
-use crate::{
- Context, ContextBuilder, Result, Thunk,
- analyze::LFunction,
- evaluate::{destructure::destruct, evaluate},
-};
-
-/// Creates Context with all argument default values applied
-/// and with unbound values causing error to be returned.
-pub fn parse_default_function_call(body_ctx: Context, func: &Rc<LFunction>) -> Result<Context> {
- let fctx = Context::new_future();
- let mut builder = ContextBuilder::extend(body_ctx, func.params.len());
-
- for param in &func.params {
- if let Some(default_expr) = ¶m.default {
- let default_expr = default_expr.clone();
- let fctxc = fctx.clone();
- let thunk = Thunk!(move || {
- let ctx = fctxc.unwrap();
- evaluate(ctx, &default_expr)
- });
- destruct(¶m.destruct, thunk, fctx.clone(), &mut builder);
- } else {
- let name = param.name.clone().unwrap_or_else(|| "<param>".into());
- let thunk = Thunk::errored(
- crate::error::ErrorKind::FunctionParameterNotBoundInCall(
- jrsonnet_ir::function::ParamName::Named(name),
- jrsonnet_ir::function::FunctionSignature::empty(),
- )
- .into(),
- );
- destruct(¶m.destruct, thunk, fctx.clone(), &mut builder);
- }
- }
-
- let ctx = builder.build().into_future(fctx);
- Ok(ctx)
-}