Class PhaseCollector<T>
java.lang.Object
io.github.douira.glsl_transformer.transform.PhaseCollector<T>
- Direct Known Subclasses:
TransformationManager
The phase collector holds the registered transformations and manages their
execution. After creating an instance, transformations should be registered
with it. During registration the phase collector organizes the phases each
transformation contributes. In order to reduce the number of times the tree
has to be walked, it processes all walk phases of each level at the same
time. A level of phases consists of all phases that were added to their
transformation at the same index.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract io.github.douira.glsl_transformer.GLSLLexergetLexer()Returns the phase collector's lexer.abstract io.github.douira.glsl_transformer.GLSLParserReturns this phase collector's parser.voidregisterTransformation(Transformation<T> transformation) Registers a single transformation with this phase collector.voidregisterTransformationMultiple(Consumer<PhaseCollector<T>> groupRegisterer) Registers multiple transformations by calling a function that consumes a phase collector.protected voidtransformTree(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx, BufferedTokenStream tokenStream) Transforms the given parse tree with the registered transformations.
-
Constructor Details
-
PhaseCollector
public PhaseCollector()
-
-
Method Details
-
getParser
public abstract io.github.douira.glsl_transformer.GLSLParser getParser()Returns this phase collector'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 phase collector's lexer.- Returns:
- The lexer
-
registerTransformation
Registers a single transformation with this phase collector. When the phase collector transforms a tree, the phases contributed by this transformation will be run.- Parameters:
transformation- The transformation to collect the phases from
-
registerTransformationMultiple
Registers multiple transformations by calling a function that consumes a phase collector. This can be used together with transformation groups by having them register many transformations with a phase collector.- Parameters:
groupRegisterer- The function that registers transformations on the phase collector it is given- See Also:
-
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
-