git.delta.rocks / jrsonnet / refs/commits / 80f37a416bf7

difftreelog

style enforce import style

Yaroslav Bolyukin2022-04-20parent: #4c00868.patch.diff
in: master

38 files changed

modified.rustfmt.tomldiffbeforeafterboth
1hard_tabs = true1hard_tabs = true
2imports_granularity = "crate"
3group_imports = "stdexternalcrate"
24
modifiedbindings/jsonnet/src/import.rsdiffbeforeafterboth
1//! Import resolution manipulation utilities1//! Import resolution manipulation utilities
22
3use jrsonnet_evaluator::{
4 error::{Error::*, Result},
5 throw, EvaluationState, ImportResolver,
6};
7use std::{3use std::{
8 any::Any,4 any::Any,
9 cell::RefCell,5 cell::RefCell,
17 rc::Rc,13 rc::Rc,
18};14};
15
16use jrsonnet_evaluator::{
17 error::{Error::*, Result},
18 throw, EvaluationState, ImportResolver,
19};
1920
20pub type JsonnetImportCallback = unsafe extern "C" fn(21pub type JsonnetImportCallback = unsafe extern "C" fn(
21 ctx: *mut c_void,22 ctx: *mut c_void,
modifiedbindings/jsonnet/src/interop.rsdiffbeforeafterboth
1//! Jrsonnet specific additional binding helpers1//! Jrsonnet specific additional binding helpers
22
3use crate::{import::jsonnet_import_callback, native::jsonnet_native_callback};
4use jrsonnet_evaluator::{EvaluationState, Val};
5use std::{3use std::{
6 ffi::c_void,4 ffi::c_void,
7 os::raw::{c_char, c_int},5 os::raw::{c_char, c_int},
8};6};
7
8use jrsonnet_evaluator::{EvaluationState, Val};
9
10use crate::{import::jsonnet_import_callback, native::jsonnet_native_callback};
911
10extern "C" {12extern "C" {
11 pub fn _jrsonnet_static_import_callback(13 pub fn _jrsonnet_static_import_callback(
modifiedbindings/jsonnet/src/lib.rsdiffbeforeafterboth
8pub mod val_modify;8pub mod val_modify;
9pub mod vars_tlas;9pub mod vars_tlas;
10
11use std::{
12 alloc::Layout,
13 ffi::{CStr, CString},
14 os::raw::{c_char, c_double, c_int, c_uint},
15 path::PathBuf,
16};
1017
11use import::NativeImportResolver;18use import::NativeImportResolver;
12use jrsonnet_evaluator::{EvaluationState, IStr, ManifestFormat, Val};19use jrsonnet_evaluator::{EvaluationState, IStr, ManifestFormat, Val};
13use std::{
14 alloc::Layout,
15 ffi::{CStr, CString},
16 os::raw::{c_char, c_double, c_int, c_uint},
17 path::PathBuf,
18};
1920
20/// WASM stub21/// WASM stub
21#[cfg(target_arch = "wasm32")]22#[cfg(target_arch = "wasm32")]
modifiedbindings/jsonnet/src/native.rsdiffbeforeafterboth
1use std::{
2 convert::TryFrom,
3 ffi::{c_void, CStr},
4 os::raw::{c_char, c_int},
5 path::Path,
6 rc::Rc,
7};
8
1use gcmodule::Cc;9use gcmodule::Cc;
2use jrsonnet_evaluator::{10use jrsonnet_evaluator::{
6 native::{NativeCallback, NativeCallbackHandler},14 native::{NativeCallback, NativeCallbackHandler},
7 EvaluationState, IStr, Val,15 EvaluationState, IStr, Val,
8};16};
9use std::{
10 convert::TryFrom,
11 ffi::{c_void, CStr},
12 os::raw::{c_char, c_int},
13 path::Path,
14 rc::Rc,
15};
1617
17type JsonnetNativeCallback = unsafe extern "C" fn(18type JsonnetNativeCallback = unsafe extern "C" fn(
18 ctx: *const c_void,19 ctx: *const c_void,
modifiedbindings/jsonnet/src/val_extract.rsdiffbeforeafterboth
1//! Extract values from VM1//! Extract values from VM
2
3use jrsonnet_evaluator::{EvaluationState, Val};
42
5use std::{3use std::{
6 ffi::CString,4 ffi::CString,
7 os::raw::{c_char, c_double, c_int},5 os::raw::{c_char, c_double, c_int},
8};6};
7
8use jrsonnet_evaluator::{EvaluationState, Val};
99
10#[no_mangle]10#[no_mangle]
11pub extern "C" fn jsonnet_json_extract_string(_vm: &EvaluationState, v: &Val) -> *mut c_char {11pub extern "C" fn jsonnet_json_extract_string(_vm: &EvaluationState, v: &Val) -> *mut c_char {
modifiedbindings/jsonnet/src/val_make.rsdiffbeforeafterboth
1//! Create values in VM1//! Create values in VM
22
3use gcmodule::Cc;
4use jrsonnet_evaluator::{ArrValue, EvaluationState, ObjValue, Val};
5use std::{3use std::{
6 ffi::CStr,4 ffi::CStr,
7 os::raw::{c_char, c_double, c_int},5 os::raw::{c_char, c_double, c_int},
8};6};
7
8use gcmodule::Cc;
9use jrsonnet_evaluator::{val::ArrValue, EvaluationState, ObjValue, Val};
910
10/// # Safety11/// # Safety
11///12///
modifiedbindings/jsonnet/src/val_modify.rsdiffbeforeafterboth
2//! Only tested with variables, which haven't altered by code before appearing here2//! Only tested with variables, which haven't altered by code before appearing here
3//! In jrsonnet every value is immutable, and this code is probally broken3//! In jrsonnet every value is immutable, and this code is probally broken
4
5use std::{ffi::CStr, os::raw::c_char};
46
5use gcmodule::Cc;7use gcmodule::Cc;
6use jrsonnet_evaluator::{ArrValue, EvaluationState, LazyBinding, LazyVal, ObjMember, Val};8use jrsonnet_evaluator::{val::ArrValue, EvaluationState, LazyBinding, LazyVal, ObjMember, Val};
7use jrsonnet_parser::Visibility;9use jrsonnet_parser::Visibility;
8use std::{ffi::CStr, os::raw::c_char};
910
10/// # Safety11/// # Safety
11///12///
modifiedbindings/jsonnet/src/vars_tlas.rsdiffbeforeafterboth
1//! Manipulate external variables and top level arguments1//! Manipulate external variables and top level arguments
22
3use jrsonnet_evaluator::EvaluationState;
4use std::{ffi::CStr, os::raw::c_char};3use std::{ffi::CStr, os::raw::c_char};
4
5use jrsonnet_evaluator::EvaluationState;
56
6/// # Safety7/// # Safety
7#[no_mangle]8#[no_mangle]
modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
1use std::{
2 fs::{create_dir_all, File},
3 io::{Read, Write},
4 path::PathBuf,
5};
6
1use clap::{AppSettings, IntoApp, Parser};7use clap::{AppSettings, IntoApp, Parser};
2use clap_complete::Shell;8use clap_complete::Shell;
3use jrsonnet_cli::{ConfigureState, GcOpts, GeneralOpts, InputOpts, ManifestOpts, OutputOpts};9use jrsonnet_cli::{ConfigureState, GcOpts, GeneralOpts, InputOpts, ManifestOpts, OutputOpts};
4use jrsonnet_evaluator::{error::LocError, EvaluationState};10use jrsonnet_evaluator::{error::LocError, EvaluationState};
5use std::{
6 fs::{create_dir_all, File},
7 io::Read,
8 io::Write,
9 path::PathBuf,
10};
1111
12#[cfg(feature = "mimalloc")]12#[cfg(feature = "mimalloc")]
13#[global_allocator]13#[global_allocator]
modifiedcrates/jrsonnet-cli/src/ext.rsdiffbeforeafterboth
1use crate::ConfigureState;1use std::{fs::read_to_string, str::FromStr};
2
2use clap::Parser;3use clap::Parser;
3use jrsonnet_evaluator::{error::Result, EvaluationState};4use jrsonnet_evaluator::{error::Result, EvaluationState};
5
4use std::{fs::read_to_string, str::FromStr};6use crate::ConfigureState;
57
6#[derive(Clone)]8#[derive(Clone)]
7pub struct ExtStr {9pub struct ExtStr {
modifiedcrates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth
3mod tla;3mod tla;
4mod trace;4mod trace;
55
6pub use ext::*;6use std::{env, path::PathBuf};
7pub use manifest::*;7
8pub use tla::*;8use clap::Parser;
9pub use trace::*;9pub use ext::*;
10
11use clap::Parser;
12use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};10use jrsonnet_evaluator::{error::Result, EvaluationState, FileImportResolver};
13use std::{env, path::PathBuf};11pub use manifest::*;
12pub use tla::*;
13pub use trace::*;
1414
15pub trait ConfigureState {15pub trait ConfigureState {
16 fn configure(&self, state: &EvaluationState) -> Result<()>;16 fn configure(&self, state: &EvaluationState) -> Result<()>;
modifiedcrates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth
1use crate::ConfigureState;1use std::{path::PathBuf, str::FromStr};
2
2use clap::Parser;3use clap::Parser;
3use jrsonnet_evaluator::{error::Result, EvaluationState, ManifestFormat};4use jrsonnet_evaluator::{error::Result, EvaluationState, ManifestFormat};
5
4use std::{path::PathBuf, str::FromStr};6use crate::ConfigureState;
57
6pub enum ManifestFormatName {8pub enum ManifestFormatName {
7 /// Expect string as output, and write them directly9 /// Expect string as output, and write them directly
modifiedcrates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth
1use crate::{ConfigureState, ExtFile, ExtStr};
2use clap::Parser;1use clap::Parser;
3use jrsonnet_evaluator::{error::Result, EvaluationState};2use jrsonnet_evaluator::{error::Result, EvaluationState};
3
4use crate::{ConfigureState, ExtFile, ExtStr};
45
5#[derive(Parser)]6#[derive(Parser)]
6#[clap(next_help_heading = "TOP LEVEL ARGUMENTS")]7#[clap(next_help_heading = "TOP LEVEL ARGUMENTS")]
modifiedcrates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth
1use crate::ConfigureState;1use std::str::FromStr;
2
2use clap::Parser;3use clap::Parser;
3use jrsonnet_evaluator::{4use jrsonnet_evaluator::{
4 error::Result,5 error::Result,
5 trace::{CompactFormat, ExplainingFormat, PathResolver},6 trace::{CompactFormat, ExplainingFormat, PathResolver},
6 EvaluationState,7 EvaluationState,
7};8};
9
8use std::str::FromStr;10use crate::ConfigureState;
911
10#[derive(PartialEq)]12#[derive(PartialEq)]
11pub enum TraceFormatName {13pub enum TraceFormatName {
modifiedcrates/jrsonnet-evaluator/build.rsdiffbeforeafterboth
1use bincode::serialize;
2use jrsonnet_parser::{parse, ParserSettings};
3use jrsonnet_stdlib::STDLIB_STR;
4use std::{1use std::{
5 env,2 env,
6 fs::File,3 fs::File,
7 io::Write,4 io::Write,
8 path::{Path, PathBuf},5 path::{Path, PathBuf},
9};6};
7
8use bincode::serialize;
9use jrsonnet_parser::{parse, ParserSettings};
10use jrsonnet_stdlib::STDLIB_STR;
1011
11fn main() {12fn main() {
12 let parsed = parse(13 let parsed = parse(
modifiedcrates/jrsonnet-evaluator/src/builtin/format.rsdiffbeforeafterboth
1//! faster std.format impl1//! faster std.format impl
2#![allow(clippy::too_many_arguments)]2#![allow(clippy::too_many_arguments)]
33
4use crate::{error::Error::*, throw, LocError, ObjValue, Result, Val};4use std::convert::TryFrom;
5
5use gcmodule::Trace;6use gcmodule::Trace;
6use jrsonnet_interner::IStr;7use jrsonnet_interner::IStr;
7use jrsonnet_types::ValType;8use jrsonnet_types::ValType;
8use std::convert::TryFrom;9use thiserror::Error;
10
9use thiserror::Error;11use crate::{error::Error::*, throw, LocError, ObjValue, Result, Val};
1012
11#[derive(Debug, Clone, Error, Trace)]13#[derive(Debug, Clone, Error, Trace)]
12pub enum FormatError {14pub enum FormatError {
modifiedcrates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth
1use crate::error::Error::*;1use crate::{
2use crate::error::Result;2 error::{Error::*, Result},
3use crate::push_description_frame;3 push_description_frame, throw, Val,
4use crate::{throw, Val};4};
55
6#[derive(PartialEq, Clone, Copy)]6#[derive(PartialEq, Clone, Copy)]
7pub enum ManifestType {7pub enum ManifestType {
modifiedcrates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth
1use crate::function::{CallLocation, StaticBuiltin};1use std::{
2 collections::HashMap,
3 convert::{TryFrom, TryInto},
4};
5
2use crate::typed::{Any, Bytes, PositiveF64, VecVal, M1};6use format::{format_arr, format_obj};
7use gcmodule::Cc;
8use jrsonnet_interner::IStr;
9use serde::Deserialize;
10use serde_yaml::DeserializingQuirks;
11
3use crate::{12use crate::{
4 builtin::manifest::{manifest_yaml_ex, ManifestYamlOptions},13 builtin::manifest::{manifest_yaml_ex, ManifestYamlOptions},
5 equals,
6 error::{Error::*, Result},14 error::{Error::*, Result},
15 function::{CallLocation, StaticBuiltin},
7 operator::evaluate_mod_op,16 operator::evaluate_mod_op,
8 primitive_equals, push_frame, throw,17 push_frame, throw,
9 typed::{Either2, Either4},18 typed::{Any, BoundedUsize, Bytes, Either2, Either4, PositiveF64, VecVal, M1},
10 with_state, ArrValue, FuncVal, IndexableVal, Val,19 val::{equals, primitive_equals, ArrValue, FuncVal, IndexableVal, Slice},
20 with_state, Either, ObjValue, Val,
11};21};
12use crate::{Either, ObjValue};
13use format::{format_arr, format_obj};
14use gcmodule::Cc;
15use jrsonnet_interner::IStr;
16use serde::Deserialize;
17use serde_yaml::DeserializingQuirks;
18use std::collections::HashMap;
19use std::convert::{TryFrom, TryInto};
2022
21pub mod stdlib;23pub mod stdlib;
22pub use stdlib::*;24pub use stdlib::*;
modifiedcrates/jrsonnet-evaluator/src/builtin/sort.rsdiffbeforeafterboth
1use gcmodule::{Cc, Trace};
2
1use crate::{3use crate::{
2 error::{Error, LocError, Result},4 error::{Error, LocError, Result},
3 throw,5 throw,
4 typed::Any,6 typed::Any,
5 FuncVal, Val,7 val::FuncVal,
8 Val,
6};9};
7use gcmodule::{Cc, Trace};
810
9#[derive(Debug, Clone, thiserror::Error, Trace)]11#[derive(Debug, Clone, thiserror::Error, Trace)]
10pub enum SortError {12pub enum SortError {
modifiedcrates/jrsonnet-evaluator/src/builtin/stdlib.rsdiffbeforeafterboth
1use jrsonnet_parser::{LocExpr, ParserSettings};
2use std::path::PathBuf;1use std::path::PathBuf;
2
3use jrsonnet_parser::{LocExpr, ParserSettings};
34
4thread_local! {5thread_local! {
5 /// To avoid parsing again when issued from the same thread6 /// To avoid parsing again when issued from the same thread
modifiedcrates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth
1use crate::cc_ptr_eq;1use std::fmt::Debug;
2
2use crate::gc::GcHashMap;3use gcmodule::{Cc, Trace};
4use jrsonnet_interner::IStr;
5
3use crate::{6use crate::{
4 error::Error::*, map::LayeredHashMap, FutureWrapper, LazyBinding, LazyVal, ObjValue, Result,7 cc_ptr_eq, error::Error::*, gc::GcHashMap, map::LayeredHashMap, FutureWrapper, LazyBinding,
5 Val,8 LazyVal, ObjValue, Result, Val,
6};9};
7use gcmodule::{Cc, Trace};
8use jrsonnet_interner::IStr;
9use std::fmt::Debug;
1010
11#[derive(Clone, Trace)]11#[derive(Clone, Trace)]
12pub struct ContextCreator(pub Context, pub FutureWrapper<GcHashMap<IStr, LazyBinding>>);12pub struct ContextCreator(pub Context, pub FutureWrapper<GcHashMap<IStr, LazyBinding>>);
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
1use crate::{1use std::{
2 builtin::{format::FormatError, sort::SortError},2 path::{Path, PathBuf},
3 typed::TypeLocError,3 rc::Rc,
4};4};
5
5use gcmodule::Trace;6use gcmodule::Trace;
6use jrsonnet_interner::IStr;7use jrsonnet_interner::IStr;
7use jrsonnet_parser::{BinaryOpType, ExprLocation, UnaryOpType};8use jrsonnet_parser::{BinaryOpType, ExprLocation, UnaryOpType};
8use jrsonnet_types::ValType;9use jrsonnet_types::ValType;
10use thiserror::Error;
11
9use std::{12use crate::{
10 path::{Path, PathBuf},13 builtin::{format::FormatError, sort::SortError},
11 rc::Rc,14 typed::TypeLocError,
12};15};
13use thiserror::Error;
1416
15#[derive(Error, Debug, Clone, Trace)]17#[derive(Error, Debug, Clone, Trace)]
16pub enum Error {18pub enum Error {
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
1use std::convert::TryFrom;1use std::convert::TryFrom;
22
3use crate::{
4 builtin::{std_slice, BUILTINS},
5 error::Error::*,
6 evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},
7 function::CallLocation,
8 gc::TraceBox,
9 push_frame, throw, with_state, ArrValue, Bindable, Context, ContextCreator, FuncDesc, FuncVal,
10 FutureWrapper, GcHashMap, LazyBinding, LazyVal, LazyValValue, ObjValue, ObjValueBuilder,
11 ObjectAssertion, Result, Val,
12};
13use gcmodule::{Cc, Trace};3use gcmodule::{Cc, Trace};
14use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;
15use jrsonnet_parser::{5use jrsonnet_parser::{
18};8};
19use jrsonnet_types::ValType;9use jrsonnet_types::ValType;
10
11use crate::{
12 builtin::{std_slice, BUILTINS},
13 error::Error::*,
14 evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},
15 function::CallLocation,
16 gc::TraceBox,
17 push_frame, throw,
18 typed::BoundedUsize,
19 val::{ArrValue, FuncDesc, FuncVal, LazyValValue},
20 with_state, Bindable, Context, ContextCreator, FutureWrapper, GcHashMap, LazyBinding, LazyVal,
21 ObjValue, ObjValueBuilder, ObjectAssertion, Result, Val,
22};
20pub mod operator;23pub mod operator;
2124
22pub fn evaluate_binding_in_future(25pub fn evaluate_binding_in_future(
modifiedcrates/jrsonnet-evaluator/src/evaluate/operator.rsdiffbeforeafterboth
1use std::convert::TryInto;1use std::convert::TryInto;
22
3use crate::builtin::std_format;
4use crate::{equals, evaluate, Context, Val};
5use crate::{error::Error::*, throw, Result};
6use jrsonnet_parser::{BinaryOpType, LocExpr, UnaryOpType};3use jrsonnet_parser::{BinaryOpType, LocExpr, UnaryOpType};
4
5use crate::{
6 builtin::std_format, error::Error::*, evaluate, throw, val::equals, Context, Result, Val,
7};
78
8pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Result<Val> {9pub fn evaluate_unary_op(op: UnaryOpType, b: &Val) -> Result<Val> {
9 use UnaryOpType::*;10 use UnaryOpType::*;
modifiedcrates/jrsonnet-evaluator/src/function.rsdiffbeforeafterboth
1use crate::{1use std::{borrow::Cow, collections::HashMap, convert::TryFrom};
2 error::{Error::*, LocError},2
3 evaluate, evaluate_named,
4 gc::TraceBox,
5 throw,
6 typed::Typed,
7 Context, FutureWrapper, GcHashMap, LazyVal, LazyValValue, Result, Val,
8};
9use gcmodule::Trace;3use gcmodule::Trace;
10use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;
11pub use jrsonnet_macros::builtin;5pub use jrsonnet_macros::builtin;
12use jrsonnet_parser::{ArgsDesc, ExprLocation, LocExpr, ParamsDesc};6use jrsonnet_parser::{ArgsDesc, ExprLocation, LocExpr, ParamsDesc};
7
13use std::{borrow::Cow, collections::HashMap, convert::TryFrom};8use crate::{
9 error::{Error::*, LocError},
10 evaluate, evaluate_named,
11 gc::TraceBox,
12 throw,
13 typed::Typed,
14 val::LazyValValue,
15 Context, FutureWrapper, GcHashMap, LazyVal, Result, Val,
16};
1417
15#[derive(Clone, Copy)]18#[derive(Clone, Copy)]
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
1use crate::{1use std::{
2 error::{Error::*, Result},2 any::Any,
3 convert::TryFrom,
4 fs,
5 io::Read,
6 path::{Path, PathBuf},
3 throw,7 rc::Rc,
4};8};
9
5use fs::File;10use fs::File;
6use jrsonnet_interner::IStr;11use jrsonnet_interner::IStr;
7use std::fs;12
8use std::{13use crate::{
9 any::Any,
10 path::{Path, PathBuf},14 error::{Error::*, Result},
11 rc::Rc,15 throw,
12};16};
13use std::{convert::TryFrom, io::Read};
1417
15/// Implements file resolution logic for `import` and `importStr`18/// Implements file resolution logic for `import` and `importStr`
16pub trait ImportResolver {19pub trait ImportResolver {
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
1use crate::{
2 error::{Error::*, LocError, Result},
3 throw, ObjValueBuilder, Val,
4};
5use serde_json::{Map, Number, Value};
6use std::convert::{TryFrom, TryInto};1use std::convert::{TryFrom, TryInto};
2
3use serde_json::{Map, Number, Value};
4
5use crate::{
6 error::{Error::*, LocError, Result},
7 throw, ObjValueBuilder, Val,
8};
79
8impl TryFrom<&Val> for Value {10impl TryFrom<&Val> for Value {
9 type Error = LocError;11 type Error = LocError;
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
13pub mod error;13pub mod error;
14mod evaluate;14mod evaluate;
15pub mod function;15pub mod function;
16pub mod gc;
16mod import;17mod import;
17mod integrations;18mod integrations;
18mod map;19mod map;
19pub mod native;20pub mod native;
20mod obj;21mod obj;
21pub mod trace;22pub mod trace;
22pub mod typed;23pub mod typed;
23mod val;24pub mod val;
2425
25pub use jrsonnet_parser as parser;26use std::{
27 cell::{Ref, RefCell, RefMut},
28 collections::HashMap,
29 fmt::Debug,
30 path::{Path, PathBuf},
31 rc::Rc,
32};
2633
27pub use ctx::*;34pub use ctx::*;
28pub use dynamic::*;35pub use dynamic::*;
33use gcmodule::{Cc, Trace, Weak};40use gcmodule::{Cc, Trace, Weak};
34pub use import::*;41pub use import::*;
35pub use jrsonnet_interner::IStr;42pub use jrsonnet_interner::IStr;
43pub use jrsonnet_parser as parser;
36use jrsonnet_parser::*;44use jrsonnet_parser::*;
37pub use obj::*;45pub use obj::*;
38use std::{
39 cell::{Ref, RefCell, RefMut},
40 collections::HashMap,
41 fmt::Debug,
42 path::{Path, PathBuf},
43 rc::Rc,
44};
45use trace::{location_to_offset, offset_to_location, CodeLocation, CompactFormat, TraceFormat};46use trace::{location_to_offset, offset_to_location, CodeLocation, CompactFormat, TraceFormat};
46pub use val::*;47pub use val::{LazyVal, ManifestFormat, Val};
47pub mod gc;
4848
49pub trait Bindable: Trace + 'static {49pub trait Bindable: Trace + 'static {
50 fn bind(&self, this: Option<ObjValue>, super_obj: Option<ObjValue>) -> Result<LazyVal>;50 fn bind(&self, this: Option<ObjValue>, super_obj: Option<ObjValue>) -> Result<LazyVal>;
693693
694#[cfg(test)]694#[cfg(test)]
695pub mod tests {695pub mod tests {
696 use super::Val;
697 use crate::{696 use std::{
698 error::Error::*, function::BuiltinParam, gc::TraceBox, native::NativeCallbackHandler,697 path::{Path, PathBuf},
699 primitive_equals, EvaluationState,698 rc::Rc,
700 };699 };
700
701 use gcmodule::{Cc, Trace};701 use gcmodule::{Cc, Trace};
702 use jrsonnet_parser::*;702 use jrsonnet_parser::*;
703
704 use super::Val;
703 use std::{705 use crate::{
706 error::Error::*,
704 path::{Path, PathBuf},707 function::{BuiltinParam, CallLocation},
705 rc::Rc,708 gc::TraceBox,
709 native::NativeCallbackHandler,
710 val::primitive_equals,
711 EvaluationState,
706 };712 };
707713
708 #[test]714 #[test]
712 state.run_in_state(|| {718 state.run_in_state(|| {
713 state719 state
714 .push(720 .push(
715 Some(&ExprLocation(PathBuf::from("test1.jsonnet").into(), 10, 20)),721 CallLocation::new(&ExprLocation(PathBuf::from("test1.jsonnet").into(), 10, 20)),
716 || "outer".to_owned(),722 || "outer".to_owned(),
717 || {723 || {
718 state.push(724 state.push(
719 Some(&ExprLocation(PathBuf::from("test2.jsonnet").into(), 30, 40)),725 CallLocation::new(&ExprLocation(
726 PathBuf::from("test2.jsonnet").into(),
727 30,
728 40,
1290 }1300 }
12911301
1292 mod derive_typed {1302 mod derive_typed {
1303 use std::path::PathBuf;
1304
1293 use crate::{typed::Typed, EvaluationState};1305 use crate::{typed::Typed, EvaluationState};
1294 use std::path::PathBuf;
12951306
1296 #[derive(Typed, PartialEq, Debug)]1307 #[derive(PartialEq, Debug, Typed)]
1297 struct MyTyped {1308 struct MyTyped {
1298 a: u32,1309 a: u32,
1299 #[typed(rename = "b")]1310 #[typed(rename = "b")]
modifiedcrates/jrsonnet-evaluator/src/native.rsdiffbeforeafterboth
1#![allow(clippy::type_complexity)]1#![allow(clippy::type_complexity)]
22
3use crate::function::{parse_builtin_call, ArgsLike, Builtin, BuiltinParam, CallLocation};3use std::{path::Path, rc::Rc};
4
4use crate::gc::TraceBox;5use gcmodule::Trace;
5use crate::Context;6
6use crate::{error::Result, Val};7use crate::{
7use gcmodule::Trace;8 error::Result,
8use std::path::Path;9 function::{parse_builtin_call, ArgsLike, Builtin, BuiltinParam, CallLocation},
9use std::rc::Rc;10 gc::TraceBox,
11 Context, Val,
12};
1013
11#[derive(Trace)]14#[derive(Trace)]
modifiedcrates/jrsonnet-evaluator/src/obj.rsdiffbeforeafterboth
1use crate::error::LocError;1use std::{
2use crate::function::CallLocation;2 cell::RefCell,
3use crate::gc::{GcHashMap, GcHashSet, TraceBox};
4use crate::operator::evaluate_add_op;3 fmt::Debug,
5use crate::push_frame;
6use crate::{4 hash::{Hash, Hasher},
7 cc_ptr_eq, error::Error::*, throw, weak_ptr_eq, weak_raw, Bindable, LazyBinding, LazyVal,
8 Result, Val,
9};5};
6
10use gcmodule::{Cc, Trace, Weak};7use gcmodule::{Cc, Trace, Weak};
11use jrsonnet_interner::IStr;8use jrsonnet_interner::IStr;
12use jrsonnet_parser::{ExprLocation, Visibility};9use jrsonnet_parser::{ExprLocation, Visibility};
13use rustc_hash::FxHashMap;10use rustc_hash::FxHashMap;
11
14use std::cell::RefCell;12use crate::{
13 cc_ptr_eq,
15use std::fmt::Debug;14 error::{Error::*, LocError},
16use std::hash::{Hash, Hasher};15 function::CallLocation,
16 gc::{GcHashMap, GcHashSet, TraceBox},
17 operator::evaluate_add_op,
18 push_frame, throw, weak_ptr_eq, weak_raw, Bindable, LazyBinding, LazyVal, Result, Val,
19};
1720
18#[derive(Debug, Trace)]21#[derive(Debug, Trace)]
19pub struct ObjMember {22pub struct ObjMember {
modifiedcrates/jrsonnet-evaluator/src/trace/mod.rsdiffbeforeafterboth
1mod location;1mod location;
22
3use crate::{error::Error, EvaluationState, LocError};
4pub use location::*;
5use std::path::{Path, PathBuf};3use std::path::{Path, PathBuf};
4
5pub use location::*;
6
7use crate::{error::Error, EvaluationState, LocError};
68
7/// The way paths should be displayed9/// The way paths should be displayed
8pub enum PathResolver {10pub enum PathResolver {
modifiedcrates/jrsonnet-evaluator/src/typed/mod.rsdiffbeforeafterboth
3mod conversions;3mod conversions;
4pub use conversions::*;4pub use conversions::*;
5
6use crate::{
7 error::{Error, LocError, Result},
8 push_description_frame, Val,
9};
10use gcmodule::Trace;5use gcmodule::Trace;
11pub use jrsonnet_types::{ComplexValType, ValType};6pub use jrsonnet_types::{ComplexValType, ValType};
12use thiserror::Error;7use thiserror::Error;
8
9use crate::{
10 error::{Error, LocError, Result},
11 push_description_frame, Val,
12};
1313
14#[derive(Debug, Error, Clone, Trace)]14#[derive(Debug, Error, Clone, Trace)]
15pub enum TypeError {15pub enum TypeError {
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
1use std::{cell::RefCell, fmt::Debug, rc::Rc};
2
3use gcmodule::{Cc, Trace};
4use jrsonnet_interner::IStr;
5use jrsonnet_parser::{LocExpr, ParamsDesc};
6use jrsonnet_types::ValType;
7
1use crate::{8use crate::{
2 builtin::manifest::{9 builtin::manifest::{
12 gc::TraceBox,19 gc::TraceBox,
13 throw, Context, ObjValue, Result,20 throw, Context, ObjValue, Result,
14};21};
15use gcmodule::{Cc, Trace};
16use jrsonnet_interner::IStr;
17use jrsonnet_parser::{LocExpr, ParamsDesc};
18use jrsonnet_types::ValType;
19use std::{cell::RefCell, fmt::Debug, rc::Rc};
2022
21pub trait LazyValValue: Trace {23pub trait LazyValValue: Trace {
22 fn get(self: Box<Self>) -> Result<Val>;24 fn get(self: Box<Self>) -> Result<Val>;
modifiedcrates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth
1use gcmodule::Trace;
2use rustc_hash::FxHashMap;
3use serde::{Deserialize, Serialize};
4use std::{1use std::{
5 borrow::Cow,2 borrow::Cow,
6 cell::RefCell,3 cell::RefCell,
12 str::Utf8Error,9 str::Utf8Error,
13};10};
11
12use gcmodule::Trace;
13use rustc_hash::FxHashMap;
14use serde::{Deserialize, Serialize};
1415
15#[derive(Clone, PartialOrd, Ord, Eq)]16#[derive(Clone, PartialOrd, Ord, Eq)]
16pub struct IStr(Rc<str>);17pub struct IStr(Rc<str>);
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
1use std::{
2 fmt::{Debug, Display},
3 ops::Deref,
4 path::{Path, PathBuf},
5 rc::Rc,
6};
7
1use gcmodule::Trace;8use gcmodule::Trace;
2use jrsonnet_interner::IStr;9use jrsonnet_interner::IStr;
3#[cfg(feature = "serde")]10#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};11use serde::{Deserialize, Serialize};
5use std::{
6 fmt::{Debug, Display},
7 ops::Deref,
8 path::{Path, PathBuf},
9 rc::Rc,
10};
1112
12#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]13#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
13#[derive(Debug, PartialEq, Trace)]14#[derive(Debug, PartialEq, Trace)]
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
1#![allow(clippy::redundant_closure_call)]1#![allow(clippy::redundant_closure_call)]
22
3use peg::parser;
4use std::{3use std::{
5 path::{Path, PathBuf},4 path::{Path, PathBuf},
6 rc::Rc,5 rc::Rc,
7};6};
7
8use peg::parser;
8mod expr;9mod expr;
9pub use expr::*;10pub use expr::*;
10pub use jrsonnet_interner::IStr;11pub use jrsonnet_interner::IStr;
317318
318#[cfg(test)]319#[cfg(test)]
319pub mod tests {320pub mod tests {
321 use std::path::PathBuf;
322
323 use BinaryOpType::*;
324
320 use super::{expr::*, parse};325 use super::{expr::*, parse};
321 use crate::ParserSettings;326 use crate::ParserSettings;
322 use std::path::PathBuf;
323 use BinaryOpType::*;
324327
325 macro_rules! parse {328 macro_rules! parse {
326 ($s:expr) => {329 ($s:expr) => {
modifiedcrates/jrsonnet-types/src/lib.rsdiffbeforeafterboth
1#![allow(clippy::redundant_closure_call)]1#![allow(clippy::redundant_closure_call)]
22
3use gcmodule::Trace;
4use std::fmt::Display;3use std::fmt::Display;
4
5use gcmodule::Trace;
56
6#[macro_export]7#[macro_export]
7macro_rules! ty {8macro_rules! ty {