git.delta.rocks / jrsonnet / refs/commits / 2d3e9127fca2

difftreelog

Merge remote-tracking branch 'origin/master' into gcmodule

Yaroslav Bolyukin2022-01-04parents: #fa16ccf #e1fb5e1.patch.diff
in: master

7 files changed

modifiedcrates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/manifest.rs
@@ -19,6 +19,8 @@
 pub struct ManifestJsonOptions<'s> {
 	pub padding: &'s str,
 	pub mtype: ManifestType,
+	pub newline: &'s str,
+	pub key_val_sep: &'s str,
 }
 
 pub fn manifest_json_ex(val: &Val, options: &ManifestJsonOptions<'_>) -> Result<String> {
@@ -49,7 +51,7 @@
 			buf.push('[');
 			if !items.is_empty() {
 				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {
-					buf.push('\n');
+					buf.push_str(options.newline);
 				}
 
 				let old_len = cur_padding.len();
@@ -60,7 +62,7 @@
 						if mtype == ManifestType::ToString {
 							buf.push(' ');
 						} else if mtype != ManifestType::Minify {
-							buf.push('\n');
+							buf.push_str(options.newline);
 						}
 					}
 					buf.push_str(cur_padding);
@@ -69,7 +71,7 @@
 				cur_padding.truncate(old_len);
 
 				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {
-					buf.push('\n');
+					buf.push_str(options.newline);
 					buf.push_str(cur_padding);
 				}
 			} else if mtype == ManifestType::Std {
@@ -86,7 +88,7 @@
 			let fields = obj.fields();
 			if !fields.is_empty() {
 				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {
-					buf.push('\n');
+					buf.push_str(options.newline);
 				}
 
 				let old_len = cur_padding.len();
@@ -97,12 +99,12 @@
 						if mtype == ManifestType::ToString {
 							buf.push(' ');
 						} else if mtype != ManifestType::Minify {
-							buf.push('\n');
+							buf.push_str(options.newline);
 						}
 					}
 					buf.push_str(cur_padding);
 					escape_string_json_buf(&field, buf);
-					buf.push_str(": ");
+					buf.push_str(options.key_val_sep);
 					push_description_frame(
 						|| format!("field <{}> manifestification", field.clone()),
 						|| {
@@ -115,7 +117,7 @@
 				cur_padding.truncate(old_len);
 
 				if mtype != ManifestType::ToString && mtype != ManifestType::Minify {
-					buf.push('\n');
+					buf.push_str(options.newline);
 					buf.push_str(cur_padding);
 				}
 			} else if mtype == ManifestType::Std {
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -1,6 +1,5 @@
 use crate::function::StaticBuiltin;
-use crate::typed::{Any, Null, PositiveF64, VecVal, M1};
-use crate::{self as jrsonnet_evaluator, Either, ObjValue};
+use crate::typed::{Any, PositiveF64, VecVal, M1};
 use crate::{
 	builtin::manifest::{manifest_yaml_ex, ManifestYamlOptions},
 	equals,
@@ -10,6 +9,7 @@
 	typed::{Either2, Either4},
 	with_state, ArrValue, Context, FuncVal, IndexableVal, Val,
 };
+use crate::{Either, ObjValue};
 use format::{format_arr, format_obj};
 use gcmodule::Cc;
 use jrsonnet_interner::IStr;
@@ -145,7 +145,7 @@
 fn builtin_length(x: Either![IStr, VecVal, ObjValue, Cc<FuncVal>]) -> Result<usize> {
 	use Either4::*;
 	Ok(match x {
-		A(x) => x.len(),
+		A(x) => x.chars().count(),
 		B(x) => x.0.len(),
 		C(x) => x
 			.fields_visibility()
@@ -566,12 +566,21 @@
 }
 
 #[jrsonnet_macros::builtin]
-fn builtin_manifest_json_ex(value: Any, indent: IStr) -> Result<String> {
+fn builtin_manifest_json_ex(
+	value: Any,
+	indent: IStr,
+	newline: Option<IStr>,
+	key_val_sep: Option<IStr>,
+) -> Result<String> {
+	let newline = newline.as_deref().unwrap_or("\n");
+	let key_val_sep = key_val_sep.as_deref().unwrap_or(": ");
 	manifest_json_ex(
 		&value.0,
 		&ManifestJsonOptions {
 			padding: &indent,
 			mtype: ManifestType::Std,
+			newline,
+			key_val_sep,
 		},
 	)
 }
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -5,6 +5,9 @@
 	clippy::ptr_arg
 )]
 
+// For jrsonnet-macros
+extern crate self as jrsonnet_evaluator;
+
 mod builtin;
 mod ctx;
 mod dynamic;
@@ -976,6 +979,14 @@
 	}
 
 	#[test]
+	fn json_minified() {
+		assert_json!(
+			r#"std.manifestJsonMinified({a:3, b:4, c:6})"#,
+			r#""{\"a\":3,\"b\":4,\"c\":6}""#
+		);
+	}
+
+	#[test]
 	fn parse_json() {
 		assert_json!(
 			r#"std.parseJson('{"a": -1,"b": 1,"c": 3.141,"d": []}')"#,
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/conversions.rs
+++ b/crates/jrsonnet-evaluator/src/typed/conversions.rs
@@ -19,7 +19,7 @@
 	($($ty:ty)*) => {$(
 		impl Typed for $ty {
 			const TYPE: &'static ComplexValType =
-				&ComplexValType::BoundedNumber(Some(<$ty>::MIN as f64), Some(<$ty>::MAX as f64));
+				&ComplexValType::BoundedNumber(Some(Self::MIN as f64), Some(Self::MAX as f64));
 		}
 		impl TryFrom<Val> for $ty {
 			type Error = LocError;
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/val.rs
1use crate::{2	builtin::manifest::{3		manifest_json_ex, manifest_yaml_ex, ManifestJsonOptions, ManifestType, ManifestYamlOptions,4	},5	cc_ptr_eq,6	error::{Error::*, LocError},7	evaluate,8	function::{parse_function_call, ArgsLike, Builtin, StaticBuiltin},9	gc::TraceBox,10	native::NativeCallback,11	throw, Context, ObjValue, Result,12};13use gcmodule::{Cc, Trace};14use jrsonnet_interner::IStr;15use jrsonnet_parser::{ExprLocation, LocExpr, ParamsDesc};16use jrsonnet_types::ValType;17use std::{cell::RefCell, fmt::Debug, rc::Rc};1819pub trait LazyValValue: Trace {20	fn get(self: Box<Self>) -> Result<Val>;21}2223#[derive(Trace)]24enum LazyValInternals {25	Computed(Val),26	Errored(LocError),27	Waiting(TraceBox<dyn LazyValValue>),28	Pending,29}3031#[derive(Clone, Trace)]32pub struct LazyVal(Cc<RefCell<LazyValInternals>>);33impl LazyVal {34	pub fn new(f: TraceBox<dyn LazyValValue>) -> Self {35		Self(Cc::new(RefCell::new(LazyValInternals::Waiting(f))))36	}37	pub fn new_resolved(val: Val) -> Self {38		Self(Cc::new(RefCell::new(LazyValInternals::Computed(val))))39	}40	pub fn force(&self) -> Result<()> {41		self.evaluate()?;42		Ok(())43	}44	pub fn evaluate(&self) -> Result<Val> {45		match &*self.0.borrow() {46			LazyValInternals::Computed(v) => return Ok(v.clone()),47			LazyValInternals::Errored(e) => return Err(e.clone()),48			LazyValInternals::Pending => return Err(RecursiveLazyValueEvaluation.into()),49			_ => (),50		};51		let value = if let LazyValInternals::Waiting(value) =52			std::mem::replace(&mut *self.0.borrow_mut(), LazyValInternals::Pending)53		{54			value55		} else {56			unreachable!()57		};58		let new_value = match value.0.get() {59			Ok(v) => v,60			Err(e) => {61				*self.0.borrow_mut() = LazyValInternals::Errored(e.clone());62				return Err(e);63			}64		};65		*self.0.borrow_mut() = LazyValInternals::Computed(new_value.clone());66		Ok(new_value)67	}68}6970impl Debug for LazyVal {71	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {72		write!(f, "Lazy")73	}74}75impl PartialEq for LazyVal {76	fn eq(&self, other: &Self) -> bool {77		cc_ptr_eq(&self.0, &other.0)78	}79}8081#[derive(Debug, PartialEq, Trace)]82pub struct FuncDesc {83	pub name: IStr,84	pub ctx: Context,85	pub params: ParamsDesc,86	pub body: LocExpr,87}8889#[derive(Trace)]90pub enum FuncVal {91	/// Plain function implemented in jsonnet92	Normal(FuncDesc),93	/// Standard library function94	StaticBuiltin(#[skip_trace] &'static dyn StaticBuiltin),9596	Builtin(TraceBox<dyn Builtin>),97	/// Library functions implemented in native98	NativeExt(IStr, Cc<NativeCallback>),99}100101impl Debug for FuncVal {102	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {103		match self {104			Self::Normal(arg0) => f.debug_tuple("Normal").field(arg0).finish(),105			Self::StaticBuiltin(arg0) => f.debug_tuple("Intrinsic").field(&arg0.name()).finish(),106			Self::Builtin(arg0) => f.debug_tuple("Intrinsic").field(&arg0.name()).finish(),107			Self::NativeExt(arg0, arg1) => {108				f.debug_tuple("NativeExt").field(arg0).field(arg1).finish()109			}110		}111	}112}113114impl PartialEq for FuncVal {115	fn eq(&self, other: &Self) -> bool {116		match (self, other) {117			(Self::Normal(a), Self::Normal(b)) => a == b,118			(Self::StaticBuiltin(an), Self::StaticBuiltin(bn)) => std::ptr::eq(*an, *bn),119			(Self::NativeExt(an, _), Self::NativeExt(bn, _)) => an == bn,120			(..) => false,121		}122	}123}124impl FuncVal {125	pub fn args_len(&self) -> usize {126		match self {127			Self::Normal(n) => n.params.iter().filter(|p| p.1.is_none()).count(),128			Self::StaticBuiltin(i) => i.params().iter().filter(|p| !p.has_default).count(),129			Self::Builtin(i) => i.params().iter().filter(|p| !p.has_default).count(),130			Self::NativeExt(_, n) => n.params.iter().filter(|p| p.1.is_none()).count(),131		}132	}133	pub fn name(&self) -> IStr {134		match self {135			Self::Normal(normal) => normal.name.clone(),136			Self::StaticBuiltin(builtin) => builtin.name().into(),137			Self::Builtin(builtin) => builtin.name().into(),138			Self::NativeExt(n, _) => format!("native.{}", n).into(),139		}140	}141	pub fn evaluate(142		&self,143		call_ctx: Context,144		loc: Option<&ExprLocation>,145		args: &dyn ArgsLike,146		tailstrict: bool,147	) -> Result<Val> {148		match self {149			Self::Normal(func) => {150				let ctx = parse_function_call(151					call_ctx,152					func.ctx.clone(),153					&func.params,154					args,155					tailstrict,156				)?;157				evaluate(ctx, &func.body)158			}159			Self::StaticBuiltin(name) => name.call(call_ctx, loc, args),160			Self::Builtin(b) => b.call(call_ctx, loc, args),161			Self::NativeExt(_name, handler) => {162				let args =163					parse_function_call(call_ctx, Context::new(), &handler.params, args, true)?;164				let mut out_args = Vec::with_capacity(handler.params.len());165				for p in handler.params.0.iter() {166					out_args.push(args.binding(p.0.clone())?.evaluate()?);167				}168				Ok(handler.call(loc.expect("todo").0.clone(), &out_args)?)169			}170		}171	}172	pub fn evaluate_simple(&self, args: &dyn ArgsLike) -> Result<Val> {173		self.evaluate(Context::default(), None, args, true)174	}175}176177#[derive(Clone)]178pub enum ManifestFormat {179	YamlStream(Box<ManifestFormat>),180	Yaml(usize),181	Json(usize),182	ToString,183	String,184}185186#[derive(Debug, Clone, Trace)]187#[force_tracking]188pub enum ArrValue {189	Lazy(Cc<Vec<LazyVal>>),190	Eager(Cc<Vec<Val>>),191	Extended(Box<(Self, Self)>),192}193impl ArrValue {194	pub fn new_eager() -> Self {195		Self::Eager(Cc::new(Vec::new()))196	}197198	pub fn len(&self) -> usize {199		match self {200			Self::Lazy(l) => l.len(),201			Self::Eager(e) => e.len(),202			Self::Extended(v) => v.0.len() + v.1.len(),203		}204	}205206	pub fn is_empty(&self) -> bool {207		self.len() == 0208	}209210	pub fn get(&self, index: usize) -> Result<Option<Val>> {211		match self {212			Self::Lazy(vec) => {213				if let Some(v) = vec.get(index) {214					Ok(Some(v.evaluate()?))215				} else {216					Ok(None)217				}218			}219			Self::Eager(vec) => Ok(vec.get(index).cloned()),220			Self::Extended(v) => {221				let a_len = v.0.len();222				if a_len > index {223					v.0.get(index)224				} else {225					v.1.get(index - a_len)226				}227			}228		}229	}230231	pub fn get_lazy(&self, index: usize) -> Option<LazyVal> {232		match self {233			Self::Lazy(vec) => vec.get(index).cloned(),234			Self::Eager(vec) => vec.get(index).cloned().map(LazyVal::new_resolved),235			Self::Extended(v) => {236				let a_len = v.0.len();237				if a_len > index {238					v.0.get_lazy(index)239				} else {240					v.1.get_lazy(index - a_len)241				}242			}243		}244	}245246	pub fn evaluated(&self) -> Result<Cc<Vec<Val>>> {247		Ok(match self {248			Self::Lazy(vec) => {249				let mut out = Vec::with_capacity(vec.len());250				for item in vec.iter() {251					out.push(item.evaluate()?);252				}253				Cc::new(out)254			}255			Self::Eager(vec) => vec.clone(),256			Self::Extended(_v) => {257				let mut out = Vec::with_capacity(self.len());258				for item in self.iter() {259					out.push(item?);260				}261				Cc::new(out)262			}263		})264	}265266	pub fn iter(&self) -> impl DoubleEndedIterator<Item = Result<Val>> + '_ {267		(0..self.len()).map(move |idx| match self {268			Self::Lazy(l) => l[idx].evaluate(),269			Self::Eager(e) => Ok(e[idx].clone()),270			Self::Extended(_) => self.get(idx).map(|e| e.unwrap()),271		})272	}273274	pub fn iter_lazy(&self) -> impl DoubleEndedIterator<Item = LazyVal> + '_ {275		(0..self.len()).map(move |idx| match self {276			Self::Lazy(l) => l[idx].clone(),277			Self::Eager(e) => LazyVal::new_resolved(e[idx].clone()),278			Self::Extended(_) => self.get_lazy(idx).unwrap(),279		})280	}281282	pub fn reversed(self) -> Self {283		match self {284			Self::Lazy(vec) => {285				let mut out = (&vec as &Vec<_>).clone();286				out.reverse();287				Self::Lazy(Cc::new(out))288			}289			Self::Eager(vec) => {290				let mut out = (&vec as &Vec<_>).clone();291				out.reverse();292				Self::Eager(Cc::new(out))293			}294			Self::Extended(b) => Self::Extended(Box::new((b.1.reversed(), b.0.reversed()))),295		}296	}297298	pub fn map(self, mapper: impl Fn(Val) -> Result<Val>) -> Result<Self> {299		let mut out = Vec::with_capacity(self.len());300301		for value in self.iter() {302			out.push(mapper(value?)?);303		}304305		Ok(Self::Eager(Cc::new(out)))306	}307308	pub fn filter(self, filter: impl Fn(&Val) -> Result<bool>) -> Result<Self> {309		let mut out = Vec::with_capacity(self.len());310311		for value in self.iter() {312			let value = value?;313			if filter(&value)? {314				out.push(value);315			}316		}317318		Ok(Self::Eager(Cc::new(out)))319	}320321	pub fn ptr_eq(a: &Self, b: &Self) -> bool {322		match (a, b) {323			(Self::Lazy(a), Self::Lazy(b)) => cc_ptr_eq(a, b),324			(Self::Eager(a), Self::Eager(b)) => cc_ptr_eq(a, b),325			_ => false,326		}327	}328}329330impl From<Vec<LazyVal>> for ArrValue {331	fn from(v: Vec<LazyVal>) -> Self {332		Self::Lazy(Cc::new(v))333	}334}335336impl From<Vec<Val>> for ArrValue {337	fn from(v: Vec<Val>) -> Self {338		Self::Eager(Cc::new(v))339	}340}341342pub enum IndexableVal {343	Str(IStr),344	Arr(ArrValue),345}346347#[derive(Debug, Clone, Trace)]348pub enum Val {349	Bool(bool),350	Null,351	Str(IStr),352	Num(f64),353	Arr(ArrValue),354	Obj(ObjValue),355	Func(Cc<FuncVal>),356}357358impl Val {359	/// Creates `Val::Num` after checking for numeric overflow.360	/// As numbers are `f64`, we can just check for their finity.361	pub fn new_checked_num(num: f64) -> Result<Self> {362		if num.is_finite() {363			Ok(Self::Num(num))364		} else {365			throw!(RuntimeError("overflow".into()))366		}367	}368369	pub fn try_cast_nullable_num(self, context: &'static str) -> Result<Option<f64>> {370		Ok(match self {371			Val::Null => None,372			Val::Num(num) => Some(num),373			_ => throw!(TypeMismatch(374				context,375				vec![ValType::Null, ValType::Num],376				self.value_type()377			)),378		})379	}380	pub const fn value_type(&self) -> ValType {381		match self {382			Self::Str(..) => ValType::Str,383			Self::Num(..) => ValType::Num,384			Self::Arr(..) => ValType::Arr,385			Self::Obj(..) => ValType::Obj,386			Self::Bool(_) => ValType::Bool,387			Self::Null => ValType::Null,388			Self::Func(..) => ValType::Func,389		}390	}391392	pub fn to_string(&self) -> Result<IStr> {393		Ok(match self {394			Self::Bool(true) => "true".into(),395			Self::Bool(false) => "false".into(),396			Self::Null => "null".into(),397			Self::Str(s) => s.clone(),398			v => manifest_json_ex(399				v,400				&ManifestJsonOptions {401					padding: "",402					mtype: ManifestType::ToString,403				},404			)?405			.into(),406		})407	}408409	/// Expects value to be object, outputs (key, manifested value) pairs410	pub fn manifest_multi(&self, ty: &ManifestFormat) -> Result<Vec<(IStr, IStr)>> {411		let obj = match self {412			Self::Obj(obj) => obj,413			_ => throw!(MultiManifestOutputIsNotAObject),414		};415		let keys = obj.fields();416		let mut out = Vec::with_capacity(keys.len());417		for key in keys {418			let value = obj419				.get(key.clone())?420				.expect("item in object")421				.manifest(ty)?;422			out.push((key, value));423		}424		Ok(out)425	}426427	/// Expects value to be array, outputs manifested values428	pub fn manifest_stream(&self, ty: &ManifestFormat) -> Result<Vec<IStr>> {429		let arr = match self {430			Self::Arr(a) => a,431			_ => throw!(StreamManifestOutputIsNotAArray),432		};433		let mut out = Vec::with_capacity(arr.len());434		for i in arr.iter() {435			out.push(i?.manifest(ty)?);436		}437		Ok(out)438	}439440	pub fn manifest(&self, ty: &ManifestFormat) -> Result<IStr> {441		Ok(match ty {442			ManifestFormat::YamlStream(format) => {443				let arr = match self {444					Self::Arr(a) => a,445					_ => throw!(StreamManifestOutputIsNotAArray),446				};447				let mut out = String::new();448449				match format as &ManifestFormat {450					ManifestFormat::YamlStream(_) => throw!(StreamManifestOutputCannotBeRecursed),451					ManifestFormat::String => throw!(StreamManifestCannotNestString),452					_ => {}453				};454455				if !arr.is_empty() {456					for v in arr.iter() {457						out.push_str("---\n");458						out.push_str(&v?.manifest(format)?);459						out.push('\n');460					}461					out.push_str("...");462				}463464				out.into()465			}466			ManifestFormat::Yaml(padding) => self.to_yaml(*padding)?,467			ManifestFormat::Json(padding) => self.to_json(*padding)?,468			ManifestFormat::ToString => self.to_string()?,469			ManifestFormat::String => match self {470				Self::Str(s) => s.clone(),471				_ => throw!(StringManifestOutputIsNotAString),472			},473		})474	}475476	/// For manifestification477	pub fn to_json(&self, padding: usize) -> Result<IStr> {478		manifest_json_ex(479			self,480			&ManifestJsonOptions {481				padding: &" ".repeat(padding),482				mtype: if padding == 0 {483					ManifestType::Minify484				} else {485					ManifestType::Manifest486				},487			},488		)489		.map(|s| s.into())490	}491492	/// Calls `std.manifestJson`493	pub fn to_std_json(&self, padding: usize) -> Result<Rc<str>> {494		manifest_json_ex(495			self,496			&ManifestJsonOptions {497				padding: &" ".repeat(padding),498				mtype: ManifestType::Std,499			},500		)501		.map(|s| s.into())502	}503504	pub fn to_yaml(&self, padding: usize) -> Result<IStr> {505		let padding = &" ".repeat(padding);506		manifest_yaml_ex(507			self,508			&ManifestYamlOptions {509				padding,510				arr_element_padding: padding,511				quote_keys: false,512			},513		)514		.map(|s| s.into())515	}516	pub fn into_indexable(self) -> Result<IndexableVal> {517		Ok(match self {518			Val::Str(s) => IndexableVal::Str(s),519			Val::Arr(arr) => IndexableVal::Arr(arr),520			_ => throw!(ValueIsNotIndexable(self.value_type())),521		})522	}523}524525const fn is_function_like(val: &Val) -> bool {526	matches!(val, Val::Func(_))527}528529/// Native implementation of `std.primitiveEquals`530pub fn primitive_equals(val_a: &Val, val_b: &Val) -> Result<bool> {531	Ok(match (val_a, val_b) {532		(Val::Bool(a), Val::Bool(b)) => a == b,533		(Val::Null, Val::Null) => true,534		(Val::Str(a), Val::Str(b)) => a == b,535		(Val::Num(a), Val::Num(b)) => (a - b).abs() <= f64::EPSILON,536		(Val::Arr(_), Val::Arr(_)) => throw!(RuntimeError(537			"primitiveEquals operates on primitive types, got array".into(),538		)),539		(Val::Obj(_), Val::Obj(_)) => throw!(RuntimeError(540			"primitiveEquals operates on primitive types, got object".into(),541		)),542		(a, b) if is_function_like(a) && is_function_like(b) => {543			throw!(RuntimeError("cannot test equality of functions".into()))544		}545		(_, _) => false,546	})547}548549/// Native implementation of `std.equals`550pub fn equals(val_a: &Val, val_b: &Val) -> Result<bool> {551	if val_a.value_type() != val_b.value_type() {552		return Ok(false);553	}554	match (val_a, val_b) {555		(Val::Arr(a), Val::Arr(b)) => {556			if ArrValue::ptr_eq(a, b) {557				return Ok(true);558			}559			if a.len() != b.len() {560				return Ok(false);561			}562			for (a, b) in a.iter().zip(b.iter()) {563				if !equals(&a?, &b?)? {564					return Ok(false);565				}566			}567			Ok(true)568		}569		(Val::Obj(a), Val::Obj(b)) => {570			if ObjValue::ptr_eq(a, b) {571				return Ok(true);572			}573			let fields = a.fields();574			if fields != b.fields() {575				return Ok(false);576			}577			for field in fields {578				if !equals(&a.get(field.clone())?.unwrap(), &b.get(field)?.unwrap())? {579					return Ok(false);580				}581			}582			Ok(true)583		}584		(a, b) => Ok(primitive_equals(a, b)?),585	}586}
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-macros/src/lib.rs
+++ b/crates/jrsonnet-macros/src/lib.rs
@@ -105,7 +105,7 @@
 				if let Some(opt_ty) = extract_type_from_option(&t.ty) {
 					quote! {{
 						if let Some(value) = parsed.get(#ident) {
-							Some(jrsonnet_evaluator::push_description_frame(
+							Some(::jrsonnet_evaluator::push_description_frame(
 								|| format!("argument <{}> evaluation", #ident),
 								|| <#opt_ty>::try_from(value.evaluate()?),
 							)?)
@@ -117,7 +117,7 @@
 					quote! {{
 						let value = parsed.get(#ident).unwrap();
 
-						jrsonnet_evaluator::push_description_frame(
+						::jrsonnet_evaluator::push_description_frame(
 							|| format!("argument <{}> evaluation", #ident),
 							|| <#ty>::try_from(value.evaluate()?),
 						)?
@@ -136,7 +136,7 @@
 		#[derive(Clone, Copy, gcmodule::Trace)]
 		#vis struct #name {}
 		const _: () = {
-			use jrsonnet_evaluator::function::{Builtin, StaticBuiltin, BuiltinParam, ArgsLike};
+			use ::jrsonnet_evaluator::function::{Builtin, StaticBuiltin, BuiltinParam, ArgsLike};
 			const PARAMS: &'static [BuiltinParam] = &[
 				#(#params),*
 			];
@@ -156,7 +156,7 @@
 					PARAMS
 				}
 				fn call(&self, context: Context, loc: Option<&ExprLocation>, args: &dyn ArgsLike) -> Result<Val> {
-					let parsed = jrsonnet_evaluator::function::parse_builtin_call(context, &PARAMS, args, false)?;
+					let parsed = ::jrsonnet_evaluator::function::parse_builtin_call(context, &PARAMS, args, false)?;
 
 					let result: #result = #name(#(#args),*);
 					let result = result?;
modifiedcrates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/std.jsonnet
+++ b/crates/jrsonnet-stdlib/src/std.jsonnet
@@ -373,6 +373,8 @@
 
   manifestJson(value):: std.manifestJsonEx(value, '    ') tailstrict,
 
+  manifestJsonMinified(value):: std.manifestJsonEx(value, '', '', ':'),
+
   manifestJsonEx:: $intrinsic(manifestJsonEx),
 
   manifestYamlDoc:: $intrinsic(manifestYamlDoc),
@@ -530,6 +532,9 @@
     else
       patch,
 
+  get(o, f, default = null, inc_hidden = true)::
+    if std.objectHasEx(o, f, inc_hidden) then o[f] else default,
+
   objectFields(o)::
     std.objectFieldsEx(o, false),