Skip to content

Commit

Permalink
fix: StateBuilder leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed May 27, 2024
1 parent e3f600e commit c9caeec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
11 changes: 1 addition & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ sha1 = "0.10.6"
sha2 = "0.10.8"
sha3 = "0.10.8"

# Pre-parsed stdlib serialization.
# TODO: Drop in favor of replacing std.jsonnet with full native implementation, version 2.0 of bincode is bad.
bincode = "1.3"

# Source code parsing.
# Jrsonnet has two parsers for jsonnet - one is for execution, and another is for better parsing diagnostics/lints/LSP.
# First (and fast one) is based on peg, second is based on rowan.
Expand Down
16 changes: 7 additions & 9 deletions cmds/jrsonnet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@ impl From<ErrorKind> for Error {
}

fn main_catch(opts: Opts) -> bool {
let s = State::default();
let trace = opts.trace.trace_format();
if let Err(e) = main_real(&s, opts) {
if let Err(e) = main_real(opts) {
if let Error::Evaluation(e) = e {
let mut out = String::new();
trace.write_trace(&mut out, &e).expect("format error");
Expand All @@ -162,18 +161,17 @@ fn main_catch(opts: Opts) -> bool {
true
}

fn main_real(s: &State, opts: Opts) -> Result<(), Error> {
fn main_real(opts: Opts) -> Result<(), Error> {
let _gc_leak_guard = opts.gc.leak_on_exit();
let _gc_print_stats = opts.gc.stats_printer();
let _stack_depth_override = opts.misc.stack_size_override();

let import_resolver = opts.misc.import_resolver();
s.set_import_resolver(import_resolver);

let std = opts.std.context_initializer()?;
if let Some(std) = std {
s.set_context_initializer(std);
}

let mut s = State::builder();
s.import_resolver(import_resolver).context_initializer(std);
let s = s.build();

let input = opts.input.input.ok_or(Error::MissingInputArgument)?;
let val = if opts.input.exec {
Expand All @@ -189,7 +187,7 @@ fn main_real(s: &State, opts: Opts) -> Result<(), Error> {

let tla = opts.tla.tla_opts()?;
#[allow(unused_mut)]
let mut val = apply_tla(s.clone(), &tla, val)?;
let mut val = apply_tla(s, &tla, val)?;

#[cfg(feature = "exp-apply")]
for apply in opts.input.exp_apply {
Expand Down

0 comments on commit c9caeec

Please sign in to comment.