git.delta.rocks / jrsonnet / refs/commits / 795a53dd5dd7

difftreelog

refactor drop ArgsLike abstraction

pltounypYaroslav Bolyukin2026-03-22parent: #cf6d90f.patch.diff
in: master

17 files changed

modifiedbindings/jsonnet/src/lib.rsdiffbeforeafterboth
2222
23use jrsonnet_evaluator::{23use jrsonnet_evaluator::{
24 apply_tla, bail,24 apply_tla, bail,
25 function::TlaArg,
26 gc::WithCapacityExt as _,25 gc::WithCapacityExt as _,
27 manifest::{JsonFormat, ManifestFormat, ToStringFormat},26 manifest::{JsonFormat, ManifestFormat, ToStringFormat},
28 rustc_hash::FxHashMap,27 rustc_hash::FxHashMap,
29 stack::set_stack_depth_limit,28 stack::set_stack_depth_limit,
29 tla::TlaArg,
30 trace::{CompactFormat, PathResolver, TraceFormat},30 trace::{CompactFormat, PathResolver, TraceFormat},
31 AsPathLike, FileImportResolver, IStr, ImportResolver, Result, State, Val,31 AsPathLike, FileImportResolver, IStr, ImportResolver, Result, State, Val,
32};32};
40pub extern "C" fn _start() {}40pub extern "C" fn _start() {}
4141
42/// Return the version string of the Jsonnet interpreter.42/// Return the version string of the Jsonnet interpreter.
43///
43/// Conforms to [semantic versioning](http://semver.org/).44/// Conforms to [semantic versioning](http://semver.org/).
44/// If this does not match `LIB_JSONNET_VERSION`45/// If this does not match `LIB_JSONNET_VERSION`
45/// then there is a mismatch between header and compiled library.46/// then there is a mismatch between header and compiled library.
modifiedbindings/jsonnet/src/vars_tlas.rsdiffbeforeafterboth
22
3use std::{ffi::CStr, os::raw::c_char};3use std::{ffi::CStr, os::raw::c_char};
44
5use jrsonnet_evaluator::{function::TlaArg, IStr};5use jrsonnet_evaluator::tla::TlaArg;
6use jrsonnet_evaluator::IStr;
67
7use crate::VM;8use crate::VM;
89
modifiedcrates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth
1use std::str::FromStr;1use std::str::FromStr;
22
3use clap::Parser;3use clap::Parser;
4use jrsonnet_evaluator::tla::TlaArg;
4use jrsonnet_evaluator::{function::TlaArg, trace::PathResolver, Result};5use jrsonnet_evaluator::{trace::PathResolver, Result};
5use jrsonnet_stdlib::ContextInitializer;6use jrsonnet_stdlib::ContextInitializer;
67
7#[derive(Clone)]8#[derive(Clone)]
modifiedcrates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth
1use clap::Parser;1use clap::Parser;
2use jrsonnet_evaluator::tla::TlaArg;
2use jrsonnet_evaluator::{3use jrsonnet_evaluator::{error::Result, gc::WithCapacityExt as _, rustc_hash::FxHashMap, IStr};
3 error::Result, function::TlaArg, gc::WithCapacityExt as _, rustc_hash::FxHashMap, IStr,
4};
54
6use crate::{ExtFile, ExtStr};5use crate::{ExtFile, ExtStr};
modifiedcrates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth
9use jrsonnet_interner::IBytes;9use jrsonnet_interner::IBytes;
10use jrsonnet_parser::{Expr, Spanned};10use jrsonnet_parser::{Expr, Spanned};
1111
12use crate::{typed::NativeFn, Context, Result, Thunk, Val};12use crate::{function::NativeFn, Context, Result, Thunk, Val};
1313
14mod spec;14mod spec;
15pub use spec::{ArrayLike, *};15pub use spec::{ArrayLike, *};
modifiedcrates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth
6use jrsonnet_parser::{Expr, Spanned};6use jrsonnet_parser::{Expr, Spanned};
77
8use super::ArrValue;8use super::ArrValue;
9use crate::typed::NativeFn;9use crate::function::NativeFn;
10use crate::val::NumValue;
11use crate::{10use crate::{
12 error::ErrorKind::InfiniteRecursionDetected, evaluate, typed::Typed, val::ThunkValue, Context,11 error::ErrorKind::InfiniteRecursionDetected, evaluate, typed::Typed, val::ThunkValue, Context,
13 Error, ObjValue, Result, Thunk, Val,12 Error, ObjValue, Result, Thunk, Val,
deletedcrates/jrsonnet-evaluator/src/function/arglike.rsdiffbeforeafterboth

no changes

modifiedcrates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth
1use std::{fmt::Debug, rc::Rc};1use std::{fmt::Debug, rc::Rc};
22
3pub use arglike::{ArgLike, ArgsLike, TlaArg};
4use educe::Educe;3use educe::Educe;
5use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_gcmodule::{Cc, Trace};
6use jrsonnet_interner::IStr;5use jrsonnet_interner::IStr;
7pub use jrsonnet_macros::builtin;6pub use jrsonnet_macros::builtin;
8use jrsonnet_parser::{Destruct, Expr, ExprParams, Span, Spanned};7use jrsonnet_parser::{ArgsDesc, Destruct, Expr, ExprParams, Span, Spanned};
98
10use self::{9use self::{
11 builtin::{Builtin, StaticBuiltin},10 builtin::{Builtin, StaticBuiltin},
17 Result, Thunk, Val,16 Result, Thunk, Val,
18};17};
1918
20pub mod arglike;
21pub mod builtin;19pub mod builtin;
22pub mod native;20mod native;
23pub mod parse;21mod parse;
24mod prepared;22mod prepared;
2523
24pub use native::NativeFn;
26pub use prepared::PreparedFuncVal;25pub use prepared::PreparedFuncVal;
2726
28pub use jrsonnet_parser::function::*;27pub use jrsonnet_parser::function::*;
81 }80 }
8281
83 /// Create context, with which body code will run82 /// Create context, with which body code will run
84 pub fn call_body_context(83 pub(crate) fn call_body_context(
85 &self,84 &self,
86 call_ctx: Context,85 call_ctx: Context,
87 args: &dyn ArgsLike,86 args: &ArgsDesc,
88 tailstrict: bool,87 tailstrict: bool,
89 ) -> Result<Context> {88 ) -> Result<Context> {
90 parse_function_call(call_ctx, self.ctx.clone(), &self.params, args, tailstrict)89 parse_function_call(call_ctx, self.ctx.clone(), &self.params, args, tailstrict)
170 &self,169 &self,
171 call_ctx: Context,170 call_ctx: Context,
172 loc: CallLocation<'_>,171 loc: CallLocation<'_>,
173 args: &dyn ArgsLike,172 args: &ArgsDesc,
174 tailstrict: bool,173 tailstrict: bool,
175 ) -> Result<Val> {174 ) -> Result<Val> {
176 match self {175 match self {
179 evaluate(body_ctx, &func.body)178 evaluate(body_ctx, &func.body)
180 }179 }
181 Self::Thunk(thunk) => {180 Self::Thunk(thunk) => {
182 if !args.is_empty() {181 if !args.named.is_empty() || !args.unnamed.is_empty() {
183 bail!(TooManyArgsFunctionHas(0, FunctionSignature::empty()))182 bail!(TooManyArgsFunctionHas(0, FunctionSignature::empty()))
184 }183 }
185 thunk.evaluate()184 thunk.evaluate()
modifiedcrates/jrsonnet-evaluator/src/function/native.rsdiffbeforeafterboth
1use std::marker::PhantomData;
2
3use jrsonnet_gcmodule::Trace;
4
1use super::PreparedFuncVal;5use super::PreparedFuncVal;
2use crate::{typed::Typed, CallLocation, Result, Thunk};6use crate::{bail, function::FuncVal, typed::Typed, CallLocation, Result, Val};
7use jrsonnet_types::{ComplexValType, ValType};
8
9#[derive(Debug, Trace, Clone)]
10pub struct NativeFn<D: 'static>(pub(crate) PreparedFuncVal, PhantomData<D>);
11macro_rules! impl_native_desc {
12 ($i:expr; $($gen:ident)*) => {
13 impl<$($gen,)* O> NativeFn<($($gen,)* O,)>
14 where
15 $($gen: Typed,)*
16 O: Typed,
17 {
18 #[allow(non_snake_case, clippy::too_many_arguments)]
19 pub fn call(
20 &self,
21 $($gen: $gen,)*
22 ) -> Result<O> {
23 let val = self.0.call(
24 CallLocation::native(),
25 &[$(Typed::into_lazy_untyped($gen),)*],
26 &[],
27 )?;
28 O::from_untyped(val)
29 }
30 }
31 impl<$($gen,)* O> Typed for NativeFn<($($gen,)* O,)> {
32 const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Func);
33
34 fn into_untyped(_typed: Self) -> Result<Val> {
35 bail!("can only convert functions from jsonnet to native")
36 }
37
38 fn from_untyped(untyped: Val) -> Result<Self> {
39 let func = FuncVal::from_untyped(untyped)?;
40 Ok(Self(
41 PreparedFuncVal::new(func, $i, &[])?,
42 PhantomData,
43 ))
44 }
45 }
46 };
47 ($i:expr; $($cur:ident)* @ $c:ident $($rest:ident)*) => {
48 impl_native_desc!($i; $($cur)*);
49 impl_native_desc!($i + 1; $($cur)* $c @ $($rest)*);
50 };
51 ($i:expr; $($cur:ident)* @) => {
52 impl_native_desc!($i; $($cur)*);
53 }
54}
55
56impl_native_desc! {
57 0; @ A B C D E F G H I J K L
58}
59
60mod native_macro {
61 #[macro_export]
62 macro_rules! NativeFn {
63 (($($t:ty),* $(,)?) -> $res:ty) => {
64 NativeFn<($($t,)* $res)>
65 }
66 }
67}
68pub use crate::NativeFn;
369
modifiedcrates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth
1use std::rc::Rc;
2
1use jrsonnet_parser::{3use jrsonnet_parser::{
2 function::{FunctionSignature, ParamName},4 function::{FunctionSignature, ParamName},
3 ExprParams,5 ArgsDesc, Expr, ExprParams, Spanned,
4};6};
5use rustc_hash::FxHashMap;7use rustc_hash::FxHashMap;
68
7use super::arglike::ArgsLike;
8use crate::{9use crate::{
9 bail,10 bail,
10 destructure::destruct,11 destructure::destruct,
11 error::{ErrorKind::*, Result},12 error::{ErrorKind::*, Result},
12 evaluate_named_param,13 evaluate, evaluate_named_param,
13 gc::WithCapacityExt as _,14 gc::WithCapacityExt as _,
14 Context, Pending, Thunk, Val,15 Context, Pending, Thunk, Val,
15};16};
17
18fn eval_arg(ctx: Context, arg: &Rc<Spanned<Expr>>, tailstrict: bool) -> Result<Thunk<Val>> {
19 if tailstrict {
20 Ok(Thunk::evaluated(evaluate(ctx, arg)?))
21 } else {
22 let arg = arg.clone();
23 Ok(Thunk!(move || evaluate(ctx, &arg)))
24 }
25}
1626
17/// Creates correct [context](Context) for function body evaluation returning error on invalid call.27/// Creates correct [context](Context) for function body evaluation returning error on invalid call.
18///28///
22/// * `params`: function parameters' definition32/// * `params`: function parameters' definition
23/// * `args`: passed function arguments33/// * `args`: passed function arguments
24/// * `tailstrict`: if set to `true` function arguments are eagerly executed, otherwise - lazily34/// * `tailstrict`: if set to `true` function arguments are eagerly executed, otherwise - lazily
25pub fn parse_function_call(35pub(crate) fn parse_function_call(
26 ctx: Context,36 ctx: Context,
27 body_ctx: Context,37 body_ctx: Context,
28 params: &ExprParams,38 params: &ExprParams,
29 args: &dyn ArgsLike,39 args: &ArgsDesc,
30 tailstrict: bool,40 tailstrict: bool,
31) -> Result<Context> {41) -> Result<Context> {
32 let mut passed_args = FxHashMap::with_capacity(params.binds_len());42 let mut passed_args = FxHashMap::with_capacity(params.binds_len());
33 if args.unnamed_len() > params.signature.len() {43 if args.unnamed.len() > params.signature.len() {
34 bail!(TooManyArgsFunctionHas(44 bail!(TooManyArgsFunctionHas(
35 params.signature.len(),45 params.signature.len(),
36 params.signature.clone(),46 params.signature.clone(),
40 let mut filled_named = 0;50 let mut filled_named = 0;
41 let mut filled_positionals = 0;51 let mut filled_positionals = 0;
4252
43 args.unnamed_iter(ctx.clone(), tailstrict, &mut |id, arg| {53 for (id, arg) in args.unnamed.iter().enumerate() {
44 destruct(54 destruct(
45 &params.exprs[id].destruct,55 &params.exprs[id].destruct,
46 arg,56 eval_arg(ctx.clone(), arg, tailstrict)?,
47 Pending::new_filled(ctx.clone()),57 Pending::new_filled(ctx.clone()),
48 &mut passed_args,58 &mut passed_args,
49 )?;59 )?;
50 filled_positionals += 1;60 filled_positionals += 1;
51 Ok(())
52 })?;61 }
5362
54 args.named_iter(ctx, tailstrict, &mut |name, value| {63 for (name, value) in &args.named {
55 // FIXME: O(n) for arg existence check64 // FIXME: O(n) for arg existence check
56 if !params.exprs.iter().any(|p| &p.destruct.name() == name) {65 if !params.exprs.iter().any(|p| &p.destruct.name() == name) {
57 bail!(UnknownFunctionParameter(name.clone()));66 bail!(UnknownFunctionParameter(name.clone()));
58 }67 }
59 if passed_args.insert(name.clone(), value).is_some() {68 if passed_args
69 .insert(name.clone(), eval_arg(ctx.clone(), value, tailstrict)?)
70 .is_some()
71 {
60 bail!(BindingParameterASecondTime(name.clone()));72 bail!(BindingParameterASecondTime(name.clone()));
61 }73 }
62 filled_named += 1;74 filled_named += 1;
63 Ok(())
64 })?;75 }
6576
66 if filled_named + filled_positionals < params.len() {77 if filled_named + filled_positionals < params.len() {
67 // Some args are unset, but maybe we have defaults for them78 // Some args are unset, but maybe we have defaults for them
104115
105 // Some args still weren't filled116 // Some args still weren't filled
106 if filled_named + filled_positionals != params.len() {117 if filled_named + filled_positionals != params.len() {
107 for param in params.exprs.iter().skip(args.unnamed_len()) {118 for param in params.exprs.iter().skip(args.unnamed.len()) {
108 let mut found = false;119 let mut found = false;
109 args.named_names(&mut |name| {120 for (name, _) in &args.named {
110 if &param.destruct.name() == name {121 if &param.destruct.name() == name {
111 found = true;122 found = true;
112 }123 }
113 });124 }
114 if !found {125 if !found {
115 bail!(FunctionParameterNotBoundInCall(126 bail!(FunctionParameterNotBoundInCall(
116 param.destruct.name(),127 param.destruct.name(),
141pub fn parse_builtin_call(152pub fn parse_builtin_call(
142 ctx: Context,153 ctx: Context,
143 params: FunctionSignature,154 params: FunctionSignature,
144 args: &dyn ArgsLike,155 args: &ArgsDesc,
145 tailstrict: bool,156 tailstrict: bool,
146) -> Result<Vec<Option<Thunk<Val>>>> {157) -> Result<Vec<Option<Thunk<Val>>>> {
147 let mut passed_args: Vec<Option<Thunk<Val>>> = vec![None; params.len()];158 let mut passed_args: Vec<Option<Thunk<Val>>> = vec![None; params.len()];
148 if args.unnamed_len() > params.len() {159 if args.unnamed.len() > params.len() {
149 bail!(TooManyArgsFunctionHas(params.len(), params,))160 bail!(TooManyArgsFunctionHas(params.len(), params,))
150 }161 }
151162
152 let mut filled_args = 0;163 let mut filled_args = 0;
153164
154 args.unnamed_iter(ctx.clone(), tailstrict, &mut |id, arg| {165 for (id, arg) in args.unnamed.iter().enumerate() {
155 passed_args[id] = Some(arg);166 passed_args[id] = Some(eval_arg(ctx.clone(), arg, tailstrict)?);
156 filled_args += 1;167 filled_args += 1;
157 Ok(())
158 })?;168 }
159169
160 args.named_iter(ctx, tailstrict, &mut |name, arg| {170 for (name, arg) in &args.named {
161 // FIXME: O(n) for arg existence check171 // FIXME: O(n) for arg existence check
162 let id = params172 let id = params
163 .iter()173 .iter()
164 .position(|p| p.name() == name)174 .position(|p| p.name() == name)
165 .ok_or_else(|| UnknownFunctionParameter(name.clone()))?;175 .ok_or_else(|| UnknownFunctionParameter(name.clone()))?;
166 if passed_args[id].replace(arg).is_some() {176 if passed_args[id]
177 .replace(eval_arg(ctx.clone(), arg, tailstrict)?)
178 .is_some()
179 {
167 bail!(BindingParameterASecondTime(name.clone()));180 bail!(BindingParameterASecondTime(name.clone()));
168 }181 }
169 filled_args += 1;182 filled_args += 1;
170 Ok(())
171 })?;183 }
172184
173 if filled_args < params.len() {185 if filled_args < params.len() {
174 for (id, _) in params.iter().enumerate().filter(|(_, p)| p.has_default()) {186 for (id, _) in params.iter().enumerate().filter(|(_, p)| p.has_default()) {
180192
181 // Some args still wasn't filled193 // Some args still wasn't filled
182 if filled_args != params.len() {194 if filled_args != params.len() {
183 for param in params.iter().skip(args.unnamed_len()) {195 for param in params.iter().skip(args.unnamed.len()) {
184 let mut found = false;196 let mut found = false;
185 args.named_names(&mut |name| {197 for (name, _) in &args.named {
186 if param.name() == name {198 if param.name() == name {
187 found = true;199 found = true;
188 }200 }
189 });201 }
190 if !found {202 if !found {
191 bail!(FunctionParameterNotBoundInCall(203 bail!(FunctionParameterNotBoundInCall(
192 param.name().clone(),204 param.name().clone(),
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
19mod obj;19mod obj;
20pub mod stack;20pub mod stack;
21pub mod stdlib;21pub mod stdlib;
22mod tla;22pub mod tla;
23pub mod trace;23pub mod trace;
24pub mod typed;24pub mod typed;
25pub mod val;25pub mod val;
modifiedcrates/jrsonnet-evaluator/src/tla.rsdiffbeforeafterboth
1use std::{collections::HashMap, hash::BuildHasher};1use std::{collections::HashMap, hash::BuildHasher};
22
3use jrsonnet_gcmodule::Trace;
3use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;
5use jrsonnet_parser::{SourceFifo, SourcePath};
46
5use crate::{7use crate::{
6 function::{CallLocation, PreparedFuncVal, TlaArg},8 function::{CallLocation, PreparedFuncVal},
7 in_description_frame, Result, Val,9 in_description_frame, with_state, Result, Thunk, Val,
8};10};
11
12#[derive(Clone, Trace)]
13pub enum TlaArg {
14 String(IStr),
15 Val(Val),
16 Lazy(Thunk<Val>),
17 Import(String),
18 ImportStr(String),
19 InlineCode(String),
20}
21impl TlaArg {
22 pub fn evaluate_tailstrict(&self) -> Result<Val> {
23 match self {
24 Self::String(s) => Ok(Val::string(s.clone())),
25 Self::Val(val) => Ok(val.clone()),
26 Self::Lazy(lazy) => Ok(lazy.evaluate()?),
27 Self::Import(p) => with_state(|s| {
28 let resolved = s.resolve_from_default(&p.as_str())?;
29 s.import_resolved(resolved)
30 }),
31 Self::ImportStr(p) => with_state(|s| {
32 let resolved = s.resolve_from_default(&p.as_str())?;
33 s.import_resolved_str(resolved).map(Val::string)
34 }),
35 Self::InlineCode(p) => with_state(|s| {
36 let resolved =
37 SourcePath::new(SourceFifo("<inline code>".to_owned(), p.as_bytes().into()));
38 s.import_resolved(resolved)
39 }),
40 }
41 }
42 pub fn evaluate(&self) -> Result<Thunk<Val>> {
43 match self {
44 Self::String(s) => Ok(Thunk::evaluated(Val::string(s.clone()))),
45 Self::Val(val) => Ok(Thunk::evaluated(val.clone())),
46 Self::Lazy(lazy) => Ok(lazy.clone()),
47 Self::Import(p) => with_state(|s| {
48 let resolved = s.resolve_from_default(&p.as_str())?;
49 Ok(Thunk!(move || s.import_resolved(resolved)))
50 }),
51 Self::ImportStr(p) => with_state(|s| {
52 let resolved = s.resolve_from_default(&p.as_str())?;
53 Ok(Thunk!(move || s
54 .import_resolved_str(resolved)
55 .map(Val::string)))
56 }),
57 Self::InlineCode(p) => with_state(|s| {
58 let resolved =
59 SourcePath::new(SourceFifo("<inline code>".to_owned(), p.as_bytes().into()));
60 Ok(Thunk!(move || s.import_resolved(resolved)))
61 }),
62 }
63 }
64}
965
10pub fn apply_tla<H: BuildHasher>(args: &HashMap<IStr, TlaArg, H>, val: Val) -> Result<Val> {66pub fn apply_tla<H: BuildHasher>(args: &HashMap<IStr, TlaArg, H>, val: Val) -> Result<Val> {
11 Ok(if let Val::Func(func) = val {67 Ok(if let Val::Func(func) = val {
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
8use crate::{8use crate::{
9 arr::{ArrValue, BytesArray},9 arr::{ArrValue, BytesArray},
10 bail,10 bail,
11 function::{CallLocation, FuncDesc, FuncVal, PreparedFuncVal},11 function::{FuncDesc, FuncVal},
12 typed::CheckType,12 typed::CheckType,
13 val::{IndexableVal, NumValue, StrValue, ThunkMapper},13 val::{IndexableVal, NumValue, StrValue, ThunkMapper},
14 ObjValue, ObjValueBuilder, Result, ResultExt, Thunk, Val,14 ObjValue, ObjValueBuilder, Result, ResultExt, Thunk, Val,
675 }675 }
676}676}
677
678#[derive(Debug, Trace, Clone)]
679pub struct NativeFn<D: 'static>(pub(crate) PreparedFuncVal, PhantomData<D>);
680macro_rules! impl_native_desc {
681 ($i:expr; $($gen:ident)*) => {
682 impl<$($gen,)* O> NativeFn<($($gen,)* O,)>
683 where
684 $($gen: Typed,)*
685 O: Typed,
686 {
687 pub fn call(
688 &self,
689 $($gen: $gen,)*
690 ) -> Result<O> {
691 let val = self.0.call(
692 CallLocation::native(),
693 &[$(Typed::into_lazy_untyped($gen),)*],
694 &[],
695 )?;
696 O::from_untyped(val)
697 }
698 }
699 impl<$($gen,)* O> Typed for NativeFn<($($gen,)* O,)> {
700 const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Func);
701
702 fn into_untyped(_typed: Self) -> Result<Val> {
703 bail!("can only convert functions from jsonnet to native")
704 }
705
706 fn from_untyped(untyped: Val) -> Result<Self> {
707 let func = FuncVal::from_untyped(untyped)?;
708 Ok(Self(
709 PreparedFuncVal::new(func, $i, &[])?,
710 PhantomData,
711 ))
712 }
713 }
714 };
715 ($i:expr; $($cur:ident)* @ $c:ident $($rest:ident)*) => {
716 impl_native_desc!($i; $($cur)*);
717 impl_native_desc!($i + 1; $($cur)* $c @ $($rest)*);
718 };
719 ($i:expr; $($cur:ident)* @) => {
720 impl_native_desc!($i; $($cur)*);
721 }
722}
723
724impl_native_desc! {
725 0; @ A B C D E F G H I J K L
726}
727
728mod native_macro {
729 #[macro_export]
730 macro_rules! NativeFn {
731 (($($t:ty),* $(,)?) -> $res:ty) => {
732 NativeFn<($($t,)* $res)>
733 }
734 }
735}
736pub use crate::NativeFn;
737677
738impl Typed for NumValue {678impl Typed for NumValue {
739 const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Num);679 const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Num);
modifiedcrates/jrsonnet-macros/src/lib.rsdiffbeforeafterboth
405 const _: () = {405 const _: () = {
406 use ::jrsonnet_evaluator::{406 use ::jrsonnet_evaluator::{
407 State, Val,407 State, Val,
408 function::{builtin::{Builtin, StaticBuiltin}, FunctionSignature, ParamParse, ParamName, ParamDefault, CallLocation, ArgsLike, parse::parse_builtin_call},408 function::{builtin::{Builtin, StaticBuiltin}, FunctionSignature, ParamParse, ParamName, ParamDefault, CallLocation},
409 Result, Context, typed::Typed,409 Result, Context, typed::Typed,
410 parser::Span, params, Thunk,410 parser::Span, params, Thunk,
411 };411 };
modifiedcrates/jrsonnet-stdlib/src/arrays.rsdiffbeforeafterboth
22
3use jrsonnet_evaluator::{3use jrsonnet_evaluator::{
4 bail,4 bail,
5 function::{builtin, FuncVal},5 function::{builtin, FuncVal, NativeFn},
6 runtime_error,6 runtime_error,
7 typed::{BoundedI32, BoundedUsize, Either2, NativeFn, Typed},7 typed::{BoundedI32, BoundedUsize, Either2, Typed},
8 val::{equals, ArrValue, IndexableVal},8 val::{equals, ArrValue, IndexableVal},
9 Either, IStr, ObjValue, ObjValueBuilder, Result, ResultExt, Thunk, Val,9 Either, IStr, ObjValue, ObjValueBuilder, Result, ResultExt, Thunk, Val,
10};10};
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
13pub use hash::*;13pub use hash::*;
14use jrsonnet_evaluator::{14use jrsonnet_evaluator::{
15 error::Result,15 error::Result,
16 function::{CallLocation, FuncVal, TlaArg},16 function::{CallLocation, FuncVal},
17 tla::TlaArg,
17 trace::PathResolver,18 trace::PathResolver,
18 val::NumValue,19 val::NumValue,
19 ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,20 ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,
modifiedtests/tests/cpp_test_suite.rsdiffbeforeafterboth
66
7use jrsonnet_evaluator::{7use jrsonnet_evaluator::{
8 FileImportResolver, IStr, ObjValueBuilder, State, Val, apply_tla,8 FileImportResolver, IStr, ObjValueBuilder, State, Val, apply_tla,
9 function::TlaArg,
10 gc::WithCapacityExt as _,9 gc::WithCapacityExt as _,
11 manifest::JsonFormat,10 manifest::JsonFormat,
12 rustc_hash::FxHashMap,11 rustc_hash::FxHashMap,
12 tla::TlaArg,
13 trace::{CompactFormat, PathResolver, TraceFormat},13 trace::{CompactFormat, PathResolver, TraceFormat},
14};14};
15use jrsonnet_stdlib::ContextInitializer;15use jrsonnet_stdlib::ContextInitializer;