Class SourceFile
java.lang.Object
com.jozufozu.flywheel.core.source.SourceFile
Immutable class representing a shader file.
This class parses shader files and generates what is effectively a high level AST of the source.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringSections of the source that must be trimmed for compilation.static final Patternfinal com.google.common.collect.ImmutableMap<String,ShaderFunction> Function lookup by name.final com.google.common.collect.ImmutableList<Import>Includes ordered as defined in the source.final SourceLinesfinal net.minecraft.resources.ResourceLocationfinal ShaderSourcesfinal Stringfinal com.google.common.collect.ImmutableMap<String,ShaderStruct> Struct lookup by name. -
Constructor Summary
ConstructorsConstructorDescriptionSourceFile(ShaderSources parent, net.minecraft.resources.ResourceLocation name, String source) -
Method Summary
Modifier and TypeMethodDescriptionfindFunction(CharSequence name) Search this file and recursively search all imports to find a function definition matching the given name.findStruct(CharSequence name) Search this file and recursively search all imports to find a struct definition matching the given name.voidgenerateFinalSource(FileIndex env, StringBuilder source) getLineSpan(int line) getLineSpanNoWhitespace(int line) toString()
-
Field Details
-
functionDeclaration
-
name
public final net.minecraft.resources.ResourceLocation name -
parent
-
source
-
elided
Sections of the source that must be trimmed for compilation. Currently, it only contains the spans of imports. -
lines
-
functions
Function lookup by name. -
structs
Struct lookup by name. -
imports
Includes ordered as defined in the source.
-
-
Constructor Details
-
SourceFile
public SourceFile(ShaderSources parent, net.minecraft.resources.ResourceLocation name, String source)
-
-
Method Details
-
getLineSpan
-
getLineSpanNoWhitespace
-
findStruct
Search this file and recursively search all imports to find a struct definition matching the given name.- Parameters:
name- The name of the struct to find.- Returns:
- null if no definition matches the name.
-
findFunction
Search this file and recursively search all imports to find a function definition matching the given name.- Parameters:
name- The name of the function to find.- Returns:
- Optional#empty() if no definition matches the name.
-
importStatement
-
generateFinalSource
-
printSource
-
toString
-