Class ExecutionPlanner<T extends JobParameters>
java.lang.Object
io.github.douira.glsl_transformer.cst.transform.ExecutionPlanner<T>
- All Implemented Interfaces:
ParameterHolder<T>
- Direct Known Subclasses:
CSTTransformer
public abstract class ExecutionPlanner<T extends JobParameters>
extends Object
implements ParameterHolder<T>
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.Returns the execution planner's current job parameters.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.io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContextReturns the current root node being processed.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.voidsetJobParameters(T jobParameters) 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.douira.glsl_transformer.job_parameter.ParameterHolder
withJobParameters
-
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
-
getJobParameters
Returns the execution planner's current job parameters. This may be null if the caller decides not to pass job parameters. However, a convention to always pass valid job parameters could be established if they are required for transformation phases to function.- Specified by:
getJobParametersin interfaceParameterHolder<T extends JobParameters>- Returns:
- The job parameters
-
setJobParameters
- Specified by:
setJobParametersin interfaceParameterHolder<T extends JobParameters>
-
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
-
getRootNode
public io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext getRootNode()Returns the current root node being processed. Access to this method is restricted to classes in this package on purpose. Classes extendingTransformationPhaseshould not have access to this but rather use it through the provided injection method.- Returns:
- The current root node being processed
-
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
-