@@ -182,35 +182,35 @@ private func evaluateIfConfig(
182
182
183
183
// Integer literals evaluate true if that are not "0".
184
184
if let intLiteral = condition. as ( IntegerLiteralExprSyntax . self) {
185
- return intLiteral. digits . text != " 0 "
185
+ return intLiteral. literal . text != " 0 "
186
186
}
187
187
188
188
// Declaration references are for custom compilation flags.
189
- if let identExpr = condition. as ( IdentifierExprSyntax . self) {
189
+ if let identExpr = condition. as ( DeclReferenceExprSyntax . self) {
190
190
// FIXME: Need a real notion of an identifier.
191
- let ident = identExpr. identifier . text
191
+ let ident = identExpr. baseName . text
192
192
193
193
// Evaluate the custom condition. If the build configuration cannot answer this query, fail.
194
194
return try configuration. isCustomConditionSet ( name: ident)
195
195
}
196
196
197
197
// Logical '!'.
198
198
if let prefixOp = condition. as ( PrefixOperatorExprSyntax . self) ,
199
- prefixOp. operatorToken ? . text == " ! "
199
+ prefixOp. operator ? . text == " ! "
200
200
{
201
- return try ! evaluateIfConfig( condition: prefixOp. postfixExpression , configuration: configuration)
201
+ return try ! evaluateIfConfig( condition: prefixOp. expression , configuration: configuration)
202
202
}
203
203
204
204
// Logical '&&' and '||'.
205
205
if let binOp = condition. as ( InfixOperatorExprSyntax . self) ,
206
- let op = binOp. operatorOperand . as ( BinaryOperatorExprSyntax . self) ,
207
- ( op. operatorToken . text == " && " || op. operatorToken . text == " || " )
206
+ let op = binOp. operator . as ( BinaryOperatorExprSyntax . self) ,
207
+ ( op. operator . text == " && " || op. operator . text == " || " )
208
208
{
209
209
// Evaluate the left-hand side.
210
210
let lhsResult = try evaluateIfConfig ( condition: binOp. leftOperand, configuration: configuration)
211
211
212
212
// Short-circuit evaluation if we know the answer.
213
- switch ( lhsResult, op. operatorToken . text) {
213
+ switch ( lhsResult, op. operator . text) {
214
214
case ( true , " || " ) : return true
215
215
case ( false , " && " ) : return false
216
216
default : break
@@ -235,7 +235,7 @@ private func evaluateIfConfig(
235
235
/// Perform a check for an operation that takes a single identifier argument.
236
236
func doSingleIdentifierArgumentCheck( _ body: ( String ) throws -> Bool , role: String ) throws -> Bool {
237
237
// Ensure that we have a single argument that is a simple identifier.
238
- guard let argExpr = call. argumentList . singleUnlabeledExpression,
238
+ guard let argExpr = call. arguments . singleUnlabeledExpression,
239
239
let arg = argExpr. simpleIdentifierExpr
240
240
else {
241
241
throw IfConfigError . requiresUnlabeledArgument ( name: fnName, role: role)
@@ -248,16 +248,16 @@ private func evaluateIfConfig(
248
248
func doVersionComparisonCheck( _ actualVersion: VersionTuple ) throws -> Bool {
249
249
// Ensure that we have a single unlabeled argument that is either >= or < as a prefix
250
250
// operator applied to a version.
251
- guard let argExpr = call. argumentList . singleUnlabeledExpression,
251
+ guard let argExpr = call. arguments . singleUnlabeledExpression,
252
252
let unaryArg = argExpr. as ( PrefixOperatorExprSyntax . self) ,
253
- let opToken = unaryArg. operatorToken
253
+ let opToken = unaryArg. operator
254
254
else {
255
255
throw IfConfigError . requiresUnlabeledArgument ( name: fnName, role: " version comparison (>= or <= a version) " )
256
256
}
257
257
258
258
// Parse the version.
259
- guard let version = VersionTuple ( parsing: unaryArg. postfixExpression . trimmedDescription) else {
260
- throw IfConfigError . invalidVersionOperand ( name: fnName, syntax: unaryArg. postfixExpression )
259
+ guard let version = VersionTuple ( parsing: unaryArg. expression . trimmedDescription) else {
260
+ throw IfConfigError . invalidVersionOperand ( name: fnName, syntax: unaryArg. expression )
261
261
}
262
262
263
263
switch opToken. text {
@@ -295,7 +295,7 @@ private func evaluateIfConfig(
295
295
case . _endian:
296
296
// Ensure that we have a single argument that is a simple identifier,
297
297
// either "little" or "big".
298
- guard let argExpr = call. argumentList . singleUnlabeledExpression,
298
+ guard let argExpr = call. arguments . singleUnlabeledExpression,
299
299
let arg = argExpr. simpleIdentifierExpr,
300
300
let expectedEndianness = Endianness ( rawValue: arg)
301
301
else {
@@ -307,7 +307,7 @@ private func evaluateIfConfig(
307
307
case . _pointerBitWidth:
308
308
// Ensure that we have a single argument that is a simple identifier, which
309
309
// is an underscore followed by an integer.
310
- guard let argExpr = call. argumentList . singleUnlabeledExpression,
310
+ guard let argExpr = call. arguments . singleUnlabeledExpression,
311
311
let arg = argExpr. simpleIdentifierExpr,
312
312
let argFirst = arg. first,
313
313
argFirst == " _ " ,
@@ -327,7 +327,7 @@ private func evaluateIfConfig(
327
327
case . _compiler_version:
328
328
// Argument is a single unlabeled argument containing a string
329
329
// literal.
330
- guard let argExpr = call. argumentList . singleUnlabeledExpression,
330
+ guard let argExpr = call. arguments . singleUnlabeledExpression,
331
331
let stringLiteral = argExpr. as ( StringLiteralExprSyntax . self) ,
332
332
stringLiteral. segments. count == 1 ,
333
333
let segment = stringLiteral. segments. first,
@@ -345,7 +345,7 @@ private func evaluateIfConfig(
345
345
case . canImport:
346
346
// Retrieve the first argument, which must not have a label. This is
347
347
// the module import path.
348
- guard let firstArg = call. argumentList . first,
348
+ guard let firstArg = call. arguments . first,
349
349
firstArg. label == nil
350
350
else {
351
351
throw IfConfigError . canImportMissingModule ( syntax: ExprSyntax ( call) )
@@ -358,7 +358,7 @@ private func evaluateIfConfig(
358
358
// If there is a second argument, it shall have the label _version or
359
359
// _underlyingVersion.
360
360
let version : CanImportVersion
361
- if let secondArg = call. argumentList . dropFirst ( ) . first {
361
+ if let secondArg = call. arguments . dropFirst ( ) . first {
362
362
if secondArg. label? . text != " _version " && secondArg. label? . text != " _underlyingVersion " {
363
363
throw IfConfigError . canImportLabel ( syntax: secondArg. expression)
364
364
}
@@ -387,7 +387,7 @@ private func evaluateIfConfig(
387
387
version = . underlyingVersion( versionTuple)
388
388
}
389
389
390
- if call. argumentList . count > 2 {
390
+ if call. arguments . count > 2 {
391
391
throw IfConfigError . canImportTwoParameters ( syntax: ExprSyntax ( call) )
392
392
}
393
393
} else {
0 commit comments