Class RunPhase<T extends JobParameters>

java.lang.Object
io.github.douira.glsl_transformer.GLSLParserBaseListener
io.github.douira.glsl_transformer.transform.TransformationPhase<T>
io.github.douira.glsl_transformer.transform.RunPhase<T>
All Implemented Interfaces:
io.github.douira.glsl_transformer.GLSLParserListener, LifecycleUser<T>, PartialParseTreeListener, ParseTreeListener

public abstract class RunPhase<T extends JobParameters> extends TransformationPhase<T>
A run phase simply executes one method when it is executed in a level by the execution planner. Even though it extends TransformationPhase, no listener methods on it are executed.
  • Nested Class Summary

    Nested classes/interfaces inherited from class io.github.douira.glsl_transformer.transform.TransformationPhase

    TransformationPhase.InjectionPoint
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    Called during planning in order to determine if this phase does any walking at all or if it just runs some code, like a RunPhase.
    protected final boolean
    checkBeforeWalk(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx)
    Method called by the execution planner before the walk happens.
    protected abstract void
    run(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx)
    This method is implemented by subclasses to be executed by the phase planner at the right time.
    protected final void
    runAfterWalk(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx)
    Method called by the execution planner after the walk happens.
    static <R extends JobParameters>
    RunPhase<R>
    Returns a new run phase that injects the given strings as an external declarations at the given location.
    static <R extends JobParameters>
    RunPhase<R>
    Returns a new run phase that injects the given nodes at the given location.
    static <R extends JobParameters>
    RunPhase<R>
    Creates a new run phase that only executes the given runnable function.

    Methods inherited from class io.github.douira.glsl_transformer.GLSLParserBaseListener

    enterAdditiveExpression, enterArrayAccessExpression, enterArraySpecifier, enterArraySpecifierSegment, enterAssignmentExpression, enterAtomicUnitType, enterAttribute, enterBitwiseAndExpression, enterBitwiseExclusiveOrExpression, enterBitwiseInclusiveOrExpression, enterBooleanType, enterBooleanVectorType, enterBreakStatement, enterBuiltinType, enterCallParameterList, enterCompoundStatement, enterConditionalExpression, enterContinueStatement, enterDeclarationMember, enterDeclarationStatement, enterDefaultCaseLabel, enterDemoteStatement, enterDiscardStatement, enterDoWhileStatement, enterEmptyDeclaration, enterEmptyStatement, enterEqualityExpression, enterEveryRule, enterExpressionStatement, enterExtensionStatement, enterExternalDeclaration, enterFloatMatrixType, enterFloatType, enterFloatVectorType, enterForStatement, enterFullySpecifiedType, enterFunctionCall, enterFunctionCallExpression, enterFunctionDeclaration, enterFunctionDefinition, enterFunctionHeader, enterFunctionIdentifier, enterFunctionParameterList, enterFunctionPrototype, enterGroupingExpression, enterImageType, enterInitDeclaratorList, enterInitializer, enterIntegerType, enterIntegerVectorType, enterInterfaceBlockDeclaration, enterInterpolationQualifier, enterInvariantQualifier, enterIterationCondition, enterLayoutDefaults, enterLayoutQualifier, enterLiteralExpression, enterLogicalAndExpression, enterLogicalExclusiveOrExpression, enterLogicalInclusiveOrExpression, enterMemberAccessExpression, enterMethodCall, enterMethodCallExpression, enterMultiplicativeExpression, enterNamedLayoutQualifier, enterParameterDeclaration, enterParameterDeclarator, enterPostfixExpression, enterPragmaStatement, enterPreciseQualifier, enterPrecisionDeclaration, enterPrecisionQualifier, enterPrefixExpression, enterReferencedType, enterReferenceExpression, enterRelationalExpression, enterReturnStatement, enterSamplerType, enterSelectionStatement, enterSequenceExpression, enterSharedLayoutQualifier, enterShiftExpression, enterSingleAttribute, enterStatement, enterStorageQualifier, enterStructBody, enterStructDeclarator, enterStructMember, enterStructSpecifier, enterStructSpecifierType, enterSwitchStatement, enterTranslationUnit, enterTypeAndInitDeclaration, enterTypeNameList, enterTypeQualifier, enterTypeSpecifier, enterValuedCaseLabel, enterVariableDeclaration, enterVariableIdentifier, enterVersionStatement, enterVoidType, enterWhileStatement, exitAdditiveExpression, exitArrayAccessExpression, exitArraySpecifier, exitArraySpecifierSegment, exitAssignmentExpression, exitAtomicUnitType, exitAttribute, exitBitwiseAndExpression, exitBitwiseExclusiveOrExpression, exitBitwiseInclusiveOrExpression, exitBooleanType, exitBooleanVectorType, exitBreakStatement, exitBuiltinType, exitCallParameterList, exitCompoundStatement, exitConditionalExpression, exitContinueStatement, exitDeclarationMember, exitDeclarationStatement, exitDefaultCaseLabel, exitDemoteStatement, exitDiscardStatement, exitDoWhileStatement, exitEmptyDeclaration, exitEmptyStatement, exitEqualityExpression, exitEveryRule, exitExpressionStatement, exitExtensionStatement, exitExternalDeclaration, exitFloatMatrixType, exitFloatType, exitFloatVectorType, exitForStatement, exitFullySpecifiedType, exitFunctionCall, exitFunctionCallExpression, exitFunctionDeclaration, exitFunctionDefinition, exitFunctionHeader, exitFunctionIdentifier, exitFunctionParameterList, exitFunctionPrototype, exitGroupingExpression, exitImageType, exitInitDeclaratorList, exitInitializer, exitIntegerType, exitIntegerVectorType, exitInterfaceBlockDeclaration, exitInterpolationQualifier, exitInvariantQualifier, exitIterationCondition, exitLayoutDefaults, exitLayoutQualifier, exitLiteralExpression, exitLogicalAndExpression, exitLogicalExclusiveOrExpression, exitLogicalInclusiveOrExpression, exitMemberAccessExpression, exitMethodCall, exitMethodCallExpression, exitMultiplicativeExpression, exitNamedLayoutQualifier, exitParameterDeclaration, exitParameterDeclarator, exitPostfixExpression, exitPragmaStatement, exitPreciseQualifier, exitPrecisionDeclaration, exitPrecisionQualifier, exitPrefixExpression, exitReferencedType, exitReferenceExpression, exitRelationalExpression, exitReturnStatement, exitSamplerType, exitSelectionStatement, exitSequenceExpression, exitSharedLayoutQualifier, exitShiftExpression, exitSingleAttribute, exitStatement, exitStorageQualifier, exitStructBody, exitStructDeclarator, exitStructMember, exitStructSpecifier, exitStructSpecifierType, exitSwitchStatement, exitTranslationUnit, exitTypeAndInitDeclaration, exitTypeNameList, exitTypeQualifier, exitTypeSpecifier, exitValuedCaseLabel, exitVariableDeclaration, exitVariableIdentifier, exitVersionStatement, exitVoidType, exitWhileStatement, visitErrorNode, visitTerminal

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.github.douira.glsl_transformer.transform.LifecycleUser

    getJobParameters, getLexer, getParser, getRootNode, init, initOnce, resetState

    Methods inherited from interface org.antlr.v4.runtime.tree.ParseTreeListener

    enterEveryRule, exitEveryRule, visitErrorNode, visitTerminal

    Methods inherited from interface io.github.douira.glsl_transformer.traversal.PartialParseTreeListener

    isDeepEnough, isFinished
  • Constructor Details

    • RunPhase

      public RunPhase()
  • Method Details

    • run

      protected abstract void run(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx)
      This method is implemented by subclasses to be executed by the phase planner at the right time.
      Parameters:
      ctx - The root node of the parse tree being transformed
    • canWalk

      protected boolean canWalk()
      Description copied from class: TransformationPhase
      Called during planning in order to determine if this phase does any walking at all or if it just runs some code, like a RunPhase. This doesn't exclude or include this phase from walking but rather helps the execution planner combine walk phases into execution levels. Enabling and disabling a phase should be done with the methods TransformationPhase.checkBeforeWalk(TranslationUnitContext) and TransformationPhase.runAfterWalk(TranslationUnitContext).
      Specified by:
      canWalk in class TransformationPhase<T extends JobParameters>
      Returns:
      If this phase needs to be walked on the tree
    • checkBeforeWalk

      protected final boolean checkBeforeWalk(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx)
      Description copied from class: TransformationPhase
      Method called by the execution planner before the walk happens. The returned boolean determines if the phase is added to the list of phases that are walked on the tree. Returns false by default and implementing classes should overwrite this.
      Overrides:
      checkBeforeWalk in class TransformationPhase<T extends JobParameters>
      Parameters:
      ctx - The root node
      Returns:
      true if the phase should be walked on the tree
    • runAfterWalk

      protected final void runAfterWalk(io.github.douira.glsl_transformer.GLSLParser.TranslationUnitContext ctx)
      Description copied from class: TransformationPhase
      Method called by the execution planner after the walk happens. Does nothing by default.
      Overrides:
      runAfterWalk in class TransformationPhase<T extends JobParameters>
      Parameters:
      ctx - The root node
    • withInjectNodes

      public static <R extends JobParameters> RunPhase<R> withInjectNodes(TransformationPhase.InjectionPoint location, ParseTree newNodes)
      Returns a new run phase that injects the given nodes at the given location.
      Type Parameters:
      R - The job parameter type
      Parameters:
      location - The location to inject the nodes at
      newNodes - The nodes to inject
      Returns:
      The run phase that does only these injections
      See Also:
    • withInjectExternalDeclarations

      public static <R extends JobParameters> RunPhase<R> withInjectExternalDeclarations(TransformationPhase.InjectionPoint location, String... str)
      Returns a new run phase that injects the given strings as an external declarations at the given location.
      Type Parameters:
      R - The job parameter type
      Parameters:
      location - The location to inject the external declarations at
      str - The strings to parse as external declarations
      Returns:
      The run phase that does only these injections
      See Also:
    • withRun

      public static <R extends JobParameters> RunPhase<R> withRun(Runnable run)
      Creates a new run phase that only executes the given runnable function. If the function is null, the generated phase does nothing.
      Type Parameters:
      R - The job parameter type
      Parameters:
      run - The runnable to run in the run phase
      Returns:
      The generated run phase