Class ExecutionPlanner<T extends JobParameters>

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

public abstract class ExecutionPlanner<T extends JobParameters> 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 Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addConcurrent(LifecycleUser<T> rootDependency)
    Registers a single lifecycle user with this execution planner.
    abstract io.github.douira.glsl_transformer.GLSLLexer
    Returns the execution planner's lexer.
    abstract io.github.douira.glsl_transformer.GLSLParser
    Returns this execution planner's parser.
    Returns the root transformation that contains all other phases and transformations.
    void
    planExecutionFor(T parameters)
    Triggers execution planning for a given set of fixed job parameters.
    protected void
    transformTree(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx, BufferedTokenStream tokenStream)
    Transforms the given parse tree with the registered transformations.
    void
    withJobParameters(T parameters, Runnable run)
    Runs a function while this transformation manager has the given job parameters set.
    <R> R
    withJobParameters(T parameters, Supplier<R> run)
    Runs a function while this transformation manager has the given job parameters set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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
    • withJobParameters

      public <R> R withJobParameters(T parameters, Supplier<R> run)
      Runs a function while this transformation manager has the given job parameters set. It returns the value that the function returns. This can be used together with non-standard ways of using a transformation manager like using TransformationManager.parse(IntStream, ExtendedContext, Function) directly.
      Type Parameters:
      R - The return type of the function
      Parameters:
      parameters - The job parameters to set
      run - The function to run while the transformation manager has job parameters
      Returns:
      The value returned by the supplier function
    • withJobParameters

      public void withJobParameters(T parameters, Runnable run)
      Runs a function while this transformation manager has the given job parameters set.
      Parameters:
      parameters - The job parameters
      run - The function to run while the transformation manager has job parameters
      See Also:
    • 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
    • planExecutionFor

      public void planExecutionFor(T parameters)
      Triggers execution planning for a given set of fixed job parameters. This can be useful for pre-computing execution plans instead of having them be computed on the fly and cached.
      Parameters:
      parameters - The fixed job parameters to compute the execution plan for
    • 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