PassOrderingHelper

The goal of this class is to provide ordered passes when invoking the order function.

  • soft dependencies (DependsOn with softDependency == true): all passes registered as soft dependency will be executed before the current pass, if they are registered independently

  • hard dependencies (DependsOn with softDependency == false (default)): all passes registered as hard dependency will be executed before the current pass (hard dependencies will be registered even if the user did not specifically register them)

  • first pass ExecuteFirst: a pass registered as first pass will be executed in the beginning

  • last pass ExecuteLast: a pass registered as last pass will be executed at the end

  • late pass ExecuteLate: a pass that is executed as late as possible without violating any of the other constraints

  • ExecuteBefore (with soft and hard dependencies): the pass is to be executed before the other pass (soft: if the other pass is also configured)

This class works by

  1. Setup

    1. Iterating through the configured passes and registering them (plus all hard == true dependencies) as PassWithDependencies containers:

      1. ExecuteFirst and ExecuteLast passes are stored in separate lists to keep the ordering logic simple.

      2. Normal passes are stored in the workingList

    2. ExecuteBefore passes: "A execute before B" implies that "B depends on A" -> the dependency is stored in the PassWithDependencies.dependenciesRemaining of "B". This logic is implemented in populateExecuteBeforeDependencies.

    3. DependsOn passes: PassWithDependencies.dependenciesRemaining keeps track of these dependencies. populateNormalDependencies implements this logic.

    4. A sanityCheck is performed.

  2. Ordering

    1. firstPassesList passes are moved to the result.

    2. While the workingList is not empty:

      1. All passes ready to be scheduled are moved to the result excluding late passes. If this found at least one pass, then the loop starts again.

      2. Late passes are considered for scheduling as well. If this found at least one pass, then the loop starts again. Otherwise, the dependencies cannot be satisfied.

    3. lastPassesList passes are moved to the result.

Note: whenever a pass is moved to the result:

Constructors

Link copied to clipboard
constructor(passes: List<KClass<out Pass<*>>>)

Collects the requested passes provided as passes and populates the internal workingList consisting of pairs of passes and their dependencies. Also, this function adds all hardDependencies

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun order(): List<List<KClass<out Pass<*>>>>

Order the passes. This function honors