Class ExecutionPlanner<T extends JobParameters>
java.lang.Object
io.github.douira.glsl_transformer.transform.ExecutionPlanner<T>
- Direct Known Subclasses:
TransformationManager
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
ConstructorsConstructorDescriptionCreates a new execution planner with no root transformation.ExecutionPlanner(Transformation<T> rootTransformation) Creates a new execution planner with a given root transformation. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConcurrent(LifecycleUser<T> rootDependency) Registers a single lifecycle user with this execution planner.abstract io.github.douira.glsl_transformer.GLSLLexergetLexer()Returns the execution planner's lexer.abstract io.github.douira.glsl_transformer.GLSLParserReturns this execution planner's parser.Returns the root transformation that contains all other phases and transformations.voidplanExecutionFor(T parameters) Triggers execution planning for a given set of fixed job parameters.voidsetRootTransformation(Transformation<T> rootTransformation) Sets the root transformation.protected voidtransformTree(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx, BufferedTokenStream tokenStream) Transforms the given parse tree with the registered transformations.voidwithJobParameters(T parameters, Runnable run) Runs a function while this transformation manager has the given job parameters set.<R> RwithJobParameters(T parameters, Supplier<R> run) Runs a function while this transformation manager has the given job parameters set.
-
Constructor Details
-
ExecutionPlanner
public ExecutionPlanner()Creates a new execution planner with no root transformation. One will be created on demand. -
ExecutionPlanner
Creates a new execution planner with a given root transformation.- Parameters:
rootTransformation- The root transformation to use
-
-
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
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 usingTransformationManager.parse(IntStream, ExtendedContext, Function)directly.- Type Parameters:
R- The return type of the function- Parameters:
parameters- The job parameters to setrun- The function to run while the transformation manager has job parameters- Returns:
- The value returned by the supplier function
-
withJobParameters
Runs a function while this transformation manager has the given job parameters set.- Parameters:
parameters- The job parametersrun- The function to run while the transformation manager has job parameters- See Also:
-
addConcurrent
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
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
-
setRootTransformation
Sets the root transformation. All dependencies should be accessible through this root transformation. Conditional dependencies can be used in the root transformation if a custom transformation is set with this method. Note that this doesn't reset the execution plan cache and can cause old execution plans unrelated to the new root transformation to be used when fixed job parameters match. This method is only intended to be used in cases where the root transformation is set once.- Parameters:
rootTransformation- The root transformation
-
planExecutionFor
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 transformedtokenStream- The token stream of the parse tree
-