-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SwiftIfConfig: A library to evaluate #if
conditionals within a Swift syntax tree.
#1816
base: main
Are you sure you want to change the base?
Commits on Jun 12, 2023
-
[SwiftIfConfig] Add a new library for evaluating
#if
conditions.Building on top of the parser and operator-precedence parsing library, introduce a new library that evaluates `#if` conditions against a particular build configuration. The build configuration is described by the aptly named `BuildConfiguration` protocol, which has queries for various build settings (e.g., configuration flags), compiler capabilities (features and attributes), and target information (OS, architecture, endianness, etc.). At present, the only user-facing operation is the `IfConfigState` initializer, which takes in an expression (the `#if` condition) and a build configuration, then evaluates that expression against the build condition to determine whether code covered by that condition is active, inactive, or completely unparsed. This is a fairly low-level API, meant to be a building block for more useful higher-level APIs that query which `#if` clause is active and whether a particular syntax node is active.
Configuration menu - View commit details
-
Copy full SHA for 5e320a3 - Browse repository at this point
Copy the full SHA 5e320a3View commit details -
Add higher-level APIs for querying active code state
`IfConfigDeclSyntax.activeClause(in:)` determines which clause is active within an `#if` syntax node. `SyntaxProtocol.isActive(in:)` determines whether a given syntax node is active in the program, based on the nested stack of `#if` configurations.
Configuration menu - View commit details
-
Copy full SHA for c4dd56f - Browse repository at this point
Copy the full SHA c4dd56fView commit details
Commits on Jun 13, 2023
-
Add support for evaluating
swift
andcompiler
conditionalsThese were introduced by SE-0212.
Configuration menu - View commit details
-
Copy full SHA for f1c3775 - Browse repository at this point
Copy the full SHA f1c3775View commit details
Commits on Jun 18, 2023
-
Configuration menu - View commit details
-
Copy full SHA for f0d8d01 - Browse repository at this point
Copy the full SHA f0d8d01View commit details -
Add support for
canImport
configuration checks.This is the last kind of check! Remove the `default` fallthrough from the main evaluation function.
Configuration menu - View commit details
-
Copy full SHA for f6671ff - Browse repository at this point
Copy the full SHA f6671ffView commit details
Commits on Jun 19, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 49feafc - Browse repository at this point
Copy the full SHA 49feafcView commit details -
Add
ActiveSyntax(Any)Visitor
visitor classes.The `ActiveSyntax(Any)Visitor` visitor classes provide visitors that only visit the regions of a syntax tree that are active according to a particular build configuration, meaning that those nodes would be included in a program that is built with that configuration.
Configuration menu - View commit details
-
Copy full SHA for 2ac9fbf - Browse repository at this point
Copy the full SHA 2ac9fbfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9c3f4cd - Browse repository at this point
Copy the full SHA 9c3f4cdView commit details -
Add an API to rewrite a syntax tree by removing inactive regions.
The operation `SyntaxProtocol.removingInactive(in:)` returns a syntax tree derived from `self` that has removed all inactive syntax nodes based on the provided configuration.
Configuration menu - View commit details
-
Copy full SHA for 4aad17b - Browse repository at this point
Copy the full SHA 4aad17bView commit details -
Implement inactive clause rewriting support for postfix
#if
Postfix `#if` expressions have a different syntactic form than other `#if` clauses because they don't fit into a list-like position in the grammar. Implement a separate, recursive folding algorithm to handle these clauses.
Configuration menu - View commit details
-
Copy full SHA for 96e6a8d - Browse repository at this point
Copy the full SHA 96e6a8dView commit details
Commits on Jun 20, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 1404f6b - Browse repository at this point
Copy the full SHA 1404f6bView commit details -
Configuration menu - View commit details
-
Copy full SHA for a0bbe00 - Browse repository at this point
Copy the full SHA a0bbe00View commit details -
Configuration menu - View commit details
-
Copy full SHA for be1c27a - Browse repository at this point
Copy the full SHA be1c27aView commit details
Commits on Jun 22, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 6712ea0 - Browse repository at this point
Copy the full SHA 6712ea0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 884d4ff - Browse repository at this point
Copy the full SHA 884d4ffView commit details -
Configuration menu - View commit details
-
Copy full SHA for 54d1c43 - Browse repository at this point
Copy the full SHA 54d1c43View commit details
Commits on Jun 25, 2023
-
[Build configuration] Drop optionality from protocol requirement resu…
…lt types The optional return was used to mean "don't know", but was always treated as false. Instead, make all of the result types non-optional, and allow these operations to throw to indicate failure. While here, drop the "syntax" parameters to all of these functions. We shouldn't be working with syntax inside the build configuration.
Configuration menu - View commit details
-
Copy full SHA for 46c082c - Browse repository at this point
Copy the full SHA 46c082cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 817228e - Browse repository at this point
Copy the full SHA 817228eView commit details -
Configuration menu - View commit details
-
Copy full SHA for e14e0c7 - Browse repository at this point
Copy the full SHA e14e0c7View commit details -
Configuration menu - View commit details
-
Copy full SHA for e19032b - Browse repository at this point
Copy the full SHA e19032bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 23c6b8b - Browse repository at this point
Copy the full SHA 23c6b8bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7425d30 - Browse repository at this point
Copy the full SHA 7425d30View commit details