git.delta.rocks / jrsonnet / refs/commits / b2f480a687a1

difftreelog

style rename bindable -> unbound

Yaroslav Bolyukin2022-04-24parent: #c65967c.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -3,8 +3,8 @@
 use gcmodule::{Cc, Trace};
 use jrsonnet_interner::IStr;
 use jrsonnet_parser::{
-	ArgsDesc, AssertStmt, BindSpec, CompSpec, Expr, FieldMember, ForSpecData, IfSpecData,
-	LiteralType, LocExpr, Member, ObjBody, ParamsDesc,
+	ArgsDesc, AssertStmt, BindSpec, CompSpec, Expr, FieldMember, FieldName, ForSpecData,
+	IfSpecData, LiteralType, LocExpr, Member, ObjBody, ParamsDesc,
 };
 use jrsonnet_types::ValType;
 
@@ -16,9 +16,9 @@
 	stdlib::{std_slice, BUILTINS},
 	tb, throw,
 	typed::Typed,
-	val::{ArrValue, CachedBindable, Thunk, ThunkValue},
-	Bindable, Context, GcHashMap, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result,
-	State, Val,
+	val::{ArrValue, CachedUnbound, Thunk, ThunkValue},
+	Context, GcHashMap, ObjValue, ObjValueBuilder, ObjectAssertion, Pending, Result, State,
+	Unbound, Val,
 };
 pub mod destructure;
 pub mod operator;
@@ -32,14 +32,10 @@
 	})))
 }
 
