difftreelog
refactor split peg parser and ir
in: master
109 files changed
Cargo.lockdiffbeforeafterboth609 "jrsonnet-cli",609 "jrsonnet-cli",610 "jrsonnet-evaluator",610 "jrsonnet-evaluator",611 "jrsonnet-gcmodule",611 "jrsonnet-gcmodule",612 "jrsonnet-parser",612 "jrsonnet-ir",613 "mimallocator",613 "mimallocator",614 "serde",614 "serde",615 "serde_json",615 "serde_json",623 "clap",623 "clap",624 "jrsonnet-evaluator",624 "jrsonnet-evaluator",625 "jrsonnet-gcmodule",625 "jrsonnet-gcmodule",626 "jrsonnet-parser",626 "jrsonnet-ir",627 "jrsonnet-stdlib",627 "jrsonnet-stdlib",628]628]629629637 "hi-doc",637 "hi-doc",638 "jrsonnet-gcmodule",638 "jrsonnet-gcmodule",639 "jrsonnet-interner",639 "jrsonnet-interner",640 "jrsonnet-ir",640 "jrsonnet-macros",641 "jrsonnet-macros",641 "jrsonnet-parser",642 "jrsonnet-peg-parser",642 "jrsonnet-types",643 "jrsonnet-types",643 "num-bigint",644 "num-bigint",644 "pathdiff",645 "pathdiff",703 "rustc-hash 2.1.1",704 "rustc-hash 2.1.1",704]705]706707[[package]]708name = "jrsonnet-ir"709version = "0.5.0-pre97"710dependencies = [711 "insta",712 "jrsonnet-gcmodule",713 "jrsonnet-interner",714 "peg",715 "static_assertions",716]705717706[[package]]718[[package]]707name = "jrsonnet-macros"719name = "jrsonnet-macros"714]726]715727716[[package]]728[[package]]717name = "jrsonnet-parser"729name = "jrsonnet-peg-parser"718version = "0.5.0-pre97"730version = "0.5.0-pre97"719dependencies = [731dependencies = [720 "insta",732 "insta",721 "jrsonnet-gcmodule",722 "jrsonnet-interner",733 "jrsonnet-ir",723 "peg",734 "peg",724 "static_assertions",725]735]726736727[[package]]737[[package]]746 "base64",756 "base64",747 "jrsonnet-evaluator",757 "jrsonnet-evaluator",748 "jrsonnet-gcmodule",758 "jrsonnet-gcmodule",759 "jrsonnet-ir",749 "jrsonnet-macros",760 "jrsonnet-macros",750 "jrsonnet-parser",751 "lru",761 "lru",752 "md5",762 "md5",753 "num-bigint",763 "num-bigint",812 "jrsonnet-evaluator",822 "jrsonnet-evaluator",813 "jrsonnet-gcmodule",823 "jrsonnet-gcmodule",814 "jrsonnet-interner",824 "jrsonnet-interner",815 "jrsonnet-parser",825 "jrsonnet-ir",816 "jrsonnet-stdlib",826 "jrsonnet-stdlib",817]827]818828Cargo.tomldiffbeforeafterboth13[workspace.dependencies]13[workspace.dependencies]14jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0-pre97" }14jrsonnet-evaluator = { path = "./crates/jrsonnet-evaluator", version = "0.5.0-pre97" }15jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0-pre97" }15jrsonnet-macros = { path = "./crates/jrsonnet-macros", version = "0.5.0-pre97" }16jrsonnet-ir = { path = "./crates/jrsonnet-ir", version = "0.5.0-pre97" }16jrsonnet-parser = { path = "./crates/jrsonnet-parser", version = "0.5.0-pre97" }17jrsonnet-peg-parser = { path = "./crates/jrsonnet-peg-parser", version = "0.5.0-pre97" }17jrsonnet-rowan-parser = { path = "./crates/jrsonnet-rowan-parser", version = "0.5.0-pre97" }18jrsonnet-rowan-parser = { path = "./crates/jrsonnet-rowan-parser", version = "0.5.0-pre97" }18jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0-pre97" }19jrsonnet-interner = { path = "./crates/jrsonnet-interner", version = "0.5.0-pre97" }19jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", version = "0.5.0-pre97" }20jrsonnet-stdlib = { path = "./crates/jrsonnet-stdlib", version = "0.5.0-pre97" }bindings/jsonnet/Cargo.tomldiffbeforeafterboth202021[dependencies]21[dependencies]22jrsonnet-evaluator.workspace = true22jrsonnet-evaluator.workspace = true23jrsonnet-parser.workspace = true23jrsonnet-ir.workspace = true24jrsonnet-stdlib.workspace = true24jrsonnet-stdlib.workspace = true25jrsonnet-gcmodule.workspace = true25jrsonnet-gcmodule.workspace = true26jrsonnet-interner.workspace = true26jrsonnet-interner.workspace = truebindings/jsonnet/src/import.rsdiffbeforeafterboth17 AsPathLike, ImportResolver, ResolvePath,17 AsPathLike, ImportResolver, ResolvePath,18};18};19use jrsonnet_gcmodule::Acyclic;19use jrsonnet_gcmodule::Acyclic;20use jrsonnet_parser::{SourceDirectory, SourceFile, SourcePath};20use jrsonnet_ir::{SourceDirectory, SourceFile, SourcePath};212122use crate::VM;22use crate::VM;2323bindings/jsonnet/src/lib.rsdiffbeforeafterboth31 AsPathLike, FileImportResolver, IStr, ImportResolver, Result, State, Val,31 AsPathLike, FileImportResolver, IStr, ImportResolver, Result, State, Val,32};32};33use jrsonnet_gcmodule::Acyclic;33use jrsonnet_gcmodule::Acyclic;34use jrsonnet_parser::SourcePath;34use jrsonnet_ir::SourcePath;35use jrsonnet_stdlib::ContextInitializer;35use jrsonnet_stdlib::ContextInitializer;363637/// WASM stub37/// WASM stubcmds/jrsonnet/Cargo.tomldiffbeforeafterboth37# obj?.field, obj?.['field']37# obj?.field, obj?.['field']38exp-null-coaelse = [38exp-null-coaelse = [39 "jrsonnet-evaluator/exp-null-coaelse",39 "jrsonnet-evaluator/exp-null-coaelse",40 "jrsonnet-parser/exp-null-coaelse",40 "jrsonnet-ir/exp-null-coaelse",41 "jrsonnet-cli/exp-null-coaelse",41 "jrsonnet-cli/exp-null-coaelse",42]42]43# --exp-apply43# --exp-apply44exp-apply = []44exp-apply = []454546[dependencies]46[dependencies]47jrsonnet-evaluator.workspace = true47jrsonnet-evaluator.workspace = true48jrsonnet-parser.workspace = true48jrsonnet-ir.workspace = true49jrsonnet-cli.workspace = true49jrsonnet-cli.workspace = true50jrsonnet-gcmodule.workspace = true50jrsonnet-gcmodule.workspace = true5151cmds/jrsonnet/src/main.rsdiffbeforeafterboth11 error::{Error as JrError, ErrorKind},11 error::{Error as JrError, ErrorKind},12 ResultExt, State, Val,12 ResultExt, State, Val,13};13};14use jrsonnet_parser::{SourceDefaultIgnoreJpath, SourcePath};14use jrsonnet_ir::{SourceDefaultIgnoreJpath, SourcePath};151516#[cfg(feature = "mimalloc")]16#[cfg(feature = "mimalloc")]17#[global_allocator]17#[global_allocator]crates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth292930[dependencies]30[dependencies]31jrsonnet-evaluator = { workspace = true, features = ["explaining-traces"] }31jrsonnet-evaluator = { workspace = true, features = ["explaining-traces"] }32jrsonnet-parser.workspace = true32jrsonnet-ir.workspace = true33jrsonnet-stdlib.workspace = true33jrsonnet-stdlib.workspace = true34jrsonnet-gcmodule.workspace = true34jrsonnet-gcmodule.workspace = true3535crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth22# Allows to preserve field order in objects22# Allows to preserve field order in objects23exp-preserve-order = []23exp-preserve-order = []24# Implements field destructuring24# Implements field destructuring25exp-destruct = ["jrsonnet-parser/exp-destruct"]25exp-destruct = ["jrsonnet-peg-parser/exp-destruct"]26# Iteration over objects yields [key, value] elements26# Iteration over objects yields [key, value] elements27exp-object-iteration = []27exp-object-iteration = []28# Bigint type28# Bigint type29exp-bigint = ["num-bigint", "jrsonnet-types/exp-bigint"]29exp-bigint = ["num-bigint", "jrsonnet-types/exp-bigint"]30# obj?.field, obj?.['field']30# obj?.field, obj?.['field']31exp-null-coaelse = ["jrsonnet-parser/exp-null-coaelse"]31exp-null-coaelse = ["jrsonnet-peg-parser/exp-null-coaelse"]323233[dependencies]33[dependencies]34jrsonnet-interner.workspace = true34jrsonnet-interner.workspace = true35jrsonnet-parser.workspace = true35jrsonnet-ir.workspace = true36jrsonnet-peg-parser.workspace = true36jrsonnet-types.workspace = true37jrsonnet-types.workspace = true37jrsonnet-macros.workspace = true38jrsonnet-macros.workspace = true38jrsonnet-gcmodule.workspace = true39jrsonnet-gcmodule.workspace = truecrates/jrsonnet-evaluator/src/arr/mod.rsdiffbeforeafterboth778use jrsonnet_gcmodule::{cc_dyn, Cc};8use jrsonnet_gcmodule::{cc_dyn, Cc};9use jrsonnet_interner::IBytes;9use jrsonnet_interner::IBytes;10use jrsonnet_parser::{Expr, Spanned};10use jrsonnet_ir::{Expr, Spanned};111112use crate::{function::NativeFn, Context, Result, Thunk, Val};12use crate::{function::NativeFn, Context, Result, Thunk, Val};1313858586 pub fn extended(a: Self, b: Self) -> Self {86 pub fn extended(a: Self, b: Self) -> Self {87 // TODO: benchmark for an optimal value, currently just a arbitrary choice87 // TODO: benchmark for an optimal value, currently just a arbitrary choice88 const ARR_EXTEND_THRESHOLD: usize = 100;88 const ARR_EXTEND_THRESHOLD: usize = 1000;898990 if a.is_empty() {90 if a.is_empty() {91 b91 bcrates/jrsonnet-evaluator/src/arr/spec.rsdiffbeforeafterboth334use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_gcmodule::{Cc, Trace};5use jrsonnet_interner::{IBytes, IStr};5use jrsonnet_interner::{IBytes, IStr};6use jrsonnet_parser::{Expr, Spanned};6use jrsonnet_ir::{Expr, Spanned};778use super::ArrValue;8use super::ArrValue;9use crate::function::NativeFn;9use crate::function::NativeFn;crates/jrsonnet-evaluator/src/async_import.rsdiffbeforeafterboth2use std::{any::Any, cell::RefCell, future::Future};2use std::{any::Any, cell::RefCell, future::Future};334use jrsonnet_gcmodule::Acyclic;4use jrsonnet_gcmodule::Acyclic;5use jrsonnet_parser::{5use jrsonnet_ir::{6 ArgsDesc, AssertExpr, AssertStmt, BindSpec, CompSpec, Destruct, Expr, ExprParam, ExprParams,6 ArgsDesc, AssertExpr, AssertStmt, BindSpec, CompSpec, Destruct, Expr, ExprParam, ExprParams,7 FieldMember, FieldName, ForSpecData, IfElse, IfSpecData, ImportKind, ObjBody, ParserSettings,7 FieldMember, FieldName, ForSpecData, IfElse, IfSpecData, ImportKind, ObjBody, Slice, SliceDesc,8 Slice, SliceDesc, Source, SourcePath, Spanned,8 Source, SourcePath, Spanned,9};9};10use jrsonnet_peg_parser::ParserSettings;10use rustc_hash::FxHashMap;11use rustc_hash::FxHashMap;111212use crate::{AsPathLike, FileData, ImportResolver, ResolvePathOwned, State};13use crate::{AsPathLike, FileData, ImportResolver, ResolvePathOwned, State};322 };323 };323 let source = Source::new(path.clone(), code.clone());324 let source = Source::new(path.clone(), code.clone());324 // If failed - then skip import325 // If failed - then skip import325 file.parsed = jrsonnet_parser::parse(&code, &ParserSettings { source })326 file.parsed = jrsonnet_peg_parser::parse(&code, &ParserSettings { source })326 .map(Rc::new)327 .map(Rc::new)327 .ok();328 .ok();328 if let Some(parsed) = &file.parsed {329 if let Some(parsed) = &file.parsed {crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth223use jrsonnet_gcmodule::{Acyclic, Trace};3use jrsonnet_gcmodule::{Acyclic, Trace};4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;5use jrsonnet_parser::{BinaryOpType, Source, SourcePath, Span, Spanned, UnaryOpType};5use jrsonnet_ir::{BinaryOpType, Source, SourcePath, Span, Spanned, UnaryOpType};6use jrsonnet_types::ValType;6use jrsonnet_types::ValType;7use thiserror::Error;7use thiserror::Error;88169 ImportSyntaxError {169 ImportSyntaxError {170 path: Source,170 path: Source,171 #[trace(skip)]171 #[trace(skip)]172 error: Box<jrsonnet_parser::ParseError>,172 error: Box<jrsonnet_peg_parser::ParseError>,173 },173 },174174175 #[error("runtime error: {}", format_empty_str(.0))]175 #[error("runtime error: {}", format_empty_str(.0))]crates/jrsonnet-evaluator/src/evaluate/destructure.rsdiffbeforeafterboth1use std::{collections::HashMap, hash::BuildHasher};1use std::{collections::HashMap, hash::BuildHasher};223use jrsonnet_interner::IStr;3use jrsonnet_interner::IStr;4use jrsonnet_parser::{BindSpec, Destruct};4use jrsonnet_ir::{BindSpec, Destruct};556use crate::{6use crate::{7 bail,7 bail,31 Destruct::Skip => {}31 Destruct::Skip => {}32 #[cfg(feature = "exp-destruct")]32 #[cfg(feature = "exp-destruct")]33 Destruct::Array { start, rest, end } => {33 Destruct::Array { start, rest, end } => {34 use jrsonnet_parser::DestructRest;34 use jrsonnet_ir::DestructRest;353536 let min_len = start.len() + end.len();36 let min_len = start.len() + end.len();37 let has_rest = rest.is_some();37 let has_rest = rest.is_some();crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth223use jrsonnet_gcmodule::{Cc, Trace};3use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;5use jrsonnet_parser::{5use jrsonnet_ir::{6 function::ParamName, ArgsDesc, AssertStmt, BinaryOpType, BindSpec, CompSpec, Expr, ExprParams,6 function::ParamName, ArgsDesc, AssertStmt, BinaryOpType, BindSpec, CompSpec, Expr, ExprParams,7 FieldMember, FieldName, ForSpecData, IfSpecData, ImportKind, LiteralType, ObjBody, ObjMembers,7 FieldMember, FieldName, ForSpecData, IfSpecData, ImportKind, LiteralType, ObjBody, ObjMembers,8 Spanned,8 Spanned,47 stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)47 stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f)48}48}494950pub fn evaluate_trivial(expr: &Spanned<Expr>) -> Option<Val> {50pub fn evaluate_trivial(expr: &Expr) -> Option<Val> {51 fn is_trivial(expr: &Spanned<Expr>) -> bool {51 fn is_trivial(expr: &Expr) -> bool {52 match &**expr {52 match &*expr {53 Expr::Str(_)53 Expr::Str(_)54 | Expr::Num(_)54 | Expr::Num(_)55 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,55 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,56 Expr::Arr(a) => a.iter().all(is_trivial),56 Expr::Arr(a) => a.iter().all(|e| is_trivial(&**e)),57 _ => false,57 _ => false,58 }58 }59 }59 }60 Some(match &**expr {60 Some(match &*expr {61 Expr::Str(s) => Val::string(s.clone()),61 Expr::Str(s) => Val::string(s.clone()),62 Expr::Num(n) => {62 Expr::Num(n) => {63 Val::Num(NumValue::new(*n).expect("parser will not allow non-finite values"))63 Val::Num(NumValue::new(*n).expect("parser will not allow non-finite values"))71 }71 }72 Val::Arr(ArrValue::eager(72 Val::Arr(ArrValue::eager(73 n.iter()73 n.iter()74 .map(evaluate_trivial)74 .map(|e| evaluate_trivial(&**e))75 .map(|e| e.expect("checked trivial"))75 .map(|e| e.expect("checked trivial"))76 .collect(),76 .collect(),77 ))77 ))395}395}396396397#[allow(clippy::too_many_lines)]397#[allow(clippy::too_many_lines)]398pub fn evaluate(ctx: Context, expr: &Spanned<Expr>) -> Result<Val> {398pub fn evaluate(ctx: Context, expr: &Expr) -> Result<Val> {399 use Expr::*;399 use Expr::*;400400401 if let Some(trivial) = evaluate_trivial(expr) {401 if let Some(trivial) = evaluate_trivial(expr) {402 return Ok(trivial);402 return Ok(trivial);403 }403 }404 let loc = expr.span();405 Ok(match &**expr {404 Ok(match expr {406 Literal(LiteralType::This) => Val::Obj(ctx.try_this()?),405 Literal(LiteralType::This) => Val::Obj(ctx.try_this()?),407 Literal(LiteralType::Super) => Val::Obj(ctx.try_sup_this()?.standalone_super()?),406 Literal(LiteralType::Super) => Val::Obj(ctx.try_sup_this()?.standalone_super()?),408 Literal(LiteralType::Dollar) => Val::Obj(ctx.try_dollar()?),407 Literal(LiteralType::Dollar) => Val::Obj(ctx.try_dollar()?),433 BinaryOp(bin) => evaluate_binary_op_special(ctx, &bin.lhs, bin.op, &bin.rhs)?,432 BinaryOp(bin) => evaluate_binary_op_special(ctx, &bin.lhs, bin.op, &bin.rhs)?,434 UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(ctx, v)?)?,433 UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(ctx, v)?)?,435 Var(name) => in_frame(434 Var(name) => in_frame(436 CallLocation::new(&loc),435 CallLocation::new(&name.span()),437 || format!("local <{name}> access"),436 || format!("local <{name}> access"),438 || ctx.binding(name.clone())?.evaluate(),437 || ctx.binding((**name).clone())?.evaluate(),439 )?,438 )?,440 Index { indexable, parts } => ensure_sufficient_stack(|| {439 Index { indexable, parts } => ensure_sufficient_stack(|| {441 let mut parts = parts.iter();440 let mut parts = parts.iter();591 &Val::Obj(evaluate_object(ctx, b)?),590 &Val::Obj(evaluate_object(ctx, b)?),592 )?,591 )?,593 Apply(value, args, tailstrict) => ensure_sufficient_stack(|| {592 Apply(value, args, tailstrict) => ensure_sufficient_stack(|| {594 evaluate_apply(ctx, value, args, CallLocation::new(&loc), *tailstrict)593 evaluate_apply(594 ctx,595 value,596 args,597 CallLocation::new(&args.span()),598 *tailstrict,599 )595 })?,600 })?,601 evaluate(ctx, &assert.rest)?606 evaluate(ctx, &assert.rest)?602 }607 }603 ErrorStmt(e) => in_frame(608 ErrorStmt(e) => in_frame(604 CallLocation::new(&loc),609 CallLocation::new(&e.span()),605 || "error statement".to_owned(),610 || "error statement".to_owned(),606 || bail!(RuntimeError(evaluate(ctx, e)?.to_string()?,)),611 || bail!(RuntimeError(evaluate(ctx, e)?.to_string()?,)),607 )?,612 )?,608 IfElse(if_else) => {613 IfElse(if_else) => {609 if in_frame(614 if in_frame(610 CallLocation::new(&loc),615 CallLocation::new(&if_else.cond.0.span()),611 || "if condition".to_owned(),616 || "if condition".to_owned(),612 || bool::from_untyped(evaluate(ctx.clone(), &if_else.cond.0)?),617 || bool::from_untyped(evaluate(ctx.clone(), &if_else.cond.0)?),613 )? {618 )? {crates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth1use std::cmp::Ordering;1use std::cmp::Ordering;223use jrsonnet_parser::{BinaryOpType, Expr, Spanned, UnaryOpType};3use jrsonnet_ir::{BinaryOpType, Expr, Spanned, UnaryOpType};445use crate::{5use crate::{6 arr::ArrValue,6 arr::ArrValue,crates/jrsonnet-evaluator/src/function/builtin.rsdiffbeforeafterboth1use std::any::Any;1use std::any::Any;223use jrsonnet_gcmodule::{cc_dyn, Trace, TraceBox};3use jrsonnet_gcmodule::{cc_dyn, Trace, TraceBox};4use jrsonnet_parser::function::{FunctionSignature, ParamDefault, ParamName, ParamParse};4use jrsonnet_ir::function::{FunctionSignature, ParamDefault, ParamName, ParamParse};556use super::CallLocation;6use super::CallLocation;7use crate::{Result, Thunk, Val};7use crate::{Result, Thunk, Val};crates/jrsonnet-evaluator/src/function/mod.rsdiffbeforeafterboth4use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_gcmodule::{Cc, Trace};5use jrsonnet_interner::IStr;5use jrsonnet_interner::IStr;6pub use jrsonnet_macros::builtin;6pub use jrsonnet_macros::builtin;7use jrsonnet_parser::{ArgsDesc, Destruct, Expr, ExprParams, Span, Spanned};7use jrsonnet_ir::{ArgsDesc, Destruct, Expr, ExprParams, Span, Spanned};889use self::{9use self::{10 builtin::{Builtin, StaticBuiltin},10 builtin::{Builtin, StaticBuiltin},24pub use native::NativeFn;24pub use native::NativeFn;25pub use prepared::PreparedFuncVal;25pub use prepared::PreparedFuncVal;262627pub use jrsonnet_parser::function::*;27pub use jrsonnet_ir::function::*;282829/// Function callsite location.29/// Function callsite location.30/// Either from other jsonnet code, specified by expression location, or from native (without location).30/// Either from other jsonnet code, specified by expression location, or from native (without location).crates/jrsonnet-evaluator/src/function/parse.rsdiffbeforeafterboth1use std::rc::Rc;1use std::rc::Rc;223use jrsonnet_parser::{3use jrsonnet_ir::{4 function::{FunctionSignature, ParamName},4 function::{FunctionSignature, ParamName},5 ArgsDesc, Expr, ExprParams, Spanned,5 ArgsDesc, Expr, ExprParams, Spanned,6};6};crates/jrsonnet-evaluator/src/function/prepared.rsdiffbeforeafterboth1use std::rc::Rc;1use std::rc::Rc;223use jrsonnet_gcmodule::{Acyclic, Trace};3use jrsonnet_gcmodule::{Acyclic, Trace};4use jrsonnet_parser::function::FunctionSignature;4use jrsonnet_ir::function::FunctionSignature;5use jrsonnet_parser::{ExprParams, IStr};5use jrsonnet_ir::{ExprParams, IStr};6use rustc_hash::{FxHashMap, FxHashSet};6use rustc_hash::{FxHashMap, FxHashSet};778use crate::destructure::destruct;8use crate::destructure::destruct;crates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth10use fs::File;10use fs::File;11use jrsonnet_gcmodule::Acyclic;11use jrsonnet_gcmodule::Acyclic;12use jrsonnet_interner::IBytes;12use jrsonnet_interner::IBytes;13use jrsonnet_parser::{13use jrsonnet_ir::{14 IStr, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,14 IStr, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,15};15};1616crates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth44pub use jrsonnet_interner::{IBytes, IStr};44pub use jrsonnet_interner::{IBytes, IStr};45#[doc(hidden)]45#[doc(hidden)]46pub use jrsonnet_macros;46pub use jrsonnet_macros;47pub use jrsonnet_parser as parser;47pub use jrsonnet_ir as parser;48use jrsonnet_parser::{Expr, ParserSettings, Source, SourcePath, Spanned};48use jrsonnet_ir::{Expr, Source, SourcePath, Spanned};49use jrsonnet_peg_parser::ParserSettings;49pub use obj::*;50pub use obj::*;50pub use rustc_hash;51pub use rustc_hash;51use rustc_hash::FxHashMap;52use rustc_hash::FxHashMap;344 let file_name = Source::new(path.clone(), code.clone());345 let file_name = Source::new(path.clone(), code.clone());345 if file.parsed.is_none() {346 if file.parsed.is_none() {346 file.parsed = Some(347 file.parsed = Some(347 jrsonnet_parser::parse(348 jrsonnet_peg_parser::parse(348 &code,349 &code,349 &ParserSettings {350 &ParserSettings {350 source: file_name.clone(),351 source: file_name.clone(),460 pub fn evaluate_snippet(&self, name: impl Into<IStr>, code: impl Into<IStr>) -> Result<Val> {461 pub fn evaluate_snippet(&self, name: impl Into<IStr>, code: impl Into<IStr>) -> Result<Val> {461 let code = code.into();462 let code = code.into();462 let source = Source::new_virtual(name.into(), code.clone());463 let source = Source::new_virtual(name.into(), code.clone());463 let parsed = jrsonnet_parser::parse(464 let parsed = jrsonnet_peg_parser::parse(464 &code,465 &code,465 &ParserSettings {466 &ParserSettings {466 source: source.clone(),467 source: source.clone(),481 ) -> Result<Val> {482 ) -> Result<Val> {482 let code = code.into();483 let code = code.into();483 let source = Source::new_virtual(name.into(), code.clone());484 let source = Source::new_virtual(name.into(), code.clone());484 let parsed = jrsonnet_parser::parse(485 let parsed = jrsonnet_peg_parser::parse(485 &code,486 &code,486 &ParserSettings {487 &ParserSettings {487 source: source.clone(),488 source: source.clone(),crates/jrsonnet-evaluator/src/obj/mod.rsdiffbeforeafterboth5use educe::Educe;5use educe::Educe;6use jrsonnet_gcmodule::{cc_dyn, Acyclic, Cc, Trace, Weak};6use jrsonnet_gcmodule::{cc_dyn, Acyclic, Cc, Trace, Weak};7use jrsonnet_interner::IStr;7use jrsonnet_interner::IStr;8use jrsonnet_parser::Span;8use jrsonnet_ir::Span;9use rustc_hash::{FxHashMap, FxHashSet};9use rustc_hash::{FxHashMap, FxHashSet};101011mod oop;11mod oop;121213pub use jrsonnet_parser::Visibility;13pub use jrsonnet_ir::Visibility;14pub use oop::ObjValueBuilder;14pub use oop::ObjValueBuilder;151516use crate::{16use crate::{crates/jrsonnet-evaluator/src/obj/oop.rsdiffbeforeafterboth8 bail, error::ErrorKind::*, in_frame, CcUnbound, MaybeUnbound, Result, Thunk, Unbound, Val,8 bail, error::ErrorKind::*, in_frame, CcUnbound, MaybeUnbound, Result, Thunk, Unbound, Val,9};9};10use jrsonnet_gcmodule::{Cc, Trace};10use jrsonnet_gcmodule::{Cc, Trace};11use jrsonnet_parser::IStr;11use jrsonnet_ir::IStr;12use rustc_hash::{FxHashMap, FxHashSet};12use rustc_hash::{FxHashMap, FxHashSet};131314use super::ordering::{FieldIndex, SuperDepth};14use super::ordering::{FieldIndex, SuperDepth};crates/jrsonnet-evaluator/src/tla.rsdiffbeforeafterboth223use jrsonnet_gcmodule::Trace;3use jrsonnet_gcmodule::Trace;4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;5use jrsonnet_parser::{SourceFifo, SourcePath};5use jrsonnet_ir::{SourceFifo, SourcePath};667use crate::{7use crate::{8 function::{CallLocation, PreparedFuncVal},8 function::{CallLocation, PreparedFuncVal},crates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth6};6};778use jrsonnet_gcmodule::Trace;8use jrsonnet_gcmodule::Trace;9use jrsonnet_parser::CodeLocation;9use jrsonnet_ir::CodeLocation;10#[cfg(feature = "explaining-traces")]10#[cfg(feature = "explaining-traces")]11use jrsonnet_parser::Span;11use jrsonnet_ir::Span;121213use crate::{error::ErrorKind, Error};13use crate::{error::ErrorKind, Error};1414crates/jrsonnet-formatter/src/lib.rsdiffbeforeafterboth855}855}856856857pub struct FormatOptions {857pub struct FormatOptions {858 // 0 for hard tabs858 // 0 for hard tabs, otherwise number of spaces859 pub indent: u8,859 pub indent: u8,860}860}861861crates/jrsonnet-ir/Cargo.tomldiffbeforeafterbothno changes
crates/jrsonnet-ir/README.adocdiffbeforeafterbothno changes
crates/jrsonnet-ir/src/expr.rsdiffbeforeafterbothno changes
crates/jrsonnet-ir/src/function.rsdiffbeforeafterbothno changes
crates/jrsonnet-ir/src/lib.rsdiffbeforeafterbothno changes
crates/jrsonnet-ir/src/location.rsdiffbeforeafterbothno changes
crates/jrsonnet-ir/src/source.rsdiffbeforeafterbothno changes
crates/jrsonnet-ir/src/unescape.rsdiffbeforeafterbothno changes
crates/jrsonnet-parser/Cargo.tomldiffbeforeafterbothno changes
crates/jrsonnet-parser/README.adocdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/expr.rsdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/function.rsdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/lib.rsdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/location.rsdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__add_location_info_to_all_sub_expressions.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_comp.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__array_test_error.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-3.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math-4.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__basic_math.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__default_param_before_nondefault.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__double_negation.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__empty_object.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports-3.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__imports.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__infix_precedence.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__missing_newline_between_comment_and_eof.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-3.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string-4.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiline_string.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__multiple_args_buf.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__reserved.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-3.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-4.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice-5.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__slice.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping-3.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_escaping.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_unescaping.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__string_verbantim.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-2.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-3.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix-4.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/snapshots/jrsonnet_parser__tests__suffix.snapdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/source.rsdiffbeforeafterbothno changes
crates/jrsonnet-parser/src/unescape.rsdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/Cargo.tomldiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/lib.rsdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__add_location_info_to_all_sub_expressions.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_comp.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__array_test_error.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__basic_math.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__default_param_before_nondefault.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__double_negation.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__empty_object.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__imports.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__infix_precedence.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__missing_newline_between_comment_and_eof.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiline_string.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__multiple_args_buf.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__reserved.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__slice.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_escaping.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_unescaping.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__string_verbantim.snapdiffbeforeafterbothno changes
crates/jrsonnet-peg-parser/src/snapshots/jrsonnet_peg_parser__tests__suffix.snapdiffbeforeafterbothno changes
crates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth16# Bigint type16# Bigint type17exp-bigint = ["dep:num-bigint", "jrsonnet-evaluator/exp-bigint"]17exp-bigint = ["dep:num-bigint", "jrsonnet-evaluator/exp-bigint"]181819exp-null-coaelse = ["jrsonnet-parser/exp-null-coaelse", "jrsonnet-evaluator/exp-null-coaelse"]19exp-null-coaelse = [20 "jrsonnet-ir/exp-null-coaelse",21 "jrsonnet-evaluator/exp-null-coaelse",22]20# std.regexMatch and other helpers23# std.regexMatch and other helpers21exp-regex = ["dep:regex", "dep:lru", "dep:rustc-hash"]24exp-regex = ["dep:regex", "dep:lru", "dep:rustc-hash"]222523[dependencies]26[dependencies]24jrsonnet-evaluator.workspace = true27jrsonnet-evaluator.workspace = true25jrsonnet-macros.workspace = true28jrsonnet-macros.workspace = true26jrsonnet-parser.workspace = true29jrsonnet-ir.workspace = true27jrsonnet-gcmodule.workspace = true30jrsonnet-gcmodule.workspace = true283129# Used for std.parseJson/std.parseYaml32# Used for std.parseJson/std.parseYaml51lru = { workspace = true, optional = true }54lru = { workspace = true, optional = true }52rustc-hash = { workspace = true, optional = true }55rustc-hash = { workspace = true, optional = true }5354[build-dependencies]55jrsonnet-parser.workspace = true5656crates/jrsonnet-stdlib/resultdiffbeforeafterbothno changes
crates/jrsonnet-stdlib/src/compat.rsdiffbeforeafterboth8#[allow(non_snake_case)]8#[allow(non_snake_case)]9pub fn builtin___compare(v1: Val, v2: Val) -> Result<i32> {9pub fn builtin___compare(v1: Val, v2: Val) -> Result<i32> {10 Ok(10 Ok(11 match evaluate_compare_op(&v1, &v2, jrsonnet_parser::BinaryOpType::Lt)? {11 match evaluate_compare_op(&v1, &v2, jrsonnet_ir::BinaryOpType::Lt)? {12 Ordering::Less => -1,12 Ordering::Less => -1,13 Ordering::Equal => 0,13 Ordering::Equal => 0,14 Ordering::Greater => 1,14 Ordering::Greater => 1,30 let ordering = evaluate_compare_op(30 let ordering = evaluate_compare_op(31 &Val::Arr(arr1),31 &Val::Arr(arr1),32 &Val::Arr(arr2),32 &Val::Arr(arr2),33 jrsonnet_parser::BinaryOpType::Lt,33 jrsonnet_ir::BinaryOpType::Lt,34 )?;34 )?;35 Ok($operator.contains(&ordering))35 Ok($operator.contains(&ordering))36 }36 }crates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth20 ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,20 ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,21};21};22use jrsonnet_gcmodule::{Acyclic, Cc, Trace};22use jrsonnet_gcmodule::{Acyclic, Cc, Trace};23use jrsonnet_parser::Source;23use jrsonnet_ir::Source;24pub use manifest::*;24pub use manifest::*;25pub use math::*;25pub use math::*;26pub use misc::*;26pub use misc::*;crates/jrsonnet-stdlib/src/manifest/ini.rsdiffbeforeafterboth4 manifest::{ManifestFormat, ToStringFormat},4 manifest::{ManifestFormat, ToStringFormat},5 typed::{FromUntyped, Typed},5 typed::{FromUntyped, Typed},6 ObjValue, Result, ResultExt, Val,6 ObjValue, Result, ResultExt, Val,7 IStr,7};8};8use jrsonnet_parser::IStr;9910pub struct IniFormat {10pub struct IniFormat {11 #[cfg(feature = "exp-preserve-order")]11 #[cfg(feature = "exp-preserve-order")]crates/jrsonnet-stdlib/src/sets.rsdiffbeforeafterboth3use jrsonnet_evaluator::{3use jrsonnet_evaluator::{4 function::builtin, operator::evaluate_compare_op, val::ArrValue, Result, Thunk, Val,4 function::builtin, operator::evaluate_compare_op, val::ArrValue, Result, Thunk, Val,5};5};6use jrsonnet_parser::BinaryOpType;6use jrsonnet_ir::BinaryOpType;778use crate::keyf::KeyF;8use crate::keyf::KeyF;99crates/jrsonnet-stdlib/src/sort.rsdiffbeforeafterboth9 val::{equals, ArrValue},9 val::{equals, ArrValue},10 Result, Thunk, Val,10 Result, Thunk, Val,11};11};12use jrsonnet_parser::BinaryOpType;12use jrsonnet_ir::BinaryOpType;131314use crate::{eval_on_empty, keyf::KeyF};14use crate::{eval_on_empty, keyf::KeyF};1515flake.nixdiffbeforeafterboth160 ]160 ]161 ++ lib.optionals (!stdenv.isDarwin) [161 ++ lib.optionals (!stdenv.isDarwin) [162 valgrind162 valgrind163 kdePackages.kcachegrind163 ];164 ];164 };165 };165 };166 };xtask/src/main.rsdiffbeforeafterboth52 } => {52 } => {53 let out = sh.create_temp_dir()?;53 let out = sh.create_temp_dir()?;545455 // build-std56 cmd!(55 cmd!(57 sh,56 sh,58 "cargo build -Zbuild-std --target={target} --profile releasedebug"57 "cargo build --target={target} --profile releasedebug"59 )58 )60 .run()?;59 .run()?;61 let built = format!("./target/{target}/releasedebug/jrsonnet");60 let built = format!("./target/{target}/releasedebug/jrsonnet");