Class ExecutionPlanner<T>

java.lang.Object
io.github.douira.glsl_transformer.transform.ExecutionPlanner<T>
Direct Known Subclasses:
TransformationManager

public abstract class ExecutionPlanner<T> extends Object
The execution planner finds a valid way of satisfying the root transformation's dependencies. All other transformations and phases are added as dependencies to the root transformation.
  • Constructor Details

    • ExecutionPlanner

      public ExecutionPlanner()
  • Method Details

    • getParser

      public abstract io.github.douira.glsl_transformer.GLSLParser getParser()
      Returns this execution planner's parser. How the parser is stored is up to the implementing class.
      Returns:
      The parser
    • getLexer

      public abstract io.github.douira.glsl_transformer.GLSLLexer getLexer()
      Returns the execution planner's lexer.
      Returns:
      The lexer
    • addConcurrent

      public void addConcurrent(LifecycleUser<T> rootDependency)
      Registers a single lifecycle user with this execution planner. This can be a transformation or a transformation phase. Multiple transformations can be added by calling this function multiple times or by adding a single enclosing transformation that includes multiple sub-transformations as concurrent dependencies.
      Parameters:
      rootDependency - The node to add as a dependency of the root node
    • getRootTransformation

      public Transformation<T> getRootTransformation()
      Returns the root transformation that contains all other phases and transformations. This is exposed so that simple structures may be added without requiring nested transformations.
      Returns:
      The root transformation instance
    • planExecution

      public void planExecution()
      Calculates the execution plan for the constructed graph of dependencies.
      Implementation Note:
      First it resolves the nested transformation so that the whole dependency graph can be traversed directly. Then nodes are visited in toplogically sorted order. Their maximum distance from the first visited node, an end node, is calculated. Finally the nodes are sorted into execution levels according to their distance values. The nodes with the lowest distance are executed first.
    • transformTree

      protected void transformTree(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx, BufferedTokenStream tokenStream)
      Transforms the given parse tree with the registered transformations.
      Parameters:
      ctx - The root node of the parse tree to be transformed
      tokenStream - The token stream of the parse tree