-pub fn evaluate_field_name(
-	s: State,
-	ctx: Context,
-	field_name: &jrsonnet_parser::FieldName,
-) -> Result<Option<IStr>> {
+pub fn evaluate_field_name(s: State, ctx: Context, field_name: &FieldName) -> Result<Option<IStr>> {
 	Ok(match field_name {
-		jrsonnet_parser::FieldName::Fixed(n) => Some(n.clone()),
-		jrsonnet_parser::FieldName::Dyn(expr) => s.push(
+		FieldName::Fixed(n) => Some(n.clone()),
+		FieldName::Dyn(expr) => s.push(
 			CallLocation::new(&expr.1),
 			|| "evaluating field name".to_string(),
 			|| {
@@ -86,19 +82,19 @@
 	Ok(())
 }
 
-trait CloneableBindable<T>: Bindable<Bound = T> + Clone {}
+trait CloneableUnbound<T>: Unbound<Bound = T> + Clone {}
 
 fn evaluate_object_locals(
 	fctx: Pending<Context>,
 	locals: Rc<Vec<BindSpec>>,
-) -> impl CloneableBindable<Context> {
+) -> impl CloneableUnbound<Context> {
 	#[derive(Trace, Clone)]
-	struct WithObjectLocals {
+	struct UnboundLocals {
 		fctx: Pending<Context>,
 		locals: Rc<Vec<BindSpec>>,
 	}
-	impl CloneableBindable<Context> for WithObjectLocals {}
-	impl Bindable for WithObjectLocals {
+	impl CloneableUnbound<Context> for UnboundLocals {}
+	impl Unbound for UnboundLocals {
 		type Bound = Context;
 
 		fn bind(
@@ -124,7 +120,7 @@
 		}
 	}
 
-	WithObjectLocals { fctx, locals }
+	UnboundLocals { fctx, locals }
 }
 
 #[allow(clippy::too_many_lines)]
@@ -143,7 +139,7 @@
 	let fctx = Context::new_future();
 
 	// We have single context for all fields, so we can cache binds
-	let uctx = CachedBindable::new(evaluate_object_locals(fctx.clone(), locals));
+	let uctx = CachedUnbound::new(evaluate_object_locals(fctx.clone(), locals));
 
 	for member in members.iter() {
 		match member {
@@ -155,12 +151,12 @@
 				value,
 			}) => {
 				#[derive(Trace)]
-				struct ObjMemberBinding<B> {
+				struct UnboundValue<B> {
 					uctx: B,
 					value: LocExpr,
 					name: IStr,
 				}
-				impl<B: Bindable<Bound = Context>> Bindable for ObjMemberBinding<B> {
+				impl<B: Unbound<Bound = Context>> Unbound for UnboundValue<B> {
 					type Bound = Thunk<Val>;
 					fn bind(
 						&self,
@@ -191,7 +187,7 @@
 					.with_location(value.1.clone())
 					.bindable(
 						s.clone(),
-						tb!(ObjMemberBinding {
+						tb!(UnboundValue {
 							uctx: uctx.clone(),
 							value: value.clone(),
 							name: name.clone()
@@ -205,13 +201,13 @@
 				..
 			}) => {
 				#[derive(Trace)]
-				struct ObjMemberBinding<B> {
+				struct UnboundMethod<B> {
 					uctx: B,
 					value: LocExpr,
 					params: ParamsDesc,
 					name: IStr,
 				}
-				impl<B: Bindable<Bound = Context>> Bindable for ObjMemberBinding<B> {
+				impl<B: Unbound<Bound = Context>> Unbound for UnboundMethod<B> {
 					type Bound = Thunk<Val>;
 					fn bind(
 						&self,
@@ -240,7 +236,7 @@
 					.with_location(value.1.clone())
 					.bindable(
 						s.clone(),
-						tb!(ObjMemberBinding {
+						tb!(UnboundMethod {
 							uctx: uctx.clone(),
 							value: value.clone(),
 							params: params.clone(),
@@ -255,7 +251,7 @@
 					uctx: B,
 					assert: AssertStmt,
 				}
-				impl<B: Bindable<Bound = Context>> ObjectAssertion for ObjectAssert<B> {
+				impl<B: Unbound<Bound = Context>> ObjectAssertion for ObjectAssert<B> {
 					fn run(
 						&self,
 						s: State,
@@ -303,11 +299,11 @@
 					Val::Null => {}
 					Val::Str(n) => {
 						#[derive(Trace)]
-						struct ObjCompBinding<B> {
+						struct UnboundValue<B> {
 							uctx: B,
 							value: LocExpr,
 						}
-						impl<B: Bindable<Bound = Context>> Bindable for ObjCompBinding<B> {
+						impl<B: Unbound<Bound = Context>> Unbound for UnboundValue<B> {
 							type Bound = Thunk<Val>;
 							fn bind(
 								&self,
@@ -333,7 +329,7 @@
 							.with_add(obj.plus)
 							.bindable(
 								s.clone(),
-								tb!(ObjCompBinding {
+								tb!(UnboundValue {
 									uctx,
 									value: obj.value.clone(),
 								}),
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
60use trace::{location_to_offset, offset_to_location, CodeLocation, CompactFormat, TraceFormat};60use trace::{location_to_offset, offset_to_location, CodeLocation, CompactFormat, TraceFormat};
61pub use val::{ManifestFormat, Thunk, Val};61pub use val::{ManifestFormat, Thunk, Val};
6262
63pub trait Bindable: Trace + 'static {63pub trait Unbound: Trace {
64 type Bound;64 type Bound;
65 fn bind(&self, s: State, sup: Option<ObjValue>, this: Option<ObjValue>) -> Result<Self::Bound>;65 fn bind(&self, s: State, sup: Option<ObjValue>, this: Option<ObjValue>) -> Result<Self::Bound>;
66}66}
6767
68#[derive(Clone, Trace)]68#[derive(Clone, Trace)]
69pub enum LazyBinding {69pub enum LazyBinding {
70 Bindable(Cc<TraceBox<dyn Bindable<Bound = Thunk<Val>>>>),70 Bindable(Cc<TraceBox<dyn Unbound<Bound = Thunk<Val>>>>),
71 Bound(Thunk<Val>),71 Bound(Thunk<Val>),
72}72}
7373
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/obj.rs
+++ b/crates/jrsonnet-evaluator/src/obj.rs
@@ -16,7 +16,7 @@
 	function::CallLocation,
 	gc::{GcHashMap, GcHashSet, TraceBox},
 	operator::evaluate_add_op,
-	throw, weak_ptr_eq, weak_raw, Bindable, LazyBinding, Result, State, Thunk, Val,
+	throw, weak_ptr_eq, weak_raw, LazyBinding, Result, State, Thunk, Unbound, Val,
 };
 
 #[cfg(not(feature = "exp-preserve-order"))]
@@ -589,7 +589,7 @@
 	pub fn bindable(
 		self,
 		s: State,
-		bindable: TraceBox<dyn Bindable<Bound = Thunk<Val>>>,
+		bindable: TraceBox<dyn Unbound<Bound = Thunk<Val>>>,
 	) -> Result<()> {
 		self.binding(s, LazyBinding::Bindable(Cc::new(bindable)))
 	}
@@ -613,7 +613,7 @@
 	pub fn value(self, value: Val) {
 		self.binding(LazyBinding::Bound(Thunk::evaluated(value)));
 	}
-	pub fn bindable(self, bindable: TraceBox<dyn Bindable<Bound = Thunk<Val>>>) {
+	pub fn bindable(self, bindable: TraceBox<dyn Unbound<Bound = Thunk<Val>>>) {
 		self.binding(LazyBinding::Bindable(Cc::new(bindable)));
 	}
 	pub fn binding(self, binding: LazyBinding) {
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -12,7 +12,7 @@
 	stdlib::manifest::{
 		manifest_json_ex, manifest_yaml_ex, ManifestJsonOptions, ManifestType, ManifestYamlOptions,
 	},
-	throw, Bindable, ObjValue, Result, State, WeakObjValue,
+	throw, ObjValue, Result, State, Unbound, WeakObjValue,
 };
 
 pub trait ThunkValue: Trace {
@@ -74,14 +74,14 @@
 type CacheKey = (Option<WeakObjValue>, Option<WeakObjValue>);
 
 #[derive(Trace, Clone)]
-pub struct CachedBindable<I, T>
+pub struct CachedUnbound<I, T>
 where
-	I: Bindable<Bound = T>,
+	I: Unbound<Bound = T>,
 {
 	cache: Cc<RefCell<GcHashMap<CacheKey, T>>>,
 	value: I,
 }
-impl<I: Bindable<Bound = T>, T: Trace> CachedBindable<I, T> {
+impl<I: Unbound<Bound = T>, T: Trace> CachedUnbound<I, T> {
 	pub fn new(value: I) -> Self {
 		Self {
 			cache: Cc::new(RefCell::new(GcHashMap::new())),
@@ -89,7 +89,7 @@
 		}
 	}
 }
-impl<I: Bindable<Bound = T>, T: Clone + Trace> Bindable for CachedBindable<I, T> {
+impl<I: Unbound<Bound = T>, T: Clone + Trace> Unbound for CachedUnbound<I, T> {
 	type Bound = T;
 	fn bind(&self, s: State, sup: Option<ObjValue>, this: Option<ObjValue>) -> Result<T> {
 		let cache_key = (