libexpr: rename forceString to isInterpolation

`ExprConcatStrings` tracks whether the expression is an interpolation or
not via an obscure boolean called `forceString`.

Instead, we rename it to `isInterpolation`.

This is a breaking change for the JSON AST representation.

Change-Id: I9f89337449b56f6e99a961e21169761f554c9896
Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
Raito Bezarius
2025-05-20 19:14:49 +02:00
parent dab871f129
commit 3e4bffcc24
9 changed files with 51 additions and 51 deletions
+1 -1
View File
@@ -1965,7 +1965,7 @@ void ExprConcatStrings::eval(EvalState & state, Env & env, Value & v)
NixInt n{0};
NixFloat nf = 0;
bool first = !forceString;
bool first = !isInterpolation;
ValueType firstType = nString;
const auto str = [&] {
+1 -1
View File
@@ -273,7 +273,7 @@ JSON ExprConcatStrings::toJSON(const SymbolTable & symbols) const
parts.push_back(part->toJSON(symbols));
return {
{"_type", "ExprConcatStrings"},
{"forceString", forceString},
{"isInterpolation", isInterpolation},
{"es", parts}
};
}
+3 -3
View File
@@ -572,10 +572,10 @@ MakeBinOp(ExprOpConcatLists, "++")
struct ExprConcatStrings : Expr
{
bool forceString;
bool isInterpolation;
std::vector<std::pair<PosIdx, std::unique_ptr<Expr>>> es;
ExprConcatStrings(const PosIdx & pos, bool forceString, std::vector<std::pair<PosIdx, std::unique_ptr<Expr>>> es)
: Expr(pos), forceString(forceString), es(std::move(es)) { };
ExprConcatStrings(const PosIdx & pos, bool isInterpolation, std::vector<std::pair<PosIdx, std::unique_ptr<Expr>>> es)
: Expr(pos), isInterpolation(isInterpolation), es(std::move(es)) { };
JSON toJSON(const SymbolTable & symbols) const override;
void eval(EvalState & state, Env & env, Value & v) override;
void accept(ExprVisitor & ev, std::unique_ptr<Expr> & ptr) override { ev.visit(*this, ptr); }
+2 -2
View File
@@ -8,10 +8,10 @@ body:
value: x
- _type: ExprVar
value: y
forceString: false
isInterpolation: false
- _type: ExprVar
value: z
forceString: false
isInterpolation: false
formals:
x: null
y: null
@@ -32,7 +32,7 @@ args:
fun:
_type: ExprVar
value: __div
forceString: false
isInterpolation: false
- _type: ExprLiteral
value: 1
valueType: Int
+30 -30
View File
@@ -115,7 +115,7 @@ attrs:
- _type: ExprLiteral
value: /lib/modules/dri
valueType: String
forceString: true
isInterpolation: true
then:
_type: ExprConcatStrings
es:
@@ -128,7 +128,7 @@ attrs:
- _type: ExprLiteral
value: /X11R6/lib/modules/drivers/
valueType: String
forceString: true
isInterpolation: true
- _type: ExprLiteral
value: " \n\nexec "
valueType: String
@@ -140,7 +140,7 @@ attrs:
'
valueType: String
forceString: true
isInterpolation: true
s14:
_type: ExprLiteral
value: "Escaping of ' followed by ': ''\nEscaping of $ followed by {: ${\nAnd\
@@ -170,7 +170,7 @@ attrs:
'
valueType: String
forceString: true
isInterpolation: true
s16:
_type: ExprLiteral
value: 'cut -d $''\t'' -f 1
@@ -188,13 +188,13 @@ attrs:
- _type: ExprLiteral
value: $
valueType: String
forceString: false
isInterpolation: false
- _type: ExprLiteral
value: '
'
valueType: String
forceString: false
isInterpolation: false
s18:
_type: ExprLiteral
value: " Lines without any indentation effectively disable the indentation\n\
@@ -255,7 +255,7 @@ attrs:
'
valueType: String
forceString: true
isInterpolation: true
s5:
_type: ExprConcatStrings
es:
@@ -284,7 +284,7 @@ attrs:
'
valueType: String
forceString: true
isInterpolation: true
s6:
_type: ExprLiteral
value: " Tabs are not interpreted as whitespace (since we can't guess\n what\
@@ -316,7 +316,7 @@ attrs:
'
valueType: String
forceString: true
isInterpolation: true
s9:
_type: ExprConcatStrings
es:
@@ -327,7 +327,7 @@ attrs:
value: " Similarly you can force an indentation level,\n in this case to\
\ 2 spaces. This works because the anti-quote\n is significant (not whitespace).\n"
valueType: String
forceString: true
isInterpolation: true
body:
_type: ExprConcatStrings
es:
@@ -373,61 +373,61 @@ body:
value: s1
- _type: ExprVar
value: s2
forceString: false
isInterpolation: false
- _type: ExprVar
value: s3
forceString: false
isInterpolation: false
- _type: ExprVar
value: s4
forceString: false
isInterpolation: false
- _type: ExprVar
value: s5
forceString: false
isInterpolation: false
- _type: ExprVar
value: s6
forceString: false
isInterpolation: false
- _type: ExprVar
value: s7
forceString: false
isInterpolation: false
- _type: ExprVar
value: s8
forceString: false
isInterpolation: false
- _type: ExprVar
value: s9
forceString: false
isInterpolation: false
- _type: ExprVar
value: s10
forceString: false
isInterpolation: false
- _type: ExprVar
value: s11
forceString: false
isInterpolation: false
- _type: ExprVar
value: s12
forceString: false
isInterpolation: false
- _type: ExprVar
value: s13
forceString: false
isInterpolation: false
- _type: ExprVar
value: s14
forceString: false
isInterpolation: false
- _type: ExprVar
value: s15
forceString: false
isInterpolation: false
- _type: ExprVar
value: s16
forceString: false
isInterpolation: false
- _type: ExprVar
value: s17
forceString: false
isInterpolation: false
- _type: ExprVar
value: s18
forceString: false
isInterpolation: false
- _type: ExprVar
value: s19
forceString: false
isInterpolation: false
- _type: ExprVar
value: s20
forceString: false
isInterpolation: false
- _type: ExprVar
value: s21
forceString: false
isInterpolation: false
+11 -11
View File
@@ -95,7 +95,7 @@ body:
- _type: ExprLiteral
value: ''
valueType: String
forceString: false
isInterpolation: false
value:
_type: ExprVar
value: 'null'
@@ -171,7 +171,7 @@ body:
- _type: ExprLiteral
value: ''
valueType: String
forceString: false
isInterpolation: false
value:
_type: ExprVar
value: 'null'
@@ -401,7 +401,7 @@ body:
fun:
_type: ExprVar
value: __div
forceString: false
isInterpolation: false
- _type: ExprLiteral
value: 1
valueType: Int
@@ -428,7 +428,7 @@ body:
fun:
_type: ExprVar
value: __sub
forceString: false
isInterpolation: false
- _type: ExprCall
args:
- _type: ExprLiteral
@@ -448,7 +448,7 @@ body:
fun:
_type: ExprVar
value: __sub
forceString: false
isInterpolation: false
- _type: ExprCall
args:
- _type: ExprLiteral
@@ -459,7 +459,7 @@ body:
fun:
_type: ExprVar
value: __sub
forceString: false
isInterpolation: false
- _type: ExprIf
cond:
_type: ExprOpImpl
@@ -581,17 +581,17 @@ body:
- _type: ExprLiteral
value: 2
valueType: Int
forceString: false
isInterpolation: false
- _type: ExprLiteral
value: 3
valueType: Int
forceString: false
isInterpolation: false
- _type: ExprConcatStrings
es:
- _type: ExprLiteral
value: ''
valueType: String
forceString: true
isInterpolation: true
- _type: ExprConcatStrings
es:
- _type: ExprLiteral
@@ -605,6 +605,6 @@ body:
- _type: ExprLiteral
value: '2'
valueType: String
forceString: false
forceString: true
isInterpolation: false
isInterpolation: true
- _type: ExprPos
@@ -33,7 +33,7 @@ elems:
- _type: ExprLiteral
value: ''
valueType: String
forceString: false
isInterpolation: false
value:
_type: ExprSet
recursive: false
@@ -22,4 +22,4 @@ body:
fun:
_type: ExprVar
value: const
forceString: true
isInterpolation: true