difftreelog
build update dependencies
in: master
6 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -426,18 +426,18 @@
[[package]]
name = "proc-macro2"
-version = "1.0.32"
+version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
+checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
-version = "1.0.10"
+version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
+checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [
"proc-macro2",
]
@@ -522,9 +522,9 @@
[[package]]
name = "syn"
-version = "1.0.82"
+version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
+checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d"
dependencies = [
"proc-macro2",
"quote",
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -9,7 +9,7 @@
[features]
default = ["serialized-stdlib", "explaining-traces"]
# Serializes standard library AST instead of parsing them every run
-serialized-stdlib = ["bincode", "jrsonnet-parser/deserialize"]
+serialized-stdlib = ["bincode", "jrsonnet-parser/serde"]
# Rustc-like trace visualization
explaining-traces = ["annotate-snippets"]
# Allows library authors to throw custom errors
@@ -21,11 +21,11 @@
jrsonnet-stdlib = { path = "../jrsonnet-stdlib", version = "0.4.2" }
jrsonnet-types = { path = "../jrsonnet-types", version = "0.4.2" }
jrsonnet-macros = { path = "../jrsonnet-macros", version = "0.4.2" }
-pathdiff = "0.2.0"
+pathdiff = "0.2.1"
md5 = "0.7.0"
base64 = "0.13.0"
-rustc-hash = "1.1.0"
+rustc-hash = "1.1"
thiserror = "1.0"
gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
@@ -40,7 +40,7 @@
# Serialized stdlib
[dependencies.bincode]
-version = "1.3.1"
+version = "1.3"
optional = true
# Explaining traces
@@ -50,10 +50,7 @@
optional = true
[build-dependencies]
-jrsonnet-parser = { path = "../jrsonnet-parser", features = [
- "serialize",
- "deserialize",
-], version = "0.4.2" }
jrsonnet-stdlib = { path = "../jrsonnet-stdlib", version = "0.4.2" }
+jrsonnet-parser = { path = "../jrsonnet-parser", version = "0.4.2" }
serde = "1.0"
-bincode = "1.3.1"
+bincode = "1.3"
crates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -8,5 +8,5 @@
[dependencies]
serde = { version = "1.0" }
-rustc-hash = "1.1.0"
+rustc-hash = "1.1"
gcmodule = { git = "https://github.com/CertainLach/gcmodule", branch = "jrsonnet" }
crates/jrsonnet-macros/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-macros/Cargo.toml
+++ b/crates/jrsonnet-macros/Cargo.toml
@@ -7,6 +7,6 @@
proc-macro = true
[dependencies]
-proc-macro2 = "1.0.32"
-quote = "1.0.10"
-syn = { version = "1.0.82", features = ["full"] }
+proc-macro2 = "1.0"
+quote = "1.0"
+syn = { version = "1.0", features = ["full"] }
crates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-parser/Cargo.toml
+++ b/crates/jrsonnet-parser/Cargo.toml
@@ -6,11 +6,6 @@
license = "MIT"
edition = "2021"
-[features]
-default = []
-serialize = ["serde"]
-deserialize = ["serde"]
-
[dependencies]
jrsonnet-interner = { path = "../jrsonnet-interner", version = "0.4.2" }
crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth1use gcmodule::Trace;2use jrsonnet_interner::IStr;3#[cfg(feature = "deserialize")]4use serde::Deserialize;5#[cfg(feature = "serialize")]6use serde::Serialize;7use std::{8 fmt::{Debug, Display},9 ops::Deref,10 path::{Path, PathBuf},11 rc::Rc,12};1314#[cfg_attr(feature = "serialize", derive(Serialize))]15#[cfg_attr(feature = "deserialize", derive(Deserialize))]16#[derive(Debug, PartialEq, Trace)]17pub enum FieldName {18 /// {fixed: 2}19 Fixed(IStr),20 /// {["dyn"+"amic"]: 3}21 Dyn(LocExpr),22}2324#[cfg_attr(feature = "serialize", derive(Serialize))]25#[cfg_attr(feature = "deserialize", derive(Deserialize))]26#[derive(Debug, Clone, Copy, PartialEq, Trace)]27pub enum Visibility {28 /// :29 Normal,30 /// ::31 Hidden,32 /// :::33 Unhide,34}3536impl Visibility {37 pub fn is_visible(&self) -> bool {38 matches!(self, Self::Normal | Self::Unhide)39 }40}4142#[cfg_attr(feature = "serialize", derive(Serialize))]43#[cfg_attr(feature = "deserialize", derive(Deserialize))]44#[derive(Clone, Debug, PartialEq, Trace)]45pub struct AssertStmt(pub LocExpr, pub Option<LocExpr>);4647#[cfg_attr(feature = "serialize", derive(Serialize))]48#[cfg_attr(feature = "deserialize", derive(Deserialize))]49#[derive(Debug, PartialEq, Trace)]50pub struct FieldMember {51 pub name: FieldName,52 pub plus: bool,53 pub params: Option<ParamsDesc>,54 pub visibility: Visibility,55 pub value: LocExpr,56}5758#[cfg_attr(feature = "serialize", derive(Serialize))]59#[cfg_attr(feature = "deserialize", derive(Deserialize))]60#[derive(Debug, PartialEq, Trace)]61pub enum Member {62 Field(FieldMember),63 BindStmt(BindSpec),64 AssertStmt(AssertStmt),65}6667#[cfg_attr(feature = "serialize", derive(Serialize))]68#[cfg_attr(feature = "deserialize", derive(Deserialize))]69#[derive(Debug, Clone, Copy, PartialEq, Trace)]70pub enum UnaryOpType {71 Plus,72 Minus,73 BitNot,74 Not,75}7677impl Display for UnaryOpType {78 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {79 use UnaryOpType::*;80 write!(81 f,82 "{}",83 match self {84 Plus => "+",85 Minus => "-",86 BitNot => "~",87 Not => "!",88 }89 )90 }91}9293#[cfg_attr(feature = "serialize", derive(Serialize))]94#[cfg_attr(feature = "deserialize", derive(Deserialize))]95#[derive(Debug, Clone, Copy, PartialEq, Trace)]96pub enum BinaryOpType {97 Mul,98 Div,99100 /// Implemented as intrinsic, put here for completeness101 Mod,102103 Add,104 Sub,105106 Lhs,107 Rhs,108109 Lt,110 Gt,111 Lte,112 Gte,113114 BitAnd,115 BitOr,116 BitXor,117118 Eq,119 Neq,120121 And,122 Or,123124 // Equialent to std.objectHasEx(a, b, true)125 In,126}127128impl Display for BinaryOpType {129 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {130 use BinaryOpType::*;131 write!(132 f,133 "{}",134 match self {135 Mul => "*",136 Div => "/",137 Mod => "%",138 Add => "+",139 Sub => "-",140 Lhs => "<<",141 Rhs => ">>",142 Lt => "<",143 Gt => ">",144 Lte => "<=",145 Gte => ">=",146 BitAnd => "&",147 BitOr => "|",148 BitXor => "^",149 Eq => "==",150 Neq => "!=",151 And => "&&",152 Or => "||",153 In => "in",154 }155 )156 }157}158159/// name, default value160#[cfg_attr(feature = "serialize", derive(Serialize))]161#[cfg_attr(feature = "deserialize", derive(Deserialize))]162#[derive(Debug, PartialEq, Trace)]163pub struct Param(pub IStr, pub Option<LocExpr>);164165/// Defined function parameters166#[cfg_attr(feature = "serialize", derive(Serialize))]167#[cfg_attr(feature = "deserialize", derive(Deserialize))]168#[derive(Debug, Clone, PartialEq, Trace)]169pub struct ParamsDesc(pub Rc<Vec<Param>>);170171impl Deref for ParamsDesc {172 type Target = Vec<Param>;173 fn deref(&self) -> &Self::Target {174 &self.0175 }176}177178#[cfg_attr(feature = "serialize", derive(Serialize))]179#[cfg_attr(feature = "deserialize", derive(Deserialize))]180#[derive(Debug, PartialEq, Trace)]181pub struct ArgsDesc {182 pub unnamed: Vec<LocExpr>,183 pub named: Vec<(IStr, LocExpr)>,184}185impl ArgsDesc {186 pub fn new(unnamed: Vec<LocExpr>, named: Vec<(IStr, LocExpr)>) -> Self {187 Self { unnamed, named }188 }189}190191#[cfg_attr(feature = "serialize", derive(Serialize))]192#[cfg_attr(feature = "deserialize", derive(Deserialize))]193#[derive(Debug, Clone, PartialEq, Trace)]194pub struct BindSpec {195 pub name: IStr,196 pub params: Option<ParamsDesc>,197 pub value: LocExpr,198}199200#[cfg_attr(feature = "serialize", derive(Serialize))]201#[cfg_attr(feature = "deserialize", derive(Deserialize))]202#[derive(Debug, PartialEq, Trace)]203pub struct IfSpecData(pub LocExpr);204205#[cfg_attr(feature = "serialize", derive(Serialize))]206#[cfg_attr(feature = "deserialize", derive(Deserialize))]207#[derive(Debug, PartialEq, Trace)]208pub struct ForSpecData(pub IStr, pub LocExpr);209210#[cfg_attr(feature = "serialize", derive(Serialize))]211#[cfg_attr(feature = "deserialize", derive(Deserialize))]212#[derive(Debug, PartialEq, Trace)]213pub enum CompSpec {214 IfSpec(IfSpecData),215 ForSpec(ForSpecData),216}217218#[cfg_attr(feature = "serialize", derive(Serialize))]219#[cfg_attr(feature = "deserialize", derive(Deserialize))]220#[derive(Debug, PartialEq, Trace)]221pub struct ObjComp {222 pub pre_locals: Vec<BindSpec>,223 pub key: LocExpr,224 pub plus: bool,225 pub value: LocExpr,226 pub post_locals: Vec<BindSpec>,227 pub compspecs: Vec<CompSpec>,228}229230#[cfg_attr(feature = "serialize", derive(Serialize))]231#[cfg_attr(feature = "deserialize", derive(Deserialize))]232#[derive(Debug, PartialEq, Trace)]233pub enum ObjBody {234 MemberList(Vec<Member>),235 ObjComp(ObjComp),236}237238#[cfg_attr(feature = "serialize", derive(Serialize))]239#[cfg_attr(feature = "deserialize", derive(Deserialize))]240#[derive(Debug, PartialEq, Clone, Copy, Trace)]241pub enum LiteralType {242 This,243 Super,244 Dollar,245 Null,246 True,247 False,248}249250#[cfg_attr(feature = "serialize", derive(Serialize))]251#[cfg_attr(feature = "deserialize", derive(Deserialize))]252#[derive(Debug, PartialEq, Trace)]253pub struct SliceDesc {254 pub start: Option<LocExpr>,255 pub end: Option<LocExpr>,256 pub step: Option<LocExpr>,257}258259/// Syntax base260#[cfg_attr(feature = "serialize", derive(Serialize))]261#[cfg_attr(feature = "deserialize", derive(Deserialize))]262#[derive(Debug, PartialEq, Trace)]263pub enum Expr {264 Literal(LiteralType),265266 /// String value: "hello"267 Str(IStr),268 /// Number: 1, 2.0, 2e+20269 Num(f64),270 /// Variable name: test271 Var(IStr),272273 /// Array of expressions: [1, 2, "Hello"]274 Arr(Vec<LocExpr>),275 /// Array comprehension:276 /// ```jsonnet277 /// ingredients: [278 /// { kind: kind, qty: 4 / 3 }279 /// for kind in [280 /// 'Honey Syrup',281 /// 'Lemon Juice',282 /// 'Farmers Gin',283 /// ]284 /// ],285 /// ```286 ArrComp(LocExpr, Vec<CompSpec>),287288 /// Object: {a: 2}289 Obj(ObjBody),290 /// Object extension: var1 {b: 2}291 ObjExtend(LocExpr, ObjBody),292293 /// (obj)294 Parened(LocExpr),295296 /// -2297 UnaryOp(UnaryOpType, LocExpr),298 /// 2 - 2299 BinaryOp(LocExpr, BinaryOpType, LocExpr),300 /// assert 2 == 2 : "Math is broken"301 AssertExpr(AssertStmt, LocExpr),302 /// local a = 2; { b: a }303 LocalExpr(Vec<BindSpec>, LocExpr),304305 /// import "hello"306 Import(PathBuf),307 /// importStr "file.txt"308 ImportStr(PathBuf),309 /// error "I'm broken"310 ErrorStmt(LocExpr),311 /// a(b, c)312 Apply(LocExpr, ArgsDesc, bool),313 /// a[b]314 Index(LocExpr, LocExpr),315 /// function(x) x316 Function(ParamsDesc, LocExpr),317 /// std.primitiveEquals318 Intrinsic(IStr),319 /// if true == false then 1 else 2320 IfElse {321 cond: IfSpecData,322 cond_then: LocExpr,323 cond_else: Option<LocExpr>,324 },325 Slice(LocExpr, SliceDesc),326}327328/// file, begin offset, end offset329#[cfg_attr(feature = "serialize", derive(Serialize))]330#[cfg_attr(feature = "deserialize", derive(Deserialize))]331#[derive(Clone, PartialEq, Trace)]332#[skip_trace]333pub struct ExprLocation(pub Rc<Path>, pub usize, pub usize);334impl ExprLocation {335 pub fn belongs_to(&self, other: &ExprLocation) -> bool {336 other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2337 }338}339340impl Debug for ExprLocation {341 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {342 write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)343 }344}345346/// Holds AST expression and its location in source file347#[cfg_attr(feature = "serialize", derive(Serialize))]348#[cfg_attr(feature = "deserialize", derive(Deserialize))]349#[derive(Clone, PartialEq, Trace)]350pub struct LocExpr(pub Rc<Expr>, pub ExprLocation);351352impl Debug for LocExpr {353 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {354 if f.alternate() {355 write!(f, "{:#?}", self.0)?;356 } else {357 write!(f, "{:?}", self.0)?;358 }359 write!(f, " from {:?}", self.1)?;360 Ok(())361 }362}1use gcmodule::Trace;2use jrsonnet_interner::IStr;3#[cfg(feature = "serde")]4use serde::{Deserialize, Serialize};5use std::{6 fmt::{Debug, Display},7 ops::Deref,8 path::{Path, PathBuf},9 rc::Rc,10};1112#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]13#[derive(Debug, PartialEq, Trace)]14pub enum FieldName {15 /// {fixed: 2}16 Fixed(IStr),17 /// {["dyn"+"amic"]: 3}18 Dyn(LocExpr),19}2021#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]22#[derive(Debug, Clone, Copy, PartialEq, Trace)]23pub enum Visibility {24 /// :25 Normal,26 /// ::27 Hidden,28 /// :::29 Unhide,30}3132impl Visibility {33 pub fn is_visible(&self) -> bool {34 matches!(self, Self::Normal | Self::Unhide)35 }36}3738#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]39#[derive(Clone, Debug, PartialEq, Trace)]40pub struct AssertStmt(pub LocExpr, pub Option<LocExpr>);4142#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]43#[derive(Debug, PartialEq, Trace)]44pub struct FieldMember {45 pub name: FieldName,46 pub plus: bool,47 pub params: Option<ParamsDesc>,48 pub visibility: Visibility,49 pub value: LocExpr,50}5152#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]53#[derive(Debug, PartialEq, Trace)]54pub enum Member {55 Field(FieldMember),56 BindStmt(BindSpec),57 AssertStmt(AssertStmt),58}5960#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]61#[derive(Debug, Clone, Copy, PartialEq, Trace)]62pub enum UnaryOpType {63 Plus,64 Minus,65 BitNot,66 Not,67}6869impl Display for UnaryOpType {70 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {71 use UnaryOpType::*;72 write!(73 f,74 "{}",75 match self {76 Plus => "+",77 Minus => "-",78 BitNot => "~",79 Not => "!",80 }81 )82 }83}8485#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]86#[derive(Debug, Clone, Copy, PartialEq, Trace)]87pub enum BinaryOpType {88 Mul,89 Div,9091 /// Implemented as intrinsic, put here for completeness92 Mod,9394 Add,95 Sub,9697 Lhs,98 Rhs,99100 Lt,101 Gt,102 Lte,103 Gte,104105 BitAnd,106 BitOr,107 BitXor,108109 Eq,110 Neq,111112 And,113 Or,114115 // Equialent to std.objectHasEx(a, b, true)116 In,117}118119impl Display for BinaryOpType {120 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {121 use BinaryOpType::*;122 write!(123 f,124 "{}",125 match self {126 Mul => "*",127 Div => "/",128 Mod => "%",129 Add => "+",130 Sub => "-",131 Lhs => "<<",132 Rhs => ">>",133 Lt => "<",134 Gt => ">",135 Lte => "<=",136 Gte => ">=",137 BitAnd => "&",138 BitOr => "|",139 BitXor => "^",140 Eq => "==",141 Neq => "!=",142 And => "&&",143 Or => "||",144 In => "in",145 }146 )147 }148}149150/// name, default value151#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]152#[derive(Debug, PartialEq, Trace)]153pub struct Param(pub IStr, pub Option<LocExpr>);154155/// Defined function parameters156#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]157#[derive(Debug, Clone, PartialEq, Trace)]158pub struct ParamsDesc(pub Rc<Vec<Param>>);159160impl Deref for ParamsDesc {161 type Target = Vec<Param>;162 fn deref(&self) -> &Self::Target {163 &self.0164 }165}166167#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]168#[derive(Debug, PartialEq, Trace)]169pub struct ArgsDesc {170 pub unnamed: Vec<LocExpr>,171 pub named: Vec<(IStr, LocExpr)>,172}173impl ArgsDesc {174 pub fn new(unnamed: Vec<LocExpr>, named: Vec<(IStr, LocExpr)>) -> Self {175 Self { unnamed, named }176 }177}178179#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]180#[derive(Debug, Clone, PartialEq, Trace)]181pub struct BindSpec {182 pub name: IStr,183 pub params: Option<ParamsDesc>,184 pub value: LocExpr,185}186187#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]188#[derive(Debug, PartialEq, Trace)]189pub struct IfSpecData(pub LocExpr);190191#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]192#[derive(Debug, PartialEq, Trace)]193pub struct ForSpecData(pub IStr, pub LocExpr);194195#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]196#[derive(Debug, PartialEq, Trace)]197pub enum CompSpec {198 IfSpec(IfSpecData),199 ForSpec(ForSpecData),200}201202#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]203#[derive(Debug, PartialEq, Trace)]204pub struct ObjComp {205 pub pre_locals: Vec<BindSpec>,206 pub key: LocExpr,207 pub plus: bool,208 pub value: LocExpr,209 pub post_locals: Vec<BindSpec>,210 pub compspecs: Vec<CompSpec>,211}212213#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]214#[derive(Debug, PartialEq, Trace)]215pub enum ObjBody {216 MemberList(Vec<Member>),217 ObjComp(ObjComp),218}219220#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]221#[derive(Debug, PartialEq, Clone, Copy, Trace)]222pub enum LiteralType {223 This,224 Super,225 Dollar,226 Null,227 True,228 False,229}230231#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]232#[derive(Debug, PartialEq, Trace)]233pub struct SliceDesc {234 pub start: Option<LocExpr>,235 pub end: Option<LocExpr>,236 pub step: Option<LocExpr>,237}238239/// Syntax base240#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]241#[derive(Debug, PartialEq, Trace)]242pub enum Expr {243 Literal(LiteralType),244245 /// String value: "hello"246 Str(IStr),247 /// Number: 1, 2.0, 2e+20248 Num(f64),249 /// Variable name: test250 Var(IStr),251252 /// Array of expressions: [1, 2, "Hello"]253 Arr(Vec<LocExpr>),254 /// Array comprehension:255 /// ```jsonnet256 /// ingredients: [257 /// { kind: kind, qty: 4 / 3 }258 /// for kind in [259 /// 'Honey Syrup',260 /// 'Lemon Juice',261 /// 'Farmers Gin',262 /// ]263 /// ],264 /// ```265 ArrComp(LocExpr, Vec<CompSpec>),266267 /// Object: {a: 2}268 Obj(ObjBody),269 /// Object extension: var1 {b: 2}270 ObjExtend(LocExpr, ObjBody),271272 /// (obj)273 Parened(LocExpr),274275 /// -2276 UnaryOp(UnaryOpType, LocExpr),277 /// 2 - 2278 BinaryOp(LocExpr, BinaryOpType, LocExpr),279 /// assert 2 == 2 : "Math is broken"280 AssertExpr(AssertStmt, LocExpr),281 /// local a = 2; { b: a }282 LocalExpr(Vec<BindSpec>, LocExpr),283284 /// import "hello"285 Import(PathBuf),286 /// importStr "file.txt"287 ImportStr(PathBuf),288 /// error "I'm broken"289 ErrorStmt(LocExpr),290 /// a(b, c)291 Apply(LocExpr, ArgsDesc, bool),292 /// a[b]293 Index(LocExpr, LocExpr),294 /// function(x) x295 Function(ParamsDesc, LocExpr),296 /// std.primitiveEquals297 Intrinsic(IStr),298 /// if true == false then 1 else 2299 IfElse {300 cond: IfSpecData,301 cond_then: LocExpr,302 cond_else: Option<LocExpr>,303 },304 Slice(LocExpr, SliceDesc),305}306307/// file, begin offset, end offset308#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]309#[derive(Clone, PartialEq, Trace)]310#[skip_trace]311pub struct ExprLocation(pub Rc<Path>, pub usize, pub usize);312impl ExprLocation {313 pub fn belongs_to(&self, other: &ExprLocation) -> bool {314 other.0 == self.0 && other.1 <= self.1 && other.2 >= self.2315 }316}317318impl Debug for ExprLocation {319 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {320 write!(f, "{:?}:{:?}-{:?}", self.0, self.1, self.2)321 }322}323324/// Holds AST expression and its location in source file325#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]326#[derive(Clone, PartialEq, Trace)]327pub struct LocExpr(pub Rc<Expr>, pub ExprLocation);328329impl Debug for LocExpr {330 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {331 if f.alternate() {332 write!(f, "{:#?}", self.0)?;333 } else {334 write!(f, "{:?}", self.0)?;335 }336 write!(f, " from {:?}", self.1)?;337 Ok(())338 }339}