git.delta.rocks / jrsonnet / refs/commits / 15dca76ce252

difftreelog

refactor(ir) drop Parened expr

ksrxlvqlYaroslav Bolyukin2026-03-19parent: #7681558.patch.diff
in: master

4 files changed

modifiedcrates/jrsonnet-evaluator/src/async_import.rsdiffbeforeafterboth
211 find_imports(expr, out);211 find_imports(expr, out);
212 }212 }
213 }213 }
214 Expr::Parened(expr) | Expr::UnaryOp(_, expr) | Expr::ErrorStmt(expr) => {214 Expr::UnaryOp(_, expr) | Expr::ErrorStmt(expr) => {
215 find_imports(expr, out);215 find_imports(expr, out);
216 }216 }
217 }217 }
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
53 | Expr::Num(_)53 | Expr::Num(_)
54 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,54 | Expr::Literal(LiteralType::False | LiteralType::True | LiteralType::Null) => true,
55 Expr::Arr(a) => a.iter().all(is_trivial),55 Expr::Arr(a) => a.iter().all(is_trivial),
56 Expr::Parened(e) => is_trivial(e),
57 _ => false,56 _ => false,
58 }57 }
59 }58 }
76 .collect(),75 .collect(),
77 ))76 ))
78 }77 }
79 Expr::Parened(e) => evaluate_trivial(e)?,
80 _ => return None,78 _ => return None,
81 })79 })
82}80}
414 Literal(LiteralType::True) => Val::Bool(true),412 Literal(LiteralType::True) => Val::Bool(true),
415 Literal(LiteralType::False) => Val::Bool(false),413 Literal(LiteralType::False) => Val::Bool(false),
416 Literal(LiteralType::Null) => Val::Null,414 Literal(LiteralType::Null) => Val::Null,
417 Parened(e) => evaluate(ctx, e)?,
418 Str(v) => Val::string(v.clone()),415 Str(v) => Val::string(v.clone()),
419 Num(v) => Val::try_num(*v)?,416 Num(v) => Val::try_num(*v)?,
420 // I have tried to remove special behavior from super by implementing standalone-super417 // I have tried to remove special behavior from super by implementing standalone-super
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
336 /// Object extension: var1 {b: 2}336 /// Object extension: var1 {b: 2}
337 ObjExtend(LocExpr, ObjBody),337 ObjExtend(LocExpr, ObjBody),
338
339 /// (obj)
340 Parened(LocExpr),
341338
342 /// -2339 /// -2
343 UnaryOp(UnaryOpType, LocExpr),340 UnaryOp(UnaryOpType, LocExpr),
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
313 use UnaryOpType::*;313 use UnaryOpType::*;
314 rule expr(s: &ParserSettings) -> LocExpr314 rule expr(s: &ParserSettings) -> LocExpr
315 = precedence! {315 = precedence! {
316 "(" _ e:expr(s) _ ")" {e}
316 start:position!() v:@ end:position!() { LocExpr::new(v, Span(s.source.clone(), start as u32, end as u32)) }317 start:position!() v:@ end:position!() { LocExpr::new(v, Span(s.source.clone(), start as u32, end as u32)) }
317 --318 --
318 a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)}319 a:(@) _ binop(<"||">) _ b:@ {expr_bin!(a Or b)}
359 a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(a, body)}360 a:(@) _ "{" _ body:objinside(s) _ "}" {Expr::ObjExtend(a, body)}
360 --361 --
361 e:expr_basic(s) {e}362 e:expr_basic(s) {e}
362 "(" _ e:expr(s) _ ")" {Expr::Parened(e)}
363 }363 }
364 pub rule index_part(s: &ParserSettings) -> IndexPart364 pub rule index_part(s: &ParserSettings) -> IndexPart
365 = n:("?" _ ensure_null_coaelse())? "." _ value:id_loc(s) {IndexPart {365 = n:("?" _ ensure_null_coaelse())? "." _ value:id_loc(s) {IndexPart {
559 el!(Expr::Num(2.0), 0, 1),559 el!(Expr::Num(2.0), 0, 1),
560 Add,560 Add,
561 el!(561 el!(
562 Expr::Parened(el!(562 Expr::BinaryOp(
563 Expr::BinaryOp(
564 el!(Expr::Num(2.0), 3, 4),563 el!(Expr::Num(2.0), 3, 4),
565 Add,564 Add,
566 el!(565 el!(
575 ),574 ),
576 3,575 3,
577 8576 8
578 )),
579 2,
580 9
581 ),577 ),
582 ),578 ),
583 0,579 0,