difftreelog
feat wire jrsonnet-web for experimental features
in: master
11 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2695,6 +2695,7 @@
"jrsonnet-stdlib",
"jrsonnet-types",
"js-sys",
+ "num-bigint",
"rustc-hash 2.1.2",
"url",
"wasm-bindgen",
bindings/jrsonnet-web/Cargo.tomldiffbeforeafterboth--- a/bindings/jrsonnet-web/Cargo.toml
+++ b/bindings/jrsonnet-web/Cargo.toml
@@ -9,6 +9,19 @@
repository.workspace = true
version.workspace = true
+[features]
+experimental = ["exp-preserve-order", "exp-bigint"]
+exp-preserve-order = [
+ "jrsonnet-evaluator/exp-preserve-order",
+ "jrsonnet-stdlib/exp-preserve-order",
+]
+exp-bigint = [
+ "dep:num-bigint",
+ "jrsonnet-evaluator/exp-bigint",
+ "jrsonnet-stdlib/exp-bigint",
+ "jrsonnet-types/exp-bigint",
+]
+
[dependencies]
console_error_panic_hook.workspace = true
getrandom = { workspace = true, features = ["wasm_js"] }
@@ -19,6 +32,7 @@
jrsonnet-stdlib.workspace = true
jrsonnet-types.workspace = true
js-sys.workspace = true
+num-bigint = { workspace = true, optional = true }
rustc-hash.workspace = true
url.workspace = true
wasm-bindgen.workspace = true
bindings/jrsonnet-web/src/lib.rsdiffbeforeafterboth--- a/bindings/jrsonnet-web/src/lib.rs
+++ b/bindings/jrsonnet-web/src/lib.rs
@@ -31,6 +31,7 @@
Arr,
Obj,
Func,
+ BigInt,
}
thread_local! {
@@ -132,6 +133,8 @@
ValType::Arr => Self::Arr,
ValType::Obj => Self::Obj,
ValType::Func => Self::Func,
+ #[cfg(feature = "exp-bigint")]
+ ValType::BigInt => Self::BigInt,
}
}
}
@@ -182,6 +185,26 @@
pub fn string(s: String) -> Self {
Self::new(Val::string(s))
}
+ pub fn bigint(value: js_sys::BigInt) -> Result<Self, JsError> {
+ #[cfg(feature = "exp-bigint")]
+ {
+ let s: String = value
+ .to_string(10)
+ .map_err(|_| JsError::new("invalid bigint"))?
+ .into();
+ let bi = s
+ .parse::<num_bigint::BigInt>()
+ .map_err(|e| JsError::new(&format!("failed to parse bigint: {e}")))?;
+ Ok(Self::new(Val::BigInt(Box::new(bi))))
+ }
+ #[cfg(not(feature = "exp-bigint"))]
+ {
+ let _ = value;
+ Err(JsError::new(
+ "bigint support is not enabled in this build (exp-bigint feature)",
+ ))
+ }
+ }
pub fn arr(items: Vec<WasmVal>) -> Self {
Self::new(Val::arr(
items.into_iter().map(|v| v.val).collect::<Vec<_>>(),
@@ -212,6 +235,24 @@
pub fn as_num(&self) -> Option<f64> {
self.val.as_num()
}
+ #[wasm_bindgen(js_name = asBigint)]
+ pub fn as_bigint(&self) -> Result<Option<js_sys::BigInt>, JsError> {
+ #[cfg(feature = "exp-bigint")]
+ {
+ let Some(bi) = self.val.as_bigint() else {
+ return Ok(None);
+ };
+ let big = js_sys::BigInt::new(&JsValue::from_str(&bi.to_string()))
+ .map_err(|e| JsError::new(&format!("{e:?}")))?;
+ Ok(Some(big))
+ }
+ #[cfg(not(feature = "exp-bigint"))]
+ {
+ Err(JsError::new(
+ "bigint support is not enabled in this build (exp-bigint feature)",
+ ))
+ }
+ }
#[wasm_bindgen(js_name = asString)]
pub fn as_string(&self) -> Option<String> {
self.val.as_str().map(|s| s.to_string())
@@ -259,7 +300,11 @@
#[wasm_bindgen(js_name = manifestJson)]
pub fn manifest_json(&self, indent: u32) -> Result<String, JsValue> {
- self.manifest_with(JsonFormat::cli(indent as usize))
+ self.manifest_with(JsonFormat::cli(
+ indent as usize,
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ ))
}
#[wasm_bindgen(js_name = manifestToString)]
pub fn manifest_to_string(&self) -> Result<String, JsValue> {
@@ -271,7 +316,12 @@
}
#[wasm_bindgen(js_name = manifestYaml)]
pub fn manifest_yaml(&self, indent: u32, quote_keys: bool) -> Result<String, JsValue> {
- self.manifest_with(YamlFormat::std_to_yaml(indent != 0, quote_keys))
+ self.manifest_with(YamlFormat::std_to_yaml(
+ indent != 0,
+ quote_keys,
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ ))
}
#[wasm_bindgen(js_name = manifestYamlStream)]
pub fn manifest_yaml_stream(
@@ -281,7 +331,12 @@
c_document_end: bool,
) -> Result<String, JsValue> {
self.manifest_with(YamlStreamFormat::std_yaml_stream(
- YamlFormat::std_to_yaml(indent != 0, quote_keys),
+ YamlFormat::std_to_yaml(
+ indent != 0,
+ quote_keys,
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ ),
c_document_end,
))
}
@@ -291,11 +346,18 @@
}
#[wasm_bindgen(js_name = manifestToml)]
pub fn manifest_toml(&self, indent: u32) -> Result<String, JsValue> {
- self.manifest_with(TomlFormat::std_to_toml(" ".repeat(indent as usize)))
+ self.manifest_with(TomlFormat::std_to_toml(
+ " ".repeat(indent as usize),
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ ))
}
#[wasm_bindgen(js_name = manifestIni)]
pub fn manifest_ini(&self) -> Result<String, JsValue> {
- self.manifest_with(IniFormat::std())
+ self.manifest_with(IniFormat::std(
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ ))
}
}
@@ -340,7 +402,10 @@
impl WasmObjValue {
pub fn keys(&self) -> Vec<String> {
self.obj
- .fields()
+ .fields(
+ #[cfg(feature = "exp-preserve-order")]
+ false,
+ )
.into_iter()
.map(|s| s.to_string())
.collect()
crates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -13,6 +13,12 @@
workspace = true
[features]
+experimental = [
+ "exp-preserve-order",
+ "exp-bigint",
+ "exp-null-coaelse",
+ "exp-regex",
+]
exp-preserve-order = [
"jrsonnet-evaluator/exp-preserve-order",
"jrsonnet-stdlib/exp-preserve-order",
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -26,6 +26,13 @@
# Use PEG parser
peg-parser = ["dep:jrsonnet-peg-parser"]
+experimental = [
+ "exp-preserve-order",
+ "exp-destruct",
+ "exp-object-iteration",
+ "exp-bigint",
+ "exp-null-coaelse",
+]
# Allows to preserve field order in objects
exp-preserve-order = []
# Implements field destructuring
crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth1//! jsonnet interpreter implementation2#![cfg_attr(nightly, feature(thread_local))]34// For jrsonnet-macros5extern crate self as jrsonnet_evaluator;67mod arr;8pub mod async_import;9mod ctx;10mod dynamic;11pub mod error;12mod evaluate;13pub mod function;14pub mod gc;15mod import;16mod integrations;17pub mod manifest;18mod obj;19pub mod stack;20pub mod stdlib;21pub mod tla;22pub mod trace;23pub mod typed;24pub mod val;2526use std::{27 any::Any,28 cell::{RefCell, RefMut},29 clone::Clone,30 collections::hash_map::Entry,31 fmt::{self, Debug},32 marker::PhantomData,33 rc::Rc,34};3536pub use ctx::*;37pub use dynamic::*;38pub use error::{Error, ErrorKind::*, Result, ResultExt, StackTraceElement};39pub use evaluate::ensure_sufficient_stack;40use function::CallLocation;41pub use import::*;42use jrsonnet_gcmodule::{Cc, Trace, cc_dyn};43pub use jrsonnet_interner::{IBytes, IStr};44use jrsonnet_ir::Expr;45pub use jrsonnet_ir::{NumValue, Source, SourcePath, SourceUrl, SourceVirtual, Span};46#[doc(hidden)]47pub use jrsonnet_macros;4849#[cfg(not(any(feature = "ir-parser", feature = "peg-parser")))]50compile_error!("at least one of `ir-parser` or `peg-parser` features must be enabled");5152pub use error::SyntaxError;53pub use obj::*;54pub use rustc_hash;55use rustc_hash::FxHashMap;56use stack::check_depth;57pub use tla::apply_tla;58pub use val::{Thunk, Val};5960pub mod analyze;61use self::analyze::{LExpr, analyze_root};62use crate::gc::WithCapacityExt as _;6364#[allow(clippy::needless_return)]65pub(crate) fn parse_jsonnet(code: &str, source: Source) -> Result<Expr, SyntaxError> {66 #[cfg(feature = "peg-parser")]67 {68 use std::sync::LazyLock;69 static USE_LEGACY_PARSER: LazyLock<bool> =70 LazyLock::new(|| std::env::var_os("JRSONNET_LEGACY_PARSER").is_some());7172 if *USE_LEGACY_PARSER {73 return parse_peg(code, source);74 }75 }76 #[cfg(feature = "ir-parser")]77 {78 return parse_ir(code, source);79 }80 #[cfg(feature = "peg-parser")]81 {82 return parse_peg(code, source);83 }84}8586#[cfg(feature = "ir-parser")]87fn parse_ir(code: &str, source: Source) -> Result<Expr, SyntaxError> {88 jrsonnet_ir_parser::parse(code, &jrsonnet_ir_parser::ParserSettings { source }).map_err(|e| {89 SyntaxError {90 message: e.message,91 location: e.location,92 }93 })94}9596#[cfg(feature = "peg-parser")]97fn parse_peg(code: &str, source: Source) -> Result<Expr, SyntaxError> {98 jrsonnet_peg_parser::parse(code, &jrsonnet_peg_parser::ParserSettings { source }).map_err(|e| {99 let message = e100 .expected101 .tokens()102 .find(|t| t.starts_with("!!!"))103 .map_or_else(104 || {105 format!(106 "expected {}, got {:?}",107 e.expected,108 code.chars()109 .nth(e.location.0)110 .map_or_else(|| "EOF".into(), |c: char| c.to_string())111 )112 },113 |v| v[3..].into(),114 );115 SyntaxError {116 message,117 location: e.location,118 }119 })120}121122cc_dyn!(123 #[derive(Clone)]124 CcUnbound<V>,125 Unbound<Bound = V>126);127128/// Thunk without bound `super`/`this`129/// object inheritance may be overriden multiple times, and will be fixed only on field read130pub trait Unbound: Trace {131 /// Type of value after object context is bound132 type Bound;133 /// Create value bound to specified object context134 fn bind(&self, sup_this: SupThis) -> Result<Self::Bound>;135}136137/// Object fields may, or may not depend on `this`/`super`, this enum allows cheaper reuse of object-independent fields for native code138/// Standard jsonnet fields are always unbound139#[derive(Clone, Trace)]140pub enum MaybeUnbound {141 /// Value needs to be bound to `this`/`super`142 Unbound(CcUnbound<Val>),143 /// Value is object-independent144 Bound(Thunk<Val>),145}146147impl Debug for MaybeUnbound {148 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {149 write!(f, "MaybeUnbound")150 }151}152impl MaybeUnbound {153 /// Attach object context to value, if required154 pub fn evaluate(&self, sup_this: SupThis) -> Result<Val> {155 match self {156 Self::Unbound(v) => v.0.bind(sup_this),157 Self::Bound(v) => Ok(v.evaluate()?),158 }159 }160}161162cc_dyn!(CcContextInitializer, ContextInitializer);163164/// During import, this trait will be called to create initial context for file.165/// It may initialize global variables, stdlib for example.166pub trait ContextInitializer {167 /// For composability: extend builder. May panic if this initialization is not supported,168 /// and the context may only be created via `initialize`.169 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder);170 /// Allows upcasting from abstract to concrete context initializer.171 /// jrsonnet by itself doesn't use this method, it is allowed for it to panic.172 fn as_any(&self) -> &dyn Any;173}174impl<T> ContextInitializer for &T175where176 T: ContextInitializer,177{178 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder) {179 (*self).populate(for_file, builder);180 }181182 fn as_any(&self) -> &dyn Any {183 (*self).as_any()184 }185}186187/// Context initializer which adds nothing.188impl ContextInitializer for () {189 fn populate(&self, _for_file: Source, _builder: &mut InitialContextBuilder) {}190 fn as_any(&self) -> &dyn Any {191 self192 }193}194195impl<T> ContextInitializer for Option<T>196where197 T: ContextInitializer + 'static,198{199 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder) {200 if let Some(ctx) = self {201 ctx.populate(for_file, builder);202 }203 }204205 fn as_any(&self) -> &dyn Any {206 self207 }208}209210macro_rules! impl_context_initializer {211 ($($gen:ident)*) => {212 #[allow(non_snake_case)]213 impl<$($gen: ContextInitializer + Trace,)*> ContextInitializer for ($($gen,)*) {214 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder) {215 let ($($gen,)*) = self;216 $($gen.populate(for_file.clone(), builder);)*217 }218 fn as_any(&self) -> &dyn Any {219 self220 }221 }222 };223 ($($cur:ident)* @ $c:ident $($rest:ident)*) => {224 impl_context_initializer!($($cur)*);225 impl_context_initializer!($($cur)* $c @ $($rest)*);226 };227 ($($cur:ident)* @) => {228 impl_context_initializer!($($cur)*);229 }230}231impl_context_initializer! {232 A @ B C D E F G233}234235#[derive(Trace)]236struct FileData {237 string: Option<IStr>,238 bytes: Option<IBytes>,239 parsed: Option<Rc<Expr>>,240 evaluated: Option<Val>,241242 evaluating: bool,243}244impl FileData {245 fn new_string(data: IStr) -> Self {246 Self {247 string: Some(data),248 bytes: None,249 parsed: None,250 evaluated: None,251 evaluating: false,252 }253 }254 fn new_bytes(data: IBytes) -> Self {255 Self {256 string: None,257 bytes: Some(data),258 parsed: None,259 evaluated: None,260 evaluating: false,261 }262 }263 pub(crate) fn get_string(&mut self) -> Option<IStr> {264 if self.string.is_none() {265 self.string = Some(266 self.bytes267 .as_ref()268 .expect("either string or bytes should be set")269 .clone()270 .cast_str()?,271 );272 }273 Some(self.string.clone().expect("just set"))274 }275}276277#[derive(Trace)]278pub struct EvaluationStateInternals {279 /// Internal state280 file_cache: RefCell<FxHashMap<SourcePath, FileData>>,281 /// Context initializer, which will be used for imports and everything282 /// [`NoopContextInitializer`] is used by default, most likely you want to have `jrsonnet-stdlib`283 context_initializer: CcContextInitializer,284 /// Used to resolve file locations/contents285 import_resolver: Rc<dyn ImportResolver>,286}287288/// Maintains stack trace and import resolution289#[derive(Clone, Trace)]290pub struct State(Cc<EvaluationStateInternals>);291292thread_local! {293 pub static DEFAULT_STATE: State = State::builder().build();294 pub static STATE: RefCell<Option<State>> = const {RefCell::new(None)};295}296pub struct StateEnterGuard(PhantomData<()>);297impl Drop for StateEnterGuard {298 fn drop(&mut self) {299 STATE.with_borrow_mut(|v| *v = None);300 }301}302303pub fn with_state<V>(v: impl FnOnce(State) -> V) -> V {304 if let Some(state) = STATE.with_borrow(Clone::clone) {305 v(state)306 } else {307 let s = DEFAULT_STATE.with(Clone::clone);308 v(s)309 }310}311312impl State {313 pub fn enter(&self) -> StateEnterGuard {314 self.try_enter().expect("entered state already exists")315 }316 pub fn try_enter(&self) -> Option<StateEnterGuard> {317 STATE.with_borrow_mut(|v| {318 if v.is_none() {319 *v = Some(self.clone());320 Some(StateEnterGuard(PhantomData))321 } else {322 None323 }324 })325 }326 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise327 pub fn import_resolved_str(&self, path: SourcePath) -> Result<IStr> {328 let mut file_cache = self.file_cache();329 let mut file = file_cache.entry(path.clone());330331 let file = match file {332 Entry::Occupied(ref mut d) => d.get_mut(),333 Entry::Vacant(v) => {334 let data = self.import_resolver().load_file_contents(&path)?;335 v.insert(FileData::new_string(336 std::str::from_utf8(&data)337 .map_err(|_| ImportBadFileUtf8(path.clone()))?338 .into(),339 ))340 }341 };342 Ok(file343 .get_string()344 .ok_or_else(|| ImportBadFileUtf8(path.clone()))?)345 }346 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise347 pub fn import_resolved_bin(&self, path: SourcePath) -> Result<IBytes> {348 let mut file_cache = self.file_cache();349 let mut file = file_cache.entry(path.clone());350351 let file = match file {352 Entry::Occupied(ref mut d) => d.get_mut(),353 Entry::Vacant(v) => {354 let data = self.import_resolver().load_file_contents(&path)?;355 v.insert(FileData::new_bytes(data.as_slice().into()))356 }357 };358 if let Some(str) = &file.bytes {359 return Ok(str.clone());360 }361 if file.bytes.is_none() {362 file.bytes = Some(363 file.string364 .as_ref()365 .expect("either string or bytes should be set")366 .clone()367 .cast_bytes(),368 );369 }370 Ok(file.bytes.as_ref().expect("just set").clone())371 }372 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise373 pub fn import_resolved(&self, path: SourcePath) -> Result<Val> {374 let mut file_cache = self.file_cache();375 let mut file = file_cache.entry(path.clone());376377 let file = match file {378 Entry::Occupied(ref mut d) => d.get_mut(),379 Entry::Vacant(v) => {380 let data = self.import_resolver().load_file_contents(&path)?;381 v.insert(FileData::new_string(382 std::str::from_utf8(&data)383 .map_err(|_| ImportBadFileUtf8(path.clone()))?384 .into(),385 ))386 }387 };388 if let Some(val) = &file.evaluated {389 return Ok(val.clone());390 }391 let code = file392 .get_string()393 .ok_or_else(|| ImportBadFileUtf8(path.clone()))?;394 let file_name = Source::new(path.clone(), code.clone());395 if file.parsed.is_none() {396 file.parsed = Some(397 parse_jsonnet(&code, file_name.clone())398 .map(Rc::new)399 .map_err(|e| {400 let span = e.location.clone();401 let mut err = Error::from(ImportSyntaxError {402 path: file_name.clone(),403 error: Box::new(e),404 });405 err.trace_mut().0.push(StackTraceElement {406 location: Some(span),407 desc: "parse imported".to_string(),408 });409 err410 })?,411 );412 }413 let parsed = file.parsed.as_ref().expect("just set").clone();414 if file.evaluating {415 bail!(InfiniteRecursionDetected)416 }417 file.evaluating = true;418 // Dropping file cache guard here, as evaluation may use this map too419 drop(file_cache);420 let (externals, thunks) = self.create_default_context(file_name).build();421 let report = analyze_root(&parsed, externals);422 if report.errored {423 return Err(StaticAnalysisError(report.diagnostics_list).into());424 }425 debug_assert_eq!(report.root_shape.n_locals as usize, thunks.len());426 debug_assert!(report.root_shape.captures.is_empty());427 let ctx = Context::root(thunks);428 let res = evaluate::evaluate(ctx, &report.lir);429430 let mut file_cache = self.file_cache();431 let mut file = file_cache.entry(path);432433 let Entry::Occupied(file) = &mut file else {434 unreachable!("this file was just here")435 };436 let file = file.get_mut();437 file.evaluating = false;438 match res {439 Ok(v) => {440 file.evaluated = Some(v.clone());441 Ok(v)442 }443 Err(e) => Err(e),444 }445 }446447 /// Has same semantics as `import 'path'` called from `from` file448 pub fn import_from(&self, from: &SourcePath, path: impl AsPathLike) -> Result<Val> {449 let resolved = self.resolve_from(from, &path)?;450 self.import_resolved(resolved)451 }452 pub fn import(&self, path: impl AsPathLike) -> Result<Val> {453 let resolved = self.resolve_from_default(&path)?;454 self.import_resolved(resolved)455 }456457 /// Creates context with all passed global variables458 pub fn create_default_context(&self, source: Source) -> InitialContextBuilder {459 self.create_default_context_with(source, &())460 }461462 /// Creates context with all passed global variables, calling custom modifier463 pub fn create_default_context_with(464 &self,465 source: Source,466 context_initializer: &dyn ContextInitializer,467 ) -> InitialContextBuilder {468 let default_initializer = self.context_initializer();469 let mut builder = InitialContextBuilder::new();470 default_initializer.populate(source.clone(), &mut builder);471 context_initializer.populate(source, &mut builder);472473 builder474 }475}476477/// Internals478impl State {479 fn file_cache(&self) -> RefMut<'_, FxHashMap<SourcePath, FileData>> {480 self.0.file_cache.borrow_mut()481 }482}483/// Executes code creating a new stack frame, to be replaced with try{}484pub fn in_frame<T>(485 e: CallLocation<'_>,486 frame_desc: impl FnOnce() -> String,487 f: impl FnOnce() -> Result<T>,488) -> Result<T> {489 let _guard = check_depth()?;490491 f().with_description_src(e, frame_desc)492}493494/// Executes code creating a new stack frame, to be replaced with try{}495pub fn in_description_frame<T>(496 frame_desc: impl FnOnce() -> String,497 f: impl FnOnce() -> Result<T>,498) -> Result<T> {499 let _guard = check_depth()?;500501 f().with_description(frame_desc)502}503504#[derive(Trace)]505pub struct InitialUnderscore(pub Thunk<Val>);506impl ContextInitializer for InitialUnderscore {507 fn populate(&self, _for_file: Source, builder: &mut InitialContextBuilder) {508 builder.bind("_", self.0.clone());509 }510511 fn as_any(&self) -> &dyn Any {512 self513 }514}515516pub struct PreparedSnippet {517 lir: LExpr,518 thunks: Vec<Thunk<Val>>,519}520521/// Raw methods evaluate passed values but don't perform TLA execution522impl State {523 /// Parses and analyses the given snippet with a custom context524 /// modifier.525 pub fn prepare_snippet_with(526 &self,527 name: impl Into<IStr>,528 code: impl Into<IStr>,529 context_initializer: &dyn ContextInitializer,530 ) -> Result<PreparedSnippet> {531 let code = code.into();532 let source = Source::new_virtual(name.into(), code.clone());533 let parsed = parse_jsonnet(&code, source.clone()).map_err(|e| ImportSyntaxError {534 path: source.clone(),535 error: Box::new(e),536 })?;537 let (externals, thunks) = self538 .create_default_context_with(source, context_initializer)539 .build();540 let report = analyze_root(&parsed, externals);541 if report.errored {542 return Err(StaticAnalysisError(report.diagnostics_list).into());543 }544 debug_assert_eq!(report.root_shape.n_locals as usize, thunks.len());545 debug_assert!(report.root_shape.captures.is_empty());546 Ok(PreparedSnippet {547 lir: report.lir,548 thunks,549 })550 }551 /// Parses and analyses the given snippet552 pub fn prepare_snippet(553 &self,554 name: impl Into<IStr>,555 code: impl Into<IStr>,556 ) -> Result<PreparedSnippet> {557 self.prepare_snippet_with(name, code, &())558 }559 pub fn evaluate_prepared_snippet(&self, prepared: &PreparedSnippet) -> Result<Val> {560 let ctx = Context::root(prepared.thunks.clone());561 evaluate::evaluate(ctx, &prepared.lir)562 }563 /// Parses and evaluates the given snippet with custom context modifier564 pub fn evaluate_snippet_with(565 &self,566 name: impl Into<IStr>,567 code: impl Into<IStr>,568 context_initializer: &dyn ContextInitializer,569 ) -> Result<Val> {570 let prepared = self.prepare_snippet_with(name, code, context_initializer)?;571 self.evaluate_prepared_snippet(&prepared)572 }573 /// Parses and evaluates the given snippet574 pub fn evaluate_snippet(&self, name: impl Into<IStr>, code: impl Into<IStr>) -> Result<Val> {575 self.evaluate_snippet_with(name, code, &())576 }577}578579/// Settings utilities580impl State {581 // Only panics in case of [`ImportResolver`] contract violation582 #[allow(clippy::missing_panics_doc)]583 pub fn resolve_from(&self, from: &SourcePath, path: &dyn AsPathLike) -> Result<SourcePath> {584 self.import_resolver().resolve_from(from, path)585 }586 #[allow(clippy::missing_panics_doc)]587 pub fn resolve_from_default(&self, path: &dyn AsPathLike) -> Result<SourcePath> {588 self.import_resolver().resolve_from_default(path)589 }590 pub fn import_resolver(&self) -> &dyn ImportResolver {591 &*self.0.import_resolver592 }593 pub fn context_initializer(&self) -> &dyn ContextInitializer {594 &*self.0.context_initializer.0595 }596}597598impl State {599 pub fn builder() -> StateBuilder {600 StateBuilder::default()601 }602}603604impl Default for State {605 fn default() -> Self {606 Self::builder().build()607 }608}609610#[derive(Default)]611pub struct StateBuilder {612 import_resolver: Option<Rc<dyn ImportResolver>>,613 context_initializer: Option<CcContextInitializer>,614}615impl StateBuilder {616 pub fn import_resolver(&mut self, import_resolver: impl ImportResolver) -> &mut Self {617 let _ = self.import_resolver.insert(Rc::new(import_resolver));618 self619 }620 pub fn context_initializer(621 &mut self,622 context_initializer: impl ContextInitializer + Trace,623 ) -> &mut Self {624 let _ = self625 .context_initializer626 .insert(CcContextInitializer::new(context_initializer));627 self628 }629 pub fn build(mut self) -> State {630 State(Cc::new(EvaluationStateInternals {631 file_cache: RefCell::new(FxHashMap::new()),632 context_initializer: self633 .context_initializer634 .take()635 .unwrap_or_else(|| CcContextInitializer::new(())),636 import_resolver: self637 .import_resolver638 .take()639 .unwrap_or_else(|| Rc::new(DummyImportResolver)),640 }))641 }642}1//! jsonnet interpreter implementation2#![cfg_attr(nightly, feature(thread_local))]34// For jrsonnet-macros5extern crate self as jrsonnet_evaluator;67mod arr;8pub mod async_import;9mod ctx;10mod dynamic;11pub mod error;12mod evaluate;13pub mod function;14pub mod gc;15mod import;16mod integrations;17pub mod manifest;18mod obj;19pub mod stack;20pub mod stdlib;21pub mod tla;22pub mod trace;23pub mod typed;24pub mod val;2526use std::{27 any::Any,28 cell::{RefCell, RefMut},29 clone::Clone,30 collections::hash_map::Entry,31 fmt::{self, Debug},32 marker::PhantomData,33 rc::Rc,34};3536pub use ctx::*;37pub use dynamic::*;38pub use error::{Error, ErrorKind::*, Result, ResultExt, StackTraceElement};39pub use evaluate::ensure_sufficient_stack;40use function::CallLocation;41pub use import::*;42use jrsonnet_gcmodule::{Cc, Trace, cc_dyn};43pub use jrsonnet_interner::{IBytes, IStr};44use jrsonnet_ir::Expr;45pub use jrsonnet_ir::{46 NumValue, Source, SourceDefaultIgnoreJpath, SourcePath, SourceUrl, SourceVirtual, Span,47};48#[doc(hidden)]49pub use jrsonnet_macros;5051#[cfg(not(any(feature = "ir-parser", feature = "peg-parser")))]52compile_error!("at least one of `ir-parser` or `peg-parser` features must be enabled");5354pub use error::SyntaxError;55pub use obj::*;56pub use rustc_hash;57use rustc_hash::FxHashMap;58use stack::check_depth;59pub use tla::apply_tla;60pub use val::{Thunk, Val};6162pub mod analyze;63use self::analyze::{LExpr, analyze_root};64use crate::gc::WithCapacityExt as _;6566#[allow(clippy::needless_return)]67pub(crate) fn parse_jsonnet(code: &str, source: Source) -> Result<Expr, SyntaxError> {68 #[cfg(feature = "peg-parser")]69 {70 use std::sync::LazyLock;71 static USE_LEGACY_PARSER: LazyLock<bool> =72 LazyLock::new(|| std::env::var_os("JRSONNET_LEGACY_PARSER").is_some());7374 if *USE_LEGACY_PARSER {75 return parse_peg(code, source);76 }77 }78 #[cfg(feature = "ir-parser")]79 {80 return parse_ir(code, source);81 }82 #[cfg(feature = "peg-parser")]83 {84 return parse_peg(code, source);85 }86}8788#[cfg(feature = "ir-parser")]89fn parse_ir(code: &str, source: Source) -> Result<Expr, SyntaxError> {90 jrsonnet_ir_parser::parse(code, &jrsonnet_ir_parser::ParserSettings { source }).map_err(|e| {91 SyntaxError {92 message: e.message,93 location: e.location,94 }95 })96}9798#[cfg(feature = "peg-parser")]99fn parse_peg(code: &str, source: Source) -> Result<Expr, SyntaxError> {100 jrsonnet_peg_parser::parse(code, &jrsonnet_peg_parser::ParserSettings { source }).map_err(|e| {101 let message = e102 .expected103 .tokens()104 .find(|t| t.starts_with("!!!"))105 .map_or_else(106 || {107 format!(108 "expected {}, got {:?}",109 e.expected,110 code.chars()111 .nth(e.location.0)112 .map_or_else(|| "EOF".into(), |c: char| c.to_string())113 )114 },115 |v| v[3..].into(),116 );117 SyntaxError {118 message,119 location: e.location,120 }121 })122}123124cc_dyn!(125 #[derive(Clone)]126 CcUnbound<V>,127 Unbound<Bound = V>128);129130/// Thunk without bound `super`/`this`131/// object inheritance may be overriden multiple times, and will be fixed only on field read132pub trait Unbound: Trace {133 /// Type of value after object context is bound134 type Bound;135 /// Create value bound to specified object context136 fn bind(&self, sup_this: SupThis) -> Result<Self::Bound>;137}138139/// Object fields may, or may not depend on `this`/`super`, this enum allows cheaper reuse of object-independent fields for native code140/// Standard jsonnet fields are always unbound141#[derive(Clone, Trace)]142pub enum MaybeUnbound {143 /// Value needs to be bound to `this`/`super`144 Unbound(CcUnbound<Val>),145 /// Value is object-independent146 Bound(Thunk<Val>),147}148149impl Debug for MaybeUnbound {150 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {151 write!(f, "MaybeUnbound")152 }153}154impl MaybeUnbound {155 /// Attach object context to value, if required156 pub fn evaluate(&self, sup_this: SupThis) -> Result<Val> {157 match self {158 Self::Unbound(v) => v.0.bind(sup_this),159 Self::Bound(v) => Ok(v.evaluate()?),160 }161 }162}163164cc_dyn!(CcContextInitializer, ContextInitializer);165166/// During import, this trait will be called to create initial context for file.167/// It may initialize global variables, stdlib for example.168pub trait ContextInitializer {169 /// For composability: extend builder. May panic if this initialization is not supported,170 /// and the context may only be created via `initialize`.171 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder);172 /// Allows upcasting from abstract to concrete context initializer.173 /// jrsonnet by itself doesn't use this method, it is allowed for it to panic.174 fn as_any(&self) -> &dyn Any;175}176impl<T> ContextInitializer for &T177where178 T: ContextInitializer,179{180 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder) {181 (*self).populate(for_file, builder);182 }183184 fn as_any(&self) -> &dyn Any {185 (*self).as_any()186 }187}188189/// Context initializer which adds nothing.190impl ContextInitializer for () {191 fn populate(&self, _for_file: Source, _builder: &mut InitialContextBuilder) {}192 fn as_any(&self) -> &dyn Any {193 self194 }195}196197impl<T> ContextInitializer for Option<T>198where199 T: ContextInitializer + 'static,200{201 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder) {202 if let Some(ctx) = self {203 ctx.populate(for_file, builder);204 }205 }206207 fn as_any(&self) -> &dyn Any {208 self209 }210}211212macro_rules! impl_context_initializer {213 ($($gen:ident)*) => {214 #[allow(non_snake_case)]215 impl<$($gen: ContextInitializer + Trace,)*> ContextInitializer for ($($gen,)*) {216 fn populate(&self, for_file: Source, builder: &mut InitialContextBuilder) {217 let ($($gen,)*) = self;218 $($gen.populate(for_file.clone(), builder);)*219 }220 fn as_any(&self) -> &dyn Any {221 self222 }223 }224 };225 ($($cur:ident)* @ $c:ident $($rest:ident)*) => {226 impl_context_initializer!($($cur)*);227 impl_context_initializer!($($cur)* $c @ $($rest)*);228 };229 ($($cur:ident)* @) => {230 impl_context_initializer!($($cur)*);231 }232}233impl_context_initializer! {234 A @ B C D E F G235}236237#[derive(Trace)]238struct FileData {239 string: Option<IStr>,240 bytes: Option<IBytes>,241 parsed: Option<Rc<Expr>>,242 evaluated: Option<Val>,243244 evaluating: bool,245}246impl FileData {247 fn new_string(data: IStr) -> Self {248 Self {249 string: Some(data),250 bytes: None,251 parsed: None,252 evaluated: None,253 evaluating: false,254 }255 }256 fn new_bytes(data: IBytes) -> Self {257 Self {258 string: None,259 bytes: Some(data),260 parsed: None,261 evaluated: None,262 evaluating: false,263 }264 }265 pub(crate) fn get_string(&mut self) -> Option<IStr> {266 if self.string.is_none() {267 self.string = Some(268 self.bytes269 .as_ref()270 .expect("either string or bytes should be set")271 .clone()272 .cast_str()?,273 );274 }275 Some(self.string.clone().expect("just set"))276 }277}278279#[derive(Trace)]280pub struct EvaluationStateInternals {281 /// Internal state282 file_cache: RefCell<FxHashMap<SourcePath, FileData>>,283 /// Context initializer, which will be used for imports and everything284 /// [`NoopContextInitializer`] is used by default, most likely you want to have `jrsonnet-stdlib`285 context_initializer: CcContextInitializer,286 /// Used to resolve file locations/contents287 import_resolver: Rc<dyn ImportResolver>,288}289290/// Maintains stack trace and import resolution291#[derive(Clone, Trace)]292pub struct State(Cc<EvaluationStateInternals>);293294thread_local! {295 pub static DEFAULT_STATE: State = State::builder().build();296 pub static STATE: RefCell<Option<State>> = const {RefCell::new(None)};297}298pub struct StateEnterGuard(PhantomData<()>);299impl Drop for StateEnterGuard {300 fn drop(&mut self) {301 STATE.with_borrow_mut(|v| *v = None);302 }303}304305pub fn with_state<V>(v: impl FnOnce(State) -> V) -> V {306 if let Some(state) = STATE.with_borrow(Clone::clone) {307 v(state)308 } else {309 let s = DEFAULT_STATE.with(Clone::clone);310 v(s)311 }312}313314impl State {315 pub fn enter(&self) -> StateEnterGuard {316 self.try_enter().expect("entered state already exists")317 }318 pub fn try_enter(&self) -> Option<StateEnterGuard> {319 STATE.with_borrow_mut(|v| {320 if v.is_none() {321 *v = Some(self.clone());322 Some(StateEnterGuard(PhantomData))323 } else {324 None325 }326 })327 }328 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise329 pub fn import_resolved_str(&self, path: SourcePath) -> Result<IStr> {330 let mut file_cache = self.file_cache();331 let mut file = file_cache.entry(path.clone());332333 let file = match file {334 Entry::Occupied(ref mut d) => d.get_mut(),335 Entry::Vacant(v) => {336 let data = self.import_resolver().load_file_contents(&path)?;337 v.insert(FileData::new_string(338 std::str::from_utf8(&data)339 .map_err(|_| ImportBadFileUtf8(path.clone()))?340 .into(),341 ))342 }343 };344 Ok(file345 .get_string()346 .ok_or_else(|| ImportBadFileUtf8(path.clone()))?)347 }348 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise349 pub fn import_resolved_bin(&self, path: SourcePath) -> Result<IBytes> {350 let mut file_cache = self.file_cache();351 let mut file = file_cache.entry(path.clone());352353 let file = match file {354 Entry::Occupied(ref mut d) => d.get_mut(),355 Entry::Vacant(v) => {356 let data = self.import_resolver().load_file_contents(&path)?;357 v.insert(FileData::new_bytes(data.as_slice().into()))358 }359 };360 if let Some(str) = &file.bytes {361 return Ok(str.clone());362 }363 if file.bytes.is_none() {364 file.bytes = Some(365 file.string366 .as_ref()367 .expect("either string or bytes should be set")368 .clone()369 .cast_bytes(),370 );371 }372 Ok(file.bytes.as_ref().expect("just set").clone())373 }374 /// Should only be called with path retrieved from [`resolve_path`], may panic otherwise375 pub fn import_resolved(&self, path: SourcePath) -> Result<Val> {376 let mut file_cache = self.file_cache();377 let mut file = file_cache.entry(path.clone());378379 let file = match file {380 Entry::Occupied(ref mut d) => d.get_mut(),381 Entry::Vacant(v) => {382 let data = self.import_resolver().load_file_contents(&path)?;383 v.insert(FileData::new_string(384 std::str::from_utf8(&data)385 .map_err(|_| ImportBadFileUtf8(path.clone()))?386 .into(),387 ))388 }389 };390 if let Some(val) = &file.evaluated {391 return Ok(val.clone());392 }393 let code = file394 .get_string()395 .ok_or_else(|| ImportBadFileUtf8(path.clone()))?;396 let file_name = Source::new(path.clone(), code.clone());397 if file.parsed.is_none() {398 file.parsed = Some(399 parse_jsonnet(&code, file_name.clone())400 .map(Rc::new)401 .map_err(|e| {402 let span = e.location.clone();403 let mut err = Error::from(ImportSyntaxError {404 path: file_name.clone(),405 error: Box::new(e),406 });407 err.trace_mut().0.push(StackTraceElement {408 location: Some(span),409 desc: "parse imported".to_string(),410 });411 err412 })?,413 );414 }415 let parsed = file.parsed.as_ref().expect("just set").clone();416 if file.evaluating {417 bail!(InfiniteRecursionDetected)418 }419 file.evaluating = true;420 // Dropping file cache guard here, as evaluation may use this map too421 drop(file_cache);422 let (externals, thunks) = self.create_default_context(file_name).build();423 let report = analyze_root(&parsed, externals);424 if report.errored {425 return Err(StaticAnalysisError(report.diagnostics_list).into());426 }427 debug_assert_eq!(report.root_shape.n_locals as usize, thunks.len());428 debug_assert!(report.root_shape.captures.is_empty());429 let ctx = Context::root(thunks);430 let res = evaluate::evaluate(ctx, &report.lir);431432 let mut file_cache = self.file_cache();433 let mut file = file_cache.entry(path);434435 let Entry::Occupied(file) = &mut file else {436 unreachable!("this file was just here")437 };438 let file = file.get_mut();439 file.evaluating = false;440 match res {441 Ok(v) => {442 file.evaluated = Some(v.clone());443 Ok(v)444 }445 Err(e) => Err(e),446 }447 }448449 /// Has same semantics as `import 'path'` called from `from` file450 pub fn import_from(&self, from: &SourcePath, path: impl AsPathLike) -> Result<Val> {451 let resolved = self.resolve_from(from, &path)?;452 self.import_resolved(resolved)453 }454 pub fn import(&self, path: impl AsPathLike) -> Result<Val> {455 let resolved = self.resolve_from_default(&path)?;456 self.import_resolved(resolved)457 }458459 /// Creates context with all passed global variables460 pub fn create_default_context(&self, source: Source) -> InitialContextBuilder {461 self.create_default_context_with(source, &())462 }463464 /// Creates context with all passed global variables, calling custom modifier465 pub fn create_default_context_with(466 &self,467 source: Source,468 context_initializer: &dyn ContextInitializer,469 ) -> InitialContextBuilder {470 let default_initializer = self.context_initializer();471 let mut builder = InitialContextBuilder::new();472 default_initializer.populate(source.clone(), &mut builder);473 context_initializer.populate(source, &mut builder);474475 builder476 }477}478479/// Internals480impl State {481 fn file_cache(&self) -> RefMut<'_, FxHashMap<SourcePath, FileData>> {482 self.0.file_cache.borrow_mut()483 }484}485/// Executes code creating a new stack frame, to be replaced with try{}486pub fn in_frame<T>(487 e: CallLocation<'_>,488 frame_desc: impl FnOnce() -> String,489 f: impl FnOnce() -> Result<T>,490) -> Result<T> {491 let _guard = check_depth()?;492493 f().with_description_src(e, frame_desc)494}495496/// Executes code creating a new stack frame, to be replaced with try{}497pub fn in_description_frame<T>(498 frame_desc: impl FnOnce() -> String,499 f: impl FnOnce() -> Result<T>,500) -> Result<T> {501 let _guard = check_depth()?;502503 f().with_description(frame_desc)504}505506#[derive(Trace)]507pub struct InitialUnderscore(pub Thunk<Val>);508impl ContextInitializer for InitialUnderscore {509 fn populate(&self, _for_file: Source, builder: &mut InitialContextBuilder) {510 builder.bind("_", self.0.clone());511 }512513 fn as_any(&self) -> &dyn Any {514 self515 }516}517518pub struct PreparedSnippet {519 lir: LExpr,520 thunks: Vec<Thunk<Val>>,521}522523/// Raw methods evaluate passed values but don't perform TLA execution524impl State {525 /// Parses and analyses the given snippet with a custom context526 /// modifier.527 pub fn prepare_snippet_with(528 &self,529 name: impl Into<IStr>,530 code: impl Into<IStr>,531 context_initializer: &dyn ContextInitializer,532 ) -> Result<PreparedSnippet> {533 let code = code.into();534 let source = Source::new_virtual(name.into(), code.clone());535 let parsed = parse_jsonnet(&code, source.clone()).map_err(|e| ImportSyntaxError {536 path: source.clone(),537 error: Box::new(e),538 })?;539 let (externals, thunks) = self540 .create_default_context_with(source, context_initializer)541 .build();542 let report = analyze_root(&parsed, externals);543 if report.errored {544 return Err(StaticAnalysisError(report.diagnostics_list).into());545 }546 debug_assert_eq!(report.root_shape.n_locals as usize, thunks.len());547 debug_assert!(report.root_shape.captures.is_empty());548 Ok(PreparedSnippet {549 lir: report.lir,550 thunks,551 })552 }553 /// Parses and analyses the given snippet554 pub fn prepare_snippet(555 &self,556 name: impl Into<IStr>,557 code: impl Into<IStr>,558 ) -> Result<PreparedSnippet> {559 self.prepare_snippet_with(name, code, &())560 }561 pub fn evaluate_prepared_snippet(&self, prepared: &PreparedSnippet) -> Result<Val> {562 let ctx = Context::root(prepared.thunks.clone());563 evaluate::evaluate(ctx, &prepared.lir)564 }565 /// Parses and evaluates the given snippet with custom context modifier566 pub fn evaluate_snippet_with(567 &self,568 name: impl Into<IStr>,569 code: impl Into<IStr>,570 context_initializer: &dyn ContextInitializer,571 ) -> Result<Val> {572 let prepared = self.prepare_snippet_with(name, code, context_initializer)?;573 self.evaluate_prepared_snippet(&prepared)574 }575 /// Parses and evaluates the given snippet576 pub fn evaluate_snippet(&self, name: impl Into<IStr>, code: impl Into<IStr>) -> Result<Val> {577 self.evaluate_snippet_with(name, code, &())578 }579}580581/// Settings utilities582impl State {583 // Only panics in case of [`ImportResolver`] contract violation584 #[allow(clippy::missing_panics_doc)]585 pub fn resolve_from(&self, from: &SourcePath, path: &dyn AsPathLike) -> Result<SourcePath> {586 self.import_resolver().resolve_from(from, path)587 }588 #[allow(clippy::missing_panics_doc)]589 pub fn resolve_from_default(&self, path: &dyn AsPathLike) -> Result<SourcePath> {590 self.import_resolver().resolve_from_default(path)591 }592 pub fn import_resolver(&self) -> &dyn ImportResolver {593 &*self.0.import_resolver594 }595 pub fn context_initializer(&self) -> &dyn ContextInitializer {596 &*self.0.context_initializer.0597 }598}599600impl State {601 pub fn builder() -> StateBuilder {602 StateBuilder::default()603 }604}605606impl Default for State {607 fn default() -> Self {608 Self::builder().build()609 }610}611612#[derive(Default)]613pub struct StateBuilder {614 import_resolver: Option<Rc<dyn ImportResolver>>,615 context_initializer: Option<CcContextInitializer>,616}617impl StateBuilder {618 pub fn import_resolver(&mut self, import_resolver: impl ImportResolver) -> &mut Self {619 let _ = self.import_resolver.insert(Rc::new(import_resolver));620 self621 }622 pub fn context_initializer(623 &mut self,624 context_initializer: impl ContextInitializer + Trace,625 ) -> &mut Self {626 let _ = self627 .context_initializer628 .insert(CcContextInitializer::new(context_initializer));629 self630 }631 pub fn build(mut self) -> State {632 State(Cc::new(EvaluationStateInternals {633 file_cache: RefCell::new(FxHashMap::new()),634 context_initializer: self635 .context_initializer636 .take()637 .unwrap_or_else(|| CcContextInitializer::new(())),638 import_resolver: self639 .import_resolver640 .take()641 .unwrap_or_else(|| Rc::new(DummyImportResolver)),642 }))643 }644}crates/jrsonnet-ir-parser/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-ir-parser/Cargo.toml
+++ b/crates/jrsonnet-ir-parser/Cargo.toml
@@ -10,6 +10,8 @@
version.workspace = true
[features]
+default = []
+experimental = ["exp-null-coaelse", "exp-destruct"]
exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]
exp-destruct = ["jrsonnet-ir/exp-destruct"]
crates/jrsonnet-ir/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-ir/Cargo.toml
+++ b/crates/jrsonnet-ir/Cargo.toml
@@ -12,6 +12,7 @@
[features]
default = []
+experimental = ["exp-destruct", "exp-null-coaelse"]
exp-destruct = []
exp-null-coaelse = []
crates/jrsonnet-peg-parser/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-peg-parser/Cargo.toml
+++ b/crates/jrsonnet-peg-parser/Cargo.toml
@@ -22,5 +22,6 @@
[features]
default = []
+experimental = ["exp-destruct", "exp-null-coaelse"]
exp-destruct = ["jrsonnet-ir/exp-destruct"]
exp-null-coaelse = ["jrsonnet-ir/exp-null-coaelse"]
crates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -13,6 +13,12 @@
workspace = true
[features]
+experimental = [
+ "exp-preserve-order",
+ "exp-bigint",
+ "exp-null-coaelse",
+ "exp-regex",
+]
# Add order preservation flag to some functions
exp-preserve-order = ["jrsonnet-evaluator/exp-preserve-order"]
# Bigint type
crates/jrsonnet-types/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -18,4 +18,5 @@
peg.workspace = true
[features]
+experimental = ["exp-bigint"]
exp-bigint = []