difftreelog
fix `Intrinsic` typo leftovers
in: master
5 files changed
crates/jrsonnet-evaluator/README.mddiffbeforeafterboth31test tests::bench_parse ... bench: 7,206,164 ns/iter (+/- 1,067,418)31test tests::bench_parse ... bench: 7,206,164 ns/iter (+/- 1,067,418)32```32```333334## Intristics34## Intrinsics353536Some functions from stdlib are implemented as intristics36Some functions from stdlib are implemented as intrinsics373738### Intristic handling38### Intrinsic handling393940If indexed jsonnet object has field '__intristic_namespace__' of type 'string', then any not found field/method is resolved as `Val::Intristic(__intristic_namespace__, name)`40If indexed jsonnet object has field '__intrinsic_namespace__' of type 'string', then any not found field/method is resolved as `Val::Intrinsic(__intrinsic_namespace__, name)`4141crates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth349 ], {349 ], {350 Ok(v)350 Ok(v)351 })?,351 })?,352 (ns, name) => throw!(IntristicNotFound(ns.into(), name.into())),352 (ns, name) => throw!(IntrinsicNotFound(ns.into(), name.into())),353 })353 })354}354}355355crates/jrsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth467 if let Some(v) = v.get(s.clone())? {467 if let Some(v) = v.get(s.clone())? {468 Ok(v.unwrap_if_lazy()?)468 Ok(v.unwrap_if_lazy()?)469 } else if let Some(Val::Str(n)) =469 } else if let Some(Val::Str(n)) =470 v.get("__intristic_namespace__".into())?470 v.get("__intrinsic_namespace__".into())?471 {471 {472 Ok(Val::Func(Rc::new(FuncVal::Intristic(n, s))))472 Ok(Val::Func(Rc::new(FuncVal::Intrinsic(n, s))))473 } else {473 } else {474 throw!(NoSuchField(s))474 throw!(NoSuchField(s))475 }475 }crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth76 /// Plain function implemented in jsonnet76 /// Plain function implemented in jsonnet77 Normal(FuncDesc),77 Normal(FuncDesc),78 /// Standard library function78 /// Standard library function79 Intristic(Rc<str>, Rc<str>),79 Intrinsic(Rc<str>, Rc<str>),80 /// Library functions implemented in native80 /// Library functions implemented in native81 NativeExt(Rc<str>, Rc<NativeCallback>),81 NativeExt(Rc<str>, Rc<NativeCallback>),82}82}85 fn eq(&self, other: &Self) -> bool {85 fn eq(&self, other: &Self) -> bool {86 match (self, other) {86 match (self, other) {87 (FuncVal::Normal(a), FuncVal::Normal(b)) => a == b,87 (FuncVal::Normal(a), FuncVal::Normal(b)) => a == b,88 (FuncVal::Intristic(ans, an), FuncVal::Intristic(bns, bn)) => ans == bns && an == bn,88 (FuncVal::Intrinsic(ans, an), FuncVal::Intrinsic(bns, bn)) => ans == bns && an == bn,89 (FuncVal::NativeExt(an, _), FuncVal::NativeExt(bn, _)) => an == bn,89 (FuncVal::NativeExt(an, _), FuncVal::NativeExt(bn, _)) => an == bn,90 (..) => false,90 (..) => false,91 }91 }92 }92 }93}93}94impl FuncVal {94impl FuncVal {95 pub fn is_ident(&self) -> bool {95 pub fn is_ident(&self) -> bool {96 matches!(&self, FuncVal::Intristic(ns, n) if ns as &str == "std" && n as &str == "id")96 matches!(&self, FuncVal::Intrinsic(ns, n) if ns as &str == "std" && n as &str == "id")97 }97 }98 pub fn name(&self) -> Rc<str> {98 pub fn name(&self) -> Rc<str> {99 match self {99 match self {100 FuncVal::Normal(normal) => normal.name.clone(),100 FuncVal::Normal(normal) => normal.name.clone(),101 FuncVal::Intristic(ns, name) => format!("intristic.{}.{}", ns, name).into(),101 FuncVal::Intrinsic(ns, name) => format!("intrinsic.{}.{}", ns, name).into(),102 FuncVal::NativeExt(n, _) => format!("native.{}", n).into(),102 FuncVal::NativeExt(n, _) => format!("native.{}", n).into(),103 }103 }104 }104 }120 )?;120 )?;121 evaluate(ctx, &func.body)121 evaluate(ctx, &func.body)122 }122 }123 FuncVal::Intristic(ns, name) => call_builtin(call_ctx, loc, &ns, &name, args),123 FuncVal::Intrinsic(ns, name) => call_builtin(call_ctx, loc, &ns, &name, args),124 FuncVal::NativeExt(_name, handler) => {124 FuncVal::NativeExt(_name, handler) => {125 let args = parse_function_call(call_ctx, None, &handler.params, args, true)?;125 let args = parse_function_call(call_ctx, None, &handler.params, args, true)?;126 let mut out_args = Vec::with_capacity(handler.params.len());126 let mut out_args = Vec::with_capacity(handler.params.len());149 )?;149 )?;150 evaluate(ctx, &func.body)150 evaluate(ctx, &func.body)151 }151 }152 FuncVal::Intristic(_, _) => todo!(),152 FuncVal::Intrinsic(_, _) => todo!(),153 FuncVal::NativeExt(_, _) => todo!(),153 FuncVal::NativeExt(_, _) => todo!(),154 }154 }155 }155 }160 let ctx = place_args(call_ctx, Some(func.ctx.clone()), &func.params, args)?;160 let ctx = place_args(call_ctx, Some(func.ctx.clone()), &func.params, args)?;161 evaluate(ctx, &func.body)161 evaluate(ctx, &func.body)162 }162 }163 FuncVal::Intristic(_, _) => todo!(),163 FuncVal::Intrinsic(_, _) => todo!(),164 FuncVal::NativeExt(_, _) => todo!(),164 FuncVal::NativeExt(_, _) => todo!(),165 }165 }166 }166 }crates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth1{1{2 __intristic_namespace__:: 'std',2 __intrinsic_namespace__:: 'std',334 local std = self,4 local std = self,5 local id = std.id,5 local id = std.id,