difftreelog
feat minimal tco
in: master
3 files changed
crates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/destructure.rs
@@ -4,9 +4,7 @@
use crate::{
Context, LocalsFrame, PackedContext, Result, SupThis, Thunk, Unbound, Val,
- analyze::{
- ClosureShape, LBind, LDestruct, LDestructField, LDestructRest, LLocalExpr, LocalSlot,
- },
+ analyze::{ClosureShape, LBind, LDestruct, LDestructField, LDestructRest, LocalSlot},
bail,
evaluate::evaluate,
};
@@ -187,15 +185,6 @@
ctx,
);
}
-}
-
-pub fn evaluate_local_expr(parent: Context, l: &LLocalExpr) -> Result<Val> {
- let ctx = parent
- .pack_captures_sup_this(&l.frame_shape)
- .enter(|fill, ctx| {
- fill_letrec_binds(fill, ctx, &l.binds);
- });
- evaluate(ctx, &l.body)
}
pub trait CloneableUnbound<T>: Unbound<Bound = T> + Clone {}
crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth778use self::{8use self::{9 compspec::{evaluate_arr_comp, evaluate_obj_comp},9 compspec::{evaluate_arr_comp, evaluate_obj_comp},10 destructure::{evaluate_local_expr, evaluate_locals_unbound},10 destructure::evaluate_locals_unbound,11 operator::evaluate_binary_op_special,11 operator::evaluate_binary_op_special,12};12};13use crate::{13use crate::{116}116}117117118#[allow(clippy::too_many_lines)]118#[allow(clippy::too_many_lines)]119pub fn evaluate(ctx: Context, expr: &LExpr) -> Result<Val> {119pub fn evaluate(mut ctx: Context, mut expr: &LExpr) -> Result<Val> {120 loop {120 Ok(match expr {121 return Ok(match expr {121 LExpr::Null => Val::Null,122 LExpr::Null => Val::Null,122 LExpr::Bool(b) => Val::Bool(*b),123 LExpr::Bool(b) => Val::Bool(*b),123 LExpr::Str(s) => Val::string(s.clone()),124 LExpr::Str(s) => Val::string(s.clone()),130 evaluate_unary_op(*op, &value)?131 evaluate_unary_op(*op, &value)?131 }132 }132 LExpr::BinaryOp { lhs, op, rhs } => evaluate_binary_op_special(ctx, lhs, *op, rhs)?,133 LExpr::BinaryOp { lhs, op, rhs } => evaluate_binary_op_special(ctx, lhs, *op, rhs)?,133 LExpr::LocalExpr(local_expr) => evaluate_local_expr(ctx, local_expr)?,134 LExpr::LocalExpr(l) => {135 ctx = ctx136 .pack_captures_sup_this(&l.frame_shape)137 .enter(|fill, ctx| {138 fill_letrec_binds(fill, ctx, &l.binds);139 });140 expr = &l.body;141 continue;142 }134 LExpr::IfElse {143 LExpr::IfElse {135 cond,144 cond,136 cond_then,145 cond_then,145 ))154 ))146 };155 };147 if b {156 if b {148 evaluate(ctx, cond_then)?157 expr = cond_then;158 continue;149 } else if let Some(e) = cond_else {159 } else if let Some(e) = cond_else {150 evaluate(ctx, e)?160 expr = e;161 continue;151 } else {162 }152 Val::Null163 Val::Null153 }154 }164 }155 LExpr::Error(s, e) => in_frame(165 LExpr::Error(s, e) => in_frame(156 CallLocation::new(s),166 CallLocation::new(s),159 )?,169 )?,160 LExpr::AssertExpr { assert, rest } => {170 LExpr::AssertExpr { assert, rest } => {161 evaluate_assert(ctx.clone(), assert)?;171 evaluate_assert(ctx.clone(), assert)?;162 evaluate(ctx, rest)?172 expr = rest;173 continue;163 }174 }164175165 LExpr::Function(func) => evaluate_method(176 LExpr::Function(func) => evaluate_method(238 ImportKind::Bin => Val::arr(state.import_resolved_bin(resolved)?),251 ImportKind::Bin => Val::arr(state.import_resolved_bin(resolved)?),239 })252 })240 })?,253 })?,241 })254 });255 }242}256}243257244fn evaluate_apply(258fn evaluate_apply(crates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/function/mod.rs
+++ b/crates/jrsonnet-evaluator/src/function/mod.rs
@@ -14,7 +14,8 @@
Context, PackedContextSupThis, Result, Thunk, Val,
analyze::LFunction,
arr::arridx,
- evaluate::{destructure::destruct, ensure_sufficient_stack, evaluate, evaluate_trivial},
+ ensure_sufficient_stack,
+ evaluate::{destructure::destruct, evaluate, evaluate_trivial},
function::builtin::BuiltinFunc,
};
@@ -68,7 +69,7 @@
self.func.signature.clone()
}
- pub fn call(
+ fn call(
&self,
unnamed: &[Thunk<Val>],
named: &[Thunk<Val>],