Class WrapIdentifier<T extends JobParameters>
java.lang.Object
io.github.douira.glsl_transformer.transform.LifecycleUserImpl<T>
io.github.douira.glsl_transformer.transform.Transformation<T>
io.github.douira.glsl_transformer.core.WrapIdentifier<T>
- All Implemented Interfaces:
LifecycleUser<T>
The wrap identifier transformation wraps the usage of a certain identifier
with new code by replacing its usage with a new expression and inserting code
that takes care of handling the conversion from the new to the old value. It
also checks that the wrapped value isn't already present in the code.
-
Constructor Summary
ConstructorsConstructorDescriptionWrapIdentifier(TransformationPhase<T> wrapResultDetector, TransformationPhase<T> wrappingReplacer, TransformationPhase<T> wrappingInjector) Creates a new wrap identifier transformation.WrapIdentifier(String wrapResult, HandlerTarget<T> wrappingTarget, TransformationPhase<T> wrappingInjector) Creates a new wrap identifier transformation with a fixed result identifier and a fixed replacement phase for which only the target is given.WrapIdentifier(String wrapResult, TransformationPhase<T> wrappingReplacer, TransformationPhase<T> wrappingInjector) Creates a new wrap identifier transformation with a fixed result identifier. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends JobParameters>
WrapIdentifier<T>fromExpression(String wrapTarget, String wrapResult, String wrapExpression, RunPhase<T> wrappingInjector) Creates a new wrap identifier transformation that uses a parsed replace target that replaces identifiers with an expression.static <T extends JobParameters>
WrapIdentifier<T>fromTerminal(String wrapTarget, String wrapResult, RunPhase<T> wrappingInjector) Creates a new wrap identifier transformation that uses an unparsed terminal replace target.static <T extends JobParameters>
WrapIdentifier<T>withExternalDeclaration(String wrapTarget, String wrapResult, String wrapExpression, TransformationPhase.InjectionPoint location, String injectedCode) Creates a new wrap identifier transformation that inserts a parsed expression as a replacement and inserts a new external declaration.Methods inherited from class io.github.douira.glsl_transformer.transform.Transformation
addDependency, addDependent, addEndDependent, addRootDependency, appendDependent, chainConcurrentDependency, chainConcurrentDependent, chainConcurrentSibling, chainDependency, chainDependent, prependDependency, setupGraphMethods inherited from class io.github.douira.glsl_transformer.transform.LifecycleUserImpl
getPlanner, isInitialized, setInitialized, setPlannerMethods 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.transform.LifecycleUser
getJobParameters, getLexer, getParser, getRootNode, init, initOnce, resetState
-
Constructor Details
-
WrapIdentifier
public WrapIdentifier(TransformationPhase<T> wrapResultDetector, TransformationPhase<T> wrappingReplacer, TransformationPhase<T> wrappingInjector) Creates a new wrap identifier transformation.- Parameters:
wrapResultDetector- A phase that makes sure the wrap result doesn't already exist in the treewrappingReplacer- The replacer phase that should replace a target identifier with a replacement expression or identifierwrappingInjector- A transformation phase that does the additional code injection, usually providing a definition for the newly inserted identifier in the form of an external declaration of some sort
-
WrapIdentifier
public WrapIdentifier(String wrapResult, TransformationPhase<T> wrappingReplacer, TransformationPhase<T> wrappingInjector) Creates a new wrap identifier transformation with a fixed result identifier.- Parameters:
wrapResult- The identifier that's inserted for the wrappingwrappingReplacer- The replacer phase that replaces a target identifier with a replacement expression or identifierwrappingInjector- A transformation phase that does the additional code injection, usually providing a definition for the newly inserted identifier in the form of an external declaration of some sort- See Also:
-
WrapIdentifier
public WrapIdentifier(String wrapResult, HandlerTarget<T> wrappingTarget, TransformationPhase<T> wrappingInjector) Creates a new wrap identifier transformation with a fixed result identifier and a fixed replacement phase for which only the target is given.- Parameters:
wrapResult- The identifier that's inserted for the wrappingwrappingTarget- A replacement target to be used in a search terminal's phasewrappingInjector- A transformation phase that does the additional code injection, usually providing a definition for the newly inserted identifier in the form of an external declaration of some sort
-
-
Method Details
-
fromTerminal
public static <T extends JobParameters> WrapIdentifier<T> fromTerminal(String wrapTarget, String wrapResult, RunPhase<T> wrappingInjector) Creates a new wrap identifier transformation that uses an unparsed terminal replace target. It uses the wrap result as the identifier to disallow as well as the terminal to insert as a replacement. This is a commonly used operation when the inserted replacement is just a different identifier.- Type Parameters:
T- The job parameter type- Parameters:
wrapTarget- The identifier to replacewrapResult- The identifier that will be used to replace itwrappingInjector- A transformation phase that does the additional code injection- Returns:
- The wrap identifier transformation with the given parameters
-
fromExpression
public static <T extends JobParameters> WrapIdentifier<T> fromExpression(String wrapTarget, String wrapResult, String wrapExpression, RunPhase<T> wrappingInjector) Creates a new wrap identifier transformation that uses a parsed replace target that replaces identifiers with an expression. (which may also just be an identifier)- Type Parameters:
T- The job parameter type- Parameters:
wrapTarget- The identifier to replacewrapResult- The identifier that will be used to replace itwrapExpression- The expression to insert instead of thewrapTargetwrappingInjector- A transformation phase that does the additional code injection- Returns:
- The wrap identifier transformation with the given parameters
-
withExternalDeclaration
public static <T extends JobParameters> WrapIdentifier<T> withExternalDeclaration(String wrapTarget, String wrapResult, String wrapExpression, TransformationPhase.InjectionPoint location, String injectedCode) Creates a new wrap identifier transformation that inserts a parsed expression as a replacement and inserts a new external declaration.- Type Parameters:
T- The job parameter type- Parameters:
wrapTarget- The identifier to replacewrapResult- The identifier that will be used to replace itwrapExpression- The expression to insert instead of thewrapTargetlocation- The injection location for the new codeinjectedCode- The code to parse and inject as an external declaration at the given location- Returns:
- The wrap identifier transformation with the given parameters
- See Also:
-